Re: [PATCH v4] staging: nrf24: add new driver for 2.4GHz radio transceiver
On Tue, Feb 19, 2019 at 11:20:10AM +0100, Greg Kroah-Hartman wrote: > On Wed, Feb 13, 2019 at 08:40:35PM +0100, Marcin Ciupak wrote: > > This patch adds driver for Nordic Semiconductor nRF24L01+ radio > > transceiver. > > > > Signed-off-by: Marcin Ciupak > > --- > > Changes in v2: > > - add terminating newlines to all logging formats > > Changes in v3: > > - patch subject > > - comments cleanup > > - goto labels cleanup > > - scnprintf bugfix > > - ida_simple_remove bugfix > > Changes in v4: > > - fix smatch warnings > > What is preventing this from being merged today with the normal > subsystem for this type of drivers? Why does this have to go into > staging? > > thanks, > > greg k-h As per TODO file: +Todo: +- opening and closing pipes via sysfs +- improve switching in between RX and TX +- improve handling of MAX_RT interrupt +- find and fix bugs +- code cleanup Additionally, I would like to add ioctl (or any similar) interface as configuration via sysfs is not very efficent in here. My beliefes are that this driver needs some time in staging, but I might be wrong and if you believe otherwise just let me know and I will try to push it ti regular sybsystem. Thanks, Marcin
[PATCH v4] staging: nrf24: add new driver for 2.4GHz radio transceiver
This patch adds driver for Nordic Semiconductor nRF24L01+ radio transceiver. Signed-off-by: Marcin Ciupak --- Changes in v2: - add terminating newlines to all logging formats Changes in v3: - patch subject - comments cleanup - goto labels cleanup - scnprintf bugfix - ida_simple_remove bugfix Changes in v4: - fix smatch warnings drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/nrf24/Kconfig | 16 + drivers/staging/nrf24/Makefile| 3 + drivers/staging/nrf24/TODO| 7 + .../nrf24/devicetree/nrf24-spi0-overlay.dts | 54 ++ .../nrf24/devicetree/nrf24-spi1-overlay.dts | 54 ++ drivers/staging/nrf24/devicetree/nrf24.txt| 1 + drivers/staging/nrf24/nRF24L01.h | 82 ++ drivers/staging/nrf24/nrf24_enums.h | 60 ++ drivers/staging/nrf24/nrf24_hal.c | 764 +++ drivers/staging/nrf24/nrf24_hal.h | 54 ++ drivers/staging/nrf24/nrf24_if.c | 893 ++ drivers/staging/nrf24/nrf24_if.h | 63 ++ drivers/staging/nrf24/nrf24_sysfs.c | 707 ++ drivers/staging/nrf24/nrf24_sysfs.h | 14 + 16 files changed, 2775 insertions(+) create mode 100644 drivers/staging/nrf24/Kconfig create mode 100644 drivers/staging/nrf24/Makefile create mode 100644 drivers/staging/nrf24/TODO create mode 100644 drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts create mode 100644 drivers/staging/nrf24/devicetree/nrf24-spi1-overlay.dts create mode 100644 drivers/staging/nrf24/devicetree/nrf24.txt create mode 100644 drivers/staging/nrf24/nRF24L01.h create mode 100644 drivers/staging/nrf24/nrf24_enums.h create mode 100644 drivers/staging/nrf24/nrf24_hal.c create mode 100644 drivers/staging/nrf24/nrf24_hal.h create mode 100644 drivers/staging/nrf24/nrf24_if.c create mode 100644 drivers/staging/nrf24/nrf24_if.h create mode 100644 drivers/staging/nrf24/nrf24_sysfs.c create mode 100644 drivers/staging/nrf24/nrf24_sysfs.h diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index c0901b96cfe4..8473823aaa6f 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -124,4 +124,6 @@ source "drivers/staging/axis-fifo/Kconfig" source "drivers/staging/erofs/Kconfig" +source "drivers/staging/nrf24/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 57c6bce13ff4..10709ab6f42c 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -52,3 +52,4 @@ obj-$(CONFIG_SOC_MT7621) += mt7621-dts/ obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket/ obj-$(CONFIG_XIL_AXIS_FIFO)+= axis-fifo/ obj-$(CONFIG_EROFS_FS) += erofs/ +obj-$(CONFIG_NRF24)+= nrf24/ diff --git a/drivers/staging/nrf24/Kconfig b/drivers/staging/nrf24/Kconfig new file mode 100644 index ..67ebf14dd982 --- /dev/null +++ b/drivers/staging/nrf24/Kconfig @@ -0,0 +1,16 @@ +config NRF24 +tristate "nRF24L01+ 2.4GHz radio module support" +depends on SPI +help + This enables support for Nordic Semiconductor nRF24L01+ radio module, + with the following features: +- multiple radio module instances via nrfX +- dedicated /dev/nrfX.Y device per pipe per instance +- dynamic and static payload lengths +- configuration via sysfs (/sys/class/nrfX) +- poll mechanism +- 64kB RX FIFO per pipe +- 64kB TX FIFO + + To compile this driver as a module, choose M here: the module will be + called nrf24. diff --git a/drivers/staging/nrf24/Makefile b/drivers/staging/nrf24/Makefile new file mode 100644 index ..f5222567c632 --- /dev/null +++ b/drivers/staging/nrf24/Makefile @@ -0,0 +1,3 @@ +obj-$(CONFIG_NRF24) += nrf24.o + +nrf24-objs := nrf24_if.o nrf24_hal.o nrf24_sysfs.o diff --git a/drivers/staging/nrf24/TODO b/drivers/staging/nrf24/TODO new file mode 100644 index ..a089e43faac5 --- /dev/null +++ b/drivers/staging/nrf24/TODO @@ -0,0 +1,7 @@ +Todo: +- opening and closing pipes via sysfs +- improve switching in between RX and TX +- improve handling of MAX_RT interrupt +- find and fix bugs +- code cleanup + diff --git a/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts b/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts new file mode 100644 index ..130e6787b76d --- /dev/null +++ b/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-2.0 + +// +// Copyright (C) 2017 Marcin Ciupak +// + +// Definitions for NRF24 +/dts-v1/; +/plugin/; + +/ { + compatible = "bcm,bcm2835", "bcm,bcm2708", "bcm,bcm2709"; + + fragment@0 { + target = <>; + __overlay__ { +
Re: [PATCH v3] staging: nrf24: add new driver for 2.4GHz radio transceiver
On Fri, Oct 19, 2018 at 09:58:01AM +0300, Dan Carpenter wrote: > Hi Marcin, > > Thank you for the patch! Perhaps something to improve: > > url: > https://github.com/0day-ci/linux/commits/Marcin-Ciupak/staging-nrf24-add-new-driver-for-2-4GHz-radio-transceiver/20181018-164230 > > smatch warnings: > drivers/staging/nrf24/nrf24_if.c:538 nrf24_create_pipe() error: 'p->dev' > dereferencing possible ERR_PTR() > drivers/staging/nrf24/nrf24_if.c:753 nrf24_probe() error: 'device' > dereferencing possible ERR_PTR() > drivers/staging/nrf24/nrf24_sysfs.c:118 plw_store() warn: impossible > condition '(old < 0) => (0-255 < 0)' > > # > https://github.com/0day-ci/linux/commit/f4952b4a228f4dc0149a814630c94e0e87a9f473 > git remote add linux-review https://github.com/0day-ci/linux > git remote update linux-review > git checkout f4952b4a228f4dc0149a814630c94e0e87a9f473 > vim +538 drivers/staging/nrf24/nrf24_if.c > > f4952b4a Marcin Ciupak 2018-10-17 503 > f4952b4a Marcin Ciupak 2018-10-17 504 static struct nrf24_pipe > *nrf24_create_pipe(struct nrf24_device *device, int id) > f4952b4a Marcin Ciupak 2018-10-17 505 { > f4952b4a Marcin Ciupak 2018-10-17 506 int ret; > f4952b4a Marcin Ciupak 2018-10-17 507 struct nrf24_pipe *p; > f4952b4a Marcin Ciupak 2018-10-17 508 > f4952b4a Marcin Ciupak 2018-10-17 509//sets flags to false as well > f4952b4a Marcin Ciupak 2018-10-17 510p = kzalloc(sizeof(*p), > GFP_KERNEL); > f4952b4a Marcin Ciupak 2018-10-17 511 if (!p) { > f4952b4a Marcin Ciupak 2018-10-17 512 ret = -ENOMEM; > f4952b4a Marcin Ciupak 2018-10-17 513goto err_return; > f4952b4a Marcin Ciupak 2018-10-17 514} > f4952b4a Marcin Ciupak 2018-10-17 515 > f4952b4a Marcin Ciupak 2018-10-17 516ret = > ida_simple_get(_ida_pipe, 0, 0, GFP_KERNEL); > f4952b4a Marcin Ciupak 2018-10-17 517if (ret < 0) { > f4952b4a Marcin Ciupak 2018-10-17 518dev_err(>dev, > "%s: get_minor failed\n", __func__); > f4952b4a Marcin Ciupak 2018-10-17 519goto err_free_mem; > f4952b4a Marcin Ciupak 2018-10-17 520 } > f4952b4a Marcin Ciupak 2018-10-17 521 > f4952b4a Marcin Ciupak 2018-10-17 522 p->devt = > MKDEV(MAJOR(nrf24_dev), ret); > f4952b4a Marcin Ciupak 2018-10-17 523p->id = id; > f4952b4a Marcin Ciupak 2018-10-17 524 > f4952b4a Marcin Ciupak 2018-10-17 525 INIT_KFIFO(p->rx_fifo); > f4952b4a Marcin Ciupak 2018-10-17 526 > init_waitqueue_head(>poll_wait_queue); > f4952b4a Marcin Ciupak 2018-10-17 527 > f4952b4a Marcin Ciupak 2018-10-17 528p->dev = > device_create_with_groups(nrf24_class, > f4952b4a Marcin Ciupak 2018-10-17 529 >>dev, > f4952b4a Marcin Ciupak 2018-10-17 530 > p->devt, > f4952b4a Marcin Ciupak 2018-10-17 531 >p, > f4952b4a Marcin Ciupak 2018-10-17 532 >nrf24_pipe_groups, > f4952b4a Marcin Ciupak 2018-10-17 533 >"%s.%d", > f4952b4a Marcin Ciupak 2018-10-17 534 >dev_name(>dev), > f4952b4a Marcin Ciupak 2018-10-17 535 >id); > f4952b4a Marcin Ciupak 2018-10-17 536 > f4952b4a Marcin Ciupak 2018-10-17 537if (IS_ERR(p->dev)) { > f4952b4a Marcin Ciupak 2018-10-17 @538dev_err(>dev, > f4952b4a Marcin Ciupak 2018-10-17 539"%s: > device_create of '%s' failed\n", > f4952b4a Marcin Ciupak 2018-10-17 540__func__, > f4952b4a Marcin Ciupak 2018-10-17 541 > dev_name(p->dev)); > f4952b4a Marcin Ciupak 2018-10-17 542ret = PTR_ERR(p->dev); > f4952b4a Marcin Ciupak 2018-10-17 543goto err_ida_remove; > f4952b4a Marcin Ciupak 2018-10-17 544} > f4952b4a Marcin Ciupak 2018-10-17 545 > f4952b4a Marcin Ciupak 2018-10-17 546cdev_init(>cdev, > _fops); > f4952b4a Marcin Ciupak 2018-10-17 547p->cdev.owner = THIS_MODULE; > f4952b4a Marcin Ciupak 2018-10-17 548ret = cdev_add(>cdev, > p->devt, 1); > f4952b4a Marcin Ciupak 2018-10-17 549if (ret < 0) { > f4952b4a Marcin Ciupak 2018-10-17 550dev_err(>dev, > "%s: cdev failed\n", __func__); > f4952b4a Marcin Ciupak 2018-10-17 551 goto err_dev_destroy; > f4952b4a Marcin Ciupak 2018-10-17 552} >
Re: [PATCH v3] staging: nrf24: add new driver for 2.4GHz radio transceiver
On Fri, Oct 19, 2018 at 09:58:01AM +0300, Dan Carpenter wrote: > Hi Marcin, > > Thank you for the patch! Perhaps something to improve: > > url: > https://github.com/0day-ci/linux/commits/Marcin-Ciupak/staging-nrf24-add-new-driver-for-2-4GHz-radio-transceiver/20181018-164230 > > smatch warnings: > drivers/staging/nrf24/nrf24_if.c:538 nrf24_create_pipe() error: 'p->dev' > dereferencing possible ERR_PTR() > drivers/staging/nrf24/nrf24_if.c:753 nrf24_probe() error: 'device' > dereferencing possible ERR_PTR() > drivers/staging/nrf24/nrf24_sysfs.c:118 plw_store() warn: impossible > condition '(old < 0) => (0-255 < 0)' > > # > https://github.com/0day-ci/linux/commit/f4952b4a228f4dc0149a814630c94e0e87a9f473 > git remote add linux-review https://github.com/0day-ci/linux > git remote update linux-review > git checkout f4952b4a228f4dc0149a814630c94e0e87a9f473 > vim +538 drivers/staging/nrf24/nrf24_if.c > > f4952b4a Marcin Ciupak 2018-10-17 503 > f4952b4a Marcin Ciupak 2018-10-17 504 static struct nrf24_pipe > *nrf24_create_pipe(struct nrf24_device *device, int id) > f4952b4a Marcin Ciupak 2018-10-17 505 { > f4952b4a Marcin Ciupak 2018-10-17 506 int ret; > f4952b4a Marcin Ciupak 2018-10-17 507 struct nrf24_pipe *p; > f4952b4a Marcin Ciupak 2018-10-17 508 > f4952b4a Marcin Ciupak 2018-10-17 509//sets flags to false as well > f4952b4a Marcin Ciupak 2018-10-17 510p = kzalloc(sizeof(*p), > GFP_KERNEL); > f4952b4a Marcin Ciupak 2018-10-17 511 if (!p) { > f4952b4a Marcin Ciupak 2018-10-17 512 ret = -ENOMEM; > f4952b4a Marcin Ciupak 2018-10-17 513goto err_return; > f4952b4a Marcin Ciupak 2018-10-17 514} > f4952b4a Marcin Ciupak 2018-10-17 515 > f4952b4a Marcin Ciupak 2018-10-17 516ret = > ida_simple_get(_ida_pipe, 0, 0, GFP_KERNEL); > f4952b4a Marcin Ciupak 2018-10-17 517if (ret < 0) { > f4952b4a Marcin Ciupak 2018-10-17 518dev_err(>dev, > "%s: get_minor failed\n", __func__); > f4952b4a Marcin Ciupak 2018-10-17 519goto err_free_mem; > f4952b4a Marcin Ciupak 2018-10-17 520 } > f4952b4a Marcin Ciupak 2018-10-17 521 > f4952b4a Marcin Ciupak 2018-10-17 522 p->devt = > MKDEV(MAJOR(nrf24_dev), ret); > f4952b4a Marcin Ciupak 2018-10-17 523p->id = id; > f4952b4a Marcin Ciupak 2018-10-17 524 > f4952b4a Marcin Ciupak 2018-10-17 525 INIT_KFIFO(p->rx_fifo); > f4952b4a Marcin Ciupak 2018-10-17 526 > init_waitqueue_head(>poll_wait_queue); > f4952b4a Marcin Ciupak 2018-10-17 527 > f4952b4a Marcin Ciupak 2018-10-17 528p->dev = > device_create_with_groups(nrf24_class, > f4952b4a Marcin Ciupak 2018-10-17 529 >>dev, > f4952b4a Marcin Ciupak 2018-10-17 530 > p->devt, > f4952b4a Marcin Ciupak 2018-10-17 531 >p, > f4952b4a Marcin Ciupak 2018-10-17 532 >nrf24_pipe_groups, > f4952b4a Marcin Ciupak 2018-10-17 533 >"%s.%d", > f4952b4a Marcin Ciupak 2018-10-17 534 >dev_name(>dev), > f4952b4a Marcin Ciupak 2018-10-17 535 >id); > f4952b4a Marcin Ciupak 2018-10-17 536 > f4952b4a Marcin Ciupak 2018-10-17 537if (IS_ERR(p->dev)) { > f4952b4a Marcin Ciupak 2018-10-17 @538dev_err(>dev, > f4952b4a Marcin Ciupak 2018-10-17 539"%s: > device_create of '%s' failed\n", > f4952b4a Marcin Ciupak 2018-10-17 540__func__, > f4952b4a Marcin Ciupak 2018-10-17 541 > dev_name(p->dev)); > f4952b4a Marcin Ciupak 2018-10-17 542ret = PTR_ERR(p->dev); > f4952b4a Marcin Ciupak 2018-10-17 543goto err_ida_remove; > f4952b4a Marcin Ciupak 2018-10-17 544} > f4952b4a Marcin Ciupak 2018-10-17 545 > f4952b4a Marcin Ciupak 2018-10-17 546cdev_init(>cdev, > _fops); > f4952b4a Marcin Ciupak 2018-10-17 547p->cdev.owner = THIS_MODULE; > f4952b4a Marcin Ciupak 2018-10-17 548ret = cdev_add(>cdev, > p->devt, 1); > f4952b4a Marcin Ciupak 2018-10-17 549if (ret < 0) { > f4952b4a Marcin Ciupak 2018-10-17 550dev_err(>dev, > "%s: cdev failed\n", __func__); > f4952b4a Marcin Ciupak 2018-10-17 551 goto err_dev_destroy; > f4952b4a Marcin Ciupak 2018-10-17 552} >
[PATCH v3] staging: nrf24: add new driver for 2.4GHz radio transceiver
This patch adds driver for Nordic Semiconductor nRF24L01+ radio transceiver. Signed-off-by: Marcin Ciupak --- Changes in v2: - add terminating newlines to all logging formats Changes in v3: - patch subject - comments cleanup - goto labels cleanup - scnprintf bugfix - ida_simple_remove bugfix drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/nrf24/Kconfig | 16 + drivers/staging/nrf24/Makefile| 3 + drivers/staging/nrf24/TODO| 7 + .../nrf24/devicetree/nrf24-spi0-overlay.dts | 54 ++ .../nrf24/devicetree/nrf24-spi1-overlay.dts | 54 ++ drivers/staging/nrf24/devicetree/nrf24.txt| 1 + drivers/staging/nrf24/nRF24L01.h | 82 ++ drivers/staging/nrf24/nrf24_enums.h | 60 ++ drivers/staging/nrf24/nrf24_hal.c | 764 +++ drivers/staging/nrf24/nrf24_hal.h | 54 ++ drivers/staging/nrf24/nrf24_if.c | 893 ++ drivers/staging/nrf24/nrf24_if.h | 63 ++ drivers/staging/nrf24/nrf24_sysfs.c | 707 ++ drivers/staging/nrf24/nrf24_sysfs.h | 14 + 16 files changed, 2775 insertions(+) create mode 100644 drivers/staging/nrf24/Kconfig create mode 100644 drivers/staging/nrf24/Makefile create mode 100644 drivers/staging/nrf24/TODO create mode 100644 drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts create mode 100644 drivers/staging/nrf24/devicetree/nrf24-spi1-overlay.dts create mode 100644 drivers/staging/nrf24/devicetree/nrf24.txt create mode 100644 drivers/staging/nrf24/nRF24L01.h create mode 100644 drivers/staging/nrf24/nrf24_enums.h create mode 100644 drivers/staging/nrf24/nrf24_hal.c create mode 100644 drivers/staging/nrf24/nrf24_hal.h create mode 100644 drivers/staging/nrf24/nrf24_if.c create mode 100644 drivers/staging/nrf24/nrf24_if.h create mode 100644 drivers/staging/nrf24/nrf24_sysfs.c create mode 100644 drivers/staging/nrf24/nrf24_sysfs.h diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 1abf76be2aa8..55d688f3112e 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -126,4 +126,6 @@ source "drivers/staging/axis-fifo/Kconfig" source "drivers/staging/erofs/Kconfig" +source "drivers/staging/nrf24/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index ab0cbe8815b1..c18e74df03af 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -53,3 +53,4 @@ obj-$(CONFIG_SOC_MT7621) += mt7621-dts/ obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket/ obj-$(CONFIG_XIL_AXIS_FIFO)+= axis-fifo/ obj-$(CONFIG_EROFS_FS) += erofs/ +obj-$(CONFIG_NRF24)+= nrf24/ diff --git a/drivers/staging/nrf24/Kconfig b/drivers/staging/nrf24/Kconfig new file mode 100644 index ..67ebf14dd982 --- /dev/null +++ b/drivers/staging/nrf24/Kconfig @@ -0,0 +1,16 @@ +config NRF24 +tristate "nRF24L01+ 2.4GHz radio module support" +depends on SPI +help + This enables support for Nordic Semiconductor nRF24L01+ radio module, + with the following features: +- multiple radio module instances via nrfX +- dedicated /dev/nrfX.Y device per pipe per instance +- dynamic and static payload lengths +- configuration via sysfs (/sys/class/nrfX) +- poll mechanism +- 64kB RX FIFO per pipe +- 64kB TX FIFO + + To compile this driver as a module, choose M here: the module will be + called nrf24. diff --git a/drivers/staging/nrf24/Makefile b/drivers/staging/nrf24/Makefile new file mode 100644 index ..f5222567c632 --- /dev/null +++ b/drivers/staging/nrf24/Makefile @@ -0,0 +1,3 @@ +obj-$(CONFIG_NRF24) += nrf24.o + +nrf24-objs := nrf24_if.o nrf24_hal.o nrf24_sysfs.o diff --git a/drivers/staging/nrf24/TODO b/drivers/staging/nrf24/TODO new file mode 100644 index ..a089e43faac5 --- /dev/null +++ b/drivers/staging/nrf24/TODO @@ -0,0 +1,7 @@ +Todo: +- opening and closing pipes via sysfs +- improve switching in between RX and TX +- improve handling of MAX_RT interrupt +- find and fix bugs +- code cleanup + diff --git a/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts b/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts new file mode 100644 index ..130e6787b76d --- /dev/null +++ b/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-2.0 + +// +// Copyright (C) 2017 Marcin Ciupak +// + +// Definitions for NRF24 +/dts-v1/; +/plugin/; + +/ { + compatible = "bcm,bcm2835", "bcm,bcm2708", "bcm,bcm2709"; + + fragment@0 { + target = <>; + __overlay__ { + #address-cells = &l
[PATCH v3] staging: nrf24: add new driver for 2.4GHz radio transceiver
This patch adds driver for Nordic Semiconductor nRF24L01+ radio transceiver. Signed-off-by: Marcin Ciupak --- Changes in v2: - add terminating newlines to all logging formats Changes in v3: - patch subject - comments cleanup - goto labels cleanup - scnprintf bugfix - ida_simple_remove bugfix drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/nrf24/Kconfig | 16 + drivers/staging/nrf24/Makefile| 3 + drivers/staging/nrf24/TODO| 7 + .../nrf24/devicetree/nrf24-spi0-overlay.dts | 54 ++ .../nrf24/devicetree/nrf24-spi1-overlay.dts | 54 ++ drivers/staging/nrf24/devicetree/nrf24.txt| 1 + drivers/staging/nrf24/nRF24L01.h | 82 ++ drivers/staging/nrf24/nrf24_enums.h | 60 ++ drivers/staging/nrf24/nrf24_hal.c | 764 +++ drivers/staging/nrf24/nrf24_hal.h | 54 ++ drivers/staging/nrf24/nrf24_if.c | 893 ++ drivers/staging/nrf24/nrf24_if.h | 63 ++ drivers/staging/nrf24/nrf24_sysfs.c | 707 ++ drivers/staging/nrf24/nrf24_sysfs.h | 14 + 16 files changed, 2775 insertions(+) create mode 100644 drivers/staging/nrf24/Kconfig create mode 100644 drivers/staging/nrf24/Makefile create mode 100644 drivers/staging/nrf24/TODO create mode 100644 drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts create mode 100644 drivers/staging/nrf24/devicetree/nrf24-spi1-overlay.dts create mode 100644 drivers/staging/nrf24/devicetree/nrf24.txt create mode 100644 drivers/staging/nrf24/nRF24L01.h create mode 100644 drivers/staging/nrf24/nrf24_enums.h create mode 100644 drivers/staging/nrf24/nrf24_hal.c create mode 100644 drivers/staging/nrf24/nrf24_hal.h create mode 100644 drivers/staging/nrf24/nrf24_if.c create mode 100644 drivers/staging/nrf24/nrf24_if.h create mode 100644 drivers/staging/nrf24/nrf24_sysfs.c create mode 100644 drivers/staging/nrf24/nrf24_sysfs.h diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 1abf76be2aa8..55d688f3112e 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -126,4 +126,6 @@ source "drivers/staging/axis-fifo/Kconfig" source "drivers/staging/erofs/Kconfig" +source "drivers/staging/nrf24/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index ab0cbe8815b1..c18e74df03af 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -53,3 +53,4 @@ obj-$(CONFIG_SOC_MT7621) += mt7621-dts/ obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket/ obj-$(CONFIG_XIL_AXIS_FIFO)+= axis-fifo/ obj-$(CONFIG_EROFS_FS) += erofs/ +obj-$(CONFIG_NRF24)+= nrf24/ diff --git a/drivers/staging/nrf24/Kconfig b/drivers/staging/nrf24/Kconfig new file mode 100644 index ..67ebf14dd982 --- /dev/null +++ b/drivers/staging/nrf24/Kconfig @@ -0,0 +1,16 @@ +config NRF24 +tristate "nRF24L01+ 2.4GHz radio module support" +depends on SPI +help + This enables support for Nordic Semiconductor nRF24L01+ radio module, + with the following features: +- multiple radio module instances via nrfX +- dedicated /dev/nrfX.Y device per pipe per instance +- dynamic and static payload lengths +- configuration via sysfs (/sys/class/nrfX) +- poll mechanism +- 64kB RX FIFO per pipe +- 64kB TX FIFO + + To compile this driver as a module, choose M here: the module will be + called nrf24. diff --git a/drivers/staging/nrf24/Makefile b/drivers/staging/nrf24/Makefile new file mode 100644 index ..f5222567c632 --- /dev/null +++ b/drivers/staging/nrf24/Makefile @@ -0,0 +1,3 @@ +obj-$(CONFIG_NRF24) += nrf24.o + +nrf24-objs := nrf24_if.o nrf24_hal.o nrf24_sysfs.o diff --git a/drivers/staging/nrf24/TODO b/drivers/staging/nrf24/TODO new file mode 100644 index ..a089e43faac5 --- /dev/null +++ b/drivers/staging/nrf24/TODO @@ -0,0 +1,7 @@ +Todo: +- opening and closing pipes via sysfs +- improve switching in between RX and TX +- improve handling of MAX_RT interrupt +- find and fix bugs +- code cleanup + diff --git a/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts b/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts new file mode 100644 index ..130e6787b76d --- /dev/null +++ b/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-2.0 + +// +// Copyright (C) 2017 Marcin Ciupak +// + +// Definitions for NRF24 +/dts-v1/; +/plugin/; + +/ { + compatible = "bcm,bcm2835", "bcm,bcm2708", "bcm,bcm2709"; + + fragment@0 { + target = <>; + __overlay__ { + #address-cells = &l
Re: [PATCH v2] staging: add nrf24 driver
On Tue, Oct 16, 2018 at 02:41:50PM +0300, Dan Carpenter wrote: > When we add drivers, can we use the new subsystem prefix for the driver? > In other words: > > [PATCH] staging: nrf24: Add new driver for 2.4Ghz radio transceiver > Sure. > This driver seems basically OK to me. I don't think you necessarily > need to go through staging? Have you tried sending it directly to > netdev? > I have not tried that, mainly as I believe it is not mature enough. I would give it some time in staging for testing and bugfixing. If you say that it is not needed and can be done out of staging, I will ask netdev if it can be accepted there. > > + //take out size of data > > This comment is sort of useless? "take out" is like Chinese food. It > seems like it should be obvious what the code does. The format is > wrong. So there are very minor things to be tidied up. > Agree, I will do comments cleanup. > > + ret = kfifo_out(>tx_fifo, , sizeof(size)); > > + if (ret != sizeof(size)) { > > + dev_dbg(>dev, "get size from fifo failed\n"); > > + mutex_unlock(>tx_fifo_mutex); > > + continue; > > + } > > + > > + //alloc space for data > > + buf = kzalloc(size, GFP_KERNEL); > > + if (!buf) { > > + dev_dbg(>dev, "buf alloc failed\n"); > > + mutex_unlock(>tx_fifo_mutex); > > + continue; > > + } > > + > > + //take out size of data > > + ret = kfifo_out(>tx_fifo, buf, size); > > + if (ret != size) { > > + dev_dbg(>dev, "get buf from fifo failed\n"); > > + mutex_unlock(>tx_fifo_mutex); > > + goto next; > > + } > > + > > + //unlock tx fifo > > + mutex_unlock(>tx_fifo_mutex); > > + > > + //enter Standby-I mode > > + nrf24_ce_lo(device); > > + > > + //set TX MODE > > + ret = nrf24_set_mode(device->spi, NRF24_MODE_TX); > > + if (ret < 0) > > + goto next; > > + > > + //set PIPE0 address > > + //this is needed to receive ACK > > + ret = nrf24_set_address(device->spi, > > + NRF24_PIPE0, > > + (u8 *)>cfg.address); > > + if (ret < 0) { > > + dev_dbg(>dev, "set PIPE0 address failed > > (%d)\n", ret); > > + goto next; > > + } > > + > > + //set TX address > > + ret = nrf24_set_address(device->spi, > > + NRF24_TX, > > + (u8 *)>cfg.address); > > + if (ret < 0) { > > + dev_dbg(>dev, "set TX address failed (%d)\n", > > ret); > > + goto next; > > + } > > + > > + //check if pipe uses static payload length > > + spl = p->cfg.plw != 0; > > + > > + //check if dynamic payload length is enabled > > + dpl = nrf24_get_dynamic_pl(device->spi); > > + > > + if (spl && dpl) { > > + //disable dynamic payload if pipe > > + //does not use dynamic payload > > + //and dynamic paload is enabled > > + ret = nrf24_disable_dynamic_pl(device->spi); > > + if (ret < 0) > > + goto next; > > + } > > + > > + memset(pload, 0, PLOAD_MAX); > > + memcpy(pload, , sizeof(size)); > > + > > + //calculate payload length > > + n = spl ? p->cfg.plw : sizeof(size); > > + > > + //send size > > + nrf24_write_tx_pload(device->spi, pload, n); > > + if (ret < 0) { > > + dev_dbg(>dev, "write TX PLOAD failed (%d)\n", > > ret); > > + goto next; > > + } > > + > > + //enter TX MODE and start transmission > > + nrf24_ce_hi(device); > > + > > + //wait for ACK > > + wait_event_interruptible(device->tx_done_wait_queue, > > +(device->tx_done || > > +kthread_should_stop())); > > + > > + if (kthread_should_stop()) > > + goto abort; > > + > > + //clear counter > > + sent = 0; > > + > > + while (size > 0) { > > + n = spl ? p->cfg.plw : min_t(ssize_t, size, PLOAD_MAX); > > + > > + dev_dbg(>dev, "tx %zd bytes\n", n); > > + > > + memset(pload, 0, PLOAD_MAX); > > + memcpy(pload, buf + sent, n); > > + > > + //write PLOAD to nRF FIFO > > + ret = nrf24_write_tx_pload(device->spi, pload, n); > > + > > + if (ret < 0) { > > + dev_dbg(>dev, > > +
Re: [PATCH v2] staging: add nrf24 driver
On Tue, Oct 16, 2018 at 02:41:50PM +0300, Dan Carpenter wrote: > When we add drivers, can we use the new subsystem prefix for the driver? > In other words: > > [PATCH] staging: nrf24: Add new driver for 2.4Ghz radio transceiver > Sure. > This driver seems basically OK to me. I don't think you necessarily > need to go through staging? Have you tried sending it directly to > netdev? > I have not tried that, mainly as I believe it is not mature enough. I would give it some time in staging for testing and bugfixing. If you say that it is not needed and can be done out of staging, I will ask netdev if it can be accepted there. > > + //take out size of data > > This comment is sort of useless? "take out" is like Chinese food. It > seems like it should be obvious what the code does. The format is > wrong. So there are very minor things to be tidied up. > Agree, I will do comments cleanup. > > + ret = kfifo_out(>tx_fifo, , sizeof(size)); > > + if (ret != sizeof(size)) { > > + dev_dbg(>dev, "get size from fifo failed\n"); > > + mutex_unlock(>tx_fifo_mutex); > > + continue; > > + } > > + > > + //alloc space for data > > + buf = kzalloc(size, GFP_KERNEL); > > + if (!buf) { > > + dev_dbg(>dev, "buf alloc failed\n"); > > + mutex_unlock(>tx_fifo_mutex); > > + continue; > > + } > > + > > + //take out size of data > > + ret = kfifo_out(>tx_fifo, buf, size); > > + if (ret != size) { > > + dev_dbg(>dev, "get buf from fifo failed\n"); > > + mutex_unlock(>tx_fifo_mutex); > > + goto next; > > + } > > + > > + //unlock tx fifo > > + mutex_unlock(>tx_fifo_mutex); > > + > > + //enter Standby-I mode > > + nrf24_ce_lo(device); > > + > > + //set TX MODE > > + ret = nrf24_set_mode(device->spi, NRF24_MODE_TX); > > + if (ret < 0) > > + goto next; > > + > > + //set PIPE0 address > > + //this is needed to receive ACK > > + ret = nrf24_set_address(device->spi, > > + NRF24_PIPE0, > > + (u8 *)>cfg.address); > > + if (ret < 0) { > > + dev_dbg(>dev, "set PIPE0 address failed > > (%d)\n", ret); > > + goto next; > > + } > > + > > + //set TX address > > + ret = nrf24_set_address(device->spi, > > + NRF24_TX, > > + (u8 *)>cfg.address); > > + if (ret < 0) { > > + dev_dbg(>dev, "set TX address failed (%d)\n", > > ret); > > + goto next; > > + } > > + > > + //check if pipe uses static payload length > > + spl = p->cfg.plw != 0; > > + > > + //check if dynamic payload length is enabled > > + dpl = nrf24_get_dynamic_pl(device->spi); > > + > > + if (spl && dpl) { > > + //disable dynamic payload if pipe > > + //does not use dynamic payload > > + //and dynamic paload is enabled > > + ret = nrf24_disable_dynamic_pl(device->spi); > > + if (ret < 0) > > + goto next; > > + } > > + > > + memset(pload, 0, PLOAD_MAX); > > + memcpy(pload, , sizeof(size)); > > + > > + //calculate payload length > > + n = spl ? p->cfg.plw : sizeof(size); > > + > > + //send size > > + nrf24_write_tx_pload(device->spi, pload, n); > > + if (ret < 0) { > > + dev_dbg(>dev, "write TX PLOAD failed (%d)\n", > > ret); > > + goto next; > > + } > > + > > + //enter TX MODE and start transmission > > + nrf24_ce_hi(device); > > + > > + //wait for ACK > > + wait_event_interruptible(device->tx_done_wait_queue, > > +(device->tx_done || > > +kthread_should_stop())); > > + > > + if (kthread_should_stop()) > > + goto abort; > > + > > + //clear counter > > + sent = 0; > > + > > + while (size > 0) { > > + n = spl ? p->cfg.plw : min_t(ssize_t, size, PLOAD_MAX); > > + > > + dev_dbg(>dev, "tx %zd bytes\n", n); > > + > > + memset(pload, 0, PLOAD_MAX); > > + memcpy(pload, buf + sent, n); > > + > > + //write PLOAD to nRF FIFO > > + ret = nrf24_write_tx_pload(device->spi, pload, n); > > + > > + if (ret < 0) { > > + dev_dbg(>dev, > > +
[PATCH v2] staging: add nrf24 driver
This patch adds driver for Nordic Semiconductor nRF24L01+ radio module. Signed-off-by: Marcin Ciupak --- Changes in v2: - add terminating newlines to all logging formats drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/nrf24/Kconfig | 16 + drivers/staging/nrf24/Makefile| 3 + drivers/staging/nrf24/TODO| 7 + .../nrf24/devicetree/nrf24-spi0-overlay.dts | 54 + .../nrf24/devicetree/nrf24-spi1-overlay.dts | 54 + drivers/staging/nrf24/devicetree/nrf24.txt| 1 + drivers/staging/nrf24/nRF24L01.h | 82 ++ drivers/staging/nrf24/nrf24_enums.h | 60 ++ drivers/staging/nrf24/nrf24_hal.c | 764 +++ drivers/staging/nrf24/nrf24_hal.h | 54 + drivers/staging/nrf24/nrf24_if.c | 919 ++ drivers/staging/nrf24/nrf24_if.h | 63 ++ drivers/staging/nrf24/nrf24_sysfs.c | 707 ++ drivers/staging/nrf24/nrf24_sysfs.h | 14 + 16 files changed, 2801 insertions(+) create mode 100644 drivers/staging/nrf24/Kconfig create mode 100644 drivers/staging/nrf24/Makefile create mode 100644 drivers/staging/nrf24/TODO create mode 100644 drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts create mode 100644 drivers/staging/nrf24/devicetree/nrf24-spi1-overlay.dts create mode 100644 drivers/staging/nrf24/devicetree/nrf24.txt create mode 100644 drivers/staging/nrf24/nRF24L01.h create mode 100644 drivers/staging/nrf24/nrf24_enums.h create mode 100644 drivers/staging/nrf24/nrf24_hal.c create mode 100644 drivers/staging/nrf24/nrf24_hal.h create mode 100644 drivers/staging/nrf24/nrf24_if.c create mode 100644 drivers/staging/nrf24/nrf24_if.h create mode 100644 drivers/staging/nrf24/nrf24_sysfs.c create mode 100644 drivers/staging/nrf24/nrf24_sysfs.h diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 1abf76be2aa8..55d688f3112e 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -126,4 +126,6 @@ source "drivers/staging/axis-fifo/Kconfig" source "drivers/staging/erofs/Kconfig" +source "drivers/staging/nrf24/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index ab0cbe8815b1..c18e74df03af 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -53,3 +53,4 @@ obj-$(CONFIG_SOC_MT7621) += mt7621-dts/ obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket/ obj-$(CONFIG_XIL_AXIS_FIFO)+= axis-fifo/ obj-$(CONFIG_EROFS_FS) += erofs/ +obj-$(CONFIG_NRF24)+= nrf24/ diff --git a/drivers/staging/nrf24/Kconfig b/drivers/staging/nrf24/Kconfig new file mode 100644 index ..67ebf14dd982 --- /dev/null +++ b/drivers/staging/nrf24/Kconfig @@ -0,0 +1,16 @@ +config NRF24 +tristate "nRF24L01+ 2.4GHz radio module support" +depends on SPI +help + This enables support for Nordic Semiconductor nRF24L01+ radio module, + with the following features: +- multiple radio module instances via nrfX +- dedicated /dev/nrfX.Y device per pipe per instance +- dynamic and static payload lengths +- configuration via sysfs (/sys/class/nrfX) +- poll mechanism +- 64kB RX FIFO per pipe +- 64kB TX FIFO + + To compile this driver as a module, choose M here: the module will be + called nrf24. diff --git a/drivers/staging/nrf24/Makefile b/drivers/staging/nrf24/Makefile new file mode 100644 index ..f5222567c632 --- /dev/null +++ b/drivers/staging/nrf24/Makefile @@ -0,0 +1,3 @@ +obj-$(CONFIG_NRF24) += nrf24.o + +nrf24-objs := nrf24_if.o nrf24_hal.o nrf24_sysfs.o diff --git a/drivers/staging/nrf24/TODO b/drivers/staging/nrf24/TODO new file mode 100644 index ..a089e43faac5 --- /dev/null +++ b/drivers/staging/nrf24/TODO @@ -0,0 +1,7 @@ +Todo: +- opening and closing pipes via sysfs +- improve switching in between RX and TX +- improve handling of MAX_RT interrupt +- find and fix bugs +- code cleanup + diff --git a/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts b/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts new file mode 100644 index ..130e6787b76d --- /dev/null +++ b/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-2.0 + +// +// Copyright (C) 2017 Marcin Ciupak +// + +// Definitions for NRF24 +/dts-v1/; +/plugin/; + +/ { + compatible = "bcm,bcm2835", "bcm,bcm2708", "bcm,bcm2709"; + + fragment@0 { + target = <>; + __overlay__ { + #address-cells = <1>; + #size-cells = <0>; + status = "o
[PATCH v2] staging: add nrf24 driver
This patch adds driver for Nordic Semiconductor nRF24L01+ radio module. Signed-off-by: Marcin Ciupak --- Changes in v2: - add terminating newlines to all logging formats drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/nrf24/Kconfig | 16 + drivers/staging/nrf24/Makefile| 3 + drivers/staging/nrf24/TODO| 7 + .../nrf24/devicetree/nrf24-spi0-overlay.dts | 54 + .../nrf24/devicetree/nrf24-spi1-overlay.dts | 54 + drivers/staging/nrf24/devicetree/nrf24.txt| 1 + drivers/staging/nrf24/nRF24L01.h | 82 ++ drivers/staging/nrf24/nrf24_enums.h | 60 ++ drivers/staging/nrf24/nrf24_hal.c | 764 +++ drivers/staging/nrf24/nrf24_hal.h | 54 + drivers/staging/nrf24/nrf24_if.c | 919 ++ drivers/staging/nrf24/nrf24_if.h | 63 ++ drivers/staging/nrf24/nrf24_sysfs.c | 707 ++ drivers/staging/nrf24/nrf24_sysfs.h | 14 + 16 files changed, 2801 insertions(+) create mode 100644 drivers/staging/nrf24/Kconfig create mode 100644 drivers/staging/nrf24/Makefile create mode 100644 drivers/staging/nrf24/TODO create mode 100644 drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts create mode 100644 drivers/staging/nrf24/devicetree/nrf24-spi1-overlay.dts create mode 100644 drivers/staging/nrf24/devicetree/nrf24.txt create mode 100644 drivers/staging/nrf24/nRF24L01.h create mode 100644 drivers/staging/nrf24/nrf24_enums.h create mode 100644 drivers/staging/nrf24/nrf24_hal.c create mode 100644 drivers/staging/nrf24/nrf24_hal.h create mode 100644 drivers/staging/nrf24/nrf24_if.c create mode 100644 drivers/staging/nrf24/nrf24_if.h create mode 100644 drivers/staging/nrf24/nrf24_sysfs.c create mode 100644 drivers/staging/nrf24/nrf24_sysfs.h diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 1abf76be2aa8..55d688f3112e 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -126,4 +126,6 @@ source "drivers/staging/axis-fifo/Kconfig" source "drivers/staging/erofs/Kconfig" +source "drivers/staging/nrf24/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index ab0cbe8815b1..c18e74df03af 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -53,3 +53,4 @@ obj-$(CONFIG_SOC_MT7621) += mt7621-dts/ obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket/ obj-$(CONFIG_XIL_AXIS_FIFO)+= axis-fifo/ obj-$(CONFIG_EROFS_FS) += erofs/ +obj-$(CONFIG_NRF24)+= nrf24/ diff --git a/drivers/staging/nrf24/Kconfig b/drivers/staging/nrf24/Kconfig new file mode 100644 index ..67ebf14dd982 --- /dev/null +++ b/drivers/staging/nrf24/Kconfig @@ -0,0 +1,16 @@ +config NRF24 +tristate "nRF24L01+ 2.4GHz radio module support" +depends on SPI +help + This enables support for Nordic Semiconductor nRF24L01+ radio module, + with the following features: +- multiple radio module instances via nrfX +- dedicated /dev/nrfX.Y device per pipe per instance +- dynamic and static payload lengths +- configuration via sysfs (/sys/class/nrfX) +- poll mechanism +- 64kB RX FIFO per pipe +- 64kB TX FIFO + + To compile this driver as a module, choose M here: the module will be + called nrf24. diff --git a/drivers/staging/nrf24/Makefile b/drivers/staging/nrf24/Makefile new file mode 100644 index ..f5222567c632 --- /dev/null +++ b/drivers/staging/nrf24/Makefile @@ -0,0 +1,3 @@ +obj-$(CONFIG_NRF24) += nrf24.o + +nrf24-objs := nrf24_if.o nrf24_hal.o nrf24_sysfs.o diff --git a/drivers/staging/nrf24/TODO b/drivers/staging/nrf24/TODO new file mode 100644 index ..a089e43faac5 --- /dev/null +++ b/drivers/staging/nrf24/TODO @@ -0,0 +1,7 @@ +Todo: +- opening and closing pipes via sysfs +- improve switching in between RX and TX +- improve handling of MAX_RT interrupt +- find and fix bugs +- code cleanup + diff --git a/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts b/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts new file mode 100644 index ..130e6787b76d --- /dev/null +++ b/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-2.0 + +// +// Copyright (C) 2017 Marcin Ciupak +// + +// Definitions for NRF24 +/dts-v1/; +/plugin/; + +/ { + compatible = "bcm,bcm2835", "bcm,bcm2708", "bcm,bcm2709"; + + fragment@0 { + target = <>; + __overlay__ { + #address-cells = <1>; + #size-cells = <0>; + status = "o
[PATCH] staging: add nrf24 driver
This patch adds driver for Nordic Semiconductor nRF24L01+ radio module. Signed-off-by: Marcin Ciupak --- drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/nrf24/Kconfig | 16 + drivers/staging/nrf24/Makefile| 3 + drivers/staging/nrf24/TODO| 7 + .../nrf24/devicetree/nrf24-spi0-overlay.dts | 54 ++ .../nrf24/devicetree/nrf24-spi1-overlay.dts | 54 ++ drivers/staging/nrf24/devicetree/nrf24.txt| 1 + drivers/staging/nrf24/nRF24L01.h | 82 ++ drivers/staging/nrf24/nrf24_enums.h | 60 ++ drivers/staging/nrf24/nrf24_hal.c | 764 +++ drivers/staging/nrf24/nrf24_hal.h | 54 ++ drivers/staging/nrf24/nrf24_if.c | 917 ++ drivers/staging/nrf24/nrf24_if.h | 63 ++ drivers/staging/nrf24/nrf24_sysfs.c | 707 ++ drivers/staging/nrf24/nrf24_sysfs.h | 14 + 16 files changed, 2799 insertions(+) create mode 100644 drivers/staging/nrf24/Kconfig create mode 100644 drivers/staging/nrf24/Makefile create mode 100644 drivers/staging/nrf24/TODO create mode 100644 drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts create mode 100644 drivers/staging/nrf24/devicetree/nrf24-spi1-overlay.dts create mode 100644 drivers/staging/nrf24/devicetree/nrf24.txt create mode 100644 drivers/staging/nrf24/nRF24L01.h create mode 100644 drivers/staging/nrf24/nrf24_enums.h create mode 100644 drivers/staging/nrf24/nrf24_hal.c create mode 100644 drivers/staging/nrf24/nrf24_hal.h create mode 100644 drivers/staging/nrf24/nrf24_if.c create mode 100644 drivers/staging/nrf24/nrf24_if.h create mode 100644 drivers/staging/nrf24/nrf24_sysfs.c create mode 100644 drivers/staging/nrf24/nrf24_sysfs.h diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 1abf76be2aa8..55d688f3112e 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -126,4 +126,6 @@ source "drivers/staging/axis-fifo/Kconfig" source "drivers/staging/erofs/Kconfig" +source "drivers/staging/nrf24/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index ab0cbe8815b1..c18e74df03af 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -53,3 +53,4 @@ obj-$(CONFIG_SOC_MT7621) += mt7621-dts/ obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket/ obj-$(CONFIG_XIL_AXIS_FIFO)+= axis-fifo/ obj-$(CONFIG_EROFS_FS) += erofs/ +obj-$(CONFIG_NRF24)+= nrf24/ diff --git a/drivers/staging/nrf24/Kconfig b/drivers/staging/nrf24/Kconfig new file mode 100644 index ..67ebf14dd982 --- /dev/null +++ b/drivers/staging/nrf24/Kconfig @@ -0,0 +1,16 @@ +config NRF24 +tristate "nRF24L01+ 2.4GHz radio module support" +depends on SPI +help + This enables support for Nordic Semiconductor nRF24L01+ radio module, + with the following features: +- multiple radio module instances via nrfX +- dedicated /dev/nrfX.Y device per pipe per instance +- dynamic and static payload lengths +- configuration via sysfs (/sys/class/nrfX) +- poll mechanism +- 64kB RX FIFO per pipe +- 64kB TX FIFO + + To compile this driver as a module, choose M here: the module will be + called nrf24. diff --git a/drivers/staging/nrf24/Makefile b/drivers/staging/nrf24/Makefile new file mode 100644 index ..f5222567c632 --- /dev/null +++ b/drivers/staging/nrf24/Makefile @@ -0,0 +1,3 @@ +obj-$(CONFIG_NRF24) += nrf24.o + +nrf24-objs := nrf24_if.o nrf24_hal.o nrf24_sysfs.o diff --git a/drivers/staging/nrf24/TODO b/drivers/staging/nrf24/TODO new file mode 100644 index ..a089e43faac5 --- /dev/null +++ b/drivers/staging/nrf24/TODO @@ -0,0 +1,7 @@ +Todo: +- opening and closing pipes via sysfs +- improve switching in between RX and TX +- improve handling of MAX_RT interrupt +- find and fix bugs +- code cleanup + diff --git a/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts b/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts new file mode 100644 index ..130e6787b76d --- /dev/null +++ b/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-2.0 + +// +// Copyright (C) 2017 Marcin Ciupak +// + +// Definitions for NRF24 +/dts-v1/; +/plugin/; + +/ { + compatible = "bcm,bcm2835", "bcm,bcm2708", "bcm,bcm2709"; + + fragment@0 { + target = <>; + __overlay__ { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + spidev@0 { +
[PATCH] staging: add nrf24 driver
This patch adds driver for Nordic Semiconductor nRF24L01+ radio module. Signed-off-by: Marcin Ciupak --- drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/nrf24/Kconfig | 16 + drivers/staging/nrf24/Makefile| 3 + drivers/staging/nrf24/TODO| 7 + .../nrf24/devicetree/nrf24-spi0-overlay.dts | 54 ++ .../nrf24/devicetree/nrf24-spi1-overlay.dts | 54 ++ drivers/staging/nrf24/devicetree/nrf24.txt| 1 + drivers/staging/nrf24/nRF24L01.h | 82 ++ drivers/staging/nrf24/nrf24_enums.h | 60 ++ drivers/staging/nrf24/nrf24_hal.c | 764 +++ drivers/staging/nrf24/nrf24_hal.h | 54 ++ drivers/staging/nrf24/nrf24_if.c | 917 ++ drivers/staging/nrf24/nrf24_if.h | 63 ++ drivers/staging/nrf24/nrf24_sysfs.c | 707 ++ drivers/staging/nrf24/nrf24_sysfs.h | 14 + 16 files changed, 2799 insertions(+) create mode 100644 drivers/staging/nrf24/Kconfig create mode 100644 drivers/staging/nrf24/Makefile create mode 100644 drivers/staging/nrf24/TODO create mode 100644 drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts create mode 100644 drivers/staging/nrf24/devicetree/nrf24-spi1-overlay.dts create mode 100644 drivers/staging/nrf24/devicetree/nrf24.txt create mode 100644 drivers/staging/nrf24/nRF24L01.h create mode 100644 drivers/staging/nrf24/nrf24_enums.h create mode 100644 drivers/staging/nrf24/nrf24_hal.c create mode 100644 drivers/staging/nrf24/nrf24_hal.h create mode 100644 drivers/staging/nrf24/nrf24_if.c create mode 100644 drivers/staging/nrf24/nrf24_if.h create mode 100644 drivers/staging/nrf24/nrf24_sysfs.c create mode 100644 drivers/staging/nrf24/nrf24_sysfs.h diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 1abf76be2aa8..55d688f3112e 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -126,4 +126,6 @@ source "drivers/staging/axis-fifo/Kconfig" source "drivers/staging/erofs/Kconfig" +source "drivers/staging/nrf24/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index ab0cbe8815b1..c18e74df03af 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -53,3 +53,4 @@ obj-$(CONFIG_SOC_MT7621) += mt7621-dts/ obj-$(CONFIG_STAGING_GASKET_FRAMEWORK) += gasket/ obj-$(CONFIG_XIL_AXIS_FIFO)+= axis-fifo/ obj-$(CONFIG_EROFS_FS) += erofs/ +obj-$(CONFIG_NRF24)+= nrf24/ diff --git a/drivers/staging/nrf24/Kconfig b/drivers/staging/nrf24/Kconfig new file mode 100644 index ..67ebf14dd982 --- /dev/null +++ b/drivers/staging/nrf24/Kconfig @@ -0,0 +1,16 @@ +config NRF24 +tristate "nRF24L01+ 2.4GHz radio module support" +depends on SPI +help + This enables support for Nordic Semiconductor nRF24L01+ radio module, + with the following features: +- multiple radio module instances via nrfX +- dedicated /dev/nrfX.Y device per pipe per instance +- dynamic and static payload lengths +- configuration via sysfs (/sys/class/nrfX) +- poll mechanism +- 64kB RX FIFO per pipe +- 64kB TX FIFO + + To compile this driver as a module, choose M here: the module will be + called nrf24. diff --git a/drivers/staging/nrf24/Makefile b/drivers/staging/nrf24/Makefile new file mode 100644 index ..f5222567c632 --- /dev/null +++ b/drivers/staging/nrf24/Makefile @@ -0,0 +1,3 @@ +obj-$(CONFIG_NRF24) += nrf24.o + +nrf24-objs := nrf24_if.o nrf24_hal.o nrf24_sysfs.o diff --git a/drivers/staging/nrf24/TODO b/drivers/staging/nrf24/TODO new file mode 100644 index ..a089e43faac5 --- /dev/null +++ b/drivers/staging/nrf24/TODO @@ -0,0 +1,7 @@ +Todo: +- opening and closing pipes via sysfs +- improve switching in between RX and TX +- improve handling of MAX_RT interrupt +- find and fix bugs +- code cleanup + diff --git a/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts b/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts new file mode 100644 index ..130e6787b76d --- /dev/null +++ b/drivers/staging/nrf24/devicetree/nrf24-spi0-overlay.dts @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-2.0 + +// +// Copyright (C) 2017 Marcin Ciupak +// + +// Definitions for NRF24 +/dts-v1/; +/plugin/; + +/ { + compatible = "bcm,bcm2835", "bcm,bcm2708", "bcm,bcm2709"; + + fragment@0 { + target = <>; + __overlay__ { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + spidev@0 { +
[PATCH 2/2] staging: pi433: fix naming when more than one radio is used
When using more than one hardware radio module pi433_probe fails as the same name is used for all modules. Create unique name by adding minor number to the device name. Signed-off-by: Marcin Ciupak <marcin.s.ciu...@gmail.com> --- drivers/staging/pi433/pi433_if.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index bc17676169cb..7a3e3101c483 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -1172,7 +1172,8 @@ static int pi433_probe(struct spi_device *spi) >dev, device->devt, device, - "pi433"); + "pi433.%d", + device->minor); if (IS_ERR(device->dev)) { pr_err("pi433: device register failed\n"); retval = PTR_ERR(device->dev); @@ -1188,7 +1189,8 @@ static int pi433_probe(struct spi_device *spi) /* start tx thread */ device->tx_task_struct = kthread_run(pi433_tx_thread, device, -"pi433_tx_task"); +"pi433.%d_tx_task", +device->minor); if (IS_ERR(device->tx_task_struct)) { dev_dbg(device->dev, "start of send thread failed"); goto send_thread_failed; -- 2.15.0
[PATCH 2/2] staging: pi433: fix naming when more than one radio is used
When using more than one hardware radio module pi433_probe fails as the same name is used for all modules. Create unique name by adding minor number to the device name. Signed-off-by: Marcin Ciupak --- drivers/staging/pi433/pi433_if.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index bc17676169cb..7a3e3101c483 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -1172,7 +1172,8 @@ static int pi433_probe(struct spi_device *spi) >dev, device->devt, device, - "pi433"); + "pi433.%d", + device->minor); if (IS_ERR(device->dev)) { pr_err("pi433: device register failed\n"); retval = PTR_ERR(device->dev); @@ -1188,7 +1189,8 @@ static int pi433_probe(struct spi_device *spi) /* start tx thread */ device->tx_task_struct = kthread_run(pi433_tx_thread, device, -"pi433_tx_task"); +"pi433.%d_tx_task", +device->minor); if (IS_ERR(device->tx_task_struct)) { dev_dbg(device->dev, "start of send thread failed"); goto send_thread_failed; -- 2.15.0
[PATCH 1/2] staging: pi433: fix (NULL device *) in log message
(NULL device *) is printed in log message in pi433_probe and pi433_get_minor functions due to device->dev being used prior to call to device_create function. Signed-off-by: Marcin Ciupak <marcin.s.ciu...@gmail.com> --- drivers/staging/pi433/pi433_if.c | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index d946838450d4..bc17676169cb 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -1051,7 +1051,7 @@ static int pi433_get_minor(struct pi433_device *device) device->minor = retval; retval = 0; } else if (retval == -ENOSPC) { - dev_err(device->dev, "too many pi433 devices\n"); + dev_err(>spi->dev, "too many pi433 devices\n"); retval = -EINVAL; } mutex_unlock(_lock); @@ -1159,19 +1159,10 @@ static int pi433_probe(struct spi_device *spi) SET_CHECKED(rf69_set_output_power_level (spi, 13)); SET_CHECKED(rf69_set_antenna_impedance (spi, fiftyOhm)); - /* start tx thread */ - device->tx_task_struct = kthread_run(pi433_tx_thread, -device, -"pi433_tx_task"); - if (IS_ERR(device->tx_task_struct)) { - dev_dbg(device->dev, "start of send thread failed"); - goto send_thread_failed; - } - /* determ minor number */ retval = pi433_get_minor(device); if (retval) { - dev_dbg(device->dev, "get of minor number failed"); + dev_dbg(>dev, "get of minor number failed"); goto minor_failed; } @@ -1194,6 +1185,15 @@ static int pi433_probe(struct spi_device *spi) device->minor); } + /* start tx thread */ + device->tx_task_struct = kthread_run(pi433_tx_thread, +device, +"pi433_tx_task"); + if (IS_ERR(device->tx_task_struct)) { + dev_dbg(device->dev, "start of send thread failed"); + goto send_thread_failed; + } + /* create cdev */ device->cdev = cdev_alloc(); device->cdev->owner = THIS_MODULE; @@ -1210,12 +1210,12 @@ static int pi433_probe(struct spi_device *spi) return 0; cdev_failed: + kthread_stop(device->tx_task_struct); +send_thread_failed: device_destroy(pi433_class, device->devt); device_create_failed: pi433_free_minor(device); minor_failed: - kthread_stop(device->tx_task_struct); -send_thread_failed: free_GPIOs(device); GPIO_failed: kfree(device); -- 2.15.0
[PATCH 1/2] staging: pi433: fix (NULL device *) in log message
(NULL device *) is printed in log message in pi433_probe and pi433_get_minor functions due to device->dev being used prior to call to device_create function. Signed-off-by: Marcin Ciupak --- drivers/staging/pi433/pi433_if.c | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index d946838450d4..bc17676169cb 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -1051,7 +1051,7 @@ static int pi433_get_minor(struct pi433_device *device) device->minor = retval; retval = 0; } else if (retval == -ENOSPC) { - dev_err(device->dev, "too many pi433 devices\n"); + dev_err(>spi->dev, "too many pi433 devices\n"); retval = -EINVAL; } mutex_unlock(_lock); @@ -1159,19 +1159,10 @@ static int pi433_probe(struct spi_device *spi) SET_CHECKED(rf69_set_output_power_level (spi, 13)); SET_CHECKED(rf69_set_antenna_impedance (spi, fiftyOhm)); - /* start tx thread */ - device->tx_task_struct = kthread_run(pi433_tx_thread, -device, -"pi433_tx_task"); - if (IS_ERR(device->tx_task_struct)) { - dev_dbg(device->dev, "start of send thread failed"); - goto send_thread_failed; - } - /* determ minor number */ retval = pi433_get_minor(device); if (retval) { - dev_dbg(device->dev, "get of minor number failed"); + dev_dbg(>dev, "get of minor number failed"); goto minor_failed; } @@ -1194,6 +1185,15 @@ static int pi433_probe(struct spi_device *spi) device->minor); } + /* start tx thread */ + device->tx_task_struct = kthread_run(pi433_tx_thread, +device, +"pi433_tx_task"); + if (IS_ERR(device->tx_task_struct)) { + dev_dbg(device->dev, "start of send thread failed"); + goto send_thread_failed; + } + /* create cdev */ device->cdev = cdev_alloc(); device->cdev->owner = THIS_MODULE; @@ -1210,12 +1210,12 @@ static int pi433_probe(struct spi_device *spi) return 0; cdev_failed: + kthread_stop(device->tx_task_struct); +send_thread_failed: device_destroy(pi433_class, device->devt); device_create_failed: pi433_free_minor(device); minor_failed: - kthread_stop(device->tx_task_struct); -send_thread_failed: free_GPIOs(device); GPIO_failed: kfree(device); -- 2.15.0
[PATCH 0/2] staging: pi433: fix logging and naming issues
These patches fix messages logging and device naming issues when probing for new radio module. Those two changes are send as one patchset since both modify the same part of code (second patch depends on first one) Marcin Ciupak (2): staging: pi433: fix (NULL device *) in log message staging: pi433: fix naming when more than one radio is used drivers/staging/pi433/pi433_if.c | 30 -- 1 file changed, 16 insertions(+), 14 deletions(-) -- 2.15.0
[PATCH 0/2] staging: pi433: fix logging and naming issues
These patches fix messages logging and device naming issues when probing for new radio module. Those two changes are send as one patchset since both modify the same part of code (second patch depends on first one) Marcin Ciupak (2): staging: pi433: fix (NULL device *) in log message staging: pi433: fix naming when more than one radio is used drivers/staging/pi433/pi433_if.c | 30 -- 1 file changed, 16 insertions(+), 14 deletions(-) -- 2.15.0
[PATCH 5/5] staging: pi433: rf69.c style fix - space before asterisk
This patch fixes the following checkpatch.pl error: ERROR: "(foo*)" should be "(foo *)" in rf69.c file as requested by TODO file. Additionally some style warnings remain valid here and could be fixed by another patch. Signed-off-by: Marcin Ciupak <marcin.s.ciu...@gmail.com> --- drivers/staging/pi433/rf69.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 6420d1b67ccc..e69a2153c999 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -919,7 +919,7 @@ int rf69_set_fifo_threshold(struct spi_device *spi, u8 threshold) return retval; // access the fifo to activate new threshold - return rf69_read_fifo (spi, (u8*) , 1); // retval used as buffer + return rf69_read_fifo(spi, (u8 *), 1); // retval used as buffer } int rf69_set_dagc(struct spi_device *spi, enum dagc dagc) -- 2.14.2
[PATCH 5/5] staging: pi433: rf69.c style fix - space before asterisk
This patch fixes the following checkpatch.pl error: ERROR: "(foo*)" should be "(foo *)" in rf69.c file as requested by TODO file. Additionally some style warnings remain valid here and could be fixed by another patch. Signed-off-by: Marcin Ciupak --- drivers/staging/pi433/rf69.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 6420d1b67ccc..e69a2153c999 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -919,7 +919,7 @@ int rf69_set_fifo_threshold(struct spi_device *spi, u8 threshold) return retval; // access the fifo to activate new threshold - return rf69_read_fifo (spi, (u8*) , 1); // retval used as buffer + return rf69_read_fifo(spi, (u8 *), 1); // retval used as buffer } int rf69_set_dagc(struct spi_device *spi, enum dagc dagc) -- 2.14.2
[PATCH 4/5] staging: pi433: rf69.c style fix - code indent should use tabs
This patch fixes the following checkpatch.pl error: ERROR: code indent should use tabs where possible in rf69.c file as requested by TODO file. Additionally some style warnings remain valid here and could be fixed by another patch. Signed-off-by: Marcin Ciupak <marcin.s.ciu...@gmail.com> --- drivers/staging/pi433/rf69.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 23d609474836..6420d1b67ccc 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -959,8 +959,8 @@ int rf69_read_fifo (struct spi_device *spi, u8 *buffer, unsigned int size) /* prepare a bidirectional transfer */ local_buffer[0] = REG_FIFO; memset(, 0, sizeof(transfer)); - transfer.tx_buf = local_buffer; - transfer.rx_buf = local_buffer; + transfer.tx_buf = local_buffer; + transfer.rx_buf = local_buffer; transfer.len= size+1; retval = spi_sync_transfer(spi, , 1); -- 2.14.2
[PATCH 4/5] staging: pi433: rf69.c style fix - code indent should use tabs
This patch fixes the following checkpatch.pl error: ERROR: code indent should use tabs where possible in rf69.c file as requested by TODO file. Additionally some style warnings remain valid here and could be fixed by another patch. Signed-off-by: Marcin Ciupak --- drivers/staging/pi433/rf69.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 23d609474836..6420d1b67ccc 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -959,8 +959,8 @@ int rf69_read_fifo (struct spi_device *spi, u8 *buffer, unsigned int size) /* prepare a bidirectional transfer */ local_buffer[0] = REG_FIFO; memset(, 0, sizeof(transfer)); - transfer.tx_buf = local_buffer; - transfer.rx_buf = local_buffer; + transfer.tx_buf = local_buffer; + transfer.rx_buf = local_buffer; transfer.len= size+1; retval = spi_sync_transfer(spi, , 1); -- 2.14.2
[PATCH 3/5] staging: pi433: rf69.c style fix - spaces before/after
his patch fixes the following checkpatch.pl errors: ERROR: space prohibited after that open parenthesis '(' ERROR: space prohibited before that ',' (ctx:WxV) ERROR: space prohibited before that close parenthesis ')' ERROR: space required after that ',' (ctx:VxV) ERROR: space required before the open parenthesis '(' in rf69.c file as requested by TODO file. Additionally some style warnings remain valid here and could be fixed by another patch. Signed-off-by: Marcin Ciupak <marcin.s.ciu...@gmail.com> --- drivers/staging/pi433/rf69.c | 154 +-- 1 file changed, 77 insertions(+), 77 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 7a79973641c9..23d609474836 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -34,7 +34,7 @@ /*-*/ #define READ_REG(x)rf69_read_reg (spi, x) -#define WRITE_REG(x,y) rf69_write_reg(spi, x, y) +#define WRITE_REG(x, y)rf69_write_reg(spi, x, y) /*-*/ @@ -199,7 +199,7 @@ int rf69_set_deviation(struct spi_device *spi, u32 deviation) // calculate register settings f_reg = deviation * factor; - do_div(f_reg , f_step); + do_div(f_reg, f_step); msb = (f_reg&0xff00) >> 8; lsb = (f_reg&0xff); @@ -250,7 +250,7 @@ int rf69_set_frequency(struct spi_device *spi, u32 frequency) // calculate reg settings f_reg = frequency * factor; - do_div(f_reg , f_step); + do_div(f_reg, f_step); msb = (f_reg&0xff) >> 16; mid = (f_reg&0xff00) >> 8; @@ -278,9 +278,9 @@ int rf69_set_amplifier_0(struct spi_device *spi, enum optionOnOff optionOnOff) dev_dbg(>dev, "set: amp #0"); #endif - switch(optionOnOff) { - case optionOn: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) | MASK_PALEVEL_PA0) ); - case optionOff: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) & ~MASK_PALEVEL_PA0) ); + switch (optionOnOff) { + case optionOn: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) | MASK_PALEVEL_PA0)); + case optionOff: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) & ~MASK_PALEVEL_PA0)); default: dev_dbg(>dev, "set: illegal input param"); return -EINVAL; @@ -293,9 +293,9 @@ int rf69_set_amplifier_1(struct spi_device *spi, enum optionOnOff optionOnOff) dev_dbg(>dev, "set: amp #1"); #endif - switch(optionOnOff) { - case optionOn: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) | MASK_PALEVEL_PA1) ); - case optionOff: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) & ~MASK_PALEVEL_PA1) ); + switch (optionOnOff) { + case optionOn: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) | MASK_PALEVEL_PA1)); + case optionOff: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) & ~MASK_PALEVEL_PA1)); default: dev_dbg(>dev, "set: illegal input param"); return -EINVAL; @@ -308,9 +308,9 @@ int rf69_set_amplifier_2(struct spi_device *spi, enum optionOnOff optionOnOff) dev_dbg(>dev, "set: amp #2"); #endif - switch(optionOnOff) { - case optionOn: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) | MASK_PALEVEL_PA2) ); - case optionOff: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) & ~MASK_PALEVEL_PA2) ); + switch (optionOnOff) { + case optionOn: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) | MASK_PALEVEL_PA2)); + case optionOff: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) & ~MASK_PALEVEL_PA2)); default: dev_dbg(>dev, "set: illegal input param"); return -EINVAL; @@ -341,7 +341,7 @@ int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp) dev_dbg(>dev, "set: pa ramp"); #endif - switch(paRamp) { + switch (paRamp) { case ramp3400: return WRITE_REG(REG_PARAMP, PARAMP_3400); case ramp2000: return WRITE_REG(REG_PARAMP, PARAMP_2000); case ramp1000: return WRITE_REG(REG_PARAMP, PARAMP_1000); @@ -370,9 +370,9 @@ int rf69_set_antenna_impedance(struct spi_device *spi, enum antennaImpedance ant dev_dbg(>dev, "set: antenna impedance"); #endif - switch(antennaImpedance) { - case fiftyOhm: return WRITE_REG(REG_LNA, (READ_REG(REG_LNA) & ~MASK_LNA_ZIN) ); - case twohundretOhm: return WRITE_REG(REG_LNA, (READ_REG(REG_LNA) | MASK_LNA_ZIN) ); + switch (antennaImpedance) { + ca
[PATCH 3/5] staging: pi433: rf69.c style fix - spaces before/after
his patch fixes the following checkpatch.pl errors: ERROR: space prohibited after that open parenthesis '(' ERROR: space prohibited before that ',' (ctx:WxV) ERROR: space prohibited before that close parenthesis ')' ERROR: space required after that ',' (ctx:VxV) ERROR: space required before the open parenthesis '(' in rf69.c file as requested by TODO file. Additionally some style warnings remain valid here and could be fixed by another patch. Signed-off-by: Marcin Ciupak --- drivers/staging/pi433/rf69.c | 154 +-- 1 file changed, 77 insertions(+), 77 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 7a79973641c9..23d609474836 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -34,7 +34,7 @@ /*-*/ #define READ_REG(x)rf69_read_reg (spi, x) -#define WRITE_REG(x,y) rf69_write_reg(spi, x, y) +#define WRITE_REG(x, y)rf69_write_reg(spi, x, y) /*-*/ @@ -199,7 +199,7 @@ int rf69_set_deviation(struct spi_device *spi, u32 deviation) // calculate register settings f_reg = deviation * factor; - do_div(f_reg , f_step); + do_div(f_reg, f_step); msb = (f_reg&0xff00) >> 8; lsb = (f_reg&0xff); @@ -250,7 +250,7 @@ int rf69_set_frequency(struct spi_device *spi, u32 frequency) // calculate reg settings f_reg = frequency * factor; - do_div(f_reg , f_step); + do_div(f_reg, f_step); msb = (f_reg&0xff) >> 16; mid = (f_reg&0xff00) >> 8; @@ -278,9 +278,9 @@ int rf69_set_amplifier_0(struct spi_device *spi, enum optionOnOff optionOnOff) dev_dbg(>dev, "set: amp #0"); #endif - switch(optionOnOff) { - case optionOn: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) | MASK_PALEVEL_PA0) ); - case optionOff: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) & ~MASK_PALEVEL_PA0) ); + switch (optionOnOff) { + case optionOn: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) | MASK_PALEVEL_PA0)); + case optionOff: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) & ~MASK_PALEVEL_PA0)); default: dev_dbg(>dev, "set: illegal input param"); return -EINVAL; @@ -293,9 +293,9 @@ int rf69_set_amplifier_1(struct spi_device *spi, enum optionOnOff optionOnOff) dev_dbg(>dev, "set: amp #1"); #endif - switch(optionOnOff) { - case optionOn: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) | MASK_PALEVEL_PA1) ); - case optionOff: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) & ~MASK_PALEVEL_PA1) ); + switch (optionOnOff) { + case optionOn: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) | MASK_PALEVEL_PA1)); + case optionOff: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) & ~MASK_PALEVEL_PA1)); default: dev_dbg(>dev, "set: illegal input param"); return -EINVAL; @@ -308,9 +308,9 @@ int rf69_set_amplifier_2(struct spi_device *spi, enum optionOnOff optionOnOff) dev_dbg(>dev, "set: amp #2"); #endif - switch(optionOnOff) { - case optionOn: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) | MASK_PALEVEL_PA2) ); - case optionOff: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) & ~MASK_PALEVEL_PA2) ); + switch (optionOnOff) { + case optionOn: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) | MASK_PALEVEL_PA2)); + case optionOff: return WRITE_REG(REG_PALEVEL, (READ_REG(REG_PALEVEL) & ~MASK_PALEVEL_PA2)); default: dev_dbg(>dev, "set: illegal input param"); return -EINVAL; @@ -341,7 +341,7 @@ int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp) dev_dbg(>dev, "set: pa ramp"); #endif - switch(paRamp) { + switch (paRamp) { case ramp3400: return WRITE_REG(REG_PARAMP, PARAMP_3400); case ramp2000: return WRITE_REG(REG_PARAMP, PARAMP_2000); case ramp1000: return WRITE_REG(REG_PARAMP, PARAMP_1000); @@ -370,9 +370,9 @@ int rf69_set_antenna_impedance(struct spi_device *spi, enum antennaImpedance ant dev_dbg(>dev, "set: antenna impedance"); #endif - switch(antennaImpedance) { - case fiftyOhm: return WRITE_REG(REG_LNA, (READ_REG(REG_LNA) & ~MASK_LNA_ZIN) ); - case twohundretOhm: return WRITE_REG(REG_LNA, (READ_REG(REG_LNA) | MASK_LNA_ZIN) ); + switch (antennaImpedance) { + case fiftyOhm: return
[PATCH 2/5] staging: pi433: rf69.c style fix - spaces required around
This patch fixes the following checkpatch.pl errors: ERROR: spaces required around that '+=' (ctx:WxV) ERROR: spaces required around that '=' (ctx:VxV) ERROR: spaces required around that '<' (ctx:VxV) in rf69.c file as requested by TODO file. Additionally some style warnings remain valid here and could be fixed by another patch. Signed-off-by: Marcin Ciupak <marcin.s.ciu...@gmail.com> --- drivers/staging/pi433/rf69.c | 26 -- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 3d9cf2cac4ef..7a79973641c9 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -323,7 +323,7 @@ int rf69_set_output_power_level(struct spi_device *spi, u8 powerLevel) dev_dbg(>dev, "set: power level"); #endif - powerLevel +=18; // TODO Abh�ngigkeit von PA0,1,2 setting + powerLevel += 18; // TODO Abh�ngigkeit von PA0,1,2 setting // check input value if (powerLevel > 0x1f) { @@ -589,24 +589,30 @@ int rf69_set_dio_mapping(struct spi_device *spi, u8 DIONumber, u8 value) switch (DIONumber) { case 0: - mask=MASK_DIO0; shift=SHIFT_DIO0; regaddr=REG_DIOMAPPING1; break; + mask = MASK_DIO0; shift = SHIFT_DIO0; regaddr = REG_DIOMAPPING1; + break; case 1: - mask=MASK_DIO1; shift=SHIFT_DIO1; regaddr=REG_DIOMAPPING1; break; + mask = MASK_DIO1; shift = SHIFT_DIO1; regaddr = REG_DIOMAPPING1; + break; case 2: - mask=MASK_DIO2; shift=SHIFT_DIO2; regaddr=REG_DIOMAPPING1; break; + mask = MASK_DIO2; shift = SHIFT_DIO2; regaddr = REG_DIOMAPPING1; + break; case 3: - mask=MASK_DIO3; shift=SHIFT_DIO3; regaddr=REG_DIOMAPPING1; break; + mask = MASK_DIO3; shift = SHIFT_DIO3; regaddr = REG_DIOMAPPING1; + break; case 4: - mask=MASK_DIO4; shift=SHIFT_DIO4; regaddr=REG_DIOMAPPING2; break; + mask = MASK_DIO4; shift = SHIFT_DIO4; regaddr = REG_DIOMAPPING2; + break; case 5: - mask=MASK_DIO5; shift=SHIFT_DIO5; regaddr=REG_DIOMAPPING2; break; + mask = MASK_DIO5; shift = SHIFT_DIO5; regaddr = REG_DIOMAPPING2; + break; default: dev_dbg(>dev, "set: illegal input param"); return -EINVAL; } // read reg - regValue=READ_REG(regaddr); + regValue = READ_REG(regaddr); // delete old value regValue = regValue & ~mask; // add new value @@ -960,7 +966,7 @@ int rf69_read_fifo (struct spi_device *spi, u8 *buffer, unsigned int size) retval = spi_sync_transfer(spi, , 1); #ifdef DEBUG_FIFO_ACCESS - for (i=0; i<size; i++) + for (i = 0; i < size; i++) dev_dbg(>dev, "%d - 0x%x\n", i, local_buffer[i+1]); #endif @@ -988,7 +994,7 @@ int rf69_write_fifo(struct spi_device *spi, u8 *buffer, unsigned int size) memcpy(_buffer[1], buffer, size); // TODO: ohne memcopy w�re sch�ner #ifdef DEBUG_FIFO_ACCESS - for (i=0; i<size; i++) + for (i = 0; i < size; i++) dev_dbg(>dev, "0x%x\n",buffer[i]); #endif -- 2.14.2
[PATCH 2/5] staging: pi433: rf69.c style fix - spaces required around
This patch fixes the following checkpatch.pl errors: ERROR: spaces required around that '+=' (ctx:WxV) ERROR: spaces required around that '=' (ctx:VxV) ERROR: spaces required around that '<' (ctx:VxV) in rf69.c file as requested by TODO file. Additionally some style warnings remain valid here and could be fixed by another patch. Signed-off-by: Marcin Ciupak --- drivers/staging/pi433/rf69.c | 26 -- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 3d9cf2cac4ef..7a79973641c9 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -323,7 +323,7 @@ int rf69_set_output_power_level(struct spi_device *spi, u8 powerLevel) dev_dbg(>dev, "set: power level"); #endif - powerLevel +=18; // TODO Abh�ngigkeit von PA0,1,2 setting + powerLevel += 18; // TODO Abh�ngigkeit von PA0,1,2 setting // check input value if (powerLevel > 0x1f) { @@ -589,24 +589,30 @@ int rf69_set_dio_mapping(struct spi_device *spi, u8 DIONumber, u8 value) switch (DIONumber) { case 0: - mask=MASK_DIO0; shift=SHIFT_DIO0; regaddr=REG_DIOMAPPING1; break; + mask = MASK_DIO0; shift = SHIFT_DIO0; regaddr = REG_DIOMAPPING1; + break; case 1: - mask=MASK_DIO1; shift=SHIFT_DIO1; regaddr=REG_DIOMAPPING1; break; + mask = MASK_DIO1; shift = SHIFT_DIO1; regaddr = REG_DIOMAPPING1; + break; case 2: - mask=MASK_DIO2; shift=SHIFT_DIO2; regaddr=REG_DIOMAPPING1; break; + mask = MASK_DIO2; shift = SHIFT_DIO2; regaddr = REG_DIOMAPPING1; + break; case 3: - mask=MASK_DIO3; shift=SHIFT_DIO3; regaddr=REG_DIOMAPPING1; break; + mask = MASK_DIO3; shift = SHIFT_DIO3; regaddr = REG_DIOMAPPING1; + break; case 4: - mask=MASK_DIO4; shift=SHIFT_DIO4; regaddr=REG_DIOMAPPING2; break; + mask = MASK_DIO4; shift = SHIFT_DIO4; regaddr = REG_DIOMAPPING2; + break; case 5: - mask=MASK_DIO5; shift=SHIFT_DIO5; regaddr=REG_DIOMAPPING2; break; + mask = MASK_DIO5; shift = SHIFT_DIO5; regaddr = REG_DIOMAPPING2; + break; default: dev_dbg(>dev, "set: illegal input param"); return -EINVAL; } // read reg - regValue=READ_REG(regaddr); + regValue = READ_REG(regaddr); // delete old value regValue = regValue & ~mask; // add new value @@ -960,7 +966,7 @@ int rf69_read_fifo (struct spi_device *spi, u8 *buffer, unsigned int size) retval = spi_sync_transfer(spi, , 1); #ifdef DEBUG_FIFO_ACCESS - for (i=0; idev, "%d - 0x%x\n", i, local_buffer[i+1]); #endif @@ -988,7 +994,7 @@ int rf69_write_fifo(struct spi_device *spi, u8 *buffer, unsigned int size) memcpy(_buffer[1], buffer, size); // TODO: ohne memcopy w�re sch�ner #ifdef DEBUG_FIFO_ACCESS - for (i=0; idev, "0x%x\n",buffer[i]); #endif -- 2.14.2
[PATCH 1/5] staging: pi433: rf69.c style fix - trailing statements
This patch fixes the following checkpatch.pl error: ERROR: trailing statements should be on next line in rf69.c file as requested by TODO file. Note: ERROR: spaces required around that '=' (ctx:VxV) remains valid here and is going to be fixed by the next patch in set. Additionally some style warnings remain valid here and could be fixed by another patch. Signed-off-by: Marcin Ciupak <marcin.s.ciu...@gmail.com> --- drivers/staging/pi433/rf69.c | 58 +++- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 0305edc16861..3d9cf2cac4ef 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -164,9 +164,12 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate) // transmit to RF 69 retval = WRITE_REG(REG_BITRATE_MSB, msb); - if (retval) return retval; + if (retval) + return retval; + retval = WRITE_REG(REG_BITRATE_LSB, lsb); - if (retval) return retval; + if (retval) + return retval; return 0; } @@ -209,9 +212,12 @@ int rf69_set_deviation(struct spi_device *spi, u32 deviation) // write to chip retval = WRITE_REG(REG_FDEV_MSB, msb); - if (retval) return retval; + if (retval) + return retval; + retval = WRITE_REG(REG_FDEV_LSB, lsb); - if (retval) return retval; + if (retval) + return retval; return 0; } @@ -252,11 +258,16 @@ int rf69_set_frequency(struct spi_device *spi, u32 frequency) // write to chip retval = WRITE_REG(REG_FRF_MSB, msb); - if (retval) return retval; + if (retval) + return retval; + retval = WRITE_REG(REG_FRF_MID, mid); - if (retval) return retval; + if (retval) + return retval; + retval = WRITE_REG(REG_FRF_LSB, lsb); - if (retval) return retval; + if (retval) + return retval; return 0; } @@ -471,9 +482,15 @@ static int rf69_set_bandwidth_intern(struct spi_device *spi, u8 reg, // add new mantisse switch(mantisse) { - case mantisse16: newValue = newValue | BW_MANT_16; break; - case mantisse20: newValue = newValue | BW_MANT_20; break; - case mantisse24: newValue = newValue | BW_MANT_24; break; + case mantisse16: + newValue = newValue | BW_MANT_16; + break; + case mantisse20: + newValue = newValue | BW_MANT_20; + break; + case mantisse24: + newValue = newValue | BW_MANT_24; + break; } // add new exponent @@ -571,12 +588,18 @@ int rf69_set_dio_mapping(struct spi_device *spi, u8 DIONumber, u8 value) #endif switch (DIONumber) { - case 0: mask=MASK_DIO0; shift=SHIFT_DIO0; regaddr=REG_DIOMAPPING1; break; - case 1: mask=MASK_DIO1; shift=SHIFT_DIO1; regaddr=REG_DIOMAPPING1; break; - case 2: mask=MASK_DIO2; shift=SHIFT_DIO2; regaddr=REG_DIOMAPPING1; break; - case 3: mask=MASK_DIO3; shift=SHIFT_DIO3; regaddr=REG_DIOMAPPING1; break; - case 4: mask=MASK_DIO4; shift=SHIFT_DIO4; regaddr=REG_DIOMAPPING2; break; - case 5: mask=MASK_DIO5; shift=SHIFT_DIO5; regaddr=REG_DIOMAPPING2; break; + case 0: + mask=MASK_DIO0; shift=SHIFT_DIO0; regaddr=REG_DIOMAPPING1; break; + case 1: + mask=MASK_DIO1; shift=SHIFT_DIO1; regaddr=REG_DIOMAPPING1; break; + case 2: + mask=MASK_DIO2; shift=SHIFT_DIO2; regaddr=REG_DIOMAPPING1; break; + case 3: + mask=MASK_DIO3; shift=SHIFT_DIO3; regaddr=REG_DIOMAPPING1; break; + case 4: + mask=MASK_DIO4; shift=SHIFT_DIO4; regaddr=REG_DIOMAPPING2; break; + case 5: + mask=MASK_DIO5; shift=SHIFT_DIO5; regaddr=REG_DIOMAPPING2; break; default: dev_dbg(>dev, "set: illegal input param"); return -EINVAL; @@ -686,7 +709,8 @@ int rf69_set_preamble_length(struct spi_device *spi, u16 preambleLength) /* transmit to chip */ retval = WRITE_REG(REG_PREAMBLE_MSB, msb); - if (retval) return retval; + if (retval) + return retval; return WRITE_REG(REG_PREAMBLE_LSB, lsb); } -- 2.14.2
[PATCH 1/5] staging: pi433: rf69.c style fix - trailing statements
This patch fixes the following checkpatch.pl error: ERROR: trailing statements should be on next line in rf69.c file as requested by TODO file. Note: ERROR: spaces required around that '=' (ctx:VxV) remains valid here and is going to be fixed by the next patch in set. Additionally some style warnings remain valid here and could be fixed by another patch. Signed-off-by: Marcin Ciupak --- drivers/staging/pi433/rf69.c | 58 +++- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 0305edc16861..3d9cf2cac4ef 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -164,9 +164,12 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate) // transmit to RF 69 retval = WRITE_REG(REG_BITRATE_MSB, msb); - if (retval) return retval; + if (retval) + return retval; + retval = WRITE_REG(REG_BITRATE_LSB, lsb); - if (retval) return retval; + if (retval) + return retval; return 0; } @@ -209,9 +212,12 @@ int rf69_set_deviation(struct spi_device *spi, u32 deviation) // write to chip retval = WRITE_REG(REG_FDEV_MSB, msb); - if (retval) return retval; + if (retval) + return retval; + retval = WRITE_REG(REG_FDEV_LSB, lsb); - if (retval) return retval; + if (retval) + return retval; return 0; } @@ -252,11 +258,16 @@ int rf69_set_frequency(struct spi_device *spi, u32 frequency) // write to chip retval = WRITE_REG(REG_FRF_MSB, msb); - if (retval) return retval; + if (retval) + return retval; + retval = WRITE_REG(REG_FRF_MID, mid); - if (retval) return retval; + if (retval) + return retval; + retval = WRITE_REG(REG_FRF_LSB, lsb); - if (retval) return retval; + if (retval) + return retval; return 0; } @@ -471,9 +482,15 @@ static int rf69_set_bandwidth_intern(struct spi_device *spi, u8 reg, // add new mantisse switch(mantisse) { - case mantisse16: newValue = newValue | BW_MANT_16; break; - case mantisse20: newValue = newValue | BW_MANT_20; break; - case mantisse24: newValue = newValue | BW_MANT_24; break; + case mantisse16: + newValue = newValue | BW_MANT_16; + break; + case mantisse20: + newValue = newValue | BW_MANT_20; + break; + case mantisse24: + newValue = newValue | BW_MANT_24; + break; } // add new exponent @@ -571,12 +588,18 @@ int rf69_set_dio_mapping(struct spi_device *spi, u8 DIONumber, u8 value) #endif switch (DIONumber) { - case 0: mask=MASK_DIO0; shift=SHIFT_DIO0; regaddr=REG_DIOMAPPING1; break; - case 1: mask=MASK_DIO1; shift=SHIFT_DIO1; regaddr=REG_DIOMAPPING1; break; - case 2: mask=MASK_DIO2; shift=SHIFT_DIO2; regaddr=REG_DIOMAPPING1; break; - case 3: mask=MASK_DIO3; shift=SHIFT_DIO3; regaddr=REG_DIOMAPPING1; break; - case 4: mask=MASK_DIO4; shift=SHIFT_DIO4; regaddr=REG_DIOMAPPING2; break; - case 5: mask=MASK_DIO5; shift=SHIFT_DIO5; regaddr=REG_DIOMAPPING2; break; + case 0: + mask=MASK_DIO0; shift=SHIFT_DIO0; regaddr=REG_DIOMAPPING1; break; + case 1: + mask=MASK_DIO1; shift=SHIFT_DIO1; regaddr=REG_DIOMAPPING1; break; + case 2: + mask=MASK_DIO2; shift=SHIFT_DIO2; regaddr=REG_DIOMAPPING1; break; + case 3: + mask=MASK_DIO3; shift=SHIFT_DIO3; regaddr=REG_DIOMAPPING1; break; + case 4: + mask=MASK_DIO4; shift=SHIFT_DIO4; regaddr=REG_DIOMAPPING2; break; + case 5: + mask=MASK_DIO5; shift=SHIFT_DIO5; regaddr=REG_DIOMAPPING2; break; default: dev_dbg(>dev, "set: illegal input param"); return -EINVAL; @@ -686,7 +709,8 @@ int rf69_set_preamble_length(struct spi_device *spi, u16 preambleLength) /* transmit to chip */ retval = WRITE_REG(REG_PREAMBLE_MSB, msb); - if (retval) return retval; + if (retval) + return retval; return WRITE_REG(REG_PREAMBLE_LSB, lsb); } -- 2.14.2
[PATCH 0/5] staging: pi433: rf69.c coding style errors cleanup
This set of patches is intended to fix coding style errors in rf69.c file in order to comply with kernel coding style guide as requested by TODO file. The following errors were fixed: ERROR: trailing statements should be on next line ERROR: spaces required around that '+=' (ctx:WxV) ERROR: spaces required around that '=' (ctx:VxV) ERROR: spaces required around that '<' (ctx:VxV) ERROR: space prohibited after that open parenthesis '(' ERROR: space prohibited before that ',' (ctx:WxV) ERROR: space prohibited before that close parenthesis ')' ERROR: space required after that ',' (ctx:VxV) ERROR: space required before the open parenthesis '(' ERROR: code indent should use tabs where possible ERROR: "(foo*)" should be "(foo *)" Marcin Ciupak (5): staging: pi433: rf69.c style fix - trailing statements staging: pi433: rf69.c style fix - spaces required around staging: pi433: rf69.c style fix - spaces before/after staging: pi433: rf69.c style fix - code indent should use tabs staging: pi433: rf69.c style fix - space before asterisk drivers/staging/pi433/rf69.c | 232 --- 1 file changed, 131 insertions(+), 101 deletions(-) -- 2.14.2
[PATCH 0/5] staging: pi433: rf69.c coding style errors cleanup
This set of patches is intended to fix coding style errors in rf69.c file in order to comply with kernel coding style guide as requested by TODO file. The following errors were fixed: ERROR: trailing statements should be on next line ERROR: spaces required around that '+=' (ctx:WxV) ERROR: spaces required around that '=' (ctx:VxV) ERROR: spaces required around that '<' (ctx:VxV) ERROR: space prohibited after that open parenthesis '(' ERROR: space prohibited before that ',' (ctx:WxV) ERROR: space prohibited before that close parenthesis ')' ERROR: space required after that ',' (ctx:VxV) ERROR: space required before the open parenthesis '(' ERROR: code indent should use tabs where possible ERROR: "(foo*)" should be "(foo *)" Marcin Ciupak (5): staging: pi433: rf69.c style fix - trailing statements staging: pi433: rf69.c style fix - spaces required around staging: pi433: rf69.c style fix - spaces before/after staging: pi433: rf69.c style fix - code indent should use tabs staging: pi433: rf69.c style fix - space before asterisk drivers/staging/pi433/rf69.c | 232 --- 1 file changed, 131 insertions(+), 101 deletions(-) -- 2.14.2
[PATCH v2] staging: pi433: replace INVALID_PARAM macro with inline code
The following macro: \#define INVALID_PARAM { \ dev_dbg(>dev, "set: illegal input param"); \ return -EINVAL; \ } affects control flow by having return statement. This is against Linux Kernel Coding Style and should be avoided and therefore this macro is replaced by inline code. Additionally following 3 minor issues: ERROR: code indent should use tabs where possible ERROR: spaces required around that '!=' (ctx:VxV) ERROR: space prohibited before that close parenthesis ')' were fiexed inline. Signed-off-by: Marcin Ciupak <marcin.s.ciu...@gmail.com> --- Changes in v2: - corrected typo in patch subject drivers/staging/pi433/rf69.c | 149 ++- 1 file changed, 104 insertions(+), 45 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 85cd70d403ba..e48ff805c672 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -35,11 +35,6 @@ #define READ_REG(x)rf69_read_reg (spi, x) #define WRITE_REG(x,y) rf69_write_reg(spi, x, y) -#define INVALID_PARAM \ - { \ - dev_dbg(>dev, "set: illegal input param"); \ - return -EINVAL; \ - } /*-*/ @@ -55,7 +50,9 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode) case synthesizer: return WRITE_REG(REG_OPMODE, (READ_REG(REG_OPMODE) & ~MASK_OPMODE_MODE) | OPMODE_MODE_SYNTHESIZER); case standby: return WRITE_REG(REG_OPMODE, (READ_REG(REG_OPMODE) & ~MASK_OPMODE_MODE) | OPMODE_MODE_STANDBY); case mode_sleep: return WRITE_REG(REG_OPMODE, (READ_REG(REG_OPMODE) & ~MASK_OPMODE_MODE) | OPMODE_MODE_SLEEP); - default: INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } // we are using packet mode, so this check is not really needed @@ -74,7 +71,9 @@ int rf69_set_data_mode(struct spi_device *spi, enum dataMode dataMode) case packet:return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODE) | DATAMODUL_MODE_PACKET); case continuous:return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODE) | DATAMODUL_MODE_CONTINUOUS); case continuousNoSync: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODE) | DATAMODUL_MODE_CONTINUOUS_NOSYNC); - default:INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } } @@ -87,7 +86,9 @@ int rf69_set_modulation(struct spi_device *spi, enum modulation modulation) switch (modulation) { case OOK: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_TYPE) | DATAMODUL_MODULATION_TYPE_OOK); case FSK: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_TYPE) | DATAMODUL_MODULATION_TYPE_FSK); - default:INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } } @@ -120,14 +121,18 @@ int rf69_set_modulation_shaping(struct spi_device *spi, enum modShaping modShapi case shaping1_0: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_1_0); case shaping0_5: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_0_3); case shaping0_3: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_0_5); - default: INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } } else { switch (modShaping) { case shapingOff: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_NONE); case shapingBR: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_BR); case shaping2BR: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_2BR); - default: INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } } } @@ -148,7 +153,7
[PATCH v2] staging: pi433: replace INVALID_PARAM macro with inline code
The following macro: \#define INVALID_PARAM { \ dev_dbg(>dev, "set: illegal input param"); \ return -EINVAL; \ } affects control flow by having return statement. This is against Linux Kernel Coding Style and should be avoided and therefore this macro is replaced by inline code. Additionally following 3 minor issues: ERROR: code indent should use tabs where possible ERROR: spaces required around that '!=' (ctx:VxV) ERROR: space prohibited before that close parenthesis ')' were fiexed inline. Signed-off-by: Marcin Ciupak --- Changes in v2: - corrected typo in patch subject drivers/staging/pi433/rf69.c | 149 ++- 1 file changed, 104 insertions(+), 45 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 85cd70d403ba..e48ff805c672 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -35,11 +35,6 @@ #define READ_REG(x)rf69_read_reg (spi, x) #define WRITE_REG(x,y) rf69_write_reg(spi, x, y) -#define INVALID_PARAM \ - { \ - dev_dbg(>dev, "set: illegal input param"); \ - return -EINVAL; \ - } /*-*/ @@ -55,7 +50,9 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode) case synthesizer: return WRITE_REG(REG_OPMODE, (READ_REG(REG_OPMODE) & ~MASK_OPMODE_MODE) | OPMODE_MODE_SYNTHESIZER); case standby: return WRITE_REG(REG_OPMODE, (READ_REG(REG_OPMODE) & ~MASK_OPMODE_MODE) | OPMODE_MODE_STANDBY); case mode_sleep: return WRITE_REG(REG_OPMODE, (READ_REG(REG_OPMODE) & ~MASK_OPMODE_MODE) | OPMODE_MODE_SLEEP); - default: INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } // we are using packet mode, so this check is not really needed @@ -74,7 +71,9 @@ int rf69_set_data_mode(struct spi_device *spi, enum dataMode dataMode) case packet:return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODE) | DATAMODUL_MODE_PACKET); case continuous:return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODE) | DATAMODUL_MODE_CONTINUOUS); case continuousNoSync: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODE) | DATAMODUL_MODE_CONTINUOUS_NOSYNC); - default:INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } } @@ -87,7 +86,9 @@ int rf69_set_modulation(struct spi_device *spi, enum modulation modulation) switch (modulation) { case OOK: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_TYPE) | DATAMODUL_MODULATION_TYPE_OOK); case FSK: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_TYPE) | DATAMODUL_MODULATION_TYPE_FSK); - default:INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } } @@ -120,14 +121,18 @@ int rf69_set_modulation_shaping(struct spi_device *spi, enum modShaping modShapi case shaping1_0: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_1_0); case shaping0_5: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_0_3); case shaping0_3: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_0_5); - default: INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } } else { switch (modShaping) { case shapingOff: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_NONE); case shapingBR: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_BR); case shaping2BR: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_2BR); - default: INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } } } @@ -148,7 +153,7 @@ int rf69_set_bit_rate(struct spi_de
Re: [PATCH] staginig: pi433: replace INVALID_PARAM macro with inline code
There is a typo in patch subject. Please drop this patch. I will send v2 with corrected subject. Thanks, Marcin
Re: [PATCH] staginig: pi433: replace INVALID_PARAM macro with inline code
There is a typo in patch subject. Please drop this patch. I will send v2 with corrected subject. Thanks, Marcin
[PATCH] staginig: pi433: replace INVALID_PARAM macro with inline code
The following macro: \#define INVALID_PARAM { \ dev_dbg(>dev, "set: illegal input param"); \ return -EINVAL; \ } affects control flow by having return statement. This is against Linux Kernel Coding Style and should be avoided and therefore this macro is replaced by inline code. Additionally following 3 minor issues: ERROR: code indent should use tabs where possible ERROR: spaces required around that '!=' (ctx:VxV) ERROR: space prohibited before that close parenthesis ')' were fiexed inline. Signed-off-by: Marcin Ciupak <marcin.s.ciu...@gmail.com> --- drivers/staging/pi433/rf69.c | 149 ++- 1 file changed, 104 insertions(+), 45 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 85cd70d403ba..e48ff805c672 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -35,11 +35,6 @@ #define READ_REG(x)rf69_read_reg (spi, x) #define WRITE_REG(x,y) rf69_write_reg(spi, x, y) -#define INVALID_PARAM \ - { \ - dev_dbg(>dev, "set: illegal input param"); \ - return -EINVAL; \ - } /*-*/ @@ -55,7 +50,9 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode) case synthesizer: return WRITE_REG(REG_OPMODE, (READ_REG(REG_OPMODE) & ~MASK_OPMODE_MODE) | OPMODE_MODE_SYNTHESIZER); case standby: return WRITE_REG(REG_OPMODE, (READ_REG(REG_OPMODE) & ~MASK_OPMODE_MODE) | OPMODE_MODE_STANDBY); case mode_sleep: return WRITE_REG(REG_OPMODE, (READ_REG(REG_OPMODE) & ~MASK_OPMODE_MODE) | OPMODE_MODE_SLEEP); - default: INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } // we are using packet mode, so this check is not really needed @@ -74,7 +71,9 @@ int rf69_set_data_mode(struct spi_device *spi, enum dataMode dataMode) case packet:return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODE) | DATAMODUL_MODE_PACKET); case continuous:return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODE) | DATAMODUL_MODE_CONTINUOUS); case continuousNoSync: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODE) | DATAMODUL_MODE_CONTINUOUS_NOSYNC); - default:INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } } @@ -87,7 +86,9 @@ int rf69_set_modulation(struct spi_device *spi, enum modulation modulation) switch (modulation) { case OOK: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_TYPE) | DATAMODUL_MODULATION_TYPE_OOK); case FSK: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_TYPE) | DATAMODUL_MODULATION_TYPE_FSK); - default:INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } } @@ -120,14 +121,18 @@ int rf69_set_modulation_shaping(struct spi_device *spi, enum modShaping modShapi case shaping1_0: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_1_0); case shaping0_5: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_0_3); case shaping0_3: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_0_5); - default: INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } } else { switch (modShaping) { case shapingOff: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_NONE); case shapingBR: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_BR); case shaping2BR: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_2BR); - default: INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } } } @@ -148,7 +153,7 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate
[PATCH] staginig: pi433: replace INVALID_PARAM macro with inline code
The following macro: \#define INVALID_PARAM { \ dev_dbg(>dev, "set: illegal input param"); \ return -EINVAL; \ } affects control flow by having return statement. This is against Linux Kernel Coding Style and should be avoided and therefore this macro is replaced by inline code. Additionally following 3 minor issues: ERROR: code indent should use tabs where possible ERROR: spaces required around that '!=' (ctx:VxV) ERROR: space prohibited before that close parenthesis ')' were fiexed inline. Signed-off-by: Marcin Ciupak --- drivers/staging/pi433/rf69.c | 149 ++- 1 file changed, 104 insertions(+), 45 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 85cd70d403ba..e48ff805c672 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -35,11 +35,6 @@ #define READ_REG(x)rf69_read_reg (spi, x) #define WRITE_REG(x,y) rf69_write_reg(spi, x, y) -#define INVALID_PARAM \ - { \ - dev_dbg(>dev, "set: illegal input param"); \ - return -EINVAL; \ - } /*-*/ @@ -55,7 +50,9 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode) case synthesizer: return WRITE_REG(REG_OPMODE, (READ_REG(REG_OPMODE) & ~MASK_OPMODE_MODE) | OPMODE_MODE_SYNTHESIZER); case standby: return WRITE_REG(REG_OPMODE, (READ_REG(REG_OPMODE) & ~MASK_OPMODE_MODE) | OPMODE_MODE_STANDBY); case mode_sleep: return WRITE_REG(REG_OPMODE, (READ_REG(REG_OPMODE) & ~MASK_OPMODE_MODE) | OPMODE_MODE_SLEEP); - default: INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } // we are using packet mode, so this check is not really needed @@ -74,7 +71,9 @@ int rf69_set_data_mode(struct spi_device *spi, enum dataMode dataMode) case packet:return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODE) | DATAMODUL_MODE_PACKET); case continuous:return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODE) | DATAMODUL_MODE_CONTINUOUS); case continuousNoSync: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODE) | DATAMODUL_MODE_CONTINUOUS_NOSYNC); - default:INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } } @@ -87,7 +86,9 @@ int rf69_set_modulation(struct spi_device *spi, enum modulation modulation) switch (modulation) { case OOK: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_TYPE) | DATAMODUL_MODULATION_TYPE_OOK); case FSK: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_TYPE) | DATAMODUL_MODULATION_TYPE_FSK); - default:INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } } @@ -120,14 +121,18 @@ int rf69_set_modulation_shaping(struct spi_device *spi, enum modShaping modShapi case shaping1_0: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_1_0); case shaping0_5: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_0_3); case shaping0_3: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_0_5); - default: INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } } else { switch (modShaping) { case shapingOff: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_NONE); case shapingBR: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_BR); case shaping2BR: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_2BR); - default: INVALID_PARAM; + default: + dev_dbg(>dev, "set: illegal input param"); + return -EINVAL; } } } @@ -148,7 +153,7 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate) bi
[PATCH 3/3] staging: pi433: rf69.c style fix - spaces open brace
This patch fixes the following checkpatch.pl error: ERROR: space required before the open brace '{' in rf69.c file as requested by TODO file. Signed-off-by: Marcin Ciupak <marcin.s.ciu...@gmail.com> --- drivers/staging/pi433/rf69.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 746ef70babf7..3e37bd205229 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -49,7 +49,7 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode) dev_dbg(>dev, "set: mode"); #endif - switch (mode){ + switch (mode) { case transmit:return WRITE_REG(REG_OPMODE, (READ_REG(REG_OPMODE) & ~MASK_OPMODE_MODE) | OPMODE_MODE_TRANSMIT); case receive: return WRITE_REG(REG_OPMODE, (READ_REG(REG_OPMODE) & ~MASK_OPMODE_MODE) | OPMODE_MODE_RECEIVE); case synthesizer: return WRITE_REG(REG_OPMODE, (READ_REG(REG_OPMODE) & ~MASK_OPMODE_MODE) | OPMODE_MODE_SYNTHESIZER); -- 2.13.0
[PATCH 3/3] staging: pi433: rf69.c style fix - spaces open brace
This patch fixes the following checkpatch.pl error: ERROR: space required before the open brace '{' in rf69.c file as requested by TODO file. Signed-off-by: Marcin Ciupak --- drivers/staging/pi433/rf69.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 746ef70babf7..3e37bd205229 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -49,7 +49,7 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode) dev_dbg(>dev, "set: mode"); #endif - switch (mode){ + switch (mode) { case transmit:return WRITE_REG(REG_OPMODE, (READ_REG(REG_OPMODE) & ~MASK_OPMODE_MODE) | OPMODE_MODE_TRANSMIT); case receive: return WRITE_REG(REG_OPMODE, (READ_REG(REG_OPMODE) & ~MASK_OPMODE_MODE) | OPMODE_MODE_RECEIVE); case synthesizer: return WRITE_REG(REG_OPMODE, (READ_REG(REG_OPMODE) & ~MASK_OPMODE_MODE) | OPMODE_MODE_SYNTHESIZER); -- 2.13.0
[PATCH 2/3] staging: pi433: rf69.c style fix - else close brace
This patch fixes the following checkpatch.pl error: ERROR: else should follow close brace '}' in rf69.c file as requested by TODO file. Signed-off-by: Marcin Ciupak <marcin.s.ciu...@gmail.com> --- drivers/staging/pi433/rf69.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 3afd217b79a7..746ef70babf7 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -122,8 +122,7 @@ int rf69_set_modulation_shaping(struct spi_device *spi, enum modShaping modShapi case shaping0_3: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_0_5); default: INVALID_PARAM; } - } - else { + } else { switch (modShaping) { case shapingOff: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_NONE); case shapingBR: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_BR); -- 2.13.0
[PATCH 2/3] staging: pi433: rf69.c style fix - else close brace
This patch fixes the following checkpatch.pl error: ERROR: else should follow close brace '}' in rf69.c file as requested by TODO file. Signed-off-by: Marcin Ciupak --- drivers/staging/pi433/rf69.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 3afd217b79a7..746ef70babf7 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -122,8 +122,7 @@ int rf69_set_modulation_shaping(struct spi_device *spi, enum modShaping modShapi case shaping0_3: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_0_5); default: INVALID_PARAM; } - } - else { + } else { switch (modShaping) { case shapingOff: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_NONE); case shapingBR: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_BR); -- 2.13.0
[PATCH 1/3] staging: pi433: rf69.c style fix - that open brace
This patch fixes the following checkpatch.pl error: ERROR: that open brace { should be on the previous line in rf69.c file as requested by TODO file. Note: ERROR: else should follow close brace '}' remains valid here and is going to be fixed by the next patch in set. Additionally some style warnings remain valid here and could be fixed by another patch. Signed-off-by: Marcin Ciupak <marcin.s.ciu...@gmail.com> --- drivers/staging/pi433/rf69.c | 33 +++-- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index f83523e3395d..3afd217b79a7 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -101,8 +101,7 @@ enum modulation rf69_get_modulation(struct spi_device *spi) currentValue = READ_REG(REG_DATAMODUL); - switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE >> 3) // TODO improvement: change 3 to define - { + switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE >> 3) { // TODO improvement: change 3 to define case DATAMODUL_MODULATION_TYPE_OOK: return OOK; case DATAMODUL_MODULATION_TYPE_FSK: return FSK; default:return undefined; @@ -115,8 +114,7 @@ int rf69_set_modulation_shaping(struct spi_device *spi, enum modShaping modShapi dev_dbg(>dev, "set: mod shaping"); #endif - if (rf69_get_modulation(spi) == FSK) - { + if (rf69_get_modulation(spi) == FSK) { switch (modShaping) { case shapingOff: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_NONE); case shaping1_0: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_1_0); @@ -125,8 +123,7 @@ int rf69_set_modulation_shaping(struct spi_device *spi, enum modShaping modShapi default: INVALID_PARAM; } } - else - { + else { switch (modShaping) { case shapingOff: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_NONE); case shapingBR: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_BR); @@ -150,8 +147,7 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate) // check input value bitRate_min = F_OSC / 8388608; // 8388608 = 2^23; - if (bitRate < bitRate_min) - { + if (bitRate < bitRate_min) { dev_dbg(>dev, "setBitRate: illegal input param"); INVALID_PARAM; } @@ -185,8 +181,7 @@ int rf69_set_deviation(struct spi_device *spi, u32 deviation) dev_dbg(>dev, "set: deviation"); #endif - if (deviation < 600 || deviation > 50) //TODO: Abh�ngigkeit von Bitrate beachten!! - { + if (deviation < 600 || deviation > 50) { //TODO: Abh�ngigkeit von Bitrate beachten!! dev_dbg(>dev, "set_deviation: illegal input param"); INVALID_PARAM; } @@ -203,8 +198,7 @@ int rf69_set_deviation(struct spi_device *spi, u32 deviation) lsb = (f_reg&0xff); // check msb - if (msb & !FDEVMASB_MASK) - { + if (msb & !FDEVMASB_MASK) { dev_dbg(>dev, "set_deviation: err in calc of msb"); INVALID_PARAM; } @@ -239,8 +233,7 @@ int rf69_set_frequency(struct spi_device *spi, u32 frequency) // check input value f_max = div_u64(f_step * 8388608, factor); - if (frequency > f_max) - { + if (frequency > f_max) { dev_dbg(>dev, "setFrequency: illegal input param"); INVALID_PARAM; } @@ -387,8 +380,7 @@ enum lnaGain rf69_get_lna_gain(struct spi_device *spi) currentValue = READ_REG(REG_LNA); - switch (currentValue & MASK_LNA_CURRENT_GAIN >> 3) // improvement: change 3 to define - { + switch (currentValue & MASK_LNA_CURRENT_GAIN >> 3) { // improvement: change 3 to define case LNA_GAIN_AUTO: return automatic; case LNA_GAIN_MAX: return max; case LNA_GAIN_MAX_MINUS_6: return maxMinus6; @@ -488,8 +480,7 @@ int rf69_set_ook_threshold_type(struct spi_device *spi, enum thresholdType thres dev_dbg(>dev, "set: threshold type"); #endif - switch (thresholdType) - { + switch (thresholdType) { case fixed: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THREST
[PATCH 1/3] staging: pi433: rf69.c style fix - that open brace
This patch fixes the following checkpatch.pl error: ERROR: that open brace { should be on the previous line in rf69.c file as requested by TODO file. Note: ERROR: else should follow close brace '}' remains valid here and is going to be fixed by the next patch in set. Additionally some style warnings remain valid here and could be fixed by another patch. Signed-off-by: Marcin Ciupak --- drivers/staging/pi433/rf69.c | 33 +++-- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index f83523e3395d..3afd217b79a7 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -101,8 +101,7 @@ enum modulation rf69_get_modulation(struct spi_device *spi) currentValue = READ_REG(REG_DATAMODUL); - switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE >> 3) // TODO improvement: change 3 to define - { + switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE >> 3) { // TODO improvement: change 3 to define case DATAMODUL_MODULATION_TYPE_OOK: return OOK; case DATAMODUL_MODULATION_TYPE_FSK: return FSK; default:return undefined; @@ -115,8 +114,7 @@ int rf69_set_modulation_shaping(struct spi_device *spi, enum modShaping modShapi dev_dbg(>dev, "set: mod shaping"); #endif - if (rf69_get_modulation(spi) == FSK) - { + if (rf69_get_modulation(spi) == FSK) { switch (modShaping) { case shapingOff: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_NONE); case shaping1_0: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_1_0); @@ -125,8 +123,7 @@ int rf69_set_modulation_shaping(struct spi_device *spi, enum modShaping modShapi default: INVALID_PARAM; } } - else - { + else { switch (modShaping) { case shapingOff: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_NONE); case shapingBR: return WRITE_REG(REG_DATAMODUL, (READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | DATAMODUL_MODULATION_SHAPE_BR); @@ -150,8 +147,7 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate) // check input value bitRate_min = F_OSC / 8388608; // 8388608 = 2^23; - if (bitRate < bitRate_min) - { + if (bitRate < bitRate_min) { dev_dbg(>dev, "setBitRate: illegal input param"); INVALID_PARAM; } @@ -185,8 +181,7 @@ int rf69_set_deviation(struct spi_device *spi, u32 deviation) dev_dbg(>dev, "set: deviation"); #endif - if (deviation < 600 || deviation > 50) //TODO: Abh�ngigkeit von Bitrate beachten!! - { + if (deviation < 600 || deviation > 50) { //TODO: Abh�ngigkeit von Bitrate beachten!! dev_dbg(>dev, "set_deviation: illegal input param"); INVALID_PARAM; } @@ -203,8 +198,7 @@ int rf69_set_deviation(struct spi_device *spi, u32 deviation) lsb = (f_reg&0xff); // check msb - if (msb & !FDEVMASB_MASK) - { + if (msb & !FDEVMASB_MASK) { dev_dbg(>dev, "set_deviation: err in calc of msb"); INVALID_PARAM; } @@ -239,8 +233,7 @@ int rf69_set_frequency(struct spi_device *spi, u32 frequency) // check input value f_max = div_u64(f_step * 8388608, factor); - if (frequency > f_max) - { + if (frequency > f_max) { dev_dbg(>dev, "setFrequency: illegal input param"); INVALID_PARAM; } @@ -387,8 +380,7 @@ enum lnaGain rf69_get_lna_gain(struct spi_device *spi) currentValue = READ_REG(REG_LNA); - switch (currentValue & MASK_LNA_CURRENT_GAIN >> 3) // improvement: change 3 to define - { + switch (currentValue & MASK_LNA_CURRENT_GAIN >> 3) { // improvement: change 3 to define case LNA_GAIN_AUTO: return automatic; case LNA_GAIN_MAX: return max; case LNA_GAIN_MAX_MINUS_6: return maxMinus6; @@ -488,8 +480,7 @@ int rf69_set_ook_threshold_type(struct spi_device *spi, enum thresholdType thres dev_dbg(>dev, "set: threshold type"); #endif - switch (thresholdType) - { + switch (thresholdType) { case fixed: return WRITE_REG(REG_OOKPEAK, ( (READ_REG(REG_OOKPEAK) & ~MASK_OOKPEAK_THRESTYPE) | OOKPEAK_THRESHTYPE_FIXED) );
[PATCH 0/3] staging: pi433: rf69.c style errors fixes - braces
This set of patches is intended to fix coding style errors with braces in rf69.c file in order to comply with kernel coding style guide as requested by TODO file. The following errors were fixed: ERROR: that open brace { should be on the previous line ERROR: else should follow close brace '}' ERROR: space required before the open brace '{' Marcin Ciupak (3): staging: pi433: rf69.c style fix - that open brace staging: pi433: rf69.c style fix - else close brace staging: pi433: rf69.c style fix - spaces open brace drivers/staging/pi433/rf69.c | 36 1 file changed, 12 insertions(+), 24 deletions(-) -- 2.13.0
[PATCH 0/3] staging: pi433: rf69.c style errors fixes - braces
This set of patches is intended to fix coding style errors with braces in rf69.c file in order to comply with kernel coding style guide as requested by TODO file. The following errors were fixed: ERROR: that open brace { should be on the previous line ERROR: else should follow close brace '}' ERROR: space required before the open brace '{' Marcin Ciupak (3): staging: pi433: rf69.c style fix - that open brace staging: pi433: rf69.c style fix - else close brace staging: pi433: rf69.c style fix - spaces open brace drivers/staging/pi433/rf69.c | 36 1 file changed, 12 insertions(+), 24 deletions(-) -- 2.13.0
[PATCH] staging: pi433: style fix - space after asterisk
This patch is intended to fix coding style issues in order to comply with kernel coding style guide as requested by TODO file. It fixes the following checkpatch.pl error: ERROR: "foo * bar" should be "foo *bar" Note: "WARNING: line over 80 characters" remains valid here and could be fixed by another patch. Signed-off-by: Marcin Ciupak <marcin.s.ciu...@gmail.com> --- drivers/staging/pi433/rf69.c | 2 +- drivers/staging/pi433/rf69.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index f83523e3395d..9f4e7173c688 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -740,7 +740,7 @@ int rf69_set_sync_values(struct spi_device *spi, u8 syncValues[8]) return retval; } -int rf69_set_packet_format(struct spi_device * spi, enum packetFormat packetFormat) +int rf69_set_packet_format(struct spi_device *spi, enum packetFormat packetFormat) { #ifdef DEBUG dev_dbg(>dev, "set: packet format"); diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h index b81e0762032e..fbccaae51c61 100644 --- a/drivers/staging/pi433/rf69.h +++ b/drivers/staging/pi433/rf69.h @@ -61,7 +61,7 @@ int rf69_set_fifo_fill_condition(struct spi_device *spi, enum fifoFillCondition int rf69_set_sync_size(struct spi_device *spi, u8 sync_size); int rf69_set_sync_tolerance(struct spi_device *spi, u8 syncTolerance); int rf69_set_sync_values(struct spi_device *spi, u8 syncValues[8]); -int rf69_set_packet_format(struct spi_device * spi, enum packetFormat packetFormat); +int rf69_set_packet_format(struct spi_device *spi, enum packetFormat packetFormat); int rf69_set_crc_enable(struct spi_device *spi, enum optionOnOff optionOnOff); int rf69_set_adressFiltering(struct spi_device *spi, enum addressFiltering addressFiltering); int rf69_set_payload_length(struct spi_device *spi, u8 payloadLength); -- 2.13.0
[PATCH] staging: pi433: style fix - space after asterisk
This patch is intended to fix coding style issues in order to comply with kernel coding style guide as requested by TODO file. It fixes the following checkpatch.pl error: ERROR: "foo * bar" should be "foo *bar" Note: "WARNING: line over 80 characters" remains valid here and could be fixed by another patch. Signed-off-by: Marcin Ciupak --- drivers/staging/pi433/rf69.c | 2 +- drivers/staging/pi433/rf69.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index f83523e3395d..9f4e7173c688 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -740,7 +740,7 @@ int rf69_set_sync_values(struct spi_device *spi, u8 syncValues[8]) return retval; } -int rf69_set_packet_format(struct spi_device * spi, enum packetFormat packetFormat) +int rf69_set_packet_format(struct spi_device *spi, enum packetFormat packetFormat) { #ifdef DEBUG dev_dbg(>dev, "set: packet format"); diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h index b81e0762032e..fbccaae51c61 100644 --- a/drivers/staging/pi433/rf69.h +++ b/drivers/staging/pi433/rf69.h @@ -61,7 +61,7 @@ int rf69_set_fifo_fill_condition(struct spi_device *spi, enum fifoFillCondition int rf69_set_sync_size(struct spi_device *spi, u8 sync_size); int rf69_set_sync_tolerance(struct spi_device *spi, u8 syncTolerance); int rf69_set_sync_values(struct spi_device *spi, u8 syncValues[8]); -int rf69_set_packet_format(struct spi_device * spi, enum packetFormat packetFormat); +int rf69_set_packet_format(struct spi_device *spi, enum packetFormat packetFormat); int rf69_set_crc_enable(struct spi_device *spi, enum optionOnOff optionOnOff); int rf69_set_adressFiltering(struct spi_device *spi, enum addressFiltering addressFiltering); int rf69_set_payload_length(struct spi_device *spi, u8 payloadLength); -- 2.13.0
Re: [PATCH v2] staging: lustre: replace simple_strtoul with kstrtoint
I did test it and not everything works as expected. I need to reconsider that change. Please drop this patch. Thanks, Marcin P.S. Sorry for late (sic!) response. On Fri, Apr 14, 2017 at 10:16:31AM +0200, Greg Kroah-Hartman wrote: > On Tue, Mar 21, 2017 at 01:46:09PM +0100, Marcin Ciupak wrote: > > Replace simple_strtoul with kstrtoint. > > simple_strtoul is marked for obsoletion as reported by checkpatch.pl > > > > Signed-off-by: Marcin Ciupak <marcin.s.ciu...@gmail.com> > > --- > > v2: > > -improving kstrtoint error handling > > -updating commit message > > > > drivers/staging/lustre/lustre/obdclass/obd_mount.c | 16 > > 1 file changed, 12 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c > > b/drivers/staging/lustre/lustre/obdclass/obd_mount.c > > index 8e0d4b1d86dc..42858ee5b444 100644 > > --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c > > +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c > > @@ -924,12 +924,20 @@ static int lmd_parse(char *options, struct > > lustre_mount_data *lmd) > > lmd->lmd_flags |= LMD_FLG_ABORT_RECOV; > > clear++; > > } else if (strncmp(s1, "recovery_time_soft=", 19) == 0) { > > - lmd->lmd_recovery_time_soft = max_t(int, > > - simple_strtoul(s1 + 19, NULL, 10), time_min); > > + int res; > > + > > + rc = kstrtoint(s1 + 19, 10, ); > > + if (rc) > > + goto invalid; > > + lmd->lmd_recovery_time_soft = max_t(int, res, time_min); > > Are you sure max_t is still needed here? > > And have you tested this change? > > thanks, > > greg k-h
Re: [PATCH v2] staging: lustre: replace simple_strtoul with kstrtoint
I did test it and not everything works as expected. I need to reconsider that change. Please drop this patch. Thanks, Marcin P.S. Sorry for late (sic!) response. On Fri, Apr 14, 2017 at 10:16:31AM +0200, Greg Kroah-Hartman wrote: > On Tue, Mar 21, 2017 at 01:46:09PM +0100, Marcin Ciupak wrote: > > Replace simple_strtoul with kstrtoint. > > simple_strtoul is marked for obsoletion as reported by checkpatch.pl > > > > Signed-off-by: Marcin Ciupak > > --- > > v2: > > -improving kstrtoint error handling > > -updating commit message > > > > drivers/staging/lustre/lustre/obdclass/obd_mount.c | 16 > > 1 file changed, 12 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c > > b/drivers/staging/lustre/lustre/obdclass/obd_mount.c > > index 8e0d4b1d86dc..42858ee5b444 100644 > > --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c > > +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c > > @@ -924,12 +924,20 @@ static int lmd_parse(char *options, struct > > lustre_mount_data *lmd) > > lmd->lmd_flags |= LMD_FLG_ABORT_RECOV; > > clear++; > > } else if (strncmp(s1, "recovery_time_soft=", 19) == 0) { > > - lmd->lmd_recovery_time_soft = max_t(int, > > - simple_strtoul(s1 + 19, NULL, 10), time_min); > > + int res; > > + > > + rc = kstrtoint(s1 + 19, 10, ); > > + if (rc) > > + goto invalid; > > + lmd->lmd_recovery_time_soft = max_t(int, res, time_min); > > Are you sure max_t is still needed here? > > And have you tested this change? > > thanks, > > greg k-h
[PATCH v2] staging: lustre: replace simple_strtoul with kstrtoint
Replace simple_strtoul with kstrtoint. simple_strtoul is marked for obsoletion as reported by checkpatch.pl Signed-off-by: Marcin Ciupak <marcin.s.ciu...@gmail.com> --- v2: -improving kstrtoint error handling -updating commit message drivers/staging/lustre/lustre/obdclass/obd_mount.c | 16 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 8e0d4b1d86dc..42858ee5b444 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -924,12 +924,20 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) lmd->lmd_flags |= LMD_FLG_ABORT_RECOV; clear++; } else if (strncmp(s1, "recovery_time_soft=", 19) == 0) { - lmd->lmd_recovery_time_soft = max_t(int, - simple_strtoul(s1 + 19, NULL, 10), time_min); + int res; + + rc = kstrtoint(s1 + 19, 10, ); + if (rc) + goto invalid; + lmd->lmd_recovery_time_soft = max_t(int, res, time_min); clear++; } else if (strncmp(s1, "recovery_time_hard=", 19) == 0) { - lmd->lmd_recovery_time_hard = max_t(int, - simple_strtoul(s1 + 19, NULL, 10), time_min); + int res; + + rc = kstrtoint(s1 + 19, 10, ); + if (rc) + goto invalid; + lmd->lmd_recovery_time_hard = max_t(int, res, time_min); clear++; } else if (strncmp(s1, "noir", 4) == 0) { lmd->lmd_flags |= LMD_FLG_NOIR; /* test purpose only. */ -- 2.11.1
[PATCH v2] staging: lustre: replace simple_strtoul with kstrtoint
Replace simple_strtoul with kstrtoint. simple_strtoul is marked for obsoletion as reported by checkpatch.pl Signed-off-by: Marcin Ciupak --- v2: -improving kstrtoint error handling -updating commit message drivers/staging/lustre/lustre/obdclass/obd_mount.c | 16 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 8e0d4b1d86dc..42858ee5b444 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -924,12 +924,20 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) lmd->lmd_flags |= LMD_FLG_ABORT_RECOV; clear++; } else if (strncmp(s1, "recovery_time_soft=", 19) == 0) { - lmd->lmd_recovery_time_soft = max_t(int, - simple_strtoul(s1 + 19, NULL, 10), time_min); + int res; + + rc = kstrtoint(s1 + 19, 10, ); + if (rc) + goto invalid; + lmd->lmd_recovery_time_soft = max_t(int, res, time_min); clear++; } else if (strncmp(s1, "recovery_time_hard=", 19) == 0) { - lmd->lmd_recovery_time_hard = max_t(int, - simple_strtoul(s1 + 19, NULL, 10), time_min); + int res; + + rc = kstrtoint(s1 + 19, 10, ); + if (rc) + goto invalid; + lmd->lmd_recovery_time_hard = max_t(int, res, time_min); clear++; } else if (strncmp(s1, "noir", 4) == 0) { lmd->lmd_flags |= LMD_FLG_NOIR; /* test purpose only. */ -- 2.11.1
Re: [PATCH] staging: lustre: replace simple_strtoul with kstrtoint
On Sun, Mar 12, 2017 at 02:36:47PM +0100, Greg Kroah-Hartman wrote: > On Thu, Mar 09, 2017 at 03:53:00PM +0100, Marcin Ciupak wrote: > > Replace simple_strtoul with kstrtoint. > > Why? Because > > simple_strtoul is marked for obsoletion. as reported by checkpatch.pl. > > > > Signed-off-by: Marcin Ciupak <marcin.s.ciu...@gmail.com> > > --- > > drivers/staging/lustre/lustre/obdclass/obd_mount.c | 20 > > > > 1 file changed, 16 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c > > b/drivers/staging/lustre/lustre/obdclass/obd_mount.c > > index 8e0d4b1d86dc..4a604e9b3e49 100644 > > --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c > > +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c > > @@ -924,12 +924,24 @@ static int lmd_parse(char *options, struct > > lustre_mount_data *lmd) > > lmd->lmd_flags |= LMD_FLG_ABORT_RECOV; > > clear++; > > } else if (strncmp(s1, "recovery_time_soft=", 19) == 0) { > > - lmd->lmd_recovery_time_soft = max_t(int, > > - simple_strtoul(s1 + 19, NULL, 10), time_min); > > + int res; > > + > > + rc = kstrtoint(s1 + 19, 10, ); > > + if (rc) > > + lmd->lmd_recovery_time_soft = time_min; > > + else > > + lmd->lmd_recovery_time_soft = max_t(int, res, > > + time_min); > > Are you sure this is correct? Do you really want to use max_t()? Why > is time_min used if there is an error? Can't this all be written a lot > simpler to actually make it semi-sane? > > thanks, > > greg k-h max_t() and time_min were already used in the original code, I did not want to change that. Regarding error handling, I saw two options here: 1. update variable with some fail-safe value and time_min looked good for that or, 2. do not update anything and do nothing or "goto invalid:" but I was not sure about that, so selected first option. If first option is not the best one, what would be better in case of error handling? Thanks, Marcin
Re: [PATCH] staging: lustre: replace simple_strtoul with kstrtoint
On Sun, Mar 12, 2017 at 02:36:47PM +0100, Greg Kroah-Hartman wrote: > On Thu, Mar 09, 2017 at 03:53:00PM +0100, Marcin Ciupak wrote: > > Replace simple_strtoul with kstrtoint. > > Why? Because > > simple_strtoul is marked for obsoletion. as reported by checkpatch.pl. > > > > Signed-off-by: Marcin Ciupak > > --- > > drivers/staging/lustre/lustre/obdclass/obd_mount.c | 20 > > > > 1 file changed, 16 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c > > b/drivers/staging/lustre/lustre/obdclass/obd_mount.c > > index 8e0d4b1d86dc..4a604e9b3e49 100644 > > --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c > > +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c > > @@ -924,12 +924,24 @@ static int lmd_parse(char *options, struct > > lustre_mount_data *lmd) > > lmd->lmd_flags |= LMD_FLG_ABORT_RECOV; > > clear++; > > } else if (strncmp(s1, "recovery_time_soft=", 19) == 0) { > > - lmd->lmd_recovery_time_soft = max_t(int, > > - simple_strtoul(s1 + 19, NULL, 10), time_min); > > + int res; > > + > > + rc = kstrtoint(s1 + 19, 10, ); > > + if (rc) > > + lmd->lmd_recovery_time_soft = time_min; > > + else > > + lmd->lmd_recovery_time_soft = max_t(int, res, > > + time_min); > > Are you sure this is correct? Do you really want to use max_t()? Why > is time_min used if there is an error? Can't this all be written a lot > simpler to actually make it semi-sane? > > thanks, > > greg k-h max_t() and time_min were already used in the original code, I did not want to change that. Regarding error handling, I saw two options here: 1. update variable with some fail-safe value and time_min looked good for that or, 2. do not update anything and do nothing or "goto invalid:" but I was not sure about that, so selected first option. If first option is not the best one, what would be better in case of error handling? Thanks, Marcin
[PATCH] staging: lustre: replace simple_strtoul with kstrtoint
Replace simple_strtoul with kstrtoint. simple_strtoul is marked for obsoletion. Signed-off-by: Marcin Ciupak <marcin.s.ciu...@gmail.com> --- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 20 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 8e0d4b1d86dc..4a604e9b3e49 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -924,12 +924,24 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) lmd->lmd_flags |= LMD_FLG_ABORT_RECOV; clear++; } else if (strncmp(s1, "recovery_time_soft=", 19) == 0) { - lmd->lmd_recovery_time_soft = max_t(int, - simple_strtoul(s1 + 19, NULL, 10), time_min); + int res; + + rc = kstrtoint(s1 + 19, 10, ); + if (rc) + lmd->lmd_recovery_time_soft = time_min; + else + lmd->lmd_recovery_time_soft = max_t(int, res, + time_min); clear++; } else if (strncmp(s1, "recovery_time_hard=", 19) == 0) { - lmd->lmd_recovery_time_hard = max_t(int, - simple_strtoul(s1 + 19, NULL, 10), time_min); + int res; + + rc = kstrtoint(s1 + 19, 10, ); + if (rc) + lmd->lmd_recovery_time_hard = time_min; + else + lmd->lmd_recovery_time_hard = max_t(int, res, + time_min); clear++; } else if (strncmp(s1, "noir", 4) == 0) { lmd->lmd_flags |= LMD_FLG_NOIR; /* test purpose only. */ -- 2.11.1
[PATCH] staging: lustre: replace simple_strtoul with kstrtoint
Replace simple_strtoul with kstrtoint. simple_strtoul is marked for obsoletion. Signed-off-by: Marcin Ciupak --- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 20 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 8e0d4b1d86dc..4a604e9b3e49 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -924,12 +924,24 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) lmd->lmd_flags |= LMD_FLG_ABORT_RECOV; clear++; } else if (strncmp(s1, "recovery_time_soft=", 19) == 0) { - lmd->lmd_recovery_time_soft = max_t(int, - simple_strtoul(s1 + 19, NULL, 10), time_min); + int res; + + rc = kstrtoint(s1 + 19, 10, ); + if (rc) + lmd->lmd_recovery_time_soft = time_min; + else + lmd->lmd_recovery_time_soft = max_t(int, res, + time_min); clear++; } else if (strncmp(s1, "recovery_time_hard=", 19) == 0) { - lmd->lmd_recovery_time_hard = max_t(int, - simple_strtoul(s1 + 19, NULL, 10), time_min); + int res; + + rc = kstrtoint(s1 + 19, 10, ); + if (rc) + lmd->lmd_recovery_time_hard = time_min; + else + lmd->lmd_recovery_time_hard = max_t(int, res, + time_min); clear++; } else if (strncmp(s1, "noir", 4) == 0) { lmd->lmd_flags |= LMD_FLG_NOIR; /* test purpose only. */ -- 2.11.1
Re: [PATCH] staging: speakup: replace simple_strtoul with kstrtou8
On Thu, Mar 02, 2017 at 04:17:12PM +0100, Samuel Thibault wrote: > Marcin Ciupak, on jeu. 02 mars 2017 15:28:23 +0100, wrote: > > - int val; > > + int ret; > > > > - val = simple_strtoul(skip_spaces(start), , 10); > > + ret = kstrtou8(skip_spaces(start), 10, dest); > > This is not the same, you need to have start properly move, since it's > used below: > > > if (*start == ',') > > start++; > > - *dest = (u_char)val; > > return start; > > Samuel You are right, start is not updated by kstrtou8 like it is by simple_strtoul. If I understand it correctly simple_strtoul cannot be replaced by kstrtou8 here. Please discard this patch. Marcin
Re: [PATCH] staging: speakup: replace simple_strtoul with kstrtou8
On Thu, Mar 02, 2017 at 04:17:12PM +0100, Samuel Thibault wrote: > Marcin Ciupak, on jeu. 02 mars 2017 15:28:23 +0100, wrote: > > - int val; > > + int ret; > > > > - val = simple_strtoul(skip_spaces(start), , 10); > > + ret = kstrtou8(skip_spaces(start), 10, dest); > > This is not the same, you need to have start properly move, since it's > used below: > > > if (*start == ',') > > start++; > > - *dest = (u_char)val; > > return start; > > Samuel You are right, start is not updated by kstrtou8 like it is by simple_strtoul. If I understand it correctly simple_strtoul cannot be replaced by kstrtou8 here. Please discard this patch. Marcin
[PATCH] staging: speakup: replace simple_strtoul with kstrtou8
Replace simple_strtoul with kstrtou8. simple_strtoul is marked for obsoletion. Signed-off-by: Marcin Ciupak <marcin.s.ciu...@gmail.com> --- drivers/staging/speakup/varhandlers.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/speakup/varhandlers.c b/drivers/staging/speakup/varhandlers.c index cc984196020f..c219db745865 100644 --- a/drivers/staging/speakup/varhandlers.c +++ b/drivers/staging/speakup/varhandlers.c @@ -323,11 +323,10 @@ char *spk_strlwr(char *s) char *spk_s2uchar(char *start, char *dest) { - int val; + int ret; - val = simple_strtoul(skip_spaces(start), , 10); + ret = kstrtou8(skip_spaces(start), 10, dest); if (*start == ',') start++; - *dest = (u_char)val; return start; } -- 2.11.1
[PATCH] staging: speakup: replace simple_strtoul with kstrtou8
Replace simple_strtoul with kstrtou8. simple_strtoul is marked for obsoletion. Signed-off-by: Marcin Ciupak --- drivers/staging/speakup/varhandlers.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/speakup/varhandlers.c b/drivers/staging/speakup/varhandlers.c index cc984196020f..c219db745865 100644 --- a/drivers/staging/speakup/varhandlers.c +++ b/drivers/staging/speakup/varhandlers.c @@ -323,11 +323,10 @@ char *spk_strlwr(char *s) char *spk_s2uchar(char *start, char *dest) { - int val; + int ret; - val = simple_strtoul(skip_spaces(start), , 10); + ret = kstrtou8(skip_spaces(start), 10, dest); if (*start == ',') start++; - *dest = (u_char)val; return start; } -- 2.11.1