Commit 0da4d283 authored by David S. Miller's avatar David S. Miller

Merge branch 'hso-neatening'

Joe Perches says:

====================
hso: neatening

This seems to be the only code in the kernel that uses
macro defines with a trailing underscore.  Fix that.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 13722bbe 3981cce6
...@@ -50,6 +50,8 @@ ...@@ -50,6 +50,8 @@
* *
*****************************************************************************/ *****************************************************************************/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -108,23 +110,12 @@ ...@@ -108,23 +110,12 @@
/*****************************************************************************/ /*****************************************************************************/
/* Debugging functions */ /* Debugging functions */
/*****************************************************************************/ /*****************************************************************************/
#define D__(lvl_, fmt, arg...) \ #define hso_dbg(lvl, fmt, ...) \
do { \ do { \
printk(lvl_ "[%d:%s]: " fmt "\n", \ if ((lvl) & debug) \
__LINE__, __func__, ## arg); \ pr_info("[%d:%s] " fmt, \
} while (0) __LINE__, __func__, ##__VA_ARGS__); \
} while (0)
#define D_(lvl, args...) \
do { \
if (lvl & debug) \
D__(KERN_INFO, args); \
} while (0)
#define D1(args...) D_(0x01, ##args)
#define D2(args...) D_(0x02, ##args)
#define D3(args...) D_(0x04, ##args)
#define D4(args...) D_(0x08, ##args)
#define D5(args...) D_(0x10, ##args)
/*****************************************************************************/ /*****************************************************************************/
/* Enumerators */ /* Enumerators */
...@@ -649,7 +640,7 @@ static int get_free_serial_index(void) ...@@ -649,7 +640,7 @@ static int get_free_serial_index(void)
} }
spin_unlock_irqrestore(&serial_table_lock, flags); spin_unlock_irqrestore(&serial_table_lock, flags);
printk(KERN_ERR "%s: no free serial devices in table\n", __func__); pr_err("%s: no free serial devices in table\n", __func__);
return -1; return -1;
} }
...@@ -709,7 +700,8 @@ static void handle_usb_error(int status, const char *function, ...@@ -709,7 +700,8 @@ static void handle_usb_error(int status, const char *function,
} }
/* log a meaningful explanation of an USB status */ /* log a meaningful explanation of an USB status */
D1("%s: received USB status - %s (%d)", function, explanation, status); hso_dbg(0x1, "%s: received USB status - %s (%d)\n",
function, explanation, status);
} }
/* Network interface functions */ /* Network interface functions */
...@@ -808,7 +800,7 @@ static netdev_tx_t hso_net_start_xmit(struct sk_buff *skb, ...@@ -808,7 +800,7 @@ static netdev_tx_t hso_net_start_xmit(struct sk_buff *skb,
DUMP1(skb->data, skb->len); DUMP1(skb->data, skb->len);
/* Copy it from kernel memory to OUR memory */ /* Copy it from kernel memory to OUR memory */
memcpy(odev->mux_bulk_tx_buf, skb->data, skb->len); memcpy(odev->mux_bulk_tx_buf, skb->data, skb->len);
D1("len: %d/%d", skb->len, MUX_BULK_TX_BUF_SIZE); hso_dbg(0x1, "len: %d/%d\n", skb->len, MUX_BULK_TX_BUF_SIZE);
/* Fill in the URB for shipping it out. */ /* Fill in the URB for shipping it out. */
usb_fill_bulk_urb(odev->mux_bulk_tx_urb, usb_fill_bulk_urb(odev->mux_bulk_tx_urb,
...@@ -872,7 +864,7 @@ static void packetizeRx(struct hso_net *odev, unsigned char *ip_pkt, ...@@ -872,7 +864,7 @@ static void packetizeRx(struct hso_net *odev, unsigned char *ip_pkt,
unsigned char *tmp_rx_buf; unsigned char *tmp_rx_buf;
/* log if needed */ /* log if needed */
D1("Rx %d bytes", count); hso_dbg(0x1, "Rx %d bytes\n", count);
DUMP(ip_pkt, min(128, (int)count)); DUMP(ip_pkt, min(128, (int)count));
while (count) { while (count) {
...@@ -912,7 +904,7 @@ static void packetizeRx(struct hso_net *odev, unsigned char *ip_pkt, ...@@ -912,7 +904,7 @@ static void packetizeRx(struct hso_net *odev, unsigned char *ip_pkt,
frame_len); frame_len);
if (!odev->skb_rx_buf) { if (!odev->skb_rx_buf) {
/* We got no receive buffer. */ /* We got no receive buffer. */
D1("could not allocate memory"); hso_dbg(0x1, "could not allocate memory\n");
odev->rx_parse_state = WAIT_SYNC; odev->rx_parse_state = WAIT_SYNC;
continue; continue;
} }
...@@ -972,11 +964,11 @@ static void packetizeRx(struct hso_net *odev, unsigned char *ip_pkt, ...@@ -972,11 +964,11 @@ static void packetizeRx(struct hso_net *odev, unsigned char *ip_pkt,
break; break;
case WAIT_SYNC: case WAIT_SYNC:
D1(" W_S"); hso_dbg(0x1, " W_S\n");
count = 0; count = 0;
break; break;
default: default:
D1(" "); hso_dbg(0x1, "\n");
count--; count--;
break; break;
} }
...@@ -1020,7 +1012,7 @@ static void read_bulk_callback(struct urb *urb) ...@@ -1020,7 +1012,7 @@ static void read_bulk_callback(struct urb *urb)
/* Sanity check */ /* Sanity check */
if (!odev || !test_bit(HSO_NET_RUNNING, &odev->flags)) { if (!odev || !test_bit(HSO_NET_RUNNING, &odev->flags)) {
D1("BULK IN callback but driver is not active!"); hso_dbg(0x1, "BULK IN callback but driver is not active!\n");
return; return;
} }
usb_mark_last_busy(urb->dev); usb_mark_last_busy(urb->dev);
...@@ -1112,11 +1104,11 @@ static void _hso_serial_set_termios(struct tty_struct *tty, ...@@ -1112,11 +1104,11 @@ static void _hso_serial_set_termios(struct tty_struct *tty,
struct hso_serial *serial = tty->driver_data; struct hso_serial *serial = tty->driver_data;
if (!serial) { if (!serial) {
printk(KERN_ERR "%s: no tty structures", __func__); pr_err("%s: no tty structures", __func__);
return; return;
} }
D4("port %d", serial->minor); hso_dbg(0x8, "port %d\n", serial->minor);
/* /*
* Fix up unsupported bits * Fix up unsupported bits
...@@ -1205,11 +1197,11 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb) ...@@ -1205,11 +1197,11 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
struct hso_serial *serial = urb->context; struct hso_serial *serial = urb->context;
int status = urb->status; int status = urb->status;
D4("\n--- Got serial_read_bulk callback %02x ---", status); hso_dbg(0x8, "--- Got serial_read_bulk callback %02x ---\n", status);
/* sanity check */ /* sanity check */
if (!serial) { if (!serial) {
D1("serial == NULL"); hso_dbg(0x1, "serial == NULL\n");
return; return;
} }
if (status) { if (status) {
...@@ -1217,7 +1209,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb) ...@@ -1217,7 +1209,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
return; return;
} }
D1("Actual length = %d\n", urb->actual_length); hso_dbg(0x1, "Actual length = %d\n", urb->actual_length);
DUMP1(urb->transfer_buffer, urb->actual_length); DUMP1(urb->transfer_buffer, urb->actual_length);
/* Anyone listening? */ /* Anyone listening? */
...@@ -1266,7 +1258,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp) ...@@ -1266,7 +1258,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
if (serial == NULL || serial->magic != HSO_SERIAL_MAGIC) { if (serial == NULL || serial->magic != HSO_SERIAL_MAGIC) {
WARN_ON(1); WARN_ON(1);
tty->driver_data = NULL; tty->driver_data = NULL;
D1("Failed to open port"); hso_dbg(0x1, "Failed to open port\n");
return -ENODEV; return -ENODEV;
} }
...@@ -1275,7 +1267,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp) ...@@ -1275,7 +1267,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
if (result < 0) if (result < 0)
goto err_out; goto err_out;
D1("Opening %d", serial->minor); hso_dbg(0x1, "Opening %d\n", serial->minor);
/* setup */ /* setup */
tty->driver_data = serial; tty->driver_data = serial;
...@@ -1298,7 +1290,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp) ...@@ -1298,7 +1290,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
kref_get(&serial->parent->ref); kref_get(&serial->parent->ref);
} }
} else { } else {
D1("Port was already open"); hso_dbg(0x1, "Port was already open\n");
} }
usb_autopm_put_interface(serial->parent->interface); usb_autopm_put_interface(serial->parent->interface);
...@@ -1317,7 +1309,7 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp) ...@@ -1317,7 +1309,7 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
struct hso_serial *serial = tty->driver_data; struct hso_serial *serial = tty->driver_data;
u8 usb_gone; u8 usb_gone;
D1("Closing serial port"); hso_dbg(0x1, "Closing serial port\n");
/* Open failed, no close cleanup required */ /* Open failed, no close cleanup required */
if (serial == NULL) if (serial == NULL)
...@@ -1357,7 +1349,7 @@ static int hso_serial_write(struct tty_struct *tty, const unsigned char *buf, ...@@ -1357,7 +1349,7 @@ static int hso_serial_write(struct tty_struct *tty, const unsigned char *buf,
/* sanity check */ /* sanity check */
if (serial == NULL) { if (serial == NULL) {
printk(KERN_ERR "%s: serial is NULL\n", __func__); pr_err("%s: serial is NULL\n", __func__);
return -ENODEV; return -ENODEV;
} }
...@@ -1412,7 +1404,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old) ...@@ -1412,7 +1404,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
unsigned long flags; unsigned long flags;
if (old) if (old)
D5("Termios called with: cflags new[%d] - old[%d]", hso_dbg(0x16, "Termios called with: cflags new[%d] - old[%d]\n",
tty->termios.c_cflag, old->c_cflag); tty->termios.c_cflag, old->c_cflag);
/* the actual setup */ /* the actual setup */
...@@ -1649,7 +1641,7 @@ static int hso_serial_tiocmget(struct tty_struct *tty) ...@@ -1649,7 +1641,7 @@ static int hso_serial_tiocmget(struct tty_struct *tty)
/* sanity check */ /* sanity check */
if (!serial) { if (!serial) {
D1("no tty structures"); hso_dbg(0x1, "no tty structures\n");
return -EINVAL; return -EINVAL;
} }
spin_lock_irq(&serial->serial_lock); spin_lock_irq(&serial->serial_lock);
...@@ -1682,7 +1674,7 @@ static int hso_serial_tiocmset(struct tty_struct *tty, ...@@ -1682,7 +1674,7 @@ static int hso_serial_tiocmset(struct tty_struct *tty,
/* sanity check */ /* sanity check */
if (!serial) { if (!serial) {
D1("no tty structures"); hso_dbg(0x1, "no tty structures\n");
return -EINVAL; return -EINVAL;
} }
...@@ -1721,7 +1713,7 @@ static int hso_serial_ioctl(struct tty_struct *tty, ...@@ -1721,7 +1713,7 @@ static int hso_serial_ioctl(struct tty_struct *tty,
{ {
struct hso_serial *serial = tty->driver_data; struct hso_serial *serial = tty->driver_data;
int ret = 0; int ret = 0;
D4("IOCTL cmd: %d, arg: %ld", cmd, arg); hso_dbg(0x8, "IOCTL cmd: %d, arg: %ld\n", cmd, arg);
if (!serial) if (!serial)
return -ENODEV; return -ENODEV;
...@@ -1783,7 +1775,7 @@ static int mux_device_request(struct hso_serial *serial, u8 type, u16 port, ...@@ -1783,7 +1775,7 @@ static int mux_device_request(struct hso_serial *serial, u8 type, u16 port,
/* Sanity check */ /* Sanity check */
if (!serial || !ctrl_urb || !ctrl_req) { if (!serial || !ctrl_urb || !ctrl_req) {
printk(KERN_ERR "%s: Wrong arguments\n", __func__); pr_err("%s: Wrong arguments\n", __func__);
return -EINVAL; return -EINVAL;
} }
...@@ -1808,7 +1800,7 @@ static int mux_device_request(struct hso_serial *serial, u8 type, u16 port, ...@@ -1808,7 +1800,7 @@ static int mux_device_request(struct hso_serial *serial, u8 type, u16 port,
pipe = usb_sndctrlpipe(serial->parent->usb, 0); pipe = usb_sndctrlpipe(serial->parent->usb, 0);
} }
/* syslog */ /* syslog */
D2("%s command (%02x) len: %d, port: %d", hso_dbg(0x2, "%s command (%02x) len: %d, port: %d\n",
type == USB_CDC_GET_ENCAPSULATED_RESPONSE ? "Read" : "Write", type == USB_CDC_GET_ENCAPSULATED_RESPONSE ? "Read" : "Write",
ctrl_req->bRequestType, ctrl_req->wLength, port); ctrl_req->bRequestType, ctrl_req->wLength, port);
...@@ -1876,11 +1868,11 @@ static void intr_callback(struct urb *urb) ...@@ -1876,11 +1868,11 @@ static void intr_callback(struct urb *urb)
handle_usb_error(status, __func__, NULL); handle_usb_error(status, __func__, NULL);
return; return;
} }
D4("\n--- Got intr callback 0x%02X ---", status); hso_dbg(0x8, "--- Got intr callback 0x%02X ---\n", status);
/* what request? */ /* what request? */
port_req = urb->transfer_buffer; port_req = urb->transfer_buffer;
D4(" port_req = 0x%.2X\n", *port_req); hso_dbg(0x8, "port_req = 0x%.2X\n", *port_req);
/* loop over all muxed ports to find the one sending this */ /* loop over all muxed ports to find the one sending this */
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
/* max 8 channels on MUX */ /* max 8 channels on MUX */
...@@ -1888,7 +1880,8 @@ static void intr_callback(struct urb *urb) ...@@ -1888,7 +1880,8 @@ static void intr_callback(struct urb *urb)
serial = get_serial_by_shared_int_and_type(shared_int, serial = get_serial_by_shared_int_and_type(shared_int,
(1 << i)); (1 << i));
if (serial != NULL) { if (serial != NULL) {
D1("Pending read interrupt on port %d\n", i); hso_dbg(0x1, "Pending read interrupt on port %d\n",
i);
spin_lock(&serial->serial_lock); spin_lock(&serial->serial_lock);
if (serial->rx_state == RX_IDLE && if (serial->rx_state == RX_IDLE &&
serial->port.count > 0) { serial->port.count > 0) {
...@@ -1900,8 +1893,8 @@ static void intr_callback(struct urb *urb) ...@@ -1900,8 +1893,8 @@ static void intr_callback(struct urb *urb)
} else } else
serial->rx_state = RX_PENDING; serial->rx_state = RX_PENDING;
} else { } else {
D1("Already a read pending on " hso_dbg(0x1, "Already a read pending on port %d or port not open\n",
"port %d or port not open\n", i); i);
} }
spin_unlock(&serial->serial_lock); spin_unlock(&serial->serial_lock);
} }
...@@ -1933,7 +1926,7 @@ static void hso_std_serial_write_bulk_callback(struct urb *urb) ...@@ -1933,7 +1926,7 @@ static void hso_std_serial_write_bulk_callback(struct urb *urb)
/* sanity check */ /* sanity check */
if (!serial) { if (!serial) {
D1("serial == NULL"); hso_dbg(0x1, "serial == NULL\n");
return; return;
} }
...@@ -1948,7 +1941,7 @@ static void hso_std_serial_write_bulk_callback(struct urb *urb) ...@@ -1948,7 +1941,7 @@ static void hso_std_serial_write_bulk_callback(struct urb *urb)
tty_port_tty_wakeup(&serial->port); tty_port_tty_wakeup(&serial->port);
hso_kick_transmit(serial); hso_kick_transmit(serial);
D1(" "); hso_dbg(0x1, "\n");
} }
/* called for writing diag or CS serial port */ /* called for writing diag or CS serial port */
...@@ -1996,8 +1989,8 @@ static void ctrl_callback(struct urb *urb) ...@@ -1996,8 +1989,8 @@ static void ctrl_callback(struct urb *urb)
/* what request? */ /* what request? */
req = (struct usb_ctrlrequest *)(urb->setup_packet); req = (struct usb_ctrlrequest *)(urb->setup_packet);
D4("\n--- Got muxed ctrl callback 0x%02X ---", status); hso_dbg(0x8, "--- Got muxed ctrl callback 0x%02X ---\n", status);
D4("Actual length of urb = %d\n", urb->actual_length); hso_dbg(0x8, "Actual length of urb = %d\n", urb->actual_length);
DUMP1(urb->transfer_buffer, urb->actual_length); DUMP1(urb->transfer_buffer, urb->actual_length);
if (req->bRequestType == if (req->bRequestType ==
...@@ -2023,7 +2016,7 @@ static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial) ...@@ -2023,7 +2016,7 @@ static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial)
/* Sanity check */ /* Sanity check */
if (urb == NULL || serial == NULL) { if (urb == NULL || serial == NULL) {
D1("serial = NULL"); hso_dbg(0x1, "serial = NULL\n");
return -2; return -2;
} }
...@@ -2035,7 +2028,7 @@ static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial) ...@@ -2035,7 +2028,7 @@ static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial)
} }
/* Push data to tty */ /* Push data to tty */
D1("data to push to tty"); hso_dbg(0x1, "data to push to tty\n");
count = tty_buffer_request_room(&serial->port, urb->actual_length); count = tty_buffer_request_room(&serial->port, urb->actual_length);
if (count >= urb->actual_length) { if (count >= urb->actual_length) {
tty_insert_flip_string(&serial->port, urb->transfer_buffer, tty_insert_flip_string(&serial->port, urb->transfer_buffer,
...@@ -2415,7 +2408,7 @@ static void hso_net_init(struct net_device *net) ...@@ -2415,7 +2408,7 @@ static void hso_net_init(struct net_device *net)
{ {
struct hso_net *hso_net = netdev_priv(net); struct hso_net *hso_net = netdev_priv(net);
D1("sizeof hso_net is %d", (int)sizeof(*hso_net)); hso_dbg(0x1, "sizeof hso_net is %zu\n", sizeof(*hso_net));
/* fill in the other fields */ /* fill in the other fields */
net->netdev_ops = &hso_netdev_ops; net->netdev_ops = &hso_netdev_ops;
...@@ -3229,7 +3222,7 @@ static int __init hso_init(void) ...@@ -3229,7 +3222,7 @@ static int __init hso_init(void)
int result; int result;
/* put it in the log */ /* put it in the log */
printk(KERN_INFO "hso: %s\n", version); pr_info("%s\n", version);
/* Initialise the serial table semaphore and table */ /* Initialise the serial table semaphore and table */
spin_lock_init(&serial_table_lock); spin_lock_init(&serial_table_lock);
...@@ -3260,7 +3253,7 @@ static int __init hso_init(void) ...@@ -3260,7 +3253,7 @@ static int __init hso_init(void)
/* register the tty driver */ /* register the tty driver */
result = tty_register_driver(tty_drv); result = tty_register_driver(tty_drv);
if (result) { if (result) {
printk(KERN_ERR "%s - tty_register_driver failed(%d)\n", pr_err("%s - tty_register_driver failed(%d)\n",
__func__, result); __func__, result);
goto err_free_tty; goto err_free_tty;
} }
...@@ -3268,8 +3261,7 @@ static int __init hso_init(void) ...@@ -3268,8 +3261,7 @@ static int __init hso_init(void)
/* register this module as an usb driver */ /* register this module as an usb driver */
result = usb_register(&hso_driver); result = usb_register(&hso_driver);
if (result) { if (result) {
printk(KERN_ERR "Could not register hso driver? error: %d\n", pr_err("Could not register hso driver - error: %d\n", result);
result);
goto err_unreg_tty; goto err_unreg_tty;
} }
...@@ -3284,7 +3276,7 @@ static int __init hso_init(void) ...@@ -3284,7 +3276,7 @@ static int __init hso_init(void)
static void __exit hso_exit(void) static void __exit hso_exit(void)
{ {
printk(KERN_INFO "hso: unloaded\n"); pr_info("unloaded\n");
tty_unregister_driver(tty_drv); tty_unregister_driver(tty_drv);
put_tty_driver(tty_drv); put_tty_driver(tty_drv);
...@@ -3301,7 +3293,7 @@ MODULE_DESCRIPTION(MOD_DESCRIPTION); ...@@ -3301,7 +3293,7 @@ MODULE_DESCRIPTION(MOD_DESCRIPTION);
MODULE_LICENSE(MOD_LICENSE); MODULE_LICENSE(MOD_LICENSE);
/* change the debug level (eg: insmod hso.ko debug=0x04) */ /* change the debug level (eg: insmod hso.ko debug=0x04) */
MODULE_PARM_DESC(debug, "Level of debug [0x01 | 0x02 | 0x04 | 0x08 | 0x10]"); MODULE_PARM_DESC(debug, "debug level mask [0x01 | 0x02 | 0x04 | 0x08 | 0x10]");
module_param(debug, int, S_IRUGO | S_IWUSR); module_param(debug, int, S_IRUGO | S_IWUSR);
/* set the major tty number (eg: insmod hso.ko tty_major=245) */ /* set the major tty number (eg: insmod hso.ko tty_major=245) */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment