Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
Z
ZIO
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
ZIO
Commits
3d9cee91
Commit
3d9cee91
authored
Jul 21, 2015
by
Federico Vaga
Browse files
Options
Browse Files
Download
Plain Diff
add version control
parents
ca75f9be
374ce826
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
133 additions
and
17 deletions
+133
-17
Makefile
Makefile
+12
-2
bus.c
bus.c
+45
-1
core.c
core.c
+5
-2
Makefile
drivers/Makefile
+1
-0
zio-ad788x.c
drivers/zio-ad788x.c
+5
-0
zio-fake-dtc.c
drivers/zio-fake-dtc.c
+5
-0
zio-gpio.c
drivers/zio-gpio.c
+5
-0
zio-irq-tdc.c
drivers/zio-irq-tdc.c
+5
-0
zio-loop.c
drivers/zio-loop.c
+5
-0
zio-mini.c
drivers/zio-mini.c
+5
-0
zio-vmk8055.c
drivers/zio-vmk8055.c
+5
-0
zio-zero.c
drivers/zio-zero.c
+5
-0
zio-user.h
include/linux/zio-user.h
+18
-3
zio.h
include/linux/zio.h
+3
-0
Makefile
tools/Makefile
+1
-1
test-dtc.c
tools/test-dtc.c
+2
-2
zio-cat-file.c
tools/zio-cat-file.c
+2
-2
zio-dump.c
tools/zio-dump.c
+4
-4
No files found.
Makefile
View file @
3d9cee91
...
...
@@ -14,7 +14,11 @@ obj-m += drivers/
obj-m
+=
buffers/
obj-m
+=
triggers/
GIT_VERSION
=
$(
shell
cd
$(src)
;
git describe
--dirty
--long
--tags
)
# src is defined byt the kernel Makefile, but we want to use it also in our
# local Makefile (tools, lib)
src
?=
$(
shell
pwd
)
GIT_VERSION
:=
$(
shell
cd
$(src)
;
git describe
--dirty
--long
--tags
)
# For this CSM_VERSION, please see ohwr.org/csm documentation
ifdef
CONFIG_CSM_VERSION
...
...
@@ -23,9 +27,15 @@ else
ccflags-y
+=
-DCERN_SUPER_MODULE
=
""
endif
# Extract major, minor and patch number
ZIO_VERSION
:=
-D__ZIO_MAJOR_VERSION
=
$(
shell
echo
$(GIT_VERSION)
|
cut
-d
'-'
-f
2 |
cut
-d
'.'
-f
1
;
)
ZIO_VERSION
+=
-D__ZIO_MINOR_VERSION
=
$(
shell
echo
$(GIT_VERSION)
|
cut
-d
'-'
-f
2 |
cut
-d
'.'
-f
2
;
)
ZIO_VERSION
+=
-D__ZIO_PATCH_VERSION
=
$(
shell
echo
$(GIT_VERSION)
|
cut
-d
'-'
-f
3
)
export
ZIO_VERSION
# WARNING: the line below doesn't work in-kernel if you compile with O=
ccflags-y
+=
-I
$(src)
/include/
-DGIT_VERSION
=
\"
$(GIT_VERSION)
\"
ccflags-y
+=
$(ZIO_VERSION)
ccflags-$(CONFIG_ZIO_DEBUG)
+=
-DDEBUG
all
:
modules tools
...
...
bus.c
View file @
3d9cee91
...
...
@@ -17,13 +17,49 @@
static
struct
zio_status
*
zstat
=
&
zio_global_status
;
/* Always use ptr */
/**
* It verifies the compatibility between the current ZIO version and the
* given driver
*/
static
int
__zobj_version_check
(
struct
zio_driver
*
drv
)
{
uint32_t
min
=
drv
->
min_version
;
if
(
!
min
)
{
pr_warn
(
"zio: %s does not have a driver version, cannot verify compatibility"
,
drv
->
driver
.
name
);
return
0
;
}
if
(
min
>
zio_version
)
goto
out
;
if
(
zio_version_major
(
min
)
!=
zio_version_major
(
zio_version
))
goto
out
;
if
(
zio_version_minor
(
min
)
!=
zio_version_minor
(
zio_version
))
goto
out
;
return
0
;
out:
pr_err
(
"zio: %s require version %d.%d-%d but ZIO is %d.%d-%d
\n
"
,
drv
->
driver
.
name
,
zio_version_major
(
min
),
zio_version_minor
(
min
),
zio_version_patch
(
min
),
zio_version_major
(
zio_version
),
zio_version_minor
(
zio_version
),
zio_version_patch
(
zio_version
));
return
-
1
;
}
/*
* zio_show_version
* It shows the current version of ZIO
*/
static
ssize_t
zio_show_version
(
struct
bus_type
*
bus
,
char
*
buf
)
{
return
sprintf
(
buf
,
"%d.%d
\n
"
,
ZIO_MAJOR_VERSION
,
ZIO_MINOR_VERSION
);
return
sprintf
(
buf
,
"%d.%d-%d
\n
"
,
zio_version_major
(
zio_version
),
zio_version_minor
(
zio_version
),
zio_version_patch
(
zio_version
));
}
/*
...
...
@@ -270,6 +306,14 @@ int zio_register_driver(struct zio_driver *zdrv)
{
int
i
,
err
;
/* Check version compatibility */
err
=
__zobj_version_check
(
zdrv
);
if
(
err
)
{
pr_err
(
"ZIO: Cannot register driver %s: incompatible version
\n
"
,
zdrv
->
driver
.
name
);
return
-
EINVAL
;
}
if
(
!
zdrv
->
id_table
)
{
pr_err
(
"ZIO: id_table is mandatory for a zio driver
\n
"
);
return
-
EINVAL
;
...
...
core.c
View file @
3d9cee91
...
...
@@ -16,6 +16,9 @@
#include <linux/zio-buffer.h>
#include "zio-internal.h"
const
uint32_t
zio_version
=
ZIO_VERSION
(
__ZIO_MAJOR_VERSION
,
__ZIO_MINOR_VERSION
,
__ZIO_PATCH_VERSION
);
struct
zio_status
zio_global_status
;
static
struct
zio_status
*
zstat
=
&
zio_global_status
;
/* Always use ptr */
/*
...
...
@@ -31,8 +34,8 @@ struct zio_control *zio_alloc_control(gfp_t gfp)
if
(
!
ctrl
)
return
NULL
;
ctrl
->
major_version
=
ZIO_MAJOR_VERSION
;
ctrl
->
minor_version
=
ZIO_MINOR_VERSION
;
ctrl
->
major_version
=
zio_version_major
(
zio_version
)
;
ctrl
->
minor_version
=
zio_version_minor
(
zio_version
)
;
if
(
ntohl
(
1
)
==
1
)
ctrl
->
flags
|=
ZIO_CONTROL_BIG_ENDIAN
;
else
...
...
drivers/Makefile
View file @
3d9cee91
...
...
@@ -10,6 +10,7 @@ else
endif
ccflags-y
+=
-I
$(src)
/../include/
-DGIT_VERSION
=
\"
$(GIT_VERSION)
\"
ccflags-y
+=
$(ZIO_VERSION)
ccflags-$(CONFIG_ZIO_DEBUG)
+=
-DDEBUG
obj-m
=
zio-zero.o
...
...
drivers/zio-ad788x.c
View file @
3d9cee91
...
...
@@ -332,6 +332,11 @@ static struct zio_driver ad788x_zdrv = {
},
.
id_table
=
ad788x_table
,
.
probe
=
ad788x_zio_probe
,
/* All drivers compiled within the ZIO projects are compatibile
with the last version */
.
min_version
=
ZIO_VERSION
(
__ZIO_MAJOR_VERSION
,
__ZIO_MINOR_VERSION
,
__ZIO_PATCH_VERSION
),
};
static
int
ad788x_spi_probe
(
struct
spi_device
*
spi
)
...
...
drivers/zio-fake-dtc.c
View file @
3d9cee91
...
...
@@ -111,6 +111,11 @@ static struct zio_driver zdtc_zdrv = {
},
.
id_table
=
zdtc_table
,
.
probe
=
zdtc_probe
,
/* All drivers compiled within the ZIO projects are compatibile
with the last version */
.
min_version
=
ZIO_VERSION
(
__ZIO_MAJOR_VERSION
,
__ZIO_MINOR_VERSION
,
__ZIO_PATCH_VERSION
),
};
/* Lazily, use a single global device */
...
...
drivers/zio-gpio.c
View file @
3d9cee91
...
...
@@ -122,6 +122,11 @@ static struct zio_driver zpg_zdrv = {
.
owner
=
THIS_MODULE
,
},
.
id_table
=
zzero_table
,
/* All drivers compiled within the ZIO projects are compatibile
with the last version */
.
min_version
=
ZIO_VERSION
(
__ZIO_MAJOR_VERSION
,
__ZIO_MINOR_VERSION
,
__ZIO_PATCH_VERSION
),
};
static
int
__init
zgp_init
(
void
)
...
...
drivers/zio-irq-tdc.c
View file @
3d9cee91
...
...
@@ -172,6 +172,11 @@ static struct zio_driver ztdc_zdrv = {
},
.
id_table
=
ztdc_table
,
.
probe
=
ztdc_probe
,
/* All drivers compiled within the ZIO projects are compatibile
with the last version */
.
min_version
=
ZIO_VERSION
(
__ZIO_MAJOR_VERSION
,
__ZIO_MINOR_VERSION
,
__ZIO_PATCH_VERSION
),
};
/* Lazily, use a single global device */
...
...
drivers/zio-loop.c
View file @
3d9cee91
...
...
@@ -274,6 +274,11 @@ static struct zio_driver zloop_zdrv = {
},
.
id_table
=
zloop_table
,
.
probe
=
zloop_probe
,
/* All drivers compiled within the ZIO projects are compatibile
with the last version */
.
min_version
=
ZIO_VERSION
(
__ZIO_MAJOR_VERSION
,
__ZIO_MINOR_VERSION
,
__ZIO_PATCH_VERSION
),
};
/*
...
...
drivers/zio-mini.c
View file @
3d9cee91
...
...
@@ -68,6 +68,11 @@ static struct zio_driver zmini_zdrv = {
.
owner
=
THIS_MODULE
,
},
.
id_table
=
zmini_table
,
/* All drivers compiled within the ZIO projects are compatibile
with the last version */
.
min_version
=
ZIO_VERSION
(
__ZIO_MAJOR_VERSION
,
__ZIO_MINOR_VERSION
,
__ZIO_PATCH_VERSION
),
};
/* The device is registered in the bus: we can have several */
...
...
drivers/zio-vmk8055.c
View file @
3d9cee91
...
...
@@ -399,6 +399,11 @@ static struct zio_driver zvmk80xx_zdrv = {
.
id_table
=
zvmk80xx_table
,
.
probe
=
zvmk80xx_zio_probe
,
.
remove
=
zvmk80xx_zio_remove
,
/* All drivers compiled within the ZIO projects are compatibile
with the last version */
.
min_version
=
ZIO_VERSION
(
__ZIO_MAJOR_VERSION
,
__ZIO_MINOR_VERSION
,
__ZIO_PATCH_VERSION
),
};
...
...
drivers/zio-zero.c
View file @
3d9cee91
...
...
@@ -208,6 +208,11 @@ static struct zio_driver zzero_zdrv = {
.
owner
=
THIS_MODULE
,
},
.
id_table
=
zzero_table
,
/* All drivers compiled within the ZIO projects are compatibile
with the last version */
.
min_version
=
ZIO_VERSION
(
__ZIO_MAJOR_VERSION
,
__ZIO_MINOR_VERSION
,
__ZIO_PATCH_VERSION
),
};
static
int
__init
zzero_init
(
void
)
...
...
include/linux/zio-user.h
View file @
3d9cee91
...
...
@@ -8,9 +8,24 @@
#ifndef __ZIO_USER_H__
#define __ZIO_USER_H__
/* ZIO_VERSION: is a zio_class attribute to identify the framework version*/
#define ZIO_MAJOR_VERSION 1
#define ZIO_MINOR_VERSION 0
#define ZIO_VERSION(M, m, p) (((M & 0xFF) << 24) | ((m & 0xFF) << 16) | (p & 0xFFFF))
static
inline
uint8_t
zio_version_major
(
uint32_t
version
)
{
return
(
version
>>
24
)
&
0xFF
;
}
static
inline
uint8_t
zio_version_minor
(
uint32_t
version
)
{
return
(
version
>>
16
)
&
0xFF
;
}
static
inline
uint16_t
zio_version_patch
(
uint32_t
version
)
{
return
version
&
0xFF
;
}
/*
* ZIO_OBJ_NAME_LEN is the name's length used for registered objects
...
...
include/linux/zio.h
View file @
3d9cee91
...
...
@@ -7,6 +7,8 @@
#ifdef __KERNEL__
/* Nothing more is for user space */
extern
const
uint32_t
zio_version
;
/*
* ZIO_NAME_LEN is the full name length used in the head structures.
* It is sometimes built at run time, for example buffer instances
...
...
@@ -124,6 +126,7 @@ struct zio_driver {
int
(
*
probe
)(
struct
zio_device
*
dev
);
int
(
*
remove
)(
struct
zio_device
*
dev
);
struct
device_driver
driver
;
uint32_t
min_version
;
/**< minimum version required to load it */
};
#define to_zio_drv(_drv) container_of(_drv, struct zio_driver, driver)
extern
struct
bus_type
zio_bus_type
;
...
...
tools/Makefile
View file @
3d9cee91
# build user-space tools for zio
CFLAGS
=
-I
$(M)
/include/
-Wall
$(EXTRACFLAGS)
CFLAGS
=
-I
$(M)
/include/
-Wall
$(
ZIO_VERSION)
$(
EXTRACFLAGS)
CC
?=
$(CROSS_COMPILE)
gcc
progs
:=
zio-dump
...
...
tools/test-dtc.c
View file @
3d9cee91
...
...
@@ -129,8 +129,8 @@ int main(int argc, char **argv)
exit
(
1
);
}
ctrl
.
major_version
=
ZIO_MAJOR_VERSION
;
ctrl
.
minor_version
=
ZIO_MINOR_VERSION
;
ctrl
.
major_version
=
__
ZIO_MAJOR_VERSION
;
ctrl
.
minor_version
=
__
ZIO_MINOR_VERSION
;
if
(
verbose
)
{
printf
(
" time: %9li.%09li
\n
"
,
ts
.
tv_sec
,
ts
.
tv_nsec
);
printf
(
"period: %9li.%09li
\n
"
,
period
.
tv_sec
,
period
.
tv_nsec
);
...
...
tools/zio-cat-file.c
View file @
3d9cee91
...
...
@@ -90,8 +90,8 @@ int main(int argc, char **argv)
if
(
i
!=
sizeof
(
ctrl
))
goto
ctrl_read_error
;
if
(
!
j
)
{
if
(
ctrl
.
major_version
!=
ZIO_MAJOR_VERSION
||
ctrl
.
minor_version
!=
ZIO_MINOR_VERSION
)
{
if
(
ctrl
.
major_version
!=
__
ZIO_MAJOR_VERSION
||
ctrl
.
minor_version
!=
__
ZIO_MINOR_VERSION
)
{
fprintf
(
stderr
,
"%s: unexpected ZIO version
\n
"
,
argv
[
0
]);
exit
(
1
);
...
...
tools/zio-dump.c
View file @
3d9cee91
...
...
@@ -112,18 +112,18 @@ void read_channel(int cfd, int dfd, FILE *log)
}
/* Fail badly if the version is not the right one */
if
(
ctrl
.
major_version
!=
ZIO_MAJOR_VERSION
)
if
(
ctrl
.
major_version
!=
__
ZIO_MAJOR_VERSION
)
err
++
;
if
(
ZIO_MAJOR_VERSION
==
0
&&
ctrl
.
minor_version
!=
ZIO_MINOR_VERSION
)
if
(
__ZIO_MAJOR_VERSION
==
0
&&
ctrl
.
minor_version
!=
__
ZIO_MINOR_VERSION
)
err
++
;
if
(
err
)
{
fprintf
(
stderr
,
"%s: kernel has zio %i.%i, "
"but I'm compiled for %i.%i
\n
"
,
prgname
,
ctrl
.
major_version
,
ctrl
.
minor_version
,
ZIO_MAJOR_VERSION
,
ZIO_MINOR_VERSION
);
__ZIO_MAJOR_VERSION
,
__
ZIO_MINOR_VERSION
);
exit
(
1
);
}
if
(
ctrl
.
minor_version
!=
ZIO_MINOR_VERSION
)
{
if
(
ctrl
.
minor_version
!=
__
ZIO_MINOR_VERSION
)
{
static
int
warned
;
if
(
!
warned
++
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment