Commit graph

76 commits

Author SHA1 Message Date
Michael Straube e086f61479 staging: pi433: add missing call to cdev_del()
If cdev_add() fails, cdev_del() should be called.
Add the missing cdev_del() call as pointed out by
Dan Carpenter.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-05 09:39:45 +01:00
Michael Straube 64c4c4ca6c staging: pi433: fix potential null dereference
Add a test for successful call to cdev_alloc() to avoid
potential null dereference. Issue reported by smatch.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Fixes: 874bcba65f ("staging: pi433: New driver")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-26 20:59:05 +01:00
Michael Straube 7e9463709c staging: pi433: remove GPL boiler plate text
The SPDX identifier is a legally binding shorthand,
which can be used instead of the full boiler plate text.

All source and header files have SPDX identifiers.
Remove the GPL boiler plate text to reduce file size.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-20 10:53:54 +01:00
Wei Yongjun 1ba60ad56c staging: pi433: fix error return code in pi433_probe()
Fix to return a negative error code from the kthread_run() error
handling case instead of 0, as done elsewhere in this function.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-12 21:49:24 +02:00
Sophie Matter 3689281604 staging: pi433: Use preferred commenting style
For multi-line comments, the preferred commenting style from the
coding style Documentation was applied to the comments, meaning
almost blank lines at the beginning and end of the comment.
One changed comment includes a line over 80 characters, causing
checkpatch.pl to complain, however breaking this line would not
make much sense, so it is kept like it is.

Signed-off-by: Sophie Matter <sophie.matter@web.de>
Signed-off-by: Rico Schrage <rico.schrage@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-11 13:12:34 +02:00
Sophie Matter 63688e61d5 staging: pi433: Comply with 80 character column limit
Lines have been split where it makes sense to shorten them in order
to comply with the coding standards and fix checkpatch.pl warnings.
There are still lines left that are too long, however breaking
those would impair readability.

Changes in v2:
 - now working on staging-next branch of the staging tree
 - the changes to the defines previously made are deleted
   due to readability

Signed-off-by: Sophie Matter <sophie.matter@web.de>
Signed-off-by: Rico Schrage <rico.schrage@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-11 13:12:33 +02:00
Valentin Vidic ecfacacf3f staging: pi433: add SPDX-License-Identifier tag
Use GPL-2.0+ based on the license text in each of the files.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 22:00:13 +09:00
Hugo Lefeuvre 983000d7fa staging: pi433: fix race condition in pi433_open
The device structure contains a useless non-atomic users counter which
is subject to race conditions. It has probably been created to handle
the case where remove is executed while operations are still executing
on open fds but this will never happen because of reference counts.

Drop the users counter and move rx buffer {de,}allocation to probe()
and remove(). Remove associated dead code from open() and release().
Remove related TODO entry from ioctl().

Signed-off-by: Hugo Lefeuvre <hle@owl.eu.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 22:00:13 +09:00
Hugo Lefeuvre 6de4ef65a8 staging: pi433: fix race condition in pi433_ioctl
In the PI433_IOC_WR_TX_CFG case in pi433_ioctl, instance->tx_cfg is
modified via

copy_from_user(&instance->tx_cfg, argp, sizeof(struct pi433_tx_cfg)))

without any kind of synchronization. In the case where two threads
would execute this same command concurrently the tx_cfg field might
enter in an inconsistent state.

Additionally: if ioctl(PI433_IOC_WR_TX_CFG) and write() execute
concurrently the tx config might be modified while it is being
copied to the fifo, resulting in potential data corruption.

Fix: Get instance->tx_cfg_lock before modifying tx config in the
PI433_IOC_WR_TX_CFG case in pi433_ioctl.

Also, do not copy data directly from user space to instance->tx_cfg.
Instead use a temporary buffer allowing future checks for correctness
of copied data and simpler code.

Signed-off-by: Hugo Lefeuvre <hle@owl.eu.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-17 09:05:12 +02:00
Simon Sandström 5de3b09027 staging: pi433: break long lines in pi433_if.c
Breaks long lines in pi433_if.c, fixing checkpatch.pl warnings:
"WARNING: line over 80 characters"

Signed-off-by: Simon Sandström <simon@nikanor.nu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-25 15:58:04 +02:00
Valentin Vidic 5451dab9b7 staging: pi433: cleanup tx_fifo locking
pi433_write requires locking due to multiple writers.  After acquiring
the lock check if enough free space is available in the kfifo to write
the whole message. This check should prevent partial writes to tx_fifo
so kfifo_reset is not needed anymore.

pi433_tx_thread is the only reader so it does not require locking
after kfifo_reset is removed.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Reviewed-by: Marcus Wolf <marcus.wolf@wolf-entwicklungen.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-23 15:40:24 +02:00
Valentin Vidic dba18d6185 staging: pi433: cleanup local variable
Rename temporary local variable and add required blank line.

Fixes checkpatch warning:

  WARNING: Missing a blank line after declarations

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-22 18:27:42 +01:00
Valentin Vidic 469b84f3f2 staging: pi433: fix CamelCase for GPIO functions
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: <setup_GPIOs>
  CHECK: Avoid CamelCase: <free_GPIOs>

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-19 19:46:51 +01:00
HariPrasath Elango c72654356d staging: pi433: Remove comments inside code
Remove comments inbetween code as in this case.

Signed-off-by: HariPrasath Elango <hariprasath.elango@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-14 13:06:24 +01:00
Valentin Vidic cd9d5291bb staging: pi433: fix CamelCase for address_filtering enum
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: <filteringOff>
  CHECK: Avoid CamelCase: <nodeAddress>
  CHECK: Avoid CamelCase: <nodeOrBroadcastAddress>

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-06 04:22:17 -08:00
Valentin Vidic 53e0b83d01 staging: pi433: fix CamelCase for afterSyncInterrupt
Fixes checkpatch warning:

  CHECK: Avoid CamelCase: <afterSyncInterrupt>

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-06 04:22:17 -08:00
Valentin Vidic 1cd41fc3f3 staging: pi433: fix CamelCase for flag enum
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: <modeSwitchCompleted>
  CHECK: Avoid CamelCase: <readyToReceive>
  CHECK: Avoid CamelCase: <readyToSend>
  CHECK: Avoid CamelCase: <pllLocked>
  CHECK: Avoid CamelCase: <rssiExceededThreshold>
  CHECK: Avoid CamelCase: <syncAddressMatch>
  CHECK: Avoid CamelCase: <packetSent>
  CHECK: Avoid CamelCase: <crcOk>
  CHECK: Avoid CamelCase: <batteryLow>

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-06 04:22:16 -08:00
Valentin Vidic c436ef3b9a staging: pi433: fix CamelCase for packetFormat enum
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: <packetFormat>
  CHECK: Avoid CamelCase: <packetLengthFix>
  CHECK: Avoid CamelCase: <packetLengthVar>

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-06 04:22:16 -08:00
Valentin Vidic e69a0500f2 staging: pi433: fix CamelCase for addressFiltering
Fixes checkpatch warning:

  CHECK: Avoid CamelCase: <addressFiltering>

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-22 14:53:05 +01:00
Eisha Chen-yen-su f1345b2f21 staging: pi433: Split subtraction across 2 lines
Split a subtraction across 2 lines in order to make these lines
no longer than 80 columns. Problem found with checkpatch.

Signed-off-by: Eisha Chen-yen-su <chenyensu0@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-20 09:03:42 +01:00
Eisha Chen-yen-su 20e5f0422e staging: pi433: Split some function calls
Split some function calls on several lines in order to make these
lines no longer than 80 columns. Problem found with checkpatch.

Signed-off-by: Eisha Chen-yen-su <chenyensu0@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-20 09:03:42 +01:00
Valentin Vidic 0b89706583 staging: pi433: fix CamelCase for Ohm identifiers
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: <fiftyOhm>
  CHECK: Avoid CamelCase: <twohundretOhm>

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-16 15:35:04 +01:00
Valentin Vidic 3861b724de staging: pi433: align function parameters with open parenthesis
Fixes checkpatch warnings:

  CHECK: Alignment should match open parenthesis

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09 16:02:18 +01:00
Valentin Vidic 9ab7bc50a8 staging: pi433: replace shifting with BIT macro
Fixes checkpatch warnings:

  CHECK: Prefer using the BIT macro

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09 15:38:48 +01:00
Derek Robson 7b4c570ee5 Staging: pi433 - fix ccheckpatch issue, updated include line.
Updated the include of compat.h to fix checkpatch error

Signed-off-by: Derek Robson <robsonde@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:33:33 +01:00
Valentin Vidic 0b9acf7ddb staging: pi433: fix CamelCase for payload identifiers
Fixes checkpatch warnings:

  CHECK: Avoid CamelCase: <payloadLength>
  CHECK: Avoid CamelCase: <payloadReady>

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:32:27 +01:00
Oliver Graute dd1114693b staging: pi433: pi433_write fixed the return value
The pi433_write function should return the number of processed bytes

Reported-by: Marcin Ciupak <marcin.s.ciupak@gmail.com>
Signed-off-by: Oliver Graute <oliver.graute@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-21 18:17:05 +01:00
Valentin Vidic ebc1dea21b staging: pi433: replace printk calls with dev_dbg
Fixes checkpatch warning:

  WARNING: printk() should include KERN_<LEVEL> facility level

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 16:05:54 +01:00
Valentin Vidic 57fa80f5b0 staging: pi433: avoid logging ENOMEM messages
Fixes checkpatch warning:

  WARNING: Possible unnecessary 'out of memory' message

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 16:05:54 +01:00
Valentin Vidic 211c282061 staging: pi433: replace unsigned with unsigned int
Fixes checkpatch warning:

  WARNING: Prefer 'unsigned int' to bare use of 'unsigned'

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 16:05:53 +01:00
Valentin Vidic 83e3e2ef74 staging: pi433: collapse else block after return statement
Fixes checkpatch warning:

  WARNING: else is not generally useful after a break or return

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 16:05:38 +01:00
Marcus Wolf da3761feae Staging: Pi433: Bugfix for wrong argument for sizeof() in TX thread
sizeof(array) != sizeof(pointer to array)
Fixes: "staging: pi433: reduce stack size in tx thread"

Fixes: 62f39d49d1 ("staging: pi433: reduce stack size in tx thread")
Signed-off-by: Marcus Wolf <linux@wolf-entwicklungen.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:55:07 +01:00
Valentin Vidic 82a708e740 staging: pi433: remove multiple blank lines
Fixes checkpatch warning for multiple blank lines in source.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:14:58 +01:00
Valentin Vidic 2b3943b3c3 staging: pi433: remove comparison with true
Fixes checkpatch warning for error prone comparison.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:59:41 +01:00
Valentin Vidic de71b5bd5a staging: pi433: remove comparison with false
Fixes checkpatch warning for error prone comparison.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:59:41 +01:00
Valentin Vidic c144df8d79 staging: pi433: add blank line after function
Fixes checkpatch warning for blank line after
function/struct/union/enum declarations.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:59:40 +01:00
Valentin Vidic 16fdcc7b41 staging: pi433: rewrite comparison with NULL
Fixes checkpatch warning for comparing value with NULL.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:59:40 +01:00
Valentin Vidic 6bd00b5ab6 staging: pi433: remove return from a void function
Fixes checkpatch warning for void function return statements.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:58:57 +01:00
Valentin Vidic 2f58f293c2 staging: pi433: remove spaces before tabs
Fixes checkpatch warning for hidden spaces before tabs.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:58:04 +01:00
Valentin Vidic 6b167a67c6 staging: pi433: move trailing statements to next line
Fixes checkpatch error for trailing if statements.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:58:04 +01:00
Valentin Vidic 3b57c15c40 staging: pi433: use tabs for code indent
Fixes checkpatch error for whitespace idents.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:58:04 +01:00
Valentin Vidic 91086b82a0 staging: pi433: use consistent brace style
Fixes checkpatch error for open/close braces.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:58:04 +01:00
Valentin Vidic 7b15049c4d staging: pi433: remove space inside parenthesis
Fixes checkpatch error for prohibited spaces.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:56:29 +01:00
Valentin Vidic e27de55d0e staging: pi433: add space around operators
Fixes checkpatch error for missing spaces.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:56:29 +01:00
Valentin Vidic dd30cfebb8 staging: pi433: add space after comma
Fixes checkpatch error for missing spaces.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:56:29 +01:00
Valentin Vidic 2e3a641d8c staging: pi433: add space before open parenthesis
Fixes checkpatch error for missing spaces.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:56:29 +01:00
Nguyen Phan Quang Minh 038a5b4eb3 staging: pi433: pi433_if.c remove SET_CHECKED macro
The macro calls its argument -a function- twice, makes the calling
function return prematurely -skipping resource cleanup code- and hurts
understandability.

Signed-off-by: Nguyen Phan Quang Minh <minhnpq16@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-08 16:31:35 +01:00
Simon Sandström 54fc95a7c5 staging: pi433: Remove SET_CHECKED usage from pi433_probe
SET_CHECKED returns from the function on failure and in pi433_probe it is
necessary to free the GPIOs and the device on failure.

Signed-off-by: Simon Sandström <simon@nikanor.nu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-06 22:07:23 +01:00
Simon Sandström c5a5bd6bda staging: pi433: Combine all rf69_set_amplifier_x()
Replaces the functions rf69_set_amplifier_1, _2, _3 with two
functions: rf69_enable_amplifier(dev, amp_mask) and
rf69_disable_amplifier(dev, amp_mask).

Signed-off-by: Simon Sandström <simon@nikanor.nu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-06 22:07:23 +01:00
Simon Sandström b92025a80c staging: pi433: Remove enum data_mode
Call rf69_set_data_mode with DATAMODUL_MODE value directly.

Signed-off-by: Simon Sandström <simon@nikanor.nu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-06 22:07:23 +01:00