Commit af163868 authored by Federico Vaga's avatar Federico Vaga

Merge branch '20-review-vaibhav-patches' into 'master'

Resolve "Review Vaibhav Patches"

Closes #20

See merge request be-cem-edl/fec/hardware-modules/fmc-adc-100m14b4cha!7
parents 39c6ddbe 3542668a
...@@ -114,3 +114,4 @@ GRTAGS ...@@ -114,3 +114,4 @@ GRTAGS
.clangd .clangd
compile_commands.json compile_commands.json
.cache .cache
*.swp
...@@ -5,28 +5,21 @@ ...@@ -5,28 +5,21 @@
variables: variables:
GIT_SUBMODULE_STRATEGY: normal GIT_SUBMODULE_STRATEGY: normal
stages: include:
- static-analysis - project: 'be-cem-edl/evergreen/gitlab-ci'
- build ref: master
file:
reuse: - 'edl-gitlab-ci.yml'
stage: static-analysis
image:
name: fsfe/reuse:latest
entrypoint: [""]
script:
- reuse lint
allow_failure: true
cppcheck: cppcheck:
stage: static-analysis stage: analyse
image: image:
name: gitlab-registry.cern.ch/coht/common-containers/static-analysis:latest name: gitlab-registry.cern.ch/coht/common-containers/static-analysis:latest
script: script:
- make -C software cppcheck - make -C software cppcheck
flawfinder: flawfinder:
stage: static-analysis stage: analyse
image: image:
name: gitlab-registry.cern.ch/coht/common-containers/static-analysis:latest name: gitlab-registry.cern.ch/coht/common-containers/static-analysis:latest
script: script:
...@@ -38,13 +31,18 @@ documentation: ...@@ -38,13 +31,18 @@ documentation:
name: gitlab-registry.cern.ch/coht/common-containers/documentation:latest name: gitlab-registry.cern.ch/coht/common-containers/documentation:latest
script: script:
- make -C doc html - make -C doc html
- mkdir -p $EDL_CI_EOS_OUTPUT_DIR
- cp -a doc/_build/html/* $EDL_CI_EOS_OUTPUT_DIR
artifacts:
paths:
- $EDL_CI_EOS_OUTPUT_DIR
.script_fetch_kernel_dep: &script_fetch_kernel_dep .script_fetch_kernel_dep: &script_fetch_kernel_dep
- git clone --depth 1 https://gitlab.cern.ch/cohtdrivers/coht.git ~/git/coht - git clone --depth 1 https://gitlab.cern.ch/cohtdrivers/coht.git ~/git/coht
- export VMEBUS=~/git/coht/vmebridge-ng - export VMEBUS=~/git/coht/vmebridge-ng
- git clone -b v1.1.4 --depth 1 https://ohwr.org/project/fmc-sw.git ~/git/fmc - git clone -b v1.1.5 --depth 1 https://ohwr.org/project/fmc-sw.git ~/git/fmc
- export FMC=~/git/fmc - export FMC=~/git/fmc
- git clone -b v1.4.0 --depth 1 https://ohwr.org/project/zio.git ~/git/zio - git clone -b v1.4.4 --depth 1 https://ohwr.org/project/zio.git ~/git/zio
- export ZIO=~/git/zio - export ZIO=~/git/zio
.script_build_kernel_dep: &script_build_kernel_dep .script_build_kernel_dep: &script_build_kernel_dep
...@@ -54,7 +52,7 @@ documentation: ...@@ -54,7 +52,7 @@ documentation:
build-centos-7: build-centos-7:
stage: build stage: build
variables: variables:
LINUX: /usr/src/kernels/*/ KERNELSRC: /usr/src/kernels/*/
image: image:
name: gitlab-registry.cern.ch/coht/common-containers/build-centos-7:latest name: gitlab-registry.cern.ch/coht/common-containers/build-centos-7:latest
before_script: before_script:
...@@ -63,38 +61,18 @@ build-centos-7: ...@@ -63,38 +61,18 @@ build-centos-7:
script: script:
- make -C software - make -C software
.script_build_kernel_ver: &script_build_kernel_ver build-kernel:
- source /linux-versions.sh
- fetch $VERSION && prepare $VERSION && export LINUX=$(linux $VERSION)
- *script_build_kernel_dep
- make -C software/kernel all
build-kernel-5.4.207:
stage: build stage: build
allow_failure: true allow_failure: true
variables:
VERSION: 5.4.207
image: image:
name: gitlab-registry.cern.ch/coht/common-containers/build-kernel:latest name: gitlab-registry.cern.ch/coht/common-containers/build-kernel:latest
parallel:
matrix:
- VERSION: [5.10.149, 5.15.74]
before_script: before_script:
- *script_fetch_kernel_dep - *script_fetch_kernel_dep
script: script:
- *script_build_kernel_ver - source /linux-versions.sh
- fetch $VERSION && prepare $VERSION && export KERNELSRC=$(linux $VERSION)
.script_build_kernel_ver: &script_build_kernel_ver - *script_build_kernel_dep
- source /linux-versions.sh - make -C software/kernel all
- fetch $VERSION && prepare $VERSION && export LINUX=$(linux $VERSION)
- *script_build_kernel_dep
- make -C software/kernel all
build-kernel-5.10.132:
stage: build
allow_failure: true
variables:
VERSION: 5.10.132
image:
name: gitlab-registry.cern.ch/coht/common-containers/build-kernel:latest
before_script:
- *script_fetch_kernel_dep
script:
- *script_build_kernel_ver
...@@ -37,7 +37,7 @@ driver from CERN BE-CEM. ...@@ -37,7 +37,7 @@ driver from CERN BE-CEM.
:: ::
$ cd /path/to/fmc-adc-100m14b4cha/software/kernel $ cd /path/to/fmc-adc-100m14b4cha/software/kernel
$ export LINUX=/path/to/linux/sources $ export KERNELSRC=/path/to/linux/sources
$ export ZIO=/path/to/zio $ export ZIO=/path/to/zio
$ export FMC=/path/to/fmc-sw $ export FMC=/path/to/fmc-sw
$ export VMEBUS=/path/to/vmebridge $ export VMEBUS=/path/to/vmebridge
...@@ -581,8 +581,8 @@ directory or fail with an error like:: ...@@ -581,8 +581,8 @@ directory or fail with an error like::
make: *** /lib/modules/<kernel-version>/build: No such file or directory. make: *** /lib/modules/<kernel-version>/build: No such file or directory.
This happens when you compiled by setting ``LINUX=`` and your sudo is not This happens when you compiled by setting ``KERNELSRC=`` and your sudo is not
propagating the environment to its child processes. In this case, you propagating the environment to its child processes. In this case, you
should run this command instead:: should run this command instead::
sudo make modules_install LINUX=$LINUX sudo make modules_install KERNELSRC=$KERNELSRC
...@@ -13,7 +13,7 @@ CPPCHECK ?= cppcheck ...@@ -13,7 +13,7 @@ CPPCHECK ?= cppcheck
DKMS ?= 0 DKMS ?= 0
CURDIR := $(shell /bin/pwd) CURDIR := $(shell /bin/pwd)
KVERSION ?= $(shell uname -r) KVERSION ?= $(shell uname -r)
LINUX ?= /lib/modules/$(KVERSION)/build KERNELSRC ?= /lib/modules/$(KVERSION)/build
ifdef REPO_PARENT ifdef REPO_PARENT
ZIO ?= $(REPO_PARENT)/fmc/zio ZIO ?= $(REPO_PARENT)/fmc/zio
...@@ -57,19 +57,14 @@ GIT_VERSION = $(shell git describe --always --dirty --long --tags) ...@@ -57,19 +57,14 @@ GIT_VERSION = $(shell git describe --always --dirty --long --tags)
all: modules all: modules
clean modules help modules_install coccicheck: clean modules help modules_install coccicheck:
$(MAKE) -C $(LINUX) M=$(CURDIR) ZIO_ABS=$(ZIO_ABS) FMC_ABS=$(FMC_ABS) \ $(MAKE) -C $(KERNELSRC) M=$(CURDIR) ZIO_ABS=$(ZIO_ABS) FMC_ABS=$(FMC_ABS) \
ZIO_EXTRA_SYMBOLS-y=$(ZIO_EXTRA_SYMBOLS-y) \ ZIO_EXTRA_SYMBOLS-y=$(ZIO_EXTRA_SYMBOLS-y) \
FMC_EXTRA_SYMBOLS-y=$(FMC_EXTRA_SYMBOLS-y) \ FMC_EXTRA_SYMBOLS-y=$(FMC_EXTRA_SYMBOLS-y) \
ZIO_VERSION=$(ZIO_VERSION) \ ZIO_VERSION=$(ZIO_VERSION) \
GIT_VERSION=$(GIT_VERSION) \ GIT_VERSION=$(GIT_VERSION) \
VMEBUS_ABS=$(VMEBUS_ABS) $@ VMEBUS_ABS=$(VMEBUS_ABS) $@
# be able to run the "clean" rule even if $(LINUX) is not valid
clean:
rm -rf *.o *~ .*.cmd *.ko *.mod.c .tmp_versions Module.symvers \
Module.markers modules.order
cppcheck: cppcheck:
$(CPPCHECK) -q -I. -I$(ZIO_ABS)/include -I$(FMC_BUS_ABS)/ --suppress=missingIncludeSystem --enable=all *.c *.h $(CPPCHECK) -q -I. -I$(ZIO_ABS)/include -I$(FMC_BUS_ABS)/ --suppress=missingIncludeSystem --enable=all *.c *.h
.PHONY: all install coccicheck cppcheck .PHONY: all coccicheck clean cppcheck modules modules_install
...@@ -339,7 +339,8 @@ static void __fa_calib_gain_update(struct fa_dev *fa) ...@@ -339,7 +339,8 @@ static void __fa_calib_gain_update(struct fa_dev *fa)
#if KERNEL_VERSION(4, 15, 0) <= LINUX_VERSION_CODE #if KERNEL_VERSION(4, 15, 0) <= LINUX_VERSION_CODE
static void fa_calib_gain_update(struct timer_list *timer) static void fa_calib_gain_update(struct timer_list *timer)
{ {
__fa_calib_gain_update(from_timer(fa, timer, calib_timer)); struct fa_dev *fa = from_timer(fa, timer, calib_timer);
__fa_calib_gain_update(fa);
} }
#else #else
static void fa_calib_gain_update(unsigned long arg) static void fa_calib_gain_update(unsigned long arg)
......
...@@ -154,7 +154,7 @@ int main(int argc, char *argv[]) ...@@ -154,7 +154,7 @@ int main(int argc, char *argv[])
exit(1); exit(1);
} }
strncat(basepath, argv[argc-1], base_len); strncat(basepath, argv[argc-1], base_len - strlen(basepath));
printf("Sysfs path to device is: %s\n", basepath); printf("Sysfs path to device is: %s\n", basepath);
if (last) { if (last) {
......
...@@ -25,7 +25,7 @@ static char git_version[] = "version: " GIT_VERSION; ...@@ -25,7 +25,7 @@ static char git_version[] = "version: " GIT_VERSION;
#define buf_len 50 #define buf_len 50
#define base_len 40 #define base_len 40
/* user will edit by adding the device name */ /* user will edit by adding the device name */
char basepath[base_len] = "/sys/bus/zio/devices/"; char basepath[base_len] = "/sys/bus/zio/devices";
enum fau_attribute { enum fau_attribute {
FAU_TRG_EN, FAU_TRG_EN,
...@@ -63,10 +63,8 @@ int fau_write_attribute(enum fau_attribute attr, uint32_t val) ...@@ -63,10 +63,8 @@ int fau_write_attribute(enum fau_attribute attr, uint32_t val)
/* convert val to string */ /* convert val to string */
snprintf(buf, buf_len, "%u",val); snprintf(buf, buf_len, "%u",val);
/* build the attribute path */ /* build the attribute path */
strncpy(fullpath, basepath, path_len);
if (path_len > 0) if (path_len > 0)
fullpath[path_len -1] = '\0'; snprintf(fullpath, path_len, "%s%s", basepath, attribute[attr]);
strncat(fullpath, attribute[attr], path_len);
/* Write the attribute */ /* Write the attribute */
printf("Writing %s in %s\n", buf, fullpath); printf("Writing %s in %s\n", buf, fullpath);
fd = open(fullpath, O_WRONLY); fd = open(fullpath, O_WRONLY);
...@@ -190,7 +188,7 @@ int main(int argc, char *argv[]) ...@@ -190,7 +188,7 @@ int main(int argc, char *argv[])
exit(1); exit(1);
} }
strncat(basepath, argv[optind], base_len); strncat(basepath, argv[optind], base_len - strlen(basepath));
printf("Sysfs path to device is: %s\n", basepath); printf("Sysfs path to device is: %s\n", basepath);
for (i = 0; i < FAU_TRIG_NUM_ATTR; ++i) { for (i = 0; i < FAU_TRIG_NUM_ATTR; ++i) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment