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
.clangd
compile_commands.json
.cache
*.swp
......@@ -5,28 +5,21 @@
variables:
GIT_SUBMODULE_STRATEGY: normal
stages:
- static-analysis
- build
reuse:
stage: static-analysis
image:
name: fsfe/reuse:latest
entrypoint: [""]
script:
- reuse lint
allow_failure: true
include:
- project: 'be-cem-edl/evergreen/gitlab-ci'
ref: master
file:
- 'edl-gitlab-ci.yml'
cppcheck:
stage: static-analysis
stage: analyse
image:
name: gitlab-registry.cern.ch/coht/common-containers/static-analysis:latest
script:
- make -C software cppcheck
flawfinder:
stage: static-analysis
stage: analyse
image:
name: gitlab-registry.cern.ch/coht/common-containers/static-analysis:latest
script:
......@@ -38,13 +31,18 @@ documentation:
name: gitlab-registry.cern.ch/coht/common-containers/documentation:latest
script:
- 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
- git clone --depth 1 https://gitlab.cern.ch/cohtdrivers/coht.git ~/git/coht
- 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
- 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
.script_build_kernel_dep: &script_build_kernel_dep
......@@ -54,7 +52,7 @@ documentation:
build-centos-7:
stage: build
variables:
LINUX: /usr/src/kernels/*/
KERNELSRC: /usr/src/kernels/*/
image:
name: gitlab-registry.cern.ch/coht/common-containers/build-centos-7:latest
before_script:
......@@ -63,38 +61,18 @@ build-centos-7:
script:
- make -C software
.script_build_kernel_ver: &script_build_kernel_ver
- 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:
build-kernel:
stage: build
allow_failure: true
variables:
VERSION: 5.4.207
image:
name: gitlab-registry.cern.ch/coht/common-containers/build-kernel:latest
parallel:
matrix:
- VERSION: [5.10.149, 5.15.74]
before_script:
- *script_fetch_kernel_dep
script:
- *script_build_kernel_ver
.script_build_kernel_ver: &script_build_kernel_ver
- source /linux-versions.sh
- fetch $VERSION && prepare $VERSION && export LINUX=$(linux $VERSION)
- fetch $VERSION && prepare $VERSION && export KERNELSRC=$(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.
::
$ 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 FMC=/path/to/fmc-sw
$ export VMEBUS=/path/to/vmebridge
......@@ -581,8 +581,8 @@ directory or fail with an error like::
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
should run this command instead::
sudo make modules_install LINUX=$LINUX
sudo make modules_install KERNELSRC=$KERNELSRC
......@@ -13,7 +13,7 @@ CPPCHECK ?= cppcheck
DKMS ?= 0
CURDIR := $(shell /bin/pwd)
KVERSION ?= $(shell uname -r)
LINUX ?= /lib/modules/$(KVERSION)/build
KERNELSRC ?= /lib/modules/$(KVERSION)/build
ifdef REPO_PARENT
ZIO ?= $(REPO_PARENT)/fmc/zio
......@@ -57,19 +57,14 @@ GIT_VERSION = $(shell git describe --always --dirty --long --tags)
all: modules
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) \
FMC_EXTRA_SYMBOLS-y=$(FMC_EXTRA_SYMBOLS-y) \
ZIO_VERSION=$(ZIO_VERSION) \
GIT_VERSION=$(GIT_VERSION) \
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) -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)
#if KERNEL_VERSION(4, 15, 0) <= LINUX_VERSION_CODE
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
static void fa_calib_gain_update(unsigned long arg)
......
......@@ -154,7 +154,7 @@ int main(int argc, char *argv[])
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);
if (last) {
......
......@@ -25,7 +25,7 @@ static char git_version[] = "version: " GIT_VERSION;
#define buf_len 50
#define base_len 40
/* 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 {
FAU_TRG_EN,
......@@ -63,10 +63,8 @@ int fau_write_attribute(enum fau_attribute attr, uint32_t val)
/* convert val to string */
snprintf(buf, buf_len, "%u",val);
/* build the attribute path */
strncpy(fullpath, basepath, path_len);
if (path_len > 0)
fullpath[path_len -1] = '\0';
strncat(fullpath, attribute[attr], path_len);
snprintf(fullpath, path_len, "%s%s", basepath, attribute[attr]);
/* Write the attribute */
printf("Writing %s in %s\n", buf, fullpath);
fd = open(fullpath, O_WRONLY);
......@@ -190,7 +188,7 @@ int main(int argc, char *argv[])
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);
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