Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: HSO: minor fixes due to code review

Fix up problems in hso.c driver as pointed out by Andrew.

Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>

authored by

Greg Kroah-Hartman and committed by
Jeff Garzik
0235f641 6c59f569

+24 -19
+24 -19
drivers/net/usb/hso.c
··· 102 102 103 103 #define MAX_RX_URBS 2 104 104 105 - #define get_serial_by_tty(x) \ 106 - (x ? (struct hso_serial *)x->driver_data : NULL) 105 + static inline struct hso_serial *get_serial_by_tty(struct tty_struct *tty) 106 + { 107 + if (tty) 108 + return tty->driver_data; 109 + return NULL; 110 + } 107 111 108 112 /*****************************************************************************/ 109 113 /* Debugging functions */ ··· 298 294 299 295 /* #define DEBUG */ 300 296 301 - #define dev2net(x) (x->port_data.dev_net) 302 - #define dev2ser(x) (x->port_data.dev_serial) 297 + static inline struct hso_net *dev2net(struct hso_device *hso_dev) 298 + { 299 + return hso_dev->port_data.dev_net; 300 + } 301 + 302 + static inline struct hso_serial *dev2ser(struct hso_device *hso_dev) 303 + { 304 + return hso_dev->port_data.dev_serial; 305 + } 303 306 304 307 /* Debugging functions */ 305 308 #ifdef DEBUG 306 309 static void dbg_dump(int line_count, const char *func_name, unsigned char *buf, 307 310 unsigned int len) 308 311 { 309 - u8 i = 0; 312 + static char name[255]; 310 313 311 - printk(KERN_DEBUG "[%d:%s]: len %d", line_count, func_name, len); 312 - 313 - for (i = 0; i < len; i++) { 314 - if (!(i % 16)) 315 - printk("\n 0x%03x: ", i); 316 - printk("%02x ", (unsigned char)buf[i]); 317 - } 318 - printk("\n"); 314 + sprintf(name, "hso[%d:%s]", line_count, func_name); 315 + print_hex_dump_bytes(name, DUMP_PREFIX_NONE, buf, len); 319 316 } 320 317 321 318 #define DUMP(buf_, len_) \ ··· 533 528 534 529 static struct hso_serial *get_serial_by_index(unsigned index) 535 530 { 536 - struct hso_serial *serial; 531 + struct hso_serial *serial = NULL; 537 532 unsigned long flags; 538 533 539 - if (!serial_table[index]) 540 - return NULL; 541 534 spin_lock_irqsave(&serial_table_lock, flags); 542 - serial = dev2ser(serial_table[index]); 535 + if (serial_table[index]) 536 + serial = dev2ser(serial_table[index]); 543 537 spin_unlock_irqrestore(&serial_table_lock, flags); 544 538 545 539 return serial; ··· 565 561 static void set_serial_by_index(unsigned index, struct hso_serial *serial) 566 562 { 567 563 unsigned long flags; 564 + 568 565 spin_lock_irqsave(&serial_table_lock, flags); 569 566 if (serial) 570 567 serial_table[index] = serial->parent; ··· 574 569 spin_unlock_irqrestore(&serial_table_lock, flags); 575 570 } 576 571 577 - /* log a meaningfull explanation of an USB status */ 572 + /* log a meaningful explanation of an USB status */ 578 573 static void log_usb_status(int status, const char *function) 579 574 { 580 575 char *explanation; ··· 2659 2654 hso_stop_net_device(network_table[i]); 2660 2655 cancel_work_sync(&network_table[i]->async_put_intf); 2661 2656 cancel_work_sync(&network_table[i]->async_get_intf); 2662 - if(rfk) 2657 + if (rfk) 2663 2658 rfkill_unregister(rfk); 2664 2659 hso_free_net_device(network_table[i]); 2665 2660 }