staging: fwserial: (coding style) Turning every "unsigned" into "unsigned int"
PATCH 1/3 staging: fwserial: (coding style) Turning every "unsigned" into "unsigned int"
Coding-style-only modifications to remove every warning saying:
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
Compiled against revision "next-20160327".
(checkpatch.pl was updated to treat "UNSPECIFIED_INT" warnings
as of commit a1ce18e4f941d20 )
--- drivers/staging/fwserial/dma_fifo.c | 8 +++---- drivers/staging/fwserial/dma_fifo.h | 16 +++++++------- drivers/staging/fwserial/fwserial.c | 38 +++++++++++++++++---------------- drivers/staging/fwserial/fwserial.h | 42 ++++++++++++++++++------------------- 4 files changed, 53 insertions(+), 51 deletions(-)
drivers/staging/fwserial/dma_fifo.c +4 -4
@@ -35,7 +35,7 @@/* * private helper fn to determine if check is in open interval (lo,hi) */ -static bool addr_check (unsigned check,unsigned lo,unsigned hi) +static bool addr_check (unsigned int check,unsigned int lo,unsigned int hi) {return check - (lo +1 ) < (hi -1 ) - lo; }
@@ -64,7 +64,7 @@ void dma_fifo_init(struct dma_fifo *fifo)* The 'apparent' size will be rounded up to next greater aligned size. * Returns 0 if no error, otherwise an error code */ -int dma_fifo_alloc (struct dma_fifo *fifo,int size,unsigned align, +int dma_fifo_alloc (struct dma_fifo *fifo,int size,unsigned int align,int tx_limit,int open_limit,gfp_t gfp_mask) {int capacity;
@@ -190,7 +190,7 @@ int dma_fifo_in(struct dma_fifo *fifo, const void *src, int n)*/ int dma_fifo_out_pend (struct dma_fifo *fifo,struct dma_pending *pended) { -unsigned len, n, ofs, l, limit; +unsigned int len, n, ofs, l, limit;if (!fifo->data)return -ENOENT ;
@@ -210,7 +210,7 @@ int dma_fifo_out_pend(struct dma_fifo *fifo, struct dma_pending *pended) n = len; ofs = fifo->out % fifo->capacity; l = fifo->capacity - ofs; - limit =min_t (unsigned, l, fifo->tx_limit); + limit = min_t(unsigned int, l, fifo->tx_limit);if (n > limit) { n = limit; fifo->out += limit;
drivers/staging/fwserial/dma_fifo.h +8 -8
@@ -45,9 +45,9 @@#define DMA_FIFO_GUARD 3/* # of cache lines to reserve for the guard area */ struct dma_fifo { -unsigned in; -unsigned out;/* updated when dma is pended */ -unsigned done;/* updated upon dma completion */ +unsigned int in; +unsigned int out;/* updated when dma is pended */ +unsigned int done;/* updated upon dma completion */ struct {unsigned corrupt:1 ; };
@@ -55,7 +55,7 @@ struct dma_fifo {int guard;/* ofs of guard area */ int capacity;/* size + reserved */ int avail;/* # of unused bytes in fifo */ -unsigned align;/* must be power of 2 */ +unsigned int align;/* must be power of 2 */ int tx_limit;/* max # of bytes per dma transaction */ int open_limit;/* max # of outstanding allowed */ int open;/* # of outstanding dma transactions */
@@ -66,9 +66,9 @@ struct dma_fifo {struct dma_pending {struct list_head link;void *data; -unsigned len; -unsigned next; -unsigned out; +unsigned int len; +unsigned int next; +unsigned int out; };static inline void dp_mark_completed (struct dma_pending *dp)
@@ -82,7 +82,7 @@ static inline bool dp_is_completed(struct dma_pending *dp) }void dma_fifo_init (struct dma_fifo *fifo); -int dma_fifo_alloc (struct dma_fifo *fifo,int size,unsigned align, +int dma_fifo_alloc (struct dma_fifo *fifo,int size,unsigned int align,int tx_limit,int open_limit,gfp_t gfp_mask);void dma_fifo_free (struct dma_fifo *fifo);void dma_fifo_reset (struct dma_fifo *fifo);
drivers/staging/fwserial/fwserial.c +20 -18
@@ -132,7 +132,7 @@ static struct fwtty_peer *__fwserial_peer_by_node_id(struct fw_card *card,#ifdef FWTTY_PROFILING -static void fwtty_profile_fifo (struct fwtty_port *port,unsigned *stat) +static void fwtty_profile_fifo (struct fwtty_port *port,unsigned int *stat) {spin_lock_bh (&port->lock);fwtty_profile_data (stat,dma_fifo_avail (&port->tx_fifo));
@@ -143,7 +143,7 @@ static void fwtty_dump_profile(struct seq_file *m, struct stats *stats) {/* for each stat, print sum of 0 to 2^k, then individually */ int k =4 ; -unsigned sum; +unsigned int sum;int j;char t[10 ];
@@ -303,9 +303,10 @@ static void fwtty_restart_tx(struct fwtty_port *port)* Note: in loopback, the port->lock is being held. Only use functions that * don't attempt to reclaim the port->lock. */ -static void fwtty_update_port_status (struct fwtty_port *port,unsigned status) +static void fwtty_update_port_status (struct fwtty_port *port, +unsigned int status) { -unsigned delta; +unsigned int delta;struct tty_struct *tty;/* simulated LSR/MSR status from remote */
@@ -396,9 +397,9 @@ static void fwtty_update_port_status(struct fwtty_port *port, unsigned status)* * Note: caller must be holding port lock */ -static unsigned __fwtty_port_line_status (struct fwtty_port *port) +static unsigned int __fwtty_port_line_status (struct fwtty_port *port) { -unsigned status =0 ; +unsigned int status =0 ;/* TODO: add module param to tie RNG to DTR as well */
@@ -424,7 +425,7 @@ static int __fwtty_write_port_status(struct fwtty_port *port) {struct fwtty_peer *peer;int err = -ENOENT ; -unsigned status =__fwtty_port_line_status (port); +unsigned int status =__fwtty_port_line_status (port);rcu_read_lock (); peer =rcu_dereference (port->peer);
@@ -454,7 +455,7 @@ static int fwtty_write_port_status(struct fwtty_port *port)static void fwtty_throttle_port (struct fwtty_port *port) {struct tty_struct *tty; -unsigned old; +unsigned int old; tty =tty_port_tty_get (&port->port);if (!tty)
@@ -540,7 +541,7 @@ static void fwtty_emit_breaks(struct work_struct *work)static int fwtty_rx (struct fwtty_port *port,unsigned char *data,size_t len) {int c, n = len; -unsigned lsr; +unsigned int lsr;int err =0 ;fwtty_dbg (port,"%d\n" , n);
@@ -635,7 +636,7 @@ static void fwtty_port_handler(struct fw_card *card,if (addr != port->rx_handler.offset || len !=4 ) { rcode =RCODE_ADDRESS_ERROR ; }else { -fwtty_update_port_status (port, *(unsigned *)data); +fwtty_update_port_status (port, *(unsigned int *)data); rcode =RCODE_COMPLETE ; }break ;
@@ -828,7 +829,7 @@ static void fwtty_write_xchar(struct fwtty_port *port, char ch)rcu_read_unlock (); } -static struct fwtty_port *fwtty_port_get (unsigned index) +static struct fwtty_port *fwtty_port_get (unsigned int index) {struct fwtty_port *port;
@@ -934,9 +935,9 @@ static int fwtty_port_carrier_raised(struct tty_port *tty_port)return rc; } -static unsigned set_termios (struct fwtty_port *port,struct tty_struct *tty) +static unsigned int set_termios (struct fwtty_port *port,struct tty_struct *tty) { -unsigned baud, frame; +unsigned int baud, frame; baud =tty_termios_baud_rate (&tty->termios);tty_termios_encode_baud_rate (&tty->termios, baud, baud);
@@ -988,7 +989,7 @@ static int fwtty_port_activate(struct tty_port *tty_port, struct tty_struct *tty) {struct fwtty_port *port =to_port (tty_port, port); -unsigned baud; +unsigned int baud;int err;set_bit (TTY_IO_ERROR , &tty->flags);
@@ -1264,7 +1265,7 @@ static int set_serial_info(struct fwtty_port *port,return 0 ; } -static int fwtty_ioctl (struct tty_struct *tty,unsigned cmd, +static int fwtty_ioctl (struct tty_struct *tty,unsigned int cmd,unsigned long arg) {struct fwtty_port *port = tty->driver_data;
@@ -1297,7 +1298,7 @@ static int fwtty_ioctl(struct tty_struct *tty, unsigned cmd,static void fwtty_set_termios (struct tty_struct *tty,struct ktermios *old) {struct fwtty_port *port = tty->driver_data; -unsigned baud; +unsigned int baud;spin_lock_bh (&port->lock); baud =set_termios (port, tty);
@@ -1369,7 +1370,7 @@ static int fwtty_break_ctl(struct tty_struct *tty, int state)static int fwtty_tiocmget (struct tty_struct *tty) {struct fwtty_port *port = tty->driver_data; -unsigned tiocm; +unsigned int tiocm;spin_lock_bh (&port->lock); tiocm = (port->mctrl &MCTRL_MASK ) | (port->mstatus & ~MCTRL_MASK );
@@ -1380,7 +1381,8 @@ static int fwtty_tiocmget(struct tty_struct *tty)return tiocm; } -static int fwtty_tiocmset (struct tty_struct *tty,unsigned set,unsigned clear) +static int fwtty_tiocmset (struct tty_struct *tty, +unsigned int set,unsigned int clear) {struct fwtty_port *port = tty->driver_data;
drivers/staging/fwserial/fwserial.h +21 -21
87 lines not on this page · raw message
Signature · 1 line
2.4.3
PATCH 2/3 staging: fwserial: (coding style) removing "!= NULL" to comply with checkpatch.pl
Removing two "!= NULL" from fwserial.c as suggested by checkpatch.pl. Note that the associated expression "port->port.console" is a 1-bit-field that is already assumed as an implicit boolean (that is: without comparison)
--- drivers/staging/fwserial/fwserial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/fwserial/fwserial.c +2 -2
@@ -1701,7 +1701,7 @@ static void fwserial_virt_plug_complete(struct fwtty_peer *peer,dma_fifo_change_tx_limit (&port->tx_fifo, port->max_payload);spin_unlock_bh (&peer->port->lock); -if (port->port.console && port->fwcon_ops->notify !=NULL ) +if (port->port.console && port->fwcon_ops->notify) (*port->fwcon_ops->notify)(FWCON_NOTIFY_ATTACH , port->con_data); fwtty_info(&peer->unit, "peer (guid:%016llx) connected on %s\n",
@@ -1808,7 +1808,7 @@ static void fwserial_release_port(struct fwtty_port *port, bool reset)RCU_INIT_POINTER (port->peer,NULL );spin_unlock_bh (&port->lock); -if (port->port.console && port->fwcon_ops->notify !=NULL ) +if (port->port.console && port->fwcon_ops->notify) (*port->fwcon_ops->notify)(FWCON_NOTIFY_DETACH , port->con_data); }
Signature · 1 line
2.4.3
Re: [PATCH 2/3] staging: fwserial: (coding style) removing "!= NULL" to comply with checkpatch.pl
Quoted 3 lines · Dominique van den Broeck
Removing two "!= NULL" from
fwserial.cas suggested by checkpatch.pl. Note that the associated expression "port->port.console" is a 1-bit-field that is already assumed as an implicit boolean (that is: without comparison)
Similarly, please change $subject to "staging: fwserial: Simplify NULL ptr check" With that,
PATCH 3/3 staging: fwserial: (coding style) Rewriting a call to a long function
In reply to Dominique van den BroeckFixing a lone row exceeding 80 columns so the only remaining warnings emitted by checkpatch.pl are missing comments on spinlocks and memory barriers.
--- drivers/staging/fwserial/fwserial.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/staging/fwserial/fwserial.c +5 -3
@@ -1343,9 +1343,11 @@ static int fwtty_break_ctl(struct tty_struct *tty, int state)if (state ==-1 ) {set_bit (STOP_TX , &port->flags); - ret =wait_event_interruptible_timeout (port->wait_tx, - !test_bit (IN_TX , &port->flags), -10 ); + ret = +wait_event_interruptible_timeout (port->wait_tx, + !test_bit (IN_TX , &port->flags), +10 ); +if (ret ==0 || ret == -ERESTARTSYS ) {clear_bit (STOP_TX , &port->flags);fwtty_restart_tx (port);
Signature · 1 line
2.4.3
Re: [PATCH 3/3] staging: fwserial: (coding style) Rewriting a call to a long function
Quoted 3 lines · Dominique van den Broeck
Fixing a lone row exceeding 80 columns so the only remaining warnings emitted by checkpatch.pl are missing comments on spinlocks and memory barriers.
[]
drivers/staging/fwserial/fwserial.c
Quoted 1 line
drivers/staging/fwserial/fwserial.c +0
-0
[]
drivers/staging/fwserial/fwserial.c static int fwtty_break_ctl(struct tty_struct *tty, int state) · line 1349
Quoted 11 lines
drivers/staging/fwserial/fwserial.c +0
-0@@ -1343,9 +1343,11 @@ static int fwtty_break_ctl(struct tty_struct *tty, int state)
if (state == -1) {
set_bit(STOP_TX, &port->flags);drivers/staging/fwserial/fwserial.c +4
-3- ret =wait_event_interruptible_timeout (port->wait_tx, - !test_bit(IN_TX, &port->flags), - 10); + ret = +wait_event_interruptible_timeout (port->wait_tx, + !test_bit(IN_TX, &port->flags), + 10);
Does this really look better to you?
Long identifiers like "wait_event_interruptible_timeout" (32 chars) make
using 80 columns a bit silly.
Please remember checkpatch is a stupid script and that not every warning it emits is dicta.
Re: [PATCH 3/3] staging: fwserial: (coding style) Rewriting a call to a long function
Quoted 8 lines
Does this really look better to you?
Long identifiers like "
wait_event_interruptible_timeout" (32 chars) make
using 80 columns a bit silly.Please remember checkpatch is a stupid script and that not every warning it emits is dicta.
Actually, not much and as a matter of fact, I hesitated before sending this particular patch. That's also why I submitted it as the last one of them all and why it fixes only a single row : so we can eventually reject it easily.
I'm not a checkpatch.pl nazi neither and anyway, even the "Development Process" document specify that it's not to be considered as a strict rule if it makes the things worse.
But I found it useful anyway because this set brings back all the warnings to only two categories (comments over spinlocks and memory barriers) and also because this kind of minor corrections could still be appreciated by people that have better things to do... :-)
Cheers.
Re: [PATCH 3/3] staging: fwserial: (coding style) Rewriting a call to a long function
In reply to Dominique van den BroeckHi Dominique,
Quoted 15 lines · Dominique van den Broeck
Fixing a lone row exceeding 80 columns so the only remaining warnings emitted by checkpatch.pl are missing comments on spinlocks and memory barriers.
Signed-off-by Dominique van den Broeck <[email protected]>--- drivers/staging/fwserial/fwserial.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/staging/fwserial/fwserial.c +0
-0@@ -1343,9 +1343,11 @@ static int fwtty_break_ctl(struct tty_struct *tty, int state)
drivers/staging/fwserial/fwserial.c static int fwtty_break_ctl(struct tty_struct *tty, int state) · line 1350
Quoted 10 lines
drivers/staging/fwserial/fwserial.c +5
-3if (state ==-1 ) {set_bit (STOP_TX , &port->flags); - ret =wait_event_interruptible_timeout (port->wait_tx, - !test_bit (IN_TX , &port->flags), -10 ); + ret = +wait_event_interruptible_timeout (port->wait_tx, + !test_bit (IN_TX , &port->flags), +10 ); +
I don't see a > 80-col line here?
And even if I did, this change would be super-ugly.
The preferred way to reduce this is to fold it into a helper function, like
if (state == -1 && fwtty_wait_tx_complete(port)) return -EINTR;
Regards,
Peter Hurley
Quoted 4 lines
drivers/staging/fwserial/fwserial.c +0
-0if (ret ==0 || ret == -ERESTARTSYS ) {clear_bit (STOP_TX , &port->flags);fwtty_restart_tx (port);
Re: [PATCH 3/3] staging: fwserial: (coding style) Rewriting a call to a long function
Hello Peter,
Thanks a lot for your review and kind advice !
Quoted 1 line
I don't see a > 80-col line here?
In fact, it was not even a 80-col issue but a mis-aligned parenthesis one. Realign the rows in this state would make them exceed the 80th column.
I tend to agree with the fact that the way it currently is remains the best one.
Quoted 3 lines
And even if I did, this change would be super-ugly. The preferred way to reduce this is to fold it into a helper function
Actually, before I resend my patches, I have two or three small questions:
1) My v1 patches already made it to staging and linux-next trees. Should I resend them anyway ?
2) Would it be helpful to people if I write a function the way you specified it or would it be better to let it as is ?
3) If we don't, and then discard the last patch, shall I number « n/2 » or « n/3 » anyway ?
Forgive me if these questions are lame, I still have only a few experience of the kernel tree. Documentation/SubmittingPatches states that no one should be expected to refer to a previous set of patches, so I suppose this would be « 1/2 » and « 2/2 » but I prefer being OK about this from the beginning.
Thanks for caring.
Re: [PATCH 3/3] staging: fwserial: (coding style) Rewriting a call to a long function
Quoted 8 lines · Dominique van den Broeck
Hello Peter,
Thanks a lot for your review and kind advice !Quoted 1 line
I don't see a > 80-col line here?
In fact, it was not even a 80-col issue but a mis-aligned parenthesis one. Realign the rows in this state would make them exceed the 80th column.
Ah, ok. Wasn't clear from the commit message.
Quoted 2 lines
I tend to agree with the fact that the way it currently is remains the best one.
Ok.
Quoted 9 lines
Quoted 3 lines
And even if I did, this change would be super-ugly. The preferred way to reduce this is to fold it into a helper function
Actually, before I resend my patches, I have two or three small questions:
1) My v1 patches already made it to staging and linux-next trees. Should I resend them anyway ?
No, I didn't know they were already in staging-next. Nevermind then :)
Quoted 2 lines
2) Would it be helpful to people if I write a function the way you specified it or would it be better to let it as is ?
As is, please.
Quoted 2 lines
3) If we don't, and then discard the last patch, shall I number « n/2 » or « n/3 » anyway ?
n/a now.
Quoted 2 lines
Forgive me if these questions are lame, I still have only a few experience of the kernel tree.
Your questions are not lame; no need to apologize.
Quoted 4 lines
Documentation/SubmittingPatchesstates
that no one should be expected to refer to a previous set of patches, so I suppose this would be « 1/2 » and « 2/2 » but I prefer being OK about this from the beginning.
If you would have sent the patches, yes, they would have been 1/2 and 2/2. What I do there is send the v2 series in-reply-to the original 1/2 patch.
Quoted 1 line
Thanks for caring.
Regards,
Peter Hurley
Quoted 7 lines · Dominique van den Broeck
Coding-style-only modifications to remove every warning saying:
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'Compiled against revision "next-20160327".
(checkpatch.pl was updated to treat "
UNSPECIFIED_INT" warnings
as of commita1ce18e4f941d20)
Please change $subject to "staging: fwserial: Convert unsigned to unsigned int" With that,
PS - For v2 of this patch, be sure to change the subject prefix to [PATCH v2 ...], and note any changes in the diffstat area of the patch itself; eg.,
---
v2: change subject per Peter Hurley's comments
drivers/staging/fwserial/dma_fifo.c | 8 +++---- drivers/staging/fwserial/dma_fifo.h | 16 +++++++------- drivers/staging/fwserial/fwserial.c | 38 +++++++++++++++++---------------- drivers/staging/fwserial/fwserial.h | 42 ++++++++++++++++++------------------- 4 files changed, 53 insertions(+), 51 deletions(-)