staging: speakup: Multiple CheckPatch issues.
cover staging: speakup: Multiple CheckPatch issues.
Improve readability by fixing multiple checkpatch.pl issues in speakup driver.
Arushi Singhal (7):
staging: speakup: Moved logical to previous line.
staging: speakup: Remove multiple assignments
staging: speakup: Simplify "NULL" comparisons
staging: speakup: fixes braces {} should be used on all arms of this
statement
staging: speakup: Remove multiple assignments
staging: speakup: Moved OR operator to previous line.
staging: speakup: spaces preferred around operator
drivers/staging/speakup/main.c | 76 +++++++++++++++++++------------- drivers/staging/speakup/selection.c | 2 +- drivers/staging/speakup/speakup.h | 12 ++--- drivers/staging/speakup/speakup_acntpc.c | 2 +- drivers/staging/speakup/speakup_decext.c | 6 +-- drivers/staging/speakup/speakup_decpc.c | 26 +++++------ drivers/staging/speakup/speakup_dectlk.c | 6 +-- drivers/staging/speakup/speakup_dtlk.c | 2 +- drivers/staging/speakup/speakup_keypc.c | 6 +-- drivers/staging/speakup/speakup_ltlk.c | 2 +- drivers/staging/speakup/varhandlers.c | 18 ++++---- 11 files changed, 87 insertions(+), 71 deletions(-)
Signature · 1 line
2.11.0
PATCH 1/7 staging: speakup: Moved logical to previous line.
Moved logical AND operators to previous line to fix the following checkpatch issue:
CHECK: Logical continuations should be on the previous line.
--- drivers/staging/speakup/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/speakup/main.c +6 -6
@@ -905,8 +905,8 @@ static int get_sentence_buf(struct vc_data *vc, int read_punc)while (start < end) { sentbuf[bn][i] =get_char (vc, (u_short *)start, &tmp);if (i >0 ) { -if (sentbuf[bn][i] ==SPACE && sentbuf[bn][i -1 ] =='.' - && numsentences[bn] <9 ) { +if (sentbuf[bn][i] ==SPACE && sentbuf[bn][i -1 ] =='.' && + numsentences[bn] <9 ) {/* Sentence Marker */ numsentences[bn]++; sentmarks[bn][numsentences[bn]] =
@@ -1292,8 +1292,8 @@ void spk_reset_default_chars(void)/* First, free any non-default */ for (i =0 ; i <256 ; i++) { -if ((spk_characters[i] !=NULL ) - && (spk_characters[i] != spk_default_chars[i])) +if (spk_characters[i] && + (spk_characters[i] != spk_default_chars[i]))kfree (spk_characters[i]); }
@@ -2088,8 +2088,8 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym, tty = vc->port.tty;if (type >=0xf0 ) type -=0xf0 ; -if (type ==KT_PAD - && (vt_get_leds (fg_console,VC_NUMLOCK ))) { +if (type ==KT_PAD && + (vt_get_leds (fg_console,VC_NUMLOCK ))) {if (up_flag) { spk_keydown =0 ; goto out;
Signature · 1 line
2.11.0
PATCH 2/7 staging: speakup: Remove multiple assignments
In reply to Arushi SinghalThis patch fixes the checkpatch.pl warning "multiple assignments should be avoided."
--- drivers/staging/speakup/main.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/staging/speakup/main.c +12 -6
@@ -270,9 +270,12 @@ static unsigned char get_attributes(struct vc_data *vc, u16 *pos)static void speakup_date (struct vc_data *vc) { - spk_x = spk_cx = vc->vc_x; - spk_y = spk_cy = vc->vc_y; - spk_pos = spk_cp = vc->vc_pos; + spk_x = vc->vc_x; + spk_cx = spk_x; + spk_y = vc->vc_y; + spk_cy = spk_y; + spk_pos = vc->vc_pos; + spk_cp = spk_pos; spk_old_attr = spk_attr; spk_attr =get_attributes (vc, (u_short *)spk_pos); }
@@ -1655,9 +1658,12 @@ static int speak_highlight(struct vc_data *vc)spk_do_flush ();spkup_write (speakup_console[vc_num]->ht.highbuf[hc], speakup_console[vc_num]->ht.highsize[hc]); - spk_pos = spk_cp = speakup_console[vc_num]->ht.rpos[hc]; - spk_x = spk_cx = speakup_console[vc_num]->ht.rx[hc]; - spk_y = spk_cy = speakup_console[vc_num]->ht.ry[hc]; + spk_pos = speakup_console[vc_num]->ht.rpos[hc]; + spk_cp = spk_pos; + spk_x = speakup_console[vc_num]->ht.rx[hc]; + spk_cx = spk_x; + spk_y = speakup_console[vc_num]->ht.ry[hc]; + spk_cy = spk_y;return 1 ; }return 0 ;
Signature · 1 line
2.11.0
PATCH 3/7 staging: speakup: Simplify "NULL" comparisons
In reply to Arushi SinghalFixed coding style for null comparisons in speakup driver to be more consistant with the rest of the kernel coding style. Replaced 'x != NULL' with 'x' and 'x = NULL' with '!x'.
--- drivers/staging/speakup/selection.c | 2 +- drivers/staging/speakup/varhandlers.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/speakup/selection.c +1 -1
@@ -175,7 +175,7 @@ static struct speakup_paste_work speakup_paste_work = {int speakup_paste_selection (struct tty_struct *tty) { -if (cmpxchg (&speakup_paste_work.tty,NULL , tty) !=NULL ) +if (cmpxchg (&speakup_paste_work.tty,NULL , tty))return -EBUSY ;tty_kref_get (tty);
drivers/staging/speakup/varhandlers.c +3 -3
@@ -98,7 +98,7 @@ void speakup_register_var(struct var_t *var) } } p_header = var_ptrs[var->var_id]; -if (p_header->data !=NULL ) +if (p_header->data)return ; p_header->data = var;switch (p_header->var_type) {
@@ -210,11 +210,11 @@ int spk_set_num_var(int input, struct st_var_header *var, int how)return -ERANGE ; var_data->u.n.value = val; -if (var->var_type ==VAR_TIME && p_val !=NULL ) { +if (var->var_type ==VAR_TIME && p_val) { *p_val =msecs_to_jiffies (val);return 0 ; } -if (p_val !=NULL ) +if (p_val) *p_val = val;if (var->var_id ==PUNC_LEVEL ) { spk_punc_mask = spk_punc_masks[val];
Signature · 1 line
2.11.0
PATCH 4/7 staging: speakup: fixes braces {} should be used on all arms of this statement
In reply to Arushi SinghalThis patch fixes the checks reported by checkpatch.pl for braces {} should be used on all arms of this statement.
--- drivers/staging/speakup/main.c | 35 +++++++++++++++++++------------- drivers/staging/speakup/speakup_decext.c | 6 +++--- drivers/staging/speakup/speakup_decpc.c | 6 +++--- drivers/staging/speakup/speakup_dectlk.c | 6 +++--- drivers/staging/speakup/varhandlers.c | 12 ++++++----- 5 files changed, 37 insertions(+), 28 deletions(-)
drivers/staging/speakup/main.c +21 -14
@@ -409,8 +409,9 @@ static void say_attributes(struct vc_data *vc)if (bg >7 ) {synth_printf (" %s " ,spk_msg_get (MSG_ON_BLINKING )); bg -=8 ; - }else + }else {synth_printf (" %s " ,spk_msg_get (MSG_ON )); + }synth_printf ("%s\n" ,spk_msg_get (MSG_COLORS_START + bg)); }
@@ -643,8 +644,9 @@ static void say_prev_word(struct vc_data *vc)break ; spk_y--; spk_x = vc->vc_cols -1 ; - }else + }else { spk_x--; + } spk_pos -=2 ; ch =get_char (vc, (u_short *)spk_pos, &temp);if (ch ==SPACE || ch ==0 )
@@ -697,8 +699,9 @@ static void say_next_word(struct vc_data *vc) spk_y++; spk_x =0 ; edge_said = edge_right; - }else + }else { spk_x++; + } spk_pos +=2 ; last_state = state; }
@@ -729,8 +732,9 @@ static void spell_word(struct vc_data *vc) spk_pitch_shift++; else /* synth has no pitch */ last_cap = spk_str_caps_stop; - }else + }else { str_cap = spk_str_caps_stop; + }if (str_cap != last_cap) {synth_printf ("%s" , str_cap); last_cap = str_cap;
@@ -1343,8 +1347,9 @@ static int speakup_allocate(struct vc_data *vc)if (!speakup_console[vc_num])return -ENOMEM ;speakup_date (vc); - }else if (!spk_parked) + }else if (!spk_parked) {speakup_date (vc); + }return 0 ; }
@@ -1397,9 +1402,9 @@ static void read_all_doc(struct vc_data *vc) prev_cursor_track = cursor_track; cursor_track = read_all_mode;spk_reset_index_count (0 ); -if (get_sentence_buf (vc,0 ) ==-1 ) +if (get_sentence_buf (vc,0 ) ==-1 ) {kbd_fakekey2 (vc,RA_DOWN_ARROW ); -else { + }else {say_sentence_num (0 ,0 );synth_insert_next_index (0 );start_read_all_timer (vc,RA_TIMER );
@@ -1446,8 +1451,9 @@ static void handle_cursor_read_all(struct vc_data *vc, int command)if (!say_sentence_num (sentcount +1 ,1 )) { sn =1 ;spk_reset_index_count (sn); - }else + }else {synth_insert_next_index (0 ); + }if (!say_sentence_num (sn,0 )) {kbd_fakekey2 (vc,RA_FIND_NEXT_SENT );return ;
@@ -1476,9 +1482,9 @@ static void handle_cursor_read_all(struct vc_data *vc, int command) rv =get_sentence_buf (vc,0 );if (rv ==-1 )read_all_doc (vc); -if (rv ==0 ) +if (rv ==0 ) {kbd_fakekey2 (vc,RA_FIND_NEXT_SENT ); -else { + }else {say_sentence_num (1 ,0 );synth_insert_next_index (0 );start_read_all_timer (vc,RA_TIMER );
@@ -2177,10 +2183,11 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym,if (type ==KT_SPEC && value ==1 ) { value ='\n' ; type =KT_LATIN ; - }else if (type ==KT_LETTER ) + }else if (type ==KT_LETTER ) { type =KT_LATIN ; -else if (value ==0x7f ) + }else if (value ==0x7f ) { value =8 ;/* make del = backspace */ + } ret = (*spk_special_handler) (vc, type, value, keycode); spk_close_press =0 ;if (ret <0 )
@@ -2274,9 +2281,9 @@ static int vt_notifier_call(struct notifier_block *nb,speakup_deallocate (vc);break ;case VT_WRITE : -if (param->c =='\b' ) +if (param->c =='\b' ) {speakup_bs (vc); -else { + }else {u16 d = param->c;speakup_con_write (vc, &d,1 ); }
drivers/staging/speakup/speakup_decext.c +3 -3
@@ -195,11 +195,11 @@ static void do_catch_up(struct spk_synth *synth)spin_lock_irqsave (&speakup_info.spinlock, flags);synth_buffer_getc ();spin_unlock_irqrestore (&speakup_info.spinlock, flags); -if (ch =='[' ) +if (ch =='[' ) { in_escape =1 ; -else if (ch ==']' ) + }else if (ch ==']' ) { in_escape =0 ; -else if (ch <=SPACE ) { + }else if (ch <=SPACE ) {if (!in_escape &&strchr (",.!?;:" , last)) synth->io_ops->synth_out (synth,PROCSPEECH );if (time_after_eq (jiffies, jiff_max)) {
drivers/staging/speakup/speakup_decpc.c +3 -3
@@ -410,11 +410,11 @@ static void do_catch_up(struct spk_synth *synth)spin_lock_irqsave (&speakup_info.spinlock, flags);synth_buffer_getc ();spin_unlock_irqrestore (&speakup_info.spinlock, flags); -if (ch =='[' ) +if (ch =='[' ) { in_escape =1 ; -else if (ch ==']' ) + }else if (ch ==']' ) { in_escape =0 ; -else if (ch <=SPACE ) { + }else if (ch <=SPACE ) {if (!in_escape &&strchr (",.!?;:" , last))dt_sendchar (PROCSPEECH );if (time_after_eq (jiffies, jiff_max)) {
drivers/staging/speakup/speakup_dectlk.c +3 -3
@@ -260,11 +260,11 @@ static void do_catch_up(struct spk_synth *synth)spin_lock_irqsave (&speakup_info.spinlock, flags);synth_buffer_getc ();spin_unlock_irqrestore (&speakup_info.spinlock, flags); -if (ch =='[' ) +if (ch =='[' ) { in_escape =1 ; -else if (ch ==']' ) + }else if (ch ==']' ) { in_escape =0 ; -else if (ch <=SPACE ) { + }else if (ch <=SPACE ) {if (!in_escape &&strchr (",.!?;:" , last)) synth->io_ops->synth_out (synth,PROCSPEECH );if (time_after_eq (jiffies, jiff_max)) {
drivers/staging/speakup/varhandlers.c +7 -5
@@ -258,10 +258,11 @@ int spk_set_string_var(const char *page, struct st_var_header *var, int len)if (var->p_val != var_data->u.s.default_val)strcpy ((char *)var->p_val, var_data->u.s.default_val);return -ERESTART ; - }else if (var->p_val) + }else if (var->p_val) {strcpy ((char *)var->p_val, page); -else + }else {return -E2BIG ; + }return 0 ; }
@@ -281,17 +282,18 @@ int spk_set_mask_bits(const char *input, const int which, const int how) spk_chartab[*cp] &= ~mask; } cp = (u_char *)input; -if (!cp) +if (!cp) { cp = spk_punc_info[which].value; -else { + }else {for (; *cp; cp++) {if (*cp <SPACE )break ;if (mask <PUNC ) {if (!(spk_chartab[*cp] &PUNC ))break ; - }else if (spk_chartab[*cp] &B_NUM ) + }else if (spk_chartab[*cp] &B_NUM ) {break ; + } }if (*cp)return -EINVAL ;
Signature · 1 line
2.11.0
PATCH 5/7 staging: speakup: Remove multiple assignments
In reply to Arushi SinghalThis patch fixes the checkpatch.pl warning "multiple assignments should be avoided."
--- drivers/staging/speakup/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/speakup/main.c +2 -1
@@ -2106,7 +2106,8 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym, spk_keydown =0 ; goto out; } - value = spk_lastkey = pad_chars[value]; + value = pad_chars[value]; + spk_lastkey = value; spk_keydown++; spk_parked &=0xfe ; goto no_map;
Signature · 1 line
2.11.0
PATCH 6/7 staging: speakup: Moved OR operator to previous line.
In reply to Arushi SinghalMoved logical OR operator to previous line to fix the following checkpatch issue:
CHECK: Logical continuations should be on the previous line.
--- drivers/staging/speakup/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/speakup/main.c +4 -4
@@ -2173,10 +2173,10 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym,if (up_flag || spk_killed || type ==KT_SHIFT ) goto out; spk_shut_up &=0xfe ; - kh = (value ==KVAL (K_DOWN )) - || (value ==KVAL (K_UP )) - || (value ==KVAL (K_LEFT )) - || (value ==KVAL (K_RIGHT )); + kh = (value ==KVAL (K_DOWN )) || + (value ==KVAL (K_UP )) || + (value ==KVAL (K_LEFT )) || + (value ==KVAL (K_RIGHT ));if ((cursor_track != read_all_mode) || !kh)if (!spk_no_intr)spk_do_flush ();
Signature · 1 line
2.11.0
PATCH 7/7 staging: speakup: spaces preferred around operator
In reply to Arushi SinghalFixed the checkpatch.pl issues like:
CHECK: spaces preferred around that '&' (ctx:VxV)
CHECK: spaces preferred around that '|' (ctx:VxV)
CHECK: spaces preferred around that '-' (ctx:VxV)
CHECK: spaces preferred around that '+' (ctx:VxV) etc.
--- drivers/staging/speakup/speakup.h | 12 ++++++------ drivers/staging/speakup/speakup_acntpc.c | 2 +- drivers/staging/speakup/speakup_decpc.c | 20 ++++++++++---------- drivers/staging/speakup/speakup_dtlk.c | 2 +- drivers/staging/speakup/speakup_keypc.c | 6 +++--- drivers/staging/speakup/speakup_ltlk.c | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-)
drivers/staging/speakup/speakup.h +6 -6
@@ -20,7 +20,7 @@#define A_CAP 0x0007#define B_NUM 0x0008#define NUM 0x0009 -#define ALPHANUM (B_ALPHA|B_NUM) +#define ALPHANUM (B_ALPHA | B_NUM)#define SOME 0x0010#define MOST 0x0020#define PUNC 0x0040
@@ -30,14 +30,14 @@#define B_EXNUM 0x0100#define CH_RPT 0x0200#define B_CTL 0x0400 -#define A_CTL (B_CTL+SYNTH_OK) +#define A_CTL (B_CTL + SYNTH_OK)#define B_SYM 0x0800 -#define B_CAPSYM (B_CAP|B_SYM) +#define B_CAPSYM (B_CAP | B_SYM)/* FIXME: u16 */ -#define IS_WDLM (x) (spk_chartab[((u_char)x)]&B_WDLM) -#define IS_CHAR (x, type) (spk_chartab[((u_char)x)]&type) -#define IS_TYPE (x, type) ((spk_chartab[((u_char)x)]&type) == type) +#define IS_WDLM (x) (spk_chartab[((u_char)x)] & B_WDLM) +#define IS_CHAR (x, type) (spk_chartab[((u_char)x)] & type) +#define IS_TYPE (x, type) ((spk_chartab[((u_char)x)] & type) == type)int speakup_thread (void *data);void spk_reset_default_chars (void );
drivers/staging/speakup/speakup_acntpc.c +1 -1
@@ -282,7 +282,7 @@ static int synth_probe(struct spk_synth *synth)if (port_val ==0x53fc ) {/* 'S' and out&input bits */ synth_port_control = synth_portlist[i]; - speakup_info.port_tts = synth_port_control+1 ; + speakup_info.port_tts = synth_port_control +1 ;break ; } }
drivers/staging/speakup/speakup_decpc.c +10 -10
@@ -250,7 +250,7 @@ static int dt_getstatus(void)static void dt_sendcmd (u_int cmd) {outb_p (cmd &0xFF , speakup_info.port_tts); -outb_p ((cmd >>8 ) &0xFF , speakup_info.port_tts+1 ); +outb_p ((cmd >>8 ) &0xFF , speakup_info.port_tts +1 ); }static int dt_waitbit (int bit)
@@ -286,11 +286,11 @@ static int dt_ctrl(u_int cmd)if (!dt_waitbit (STAT_cmd_ready))return -1 ; -outb_p (0 , speakup_info.port_tts+2 ); -outb_p (0 , speakup_info.port_tts+3 ); +outb_p (0 , speakup_info.port_tts +2 ); +outb_p (0 , speakup_info.port_tts +3 );dt_getstatus (); -dt_sendcmd (CMD_control|cmd); -outb_p (0 , speakup_info.port_tts+6 ); +dt_sendcmd (CMD_control | cmd); +outb_p (0 , speakup_info.port_tts +6 );while (dt_getstatus () & STAT_cmd_ready) {udelay (20 );if (--timeout ==0 )
@@ -318,8 +318,8 @@ udelay(50);break ;udelay (50 ); } -outb_p (DMA_sync, speakup_info.port_tts+4 ); -outb_p (0 , speakup_info.port_tts+4 ); +outb_p (DMA_sync, speakup_info.port_tts +4 ); +outb_p (0 , speakup_info.port_tts +4 );udelay (100 );for (timeout =0 ; timeout <10 ; timeout++) {if (!(dt_getstatus () & STAT_flushing))
@@ -337,8 +337,8 @@ static int dt_sendchar(char ch)return -1 ;if (!(dt_stat & STAT_rr_char))return -2 ; -outb_p (DMA_single_in, speakup_info.port_tts+4 ); -outb_p (ch, speakup_info.port_tts+4 ); +outb_p (DMA_single_in, speakup_info.port_tts +4 ); +outb_p (ch, speakup_info.port_tts +4 ); dma_state ^= STAT_dma_state;return 0 ; }
@@ -354,7 +354,7 @@ static int testkernel(void)dt_sendcmd (CMD_sync);if (!dt_waitbit (STAT_cmd_ready)) status =-2 ; -else if (dt_stat&0x8000 ) +else if (dt_stat &0x8000 )return 0 ;else if (dt_stat ==0x0dec ) pr_warn("dec_pc at 0x%x, software not loaded\n",
drivers/staging/speakup/speakup_dtlk.c +1 -1
@@ -300,7 +300,7 @@ static struct synth_settings *synth_interrogate(struct spk_synth *synth) t +=2 ;for (i =0 ; *t !='\r' ; t++) { status.rom_version[i] = *t; -if (i <sizeof (status.rom_version)-1 ) +if (i <sizeof (status.rom_version) -1 ) i++; } status.rom_version[i] =0 ;
drivers/staging/speakup/speakup_keypc.c +3 -3
@@ -142,9 +142,9 @@ static char *oops(void)int s1, s2, s3, s4; s1 =inb_p (synth_port); - s2 =inb_p (synth_port+1 ); - s3 =inb_p (synth_port+2 ); - s4 =inb_p (synth_port+3 ); + s2 =inb_p (synth_port +1 ); + s3 =inb_p (synth_port +2 ); + s4 =inb_p (synth_port +3 );pr_warn ("synth timeout %d %d %d %d\n" , s1, s2, s3, s4);return NULL ; }
drivers/staging/speakup/speakup_ltlk.c +1 -1
@@ -145,7 +145,7 @@ static void synth_interrogate(struct spk_synth *synth)if (i >2 && buf[i] ==0x7f )break ; } - t = buf+2 ; + t = buf +2 ;for (i =0 ; *t !='\r' ; t++) { rom_v[i] = *t;if (++i >=19 )
Signature · 1 line
2.11.0