[PATCH] drivers/staging/speakup: fix some coding style problem in spk_ttyio.c
This is a patch to the spk_ttyio.c file which fixes up the problems reported by the checkpatch.pl tool. Signed-off-by: Rui Teng --- drivers/staging/speakup/spk_ttyio.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/speakup/spk_ttyio.c b/drivers/staging/speakup/spk_ttyio.c index 6e0f042f6a44..791da6e6d6ed 100644 --- a/drivers/staging/speakup/spk_ttyio.c +++ b/drivers/staging/speakup/spk_ttyio.c @@ -25,10 +25,8 @@ static int spk_ttyio_ldisc_open(struct tty_struct *tty) speakup_tty = tty; ldisc_data = kmalloc(sizeof(struct spk_ldisc_data), GFP_KERNEL); - if (!ldisc_data) { - pr_err("speakup: Failed to allocate ldisc_data.\n"); + if (!ldisc_data) return -ENOMEM; - } sema_init(&ldisc_data->sem, 0); ldisc_data->buf_free = true; @@ -50,6 +48,7 @@ static int spk_ttyio_receive_buf2(struct tty_struct *tty, if (spk_ttyio_synth->read_buff_add) { int i; + for (i = 0; i < count; i++) spk_ttyio_synth->read_buff_add(cp[i]); @@ -61,7 +60,8 @@ static int spk_ttyio_receive_buf2(struct tty_struct *tty, return 0; /* Make sure the consumer has read buf before we have seen - * buf_free == true and overwrite buf */ +* buf_free == true and overwrite buf +*/ mb(); ldisc_data->buf = cp[0]; @@ -162,6 +162,7 @@ static int spk_ttyio_out(struct spk_synth *in_synth, const char ch) { if (in_synth->alive && speakup_tty && speakup_tty->ops->write) { int ret = speakup_tty->ops->write(speakup_tty, &ch, 1); + if (ret == 0) /* No room */ return 0; @@ -204,7 +205,8 @@ static unsigned char ttyio_in(int timeout) rv = ldisc_data->buf; /* Make sure we have read buf before we set buf_free to let -* the producer overwrite it */ +* the producer overwrite it +*/ mb(); ldisc_data->buf_free = true; /* Let TTY push more characters */ -- 2.11.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] drivers/staging/speakup: fix indent coding style problem in spk_ttyio.c
This is a patch to the spk_ttyio.c file which fixes up the indent error reported by the checkpatch.pl tool. Signed-off-by: Rui Teng --- drivers/staging/speakup/spk_ttyio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/speakup/spk_ttyio.c b/drivers/staging/speakup/spk_ttyio.c index 6e0f042f6a44..7964a51334d9 100644 --- a/drivers/staging/speakup/spk_ttyio.c +++ b/drivers/staging/speakup/spk_ttyio.c @@ -61,7 +61,7 @@ static int spk_ttyio_receive_buf2(struct tty_struct *tty, return 0; /* Make sure the consumer has read buf before we have seen - * buf_free == true and overwrite buf */ +* buf_free == true and overwrite buf */ mb(); ldisc_data->buf = cp[0]; -- 2.11.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] drivers/staging/wilc1000: fix sparse warning: right shift by bigger than source value
This patch sets memory to zero directly to avoid unnecessary shift and bitwise operations on bool type, which can fix a sparse warning and also improve performance. Signed-off-by: Rui Teng --- drivers/staging/wilc1000/host_interface.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 2568dfc15181..036c5c19a016 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -2416,10 +2416,9 @@ static void Handle_SetMulticastFilter(struct wilc_vif *vif, goto ERRORHANDLER; pu8CurrByte = wid.val; - *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF); - *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 8) & 0xFF); - *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 16) & 0xFF); - *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 24) & 0xFF); + memset(pu8CurrByte, 0, 4); + *pu8CurrByte = (strHostIfSetMulti->enabled & 0xFF); + pu8CurrByte += 4; *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF); *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF); -- 2.11.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] drivers/staging/wilc1000: fix sparse warning: right shift by bigger than source value
On 12/07/2017 1:04 AM, Greg Kroah-Hartman wrote: On Mon, Jul 10, 2017 at 04:57:31PM +0800, Rui Teng wrote: This patch sets memory to zero directly to avoid unnecessary shift and bitwise operations on bool type, which can fix a sparse warning and also improve performance. It does? How did you measure the performance impact? What was now faster? It can avoid 3 times right shift and 3 times bitwise operations. And once memory set should also faster than 4 times copy operations. And add number 4 once should also faster than 4 times plus plus. thanks, greg k-h Signed-off-by: Rui Teng --- drivers/staging/wilc1000/host_interface.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 2568dfc15181..036c5c19a016 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -2416,10 +2416,9 @@ static void Handle_SetMulticastFilter(struct wilc_vif *vif, goto ERRORHANDLER; pu8CurrByte = wid.val; - *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF); - *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 8) & 0xFF); - *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 16) & 0xFF); - *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 24) & 0xFF); + memset(pu8CurrByte, 0, 4); + *pu8CurrByte = (strHostIfSetMulti->enabled & 0xFF); + pu8CurrByte += 4; Are you sure enabled isn't larger than 8 bits? The size of bool may larger than 8 bits. But when we assign any value to bool type, the value of bool type will only be 1 or 0. For example, the following output will be 1 other than 0x100. bool b = 0x100; printf("b: %d\n", b); Or I think it should change 'enabled' type from bool to u32, to make sure that the right shift operation can take effect. thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] stating: lustre: fix sparse error: incompatible types in comparison expression
Comparing two user space addresses to avoid sparse error: drivers/staging//lustre/lnet/selftest/conrpc.c:490:30: error: incompatible types in comparison expression (different address spaces) Signed-off-by: Rui Teng --- drivers/staging/lustre/lnet/selftest/conrpc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c index da36c55b86d3..ae7c2772825e 100644 --- a/drivers/staging/lustre/lnet/selftest/conrpc.c +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c @@ -487,10 +487,9 @@ lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans, sizeof(struct list_head))) return -EFAULT; - if (tmp.next == head_up) - return 0; - next = tmp.next; + if (next == head_up) + return 0; ent = list_entry(next, struct lstcon_rpc_ent, rpe_link); -- 2.11.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel