[PATCH] staging: rb8822be Change line not to end with '('

2018-11-26 Thread Ricardo Silva
To comply with checkpatch.

CHECK: Lines should not end with a '('
+u8 rtl_mrate_idx_to_arfr_id(

Signed-off-by: Ricardo Silva 
---
 drivers/staging/rtlwifi/base.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtlwifi/base.h b/drivers/staging/rtlwifi/base.h
index 4299ca181365..591f433be1c3 100644
--- a/drivers/staging/rtlwifi/base.h
+++ b/drivers/staging/rtlwifi/base.h
@@ -151,9 +151,9 @@ void rtl_c2hcmd_wq_callback(void *data);
 void rtl_c2hcmd_launcher(struct ieee80211_hw *hw, int exec);
 void rtl_c2hcmd_enqueue(struct ieee80211_hw *hw, u8 tag, u8 len, u8 *val);
 
-u8 rtl_mrate_idx_to_arfr_id(
-   struct ieee80211_hw *hw, u8 rate_index,
-   enum wireless_mode wirelessmode);
+u8 rtl_mrate_idx_to_arfr_id(struct ieee80211_hw *hw,
+   u8 rate_index,
+   enum wireless_mode wirelessmode);
 void rtl_get_tcb_desc(struct ieee80211_hw *hw,
  struct ieee80211_tx_info *info,
  struct ieee80211_sta *sta,
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vme: Use BIT macro for bit definitions

2017-05-15 Thread Ricardo Silva
Use the BIT(n) macro instead of '(1 << n)' in definitions where the bit
semantics clearly applies.

Fixes true positive "Prefer using the BIT macro" checks reported by
checkpatch.

Some of these checks are still triggering on definitions using
'(1 << n)', namely for PIO2_CNTR_SC_DEV1, PIO2_CNTR_RW_LSB and
PIO2_CNTR_MODE1. Leave them be, as the context there is more of a
"multi-bit field value" ((val << n), where for some cases 'val' happens
to be 1) rather than a "single bit" (1 << n), so keeping the value as is
in the code makes it more readable that using a combination of BIT
macros.

Signed-off-by: Ricardo Silva 
---
 drivers/staging/vme/devices/vme_pio2.h | 80 +-
 1 file changed, 40 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/vme/devices/vme_pio2.h 
b/drivers/staging/vme/devices/vme_pio2.h
index 5577df3199e7..ac4a4bad4091 100644
--- a/drivers/staging/vme/devices/vme_pio2.h
+++ b/drivers/staging/vme/devices/vme_pio2.h
@@ -68,38 +68,38 @@ static const int PIO2_CHANNEL_BANK[32] = { 0, 0, 0, 0, 0, 
0, 0, 0,
2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3 };
 
-#define PIO2_CHANNEL0_BIT  (1 << 0)
-#define PIO2_CHANNEL1_BIT  (1 << 1)
-#define PIO2_CHANNEL2_BIT  (1 << 2)
-#define PIO2_CHANNEL3_BIT  (1 << 3)
-#define PIO2_CHANNEL4_BIT  (1 << 4)
-#define PIO2_CHANNEL5_BIT  (1 << 5)
-#define PIO2_CHANNEL6_BIT  (1 << 6)
-#define PIO2_CHANNEL7_BIT  (1 << 7)
-#define PIO2_CHANNEL8_BIT  (1 << 0)
-#define PIO2_CHANNEL9_BIT  (1 << 1)
-#define PIO2_CHANNEL10_BIT (1 << 2)
-#define PIO2_CHANNEL11_BIT (1 << 3)
-#define PIO2_CHANNEL12_BIT (1 << 4)
-#define PIO2_CHANNEL13_BIT (1 << 5)
-#define PIO2_CHANNEL14_BIT (1 << 6)
-#define PIO2_CHANNEL15_BIT (1 << 7)
-#define PIO2_CHANNEL16_BIT (1 << 0)
-#define PIO2_CHANNEL17_BIT (1 << 1)
-#define PIO2_CHANNEL18_BIT (1 << 2)
-#define PIO2_CHANNEL19_BIT (1 << 3)
-#define PIO2_CHANNEL20_BIT (1 << 4)
-#define PIO2_CHANNEL21_BIT (1 << 5)
-#define PIO2_CHANNEL22_BIT (1 << 6)
-#define PIO2_CHANNEL23_BIT (1 << 7)
-#define PIO2_CHANNEL24_BIT (1 << 0)
-#define PIO2_CHANNEL25_BIT (1 << 1)
-#define PIO2_CHANNEL26_BIT (1 << 2)
-#define PIO2_CHANNEL27_BIT (1 << 3)
-#define PIO2_CHANNEL28_BIT (1 << 4)
-#define PIO2_CHANNEL29_BIT (1 << 5)
-#define PIO2_CHANNEL30_BIT (1 << 6)
-#define PIO2_CHANNEL31_BIT (1 << 7)
+#define PIO2_CHANNEL0_BIT  BIT(0)
+#define PIO2_CHANNEL1_BIT  BIT(1)
+#define PIO2_CHANNEL2_BIT  BIT(2)
+#define PIO2_CHANNEL3_BIT  BIT(3)
+#define PIO2_CHANNEL4_BIT  BIT(4)
+#define PIO2_CHANNEL5_BIT  BIT(5)
+#define PIO2_CHANNEL6_BIT  BIT(6)
+#define PIO2_CHANNEL7_BIT  BIT(7)
+#define PIO2_CHANNEL8_BIT  BIT(0)
+#define PIO2_CHANNEL9_BIT  BIT(1)
+#define PIO2_CHANNEL10_BIT BIT(2)
+#define PIO2_CHANNEL11_BIT BIT(3)
+#define PIO2_CHANNEL12_BIT BIT(4)
+#define PIO2_CHANNEL13_BIT BIT(5)
+#define PIO2_CHANNEL14_BIT BIT(6)
+#define PIO2_CHANNEL15_BIT BIT(7)
+#define PIO2_CHANNEL16_BIT BIT(0)
+#define PIO2_CHANNEL17_BIT BIT(1)
+#define PIO2_CHANNEL18_BIT BIT(2)
+#define PIO2_CHANNEL19_BIT BIT(3)
+#define PIO2_CHANNEL20_BIT BIT(4)
+#define PIO2_CHANNEL21_BIT BIT(5)
+#define PIO2_CHANNEL22_BIT BIT(6)
+#define PIO2_CHANNEL23_BIT BIT(7)
+#define PIO2_CHANNEL24_BIT BIT(0)
+#define PIO2_CHANNEL25_BIT BIT(1)
+#define PIO2_CHANNEL26_BIT BIT(2)
+#define PIO2_CHANNEL27_BIT BIT(3)
+#define PIO2_CHANNEL28_BIT BIT(4)
+#define PIO2_CHANNEL29_BIT BIT(5)
+#define PIO2_CHANNEL30_BIT BIT(6)
+#define PIO2_CHANNEL31_BIT BIT(7)
 
 static const int PIO2_CHANNEL_BIT[32] = { PIO2_CHANNEL0_BIT, PIO2_CHANNEL1_BIT,
PIO2_CHANNEL2_BIT, PIO2_CHANNEL3_BIT,
@@ -120,12 +120,12 @@ static const int PIO2_CHANNEL_BIT[32] = { 
PIO2_CHANNEL0_BIT, PIO2_CHANNEL1_BIT,
};
 
 /* PIO2_REGS_INT_STAT_CNTR (0xc) */
-#define PIO2_COUNTER0  (1 << 0)
-#define PIO2_COUNTER1  

[PATCH 0/5] staging: media: lirc: Fix several checkpatch issues

2017-05-15 Thread Ricardo Silva
This patch series is intended to fix several checkpatch issues (from
CHECK level) found on lirc_zilog.c:

The 1st patch focus on whitespace related fixes.
The 2nd patch fixes NULL comparisons style.
The 3rd patch is for using __func__ in logging functions that are to
trace the function's name, instead of writing down the actual function
name.
The 4th patch changes use of sizeof(struct s) to sizeof(*s_ptr) instead.
Finally, the 5th patch fixes unbalanced braces around if/else
statements.

All checks were fixed, except for the following (and why):

 * CHECK: "Do not include the paragraph about writing to the Free
   Software Foundation...", in the file's header.
   Didn't want to mess with the license notice, unless given explicit
   permission.

 * CHECK: "struct mutex definition without comment", for the ir_lock
   mutex from struct IR. I understand the mutex is there to serialize
   access to the i2c bus but felt hesitant about adding such comment,
   due to lack of deeper knowledge about the driver.

 * CHECK: "Please don't use multiple blank lines". Two instances of
   these were left because acting as logical code blocks separators
   (separating vars declarations from functions, etc.). They seem
   intended for readability purposes.

 * CHECK: "Alignment should match open parenthesis", unchanged because
   makes the code more readable.

 * CHECK: "usleep_range is preferred over udelay".
   Wouldn't know which range to use, due to lack of deeper knowledge
   about the module.

 * CHECK: "ENOSYS means 'invalid syscall nr' and nothing else", in some
   of the module's ioctl function return paths. I believe correct return
   value here would be -ENOTTY, but had some doubts about doing the
   change, as this could break userspace. Will gladly do the change if
   it's OK.

Please advise if it's ok to go ahead and fix these remaining checks.

Ricardo Silva (5):
  staging: media: lirc: Fix whitespace style checks
  staging: media: lirc: Fix NULL comparisons style
  staging: media: lirc: Use __func__ for logging function name
  staging: media: lirc: Use sizeof(*p) instead of sizeof(struct P)
  staging: media: lirc: Fix unbalanced braces around if/else

 drivers/staging/media/lirc/lirc_zilog.c | 110 
 1 file changed, 56 insertions(+), 54 deletions(-)

-- 
2.12.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/5] staging: media: lirc: Use sizeof(*p) instead of sizeof(struct P)

2017-05-15 Thread Ricardo Silva
Fix all checkpatch reported issues for "CHECK: Prefer
kzalloc(sizeof(*)...) over kzalloc(sizeof(struct )...)".

Other similar case in the code already using recommended style, so make
it all consistent with the recommended practice.

Signed-off-by: Ricardo Silva 
---
 drivers/staging/media/lirc/lirc_zilog.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_zilog.c 
b/drivers/staging/media/lirc/lirc_zilog.c
index 99b5858124e0..7e36693b66a8 100644
--- a/drivers/staging/media/lirc/lirc_zilog.c
+++ b/drivers/staging/media/lirc/lirc_zilog.c
@@ -1474,7 +1474,7 @@ static int ir_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
/* Use a single struct IR instance for both the Rx and Tx functions */
ir = get_ir_device_by_adapter(adap);
if (!ir) {
-   ir = kzalloc(sizeof(struct IR), GFP_KERNEL);
+   ir = kzalloc(sizeof(*ir), GFP_KERNEL);
if (!ir) {
ret = -ENOMEM;
goto out_no_ir;
@@ -1514,7 +1514,7 @@ static int ir_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
rx = get_ir_rx(ir);
 
/* Set up a struct IR_tx instance */
-   tx = kzalloc(sizeof(struct IR_tx), GFP_KERNEL);
+   tx = kzalloc(sizeof(*tx), GFP_KERNEL);
if (!tx) {
ret = -ENOMEM;
goto out_put_xx;
@@ -1558,7 +1558,7 @@ static int ir_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
tx = get_ir_tx(ir);
 
/* Set up a struct IR_rx instance */
-   rx = kzalloc(sizeof(struct IR_rx), GFP_KERNEL);
+   rx = kzalloc(sizeof(*rx), GFP_KERNEL);
if (!rx) {
ret = -ENOMEM;
goto out_put_xx;
-- 
2.12.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/5] staging: media: lirc: Fix NULL comparisons style

2017-05-15 Thread Ricardo Silva
Fix all checkpatch reported issues for "CHECK: Comparison to NULL could
be written...".

Do these comparisons using the recommended coding style and consistent
with other similar cases in the file, which already used the recommended
way.

Signed-off-by: Ricardo Silva 
---
 drivers/staging/media/lirc/lirc_zilog.c | 48 -
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_zilog.c 
b/drivers/staging/media/lirc/lirc_zilog.c
index 0cb974461cd2..b33a2c820dc2 100644
--- a/drivers/staging/media/lirc/lirc_zilog.c
+++ b/drivers/staging/media/lirc/lirc_zilog.c
@@ -215,7 +215,7 @@ static struct IR_rx *get_ir_rx(struct IR *ir)
 
spin_lock(&ir->rx_ref_lock);
rx = ir->rx;
-   if (rx != NULL)
+   if (rx)
kref_get(&rx->ref);
spin_unlock(&ir->rx_ref_lock);
return rx;
@@ -277,7 +277,7 @@ static struct IR_tx *get_ir_tx(struct IR *ir)
 
spin_lock(&ir->tx_ref_lock);
tx = ir->tx;
-   if (tx != NULL)
+   if (tx)
kref_get(&tx->ref);
spin_unlock(&ir->tx_ref_lock);
return tx;
@@ -327,12 +327,12 @@ static int add_to_buf(struct IR *ir)
}
 
rx = get_ir_rx(ir);
-   if (rx == NULL)
+   if (!rx)
return -ENXIO;
 
/* Ensure our rx->c i2c_client remains valid for the duration */
mutex_lock(&rx->client_lock);
-   if (rx->c == NULL) {
+   if (!rx->c) {
mutex_unlock(&rx->client_lock);
put_ir_rx(rx, false);
return -ENXIO;
@@ -388,7 +388,7 @@ static int add_to_buf(struct IR *ir)
break;
}
schedule_timeout((100 * HZ + 999) / 1000);
-   if (tx != NULL)
+   if (tx)
tx->need_boot = 1;
 
++failures;
@@ -444,7 +444,7 @@ static int add_to_buf(struct IR *ir)
} while (!lirc_buffer_full(rbuf));
 
mutex_unlock(&rx->client_lock);
-   if (tx != NULL)
+   if (tx)
put_ir_tx(tx, false);
put_ir_rx(rx, false);
return ret;
@@ -772,7 +772,7 @@ static int fw_load(struct IR_tx *tx)
 
/* Parse the file */
tx_data = vmalloc(sizeof(*tx_data));
-   if (tx_data == NULL) {
+   if (!tx_data) {
release_firmware(fw_entry);
ret = -ENOMEM;
goto out;
@@ -781,7 +781,7 @@ static int fw_load(struct IR_tx *tx)
 
/* Copy the data so hotplug doesn't get confused and timeout */
tx_data->datap = vmalloc(fw_entry->size);
-   if (tx_data->datap == NULL) {
+   if (!tx_data->datap) {
release_firmware(fw_entry);
vfree(tx_data);
ret = -ENOMEM;
@@ -818,7 +818,7 @@ static int fw_load(struct IR_tx *tx)
 
tx_data->code_sets = vmalloc(
tx_data->num_code_sets * sizeof(char *));
-   if (tx_data->code_sets == NULL) {
+   if (!tx_data->code_sets) {
fw_unload_locked();
ret = -ENOMEM;
goto out;
@@ -905,7 +905,7 @@ static ssize_t read(struct file *filep, char __user 
*outbuf, size_t n,
}
 
rx = get_ir_rx(ir);
-   if (rx == NULL)
+   if (!rx)
return -ENXIO;
 
/*
@@ -,12 +,12 @@ static ssize_t write(struct file *filep, const char 
__user *buf, size_t n,
 
/* Get a struct IR_tx reference */
tx = get_ir_tx(ir);
-   if (tx == NULL)
+   if (!tx)
return -ENXIO;
 
/* Ensure our tx->c i2c_client remains valid for the duration */
mutex_lock(&tx->client_lock);
-   if (tx->c == NULL) {
+   if (!tx->c) {
mutex_unlock(&tx->client_lock);
put_ir_tx(tx, false);
return -ENXIO;
@@ -1215,7 +1215,7 @@ static unsigned int poll(struct file *filep, poll_table 
*wait)
dev_dbg(ir->l.dev, "poll called\n");
 
rx = get_ir_rx(ir);
-   if (rx == NULL) {
+   if (!rx) {
/*
 * Revisit this, if our poll function ever reports writeable
 * status for Tx
@@ -1322,7 +1322,7 @@ static int open(struct inode *node, struct file *filep)
/* find our IR struct */
ir = get_ir_device_by_minor(minor);
 
-   if (ir == NULL)
+   if (!ir)
return -ENODEV;
 
atomic_inc(&ir->open_count);
@@ -1340,7 +1340,7 @@ static int close(struct inode *node, struct file *filep)
/* find our IR struct */
struct IR *ir = filep->private_data;
 
-   if (ir == NULL) {
+   if (!ir) {
pr_err("ir: close: no private_data attached to the file!

[PATCH 1/5] staging: media: lirc: Fix whitespace style checks

2017-05-15 Thread Ricardo Silva
Fix style issues reported by checkpatch, affecting whitespace only:

 * CHECK: "Please don't use multiple blank lines".
   Two of these still triggering and left untouched because used for
   separating logical blocks (vars from functions, etc.).

 * CHECK: "spaces preferred around that ''".
   All fixed.

 * CHECK: "Alignment should match open parenthesis".
   All fixed except one on line 1161, left untouched for readability.

Move towards recommended coding style without compromising readability.

Signed-off-by: Ricardo Silva 
---
 drivers/staging/media/lirc/lirc_zilog.c | 37 -
 1 file changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_zilog.c 
b/drivers/staging/media/lirc/lirc_zilog.c
index 8ce1db04414a..0cb974461cd2 100644
--- a/drivers/staging/media/lirc/lirc_zilog.c
+++ b/drivers/staging/media/lirc/lirc_zilog.c
@@ -472,7 +472,7 @@ static int lirc_thread(void *arg)
 
/* if device not opened, we can sleep half a second */
if (atomic_read(&ir->open_count) == 0) {
-   schedule_timeout(HZ/2);
+   schedule_timeout(HZ / 2);
continue;
}
 
@@ -508,7 +508,7 @@ static void set_use_dec(void *data)
 
 /* safe read of a uint32 (always network byte order) */
 static int read_uint32(unsigned char **data,
-unsigned char *endp, unsigned int *val)
+  unsigned char *endp, unsigned int *val)
 {
if (*data + 4 > endp)
return 0;
@@ -520,7 +520,7 @@ static int read_uint32(unsigned char **data,
 
 /* safe read of a uint8 */
 static int read_uint8(unsigned char **data,
-   unsigned char *endp, unsigned char *val)
+ unsigned char *endp, unsigned char *val)
 {
if (*data + 1 > endp)
return 0;
@@ -530,7 +530,7 @@ static int read_uint8(unsigned char **data,
 
 /* safe skipping of N bytes */
 static int skip(unsigned char **data,
- unsigned char *endp, unsigned int distance)
+   unsigned char *endp, unsigned int distance)
 {
if (*data + distance > endp)
return 0;
@@ -540,7 +540,7 @@ static int skip(unsigned char **data,
 
 /* decompress key data into the given buffer */
 static int get_key_data(unsigned char *buf,
-unsigned int codeset, unsigned int key)
+   unsigned int codeset, unsigned int key)
 {
unsigned char *data, *endp, *diffs, *key_block;
unsigned char keys, ndiffs, id;
@@ -810,7 +810,7 @@ static int fw_load(struct IR_tx *tx)
goto corrupt;
 
if (!read_uint32(&data, tx_data->endp,
- &tx_data->num_code_sets))
+&tx_data->num_code_sets))
goto corrupt;
 
dev_dbg(tx->ir->l.dev, "%u IR blaster codesets loaded\n",
@@ -866,12 +866,12 @@ static int fw_load(struct IR_tx *tx)
 * global fixed
 */
if (!skip(&data, tx_data->endp,
-  1 + TX_BLOCK_SIZE - num_global_fixed))
+ 1 + TX_BLOCK_SIZE - num_global_fixed))
goto corrupt;
 
/* Then we have keys-1 blocks of key id+diffs */
if (!skip(&data, tx_data->endp,
-  (ndiffs + 1) * (keys - 1)))
+ (ndiffs + 1) * (keys - 1)))
goto corrupt;
}
ret = 0;
@@ -1065,7 +1065,7 @@ static int send_code(struct IR_tx *tx, unsigned int code, 
unsigned int key)
break;
dev_dbg(tx->ir->l.dev,
"NAK expected: i2c_master_send failed with %d (try 
%d)\n",
-   ret, i+1);
+   ret, i + 1);
}
if (ret != 1) {
dev_err(tx->ir->l.dev,
@@ -1231,7 +1231,7 @@ static unsigned int poll(struct file *filep, poll_table 
*wait)
poll_wait(filep, &rbuf->wait_poll, wait);
 
/* Indicate what ops could happen immediately without blocking */
-   ret = lirc_buffer_empty(rbuf) ? 0 : (POLLIN|POLLRDNORM);
+   ret = lirc_buffer_empty(rbuf) ? 0 : (POLLIN | POLLRDNORM);
 
dev_dbg(ir->l.dev, "poll result = %s\n",
ret ? "POLLIN|POLLRDNORM" : "none");
@@ -1255,15 +1255,15 @@ static long ioctl(struct file *filep, unsigned int cmd, 
unsigned long arg)
result = put_user(features, uptr);
break;
case LIRC_GET_REC_MODE:
-   if (!(features&LIRC_CAN_REC_MASK))
+   if (!(features & LIRC_CAN_REC_MASK))
return -ENO

[PATCH 5/5] staging: media: lirc: Fix unbalanced braces around if/else

2017-05-15 Thread Ricardo Silva
Fix all checkpatch reported issues for:

 * CHECK: "braces {} should be used on all arms of this statement".
 * CHECK: "Unbalanced braces around else statement".

Make sure all if/else statements are balanced in terms of braces. Most
cases in code are, but a few were left unbalanced, so put them all
consistent with the recommended style.

Signed-off-by: Ricardo Silva 
---
 drivers/staging/media/lirc/lirc_zilog.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_zilog.c 
b/drivers/staging/media/lirc/lirc_zilog.c
index 7e36693b66a8..121126beccd0 100644
--- a/drivers/staging/media/lirc/lirc_zilog.c
+++ b/drivers/staging/media/lirc/lirc_zilog.c
@@ -554,9 +554,9 @@ static int get_key_data(unsigned char *buf,
if (!read_uint32(&data, tx_data->endp, &i))
goto corrupt;
 
-   if (i == codeset)
+   if (i == codeset) {
break;
-   else if (codeset > i) {
+   } else if (codeset > i) {
base = pos + 1;
--lim;
}
@@ -990,8 +990,9 @@ static int send_code(struct IR_tx *tx, unsigned int code, 
unsigned int key)
"failed to get data for code %u, key %u -- check 
lircd.conf entries\n",
code, key);
return ret;
-   } else if (ret != 0)
+   } else if (ret != 0) {
return ret;
+   }
 
/* Send the data block */
ret = send_data_block(tx, data_block);
@@ -1188,8 +1189,9 @@ static ssize_t write(struct file *filep, const char 
__user *buf, size_t n,
schedule_timeout((100 * HZ + 999) / 1000);
tx->need_boot = 1;
++failures;
-   } else
+   } else {
i += sizeof(int);
+   }
}
 
/* Release i2c bus */
-- 
2.12.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/5] staging: media: lirc: Use __func__ for logging function name

2017-05-15 Thread Ricardo Silva
Fix all checkpatch reported issues for "CHECK: Prefer using '"%s...",
__func__' to using '', ..."

Use recommended style. Additionally, __func__ was already used in
similar cases throughout the code, so make it all consistent.

Signed-off-by: Ricardo Silva 
---
 drivers/staging/media/lirc/lirc_zilog.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_zilog.c 
b/drivers/staging/media/lirc/lirc_zilog.c
index b33a2c820dc2..99b5858124e0 100644
--- a/drivers/staging/media/lirc/lirc_zilog.c
+++ b/drivers/staging/media/lirc/lirc_zilog.c
@@ -1212,7 +1212,7 @@ static unsigned int poll(struct file *filep, poll_table 
*wait)
struct lirc_buffer *rbuf = ir->l.rbuf;
unsigned int ret;
 
-   dev_dbg(ir->l.dev, "poll called\n");
+   dev_dbg(ir->l.dev, "%s called\n", __func__);
 
rx = get_ir_rx(ir);
if (!rx) {
@@ -1220,7 +1220,7 @@ static unsigned int poll(struct file *filep, poll_table 
*wait)
 * Revisit this, if our poll function ever reports writeable
 * status for Tx
 */
-   dev_dbg(ir->l.dev, "poll result = POLLERR\n");
+   dev_dbg(ir->l.dev, "%s result = POLLERR\n", __func__);
return POLLERR;
}
 
@@ -1233,7 +1233,7 @@ static unsigned int poll(struct file *filep, poll_table 
*wait)
/* Indicate what ops could happen immediately without blocking */
ret = lirc_buffer_empty(rbuf) ? 0 : (POLLIN | POLLRDNORM);
 
-   dev_dbg(ir->l.dev, "poll result = %s\n",
+   dev_dbg(ir->l.dev, "%s result = %s\n", __func__,
ret ? "POLLIN|POLLRDNORM" : "none");
return ret;
 }
@@ -1341,7 +1341,8 @@ static int close(struct inode *node, struct file *filep)
struct IR *ir = filep->private_data;
 
if (!ir) {
-   pr_err("ir: close: no private_data attached to the file!\n");
+   pr_err("ir: %s: no private_data attached to the file!\n",
+  __func__);
return -ENODEV;
}
 
-- 
2.12.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/4] staging: wlan-ng: prism2sta: Use endian types in 'comm_tallies_{16, 32}' structs fields

2017-07-18 Thread Ricardo Silva
Fields from structures 'hfa384x_comm_tallies_16' and
'hfa384x_comm_tallies_32' represent little-endian integers (16-bit and
32-bit, respectively), so declare them as such in the containing
structure and access them as such in the 'prism2sta_inf_tallies()'
function.

Fixes the following sparse warnings being raised when the structures'
fields are accessed via 'le16_to_cpu()' and 'le32_to_cpu()' functions:

 prism2sta.c:1010:33: warning: cast to restricted __le32
 prism2sta.c:1015:33: warning: cast to restricted __le16

Signed-off-by: Ricardo Silva 
---
 drivers/staging/wlan-ng/hfa384x.h   | 84 ++---
 drivers/staging/wlan-ng/prism2sta.c |  8 ++--
 2 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/wlan-ng/hfa384x.h 
b/drivers/staging/wlan-ng/hfa384x.h
index 9837a591e7e3..0fe316b5ab5d 100644
--- a/drivers/staging/wlan-ng/hfa384x.h
+++ b/drivers/staging/wlan-ng/hfa384x.h
@@ -598,51 +598,51 @@ struct hfa384x_rx_frame {
 
 /*--  Inquiry Frame, Diagnose: Communication Tallies --*/
 struct hfa384x_comm_tallies_16 {
-   u16 txunicastframes;
-   u16 txmulticastframes;
-   u16 txfragments;
-   u16 txunicastoctets;
-   u16 txmulticastoctets;
-   u16 txdeferredtrans;
-   u16 txsingleretryframes;
-   u16 txmultipleretryframes;
-   u16 txretrylimitexceeded;
-   u16 txdiscards;
-   u16 rxunicastframes;
-   u16 rxmulticastframes;
-   u16 rxfragments;
-   u16 rxunicastoctets;
-   u16 rxmulticastoctets;
-   u16 rxfcserrors;
-   u16 rxdiscardsnobuffer;
-   u16 txdiscardswrongsa;
-   u16 rxdiscardswepundecr;
-   u16 rxmsginmsgfrag;
-   u16 rxmsginbadmsgfrag;
+   __le16 txunicastframes;
+   __le16 txmulticastframes;
+   __le16 txfragments;
+   __le16 txunicastoctets;
+   __le16 txmulticastoctets;
+   __le16 txdeferredtrans;
+   __le16 txsingleretryframes;
+   __le16 txmultipleretryframes;
+   __le16 txretrylimitexceeded;
+   __le16 txdiscards;
+   __le16 rxunicastframes;
+   __le16 rxmulticastframes;
+   __le16 rxfragments;
+   __le16 rxunicastoctets;
+   __le16 rxmulticastoctets;
+   __le16 rxfcserrors;
+   __le16 rxdiscardsnobuffer;
+   __le16 txdiscardswrongsa;
+   __le16 rxdiscardswepundecr;
+   __le16 rxmsginmsgfrag;
+   __le16 rxmsginbadmsgfrag;
 } __packed;
 
 struct hfa384x_comm_tallies_32 {
-   u32 txunicastframes;
-   u32 txmulticastframes;
-   u32 txfragments;
-   u32 txunicastoctets;
-   u32 txmulticastoctets;
-   u32 txdeferredtrans;
-   u32 txsingleretryframes;
-   u32 txmultipleretryframes;
-   u32 txretrylimitexceeded;
-   u32 txdiscards;
-   u32 rxunicastframes;
-   u32 rxmulticastframes;
-   u32 rxfragments;
-   u32 rxunicastoctets;
-   u32 rxmulticastoctets;
-   u32 rxfcserrors;
-   u32 rxdiscardsnobuffer;
-   u32 txdiscardswrongsa;
-   u32 rxdiscardswepundecr;
-   u32 rxmsginmsgfrag;
-   u32 rxmsginbadmsgfrag;
+   __le32 txunicastframes;
+   __le32 txmulticastframes;
+   __le32 txfragments;
+   __le32 txunicastoctets;
+   __le32 txmulticastoctets;
+   __le32 txdeferredtrans;
+   __le32 txsingleretryframes;
+   __le32 txmultipleretryframes;
+   __le32 txretrylimitexceeded;
+   __le32 txdiscards;
+   __le32 rxunicastframes;
+   __le32 rxmulticastframes;
+   __le32 rxfragments;
+   __le32 rxunicastoctets;
+   __le32 rxmulticastoctets;
+   __le32 rxfcserrors;
+   __le32 rxdiscardsnobuffer;
+   __le32 txdiscardswrongsa;
+   __le32 rxdiscardswepundecr;
+   __le32 rxmsginmsgfrag;
+   __le32 rxmsginbadmsgfrag;
 } __packed;
 
 /*--  Inquiry Frame, Diagnose: Scan Results & Subfields--*/
diff --git a/drivers/staging/wlan-ng/prism2sta.c 
b/drivers/staging/wlan-ng/prism2sta.c
index 250af0de9c3e..8c347128e810 100644
--- a/drivers/staging/wlan-ng/prism2sta.c
+++ b/drivers/staging/wlan-ng/prism2sta.c
@@ -991,9 +991,9 @@ static void prism2sta_inf_tallies(struct wlandevice 
*wlandev,
  struct hfa384x_inf_frame *inf)
 {
struct hfa384x *hw = wlandev->priv;
-   u16 *src16;
+   __le16 *src16;
u32 *dst;
-   u32 *src32;
+   __le32 *src32;
int i;
int cnt;
 
@@ -1005,12 +1005,12 @@ static void prism2sta_inf_tallies(struct wlandevice 
*wlandev,
cnt = sizeof(struct hfa384x_comm_tallies_32) / sizeof(u32);
if (inf->framelen > 22) {
dst = (u32 *)&hw->tallies;
-   src32 = (u32 *)&inf->info.commtallies32;
+   src32 = (__le32 *)&inf->info.commtallies32;
for (i = 0; i < cnt; i++, dst++, src32++)
*dst += le32_to_cpu(*src32);
} else {
dst = (u32 *)&hw->talli

[PATCH 0/4] staging: wlan-ng: prism2sta: Fix sparse warnings (endian)

2017-07-18 Thread Ricardo Silva
This series intends to fix all sparse warnings left in 'prism2sta.c' from the
'wlan-ng' staging driver.

Patch 1 fixes the fields declarations of 'struct hfa384x_comm_tallies_{16.32}'
and the way they are accessed from 'prism2sta_inf_tallies()'.

Patches 2 and 3 each fix a different struct field declaration to have endianess
indication.

Patch 4 fixes the remaining endian related sparse warnings in function
'prism2sta_inf_chinforesults()' by using 'in situ' conversions, required due to
the same structures being shared for storing both the little-endian values and
the converted ones.

With this series, no sparse reported issues are left in the 'wlan-ng' driver.

Ricardo Silva (4):
  staging: wlan-ng: prism2sta: Use endian types in 'comm_tallies_{16,32}' 
structs fields
  staging: wlan-ng: prism2sta: Use endian type in 'hfa384x_link_status' struct
  staging: wlan-ng: prism2sta: Use endian type in 'hfa384x_ps_user_count' struct
  staging: wlan-ng: prism2sta: Use 'in situ' endian conversions in 
'prism2sta_inf_chinforesults()'

 drivers/staging/wlan-ng/hfa384x.h   | 88 ++---
 drivers/staging/wlan-ng/prism2sta.c | 25 +++
 2 files changed, 60 insertions(+), 53 deletions(-)

-- 
2.13.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/4] staging: wlan-ng: prism2sta: Use endian type in 'hfa384x_ps_user_count' struct

2017-07-18 Thread Ricardo Silva
The 'usercnt' field from struct 'hfa384x_ps_user_count' represents a
16-bit little-endian integer, so declare it as such to avoid the
following sparse warning when accessing it through the 'le16_to_cpu()'
function:

 prism2sta.c:1727:27: warning: cast to restricted __le16

Signed-off-by: Ricardo Silva 
---
 drivers/staging/wlan-ng/hfa384x.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wlan-ng/hfa384x.h 
b/drivers/staging/wlan-ng/hfa384x.h
index b61ace1d1e66..f5a3a1ce21ce 100644
--- a/drivers/staging/wlan-ng/hfa384x.h
+++ b/drivers/staging/wlan-ng/hfa384x.h
@@ -739,7 +739,7 @@ struct hfa384x_auth_request {
 /*--  Unsolicited Frame, MAC Mgmt: PSUserCount (AP Only) --*/
 
 struct hfa384x_ps_user_count {
-   u16 usercnt;
+   __le16 usercnt;
 } __packed;
 
 struct hfa384x_key_id_changed {
-- 
2.13.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/4] staging: wlan-ng: prism2sta: Use endian type in 'hfa384x_link_status' struct

2017-07-18 Thread Ricardo Silva
The 'linkstatus' field from struct 'hfa384x_link_status' represents a
16-bit little-endian integer, so declare it as such to avoid the
following sparse warning when accessing it through the 'le16_to_cpu()'
function:

 prism2sta.c:1450:31: warning: cast to restricted __le16

Signed-off-by: Ricardo Silva 
---
 drivers/staging/wlan-ng/hfa384x.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wlan-ng/hfa384x.h 
b/drivers/staging/wlan-ng/hfa384x.h
index 0fe316b5ab5d..b61ace1d1e66 100644
--- a/drivers/staging/wlan-ng/hfa384x.h
+++ b/drivers/staging/wlan-ng/hfa384x.h
@@ -711,7 +711,7 @@ struct hfa384x_hscan_result {
 #define HFA384x_LINK_ASSOCFAIL ((u16)6)
 
 struct hfa384x_link_status {
-   u16 linkstatus;
+   __le16 linkstatus;
 } __packed;
 
 /*--  Unsolicited Frame, MAC Mgmt: AssociationStatus (--*/
-- 
2.13.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/4] staging: wlan-ng: prism2sta: Use 'in situ' endian conversions in 'prism2sta_inf_chinforesults()'

2017-07-18 Thread Ricardo Silva
Function 'prism2sta_inf_chinforesults()' decodes some little-endian
16-bit values from a received Channel Info Results info frame and stores
them on the 'struct hfa384x' associated instance.

To note that the structs and fields for storing both the little-endian
(in info frame struct) and CPU byte order (in instance struct) values
are the same ('struct hfa384x_ch_info_result').

Some sparse warnings are being triggered when accessing the
little-endian values using 'le16_to_cpu()' from within
'prism2sta_inf_chinforesults()':

 prism2sta.c:1139:13: warning: cast to restricted __le16
 prism2sta.c:1150:24: warning: cast to restricted __le16
 prism2sta.c:1157:37: warning: cast to restricted __le16
 prism2sta.c:1158:37: warning: cast to restricted __le16
 prism2sta.c:1159:40: warning: cast to restricted __le16

Changing the relevant fields declarations to '__le16' won't fix the
issue, because the same struct and fields are also used for storing the
values in CPU byte order (which must be 'u16').

This way, use 'in situ' conversion on the info frame fields and then
assign the converted values to the associated fields on the instance
data side. Add a local 'le16_to_cpus_ret()' function as a helper for
this process, doing the 'in situ' conversion and returning the converted
value.

The 'in situ' conversions on the info frame side fields is safe, in the
sense that there are no posterior accesses to the (now already
converted) values, otherwise any posterior accesses must consider that
the conversion was already done.

Signed-off-by: Ricardo Silva 
---
 drivers/staging/wlan-ng/prism2sta.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wlan-ng/prism2sta.c 
b/drivers/staging/wlan-ng/prism2sta.c
index 8c347128e810..a549ef0e2ff4 100644
--- a/drivers/staging/wlan-ng/prism2sta.c
+++ b/drivers/staging/wlan-ng/prism2sta.c
@@ -132,6 +132,13 @@ static void prism2sta_inf_authreq_defer(struct wlandevice 
*wlandev,
 static void prism2sta_inf_psusercnt(struct wlandevice *wlandev,
struct hfa384x_inf_frame *inf);
 
+/* Convert from __le16 to u16 in situ and return converted value. */
+static inline u16 le16_to_cpus_ret(u16 *var)
+{
+   le16_to_cpus(var);
+   return *var;
+}
+
 /*
  * prism2sta_open
  *
@@ -1136,7 +1143,7 @@ static void prism2sta_inf_chinforesults(struct wlandevice 
*wlandev,
unsigned int i, n;
 
hw->channel_info.results.scanchannels =
-   le16_to_cpu(inf->info.chinforesult.scanchannels);
+   le16_to_cpus_ret(&inf->info.chinforesult.scanchannels);
 
for (i = 0, n = 0; i < HFA384x_CHINFORESULT_MAX; i++) {
struct hfa384x_ch_info_result_sub *result;
@@ -1147,16 +1154,16 @@ static void prism2sta_inf_chinforesults(struct 
wlandevice *wlandev,
continue;
 
result = &inf->info.chinforesult.result[n];
-   chan = le16_to_cpu(result->chid) - 1;
+   chan = le16_to_cpus_ret(&result->chid) - 1;
 
if (chan < 0 || chan >= HFA384x_CHINFORESULT_MAX)
continue;
 
chinforesult = &hw->channel_info.results.result[chan];
chinforesult->chid = chan;
-   chinforesult->anl = le16_to_cpu(result->anl);
-   chinforesult->pnl = le16_to_cpu(result->pnl);
-   chinforesult->active = le16_to_cpu(result->active);
+   chinforesult->anl = le16_to_cpus_ret(&result->anl);
+   chinforesult->pnl = le16_to_cpus_ret(&result->pnl);
+   chinforesult->active = le16_to_cpus_ret(&result->active);
 
pr_debug("chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf 
%d\n",
 chan + 1,
-- 
2.13.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 4/4] staging: wlan-ng: prism2sta: Use 'in situ' endian conversions in 'prism2sta_inf_chinforesults()'

2017-07-18 Thread Ricardo Silva
Hello Dan,

On 07/18/2017 02:52 PM, Dan Carpenter wrote:
> No no no no no no...  Don't change them in place for no reason just
> because it doesn't cause a bug.  It's better to just cast away the
> warnings except we're going to automatically NAK that patch as well...
> But this is even worse.
> 

Got it. Thanks for reviewing.

Another possibility would be to use different (although twin) structs
for the info frame data (using __le16) and the associated instance
data (using u16), but that would mean having to maintain the 2 structs
in sync with each other in case some change is needed.
Would this be acceptable?
Or, shall I just leave the warnings there?

Regards,
Ricardo Silva

> regards,
> dan carpenter
> 
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: wlan-ng: hfa384x.h: Use endian type in 'hfa384x_link_status' struct

2017-08-16 Thread Ricardo Silva
The 'linkstatus' field from struct 'hfa384x_link_status' represents a
16-bit little-endian integer, so declare it as such to avoid the
following sparse warning when accessing it through the 'le16_to_cpu()'
function:

 prism2sta.c:1450:31: warning: cast to restricted __le16

Signed-off-by: Ricardo Silva 
---
 drivers/staging/wlan-ng/hfa384x.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wlan-ng/hfa384x.h 
b/drivers/staging/wlan-ng/hfa384x.h
index cb5afeffb234..f5a3a1ce21ce 100644
--- a/drivers/staging/wlan-ng/hfa384x.h
+++ b/drivers/staging/wlan-ng/hfa384x.h
@@ -711,7 +711,7 @@ struct hfa384x_hscan_result {
 #define HFA384x_LINK_ASSOCFAIL ((u16)6)
 
 struct hfa384x_link_status {
-   u16 linkstatus;
+   __le16 linkstatus;
 } __packed;
 
 /*--  Unsolicited Frame, MAC Mgmt: AssociationStatus (--*/
-- 
2.13.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: wlan-ng: Fix sparse warning: cast to restricted __le16.

2017-08-18 Thread Ricardo Silva
Hi,

On 08/09/2017 11:35 PM, AbdAllah-MEZITI wrote:
> The same structure is used in both side, so we dont need to cast.

I believe there were no casts there, but calls to le16_to_cpu(),
meaning there was previously a bug or the data being accessed was
really stored in little-endian format, so we shouldn't just remove
them for silencing sparse.

> This will fix the following sparse warnings:
> drivers/staging/wlan-ng/prism2sta.c:1139:13: warning: cast to restricted 
> __le16
> drivers/staging/wlan-ng/prism2sta.c:1150:24: warning: cast to restricted 
> __le16
> drivers/staging/wlan-ng/prism2sta.c:1157:37: warning: cast to restricted 
> __le16
> drivers/staging/wlan-ng/prism2sta.c:1158:37: warning: cast to restricted 
> __le16
> drivers/staging/wlan-ng/prism2sta.c:1159:40: warning: cast to restricted 
> __le16
> drivers/staging/wlan-ng/prism2sta.c:1450:31: warning: cast to restricted 
> __le16
> 
> Signed-off-by: AbdAllah MEZITI 
> ---
>  drivers/staging/wlan-ng/prism2sta.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/wlan-ng/prism2sta.c 
> b/drivers/staging/wlan-ng/prism2sta.c
> index 8c34712..c9df450 100644
> --- a/drivers/staging/wlan-ng/prism2sta.c
> +++ b/drivers/staging/wlan-ng/prism2sta.c
> @@ -1136,7 +1136,7 @@ static void prism2sta_inf_chinforesults(struct 
> wlandevice *wlandev,
>   unsigned int i, n;
>  
>   hw->channel_info.results.scanchannels =
> - le16_to_cpu(inf->info.chinforesult.scanchannels);
> + inf->info.chinforesult.scanchannels;

If this is not fixing some issue, then I believe it can be introducing
one on big-endian CPUs, right?

>  
>   for (i = 0, n = 0; i < HFA384x_CHINFORESULT_MAX; i++) {
>   struct hfa384x_ch_info_result_sub *result;
> @@ -1147,16 +1147,16 @@ static void prism2sta_inf_chinforesults(struct 
> wlandevice *wlandev,
>   continue;
>  
>   result = &inf->info.chinforesult.result[n];
> - chan = le16_to_cpu(result->chid) - 1;
> + chan = result->chid - 1;

Ditto.

>  
>   if (chan < 0 || chan >= HFA384x_CHINFORESULT_MAX)
>   continue;
>  
>   chinforesult = &hw->channel_info.results.result[chan];
>   chinforesult->chid = chan;
> - chinforesult->anl = le16_to_cpu(result->anl);
> - chinforesult->pnl = le16_to_cpu(result->pnl);
> - chinforesult->active = le16_to_cpu(result->active);
> + chinforesult->anl = result->anl;
> + chinforesult->pnl = result->pnl;
> + chinforesult->active = result->active;

Ditto.

>  
>   pr_debug("chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf 
> %d\n",
>chan + 1,
> @@ -1447,7 +1447,7 @@ static void prism2sta_inf_linkstatus(struct wlandevice 
> *wlandev,
>  {
>   struct hfa384x *hw = wlandev->priv;
>  
> - hw->link_status_new = le16_to_cpu(inf->info.linkstatus.linkstatus);
> + hw->link_status_new = inf->info.linkstatus.linkstatus;

Ditto.
If I'm wrong about this being incorrect, then I have a patch submitted for 
fixing
the sparse warning here that should be discarded. My patch is:

  staging: wlan-ng: hfa384x.h: Use endian type in 'hfa384x_link_status'

and changes the linkstatus field to le16.

Regards,

Ricardo Silva

>  
>   schedule_work(&hw->link_bh);
>  }
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel