dect
/
linux-2.6
Archived
13
0
Fork 0

USB: usblp: fixed switch, brace, whitespace and spacing coding style issues

Fixed switch, brace, whitespace and spacing coding style issues.

Signed-off-by: Nicolas Kaiser <nikai@nikai.net>
Acked-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Nicolas Kaiser 2010-06-25 20:25:37 +02:00 committed by Greg Kroah-Hartman
parent 3da7cff4e7
commit 916de02720
1 changed files with 184 additions and 185 deletions

View File

@ -135,7 +135,7 @@ MFG:HEWLETT-PACKARD;MDL:DESKJET 970C;CMD:MLC,PCL,PML;CLASS:PRINTER;DESCRIPTION:H
* ->lock locks what interrupt accesses. * ->lock locks what interrupt accesses.
*/ */
struct usblp { struct usblp {
struct usb_device *dev; /* USB device */ struct usb_device *dev; /* USB device */
struct mutex wmut; struct mutex wmut;
struct mutex mut; struct mutex mut;
spinlock_t lock; /* locks rcomplete, wcomplete */ spinlock_t lock; /* locks rcomplete, wcomplete */
@ -169,7 +169,8 @@ struct usblp {
}; };
#ifdef DEBUG #ifdef DEBUG
static void usblp_dump(struct usblp *usblp) { static void usblp_dump(struct usblp *usblp)
{
int p; int p;
dbg("usblp=0x%p", usblp); dbg("usblp=0x%p", usblp);
@ -216,8 +217,8 @@ static const struct quirk_printer_struct quirk_printers[] = {
{ 0x03f0, 0x0304, USBLP_QUIRK_BIDIR }, /* HP DeskJet 810C/812C */ { 0x03f0, 0x0304, USBLP_QUIRK_BIDIR }, /* HP DeskJet 810C/812C */
{ 0x03f0, 0x0404, USBLP_QUIRK_BIDIR }, /* HP DeskJet 830C */ { 0x03f0, 0x0404, USBLP_QUIRK_BIDIR }, /* HP DeskJet 830C */
{ 0x03f0, 0x0504, USBLP_QUIRK_BIDIR }, /* HP DeskJet 885C */ { 0x03f0, 0x0504, USBLP_QUIRK_BIDIR }, /* HP DeskJet 885C */
{ 0x03f0, 0x0604, USBLP_QUIRK_BIDIR }, /* HP DeskJet 840C */ { 0x03f0, 0x0604, USBLP_QUIRK_BIDIR }, /* HP DeskJet 840C */
{ 0x03f0, 0x0804, USBLP_QUIRK_BIDIR }, /* HP DeskJet 816C */ { 0x03f0, 0x0804, USBLP_QUIRK_BIDIR }, /* HP DeskJet 816C */
{ 0x03f0, 0x1104, USBLP_QUIRK_BIDIR }, /* HP Deskjet 959C */ { 0x03f0, 0x1104, USBLP_QUIRK_BIDIR }, /* HP Deskjet 959C */
{ 0x0409, 0xefbe, USBLP_QUIRK_BIDIR }, /* NEC Picty900 (HP OEM) */ { 0x0409, 0xefbe, USBLP_QUIRK_BIDIR }, /* NEC Picty900 (HP OEM) */
{ 0x0409, 0xbef4, USBLP_QUIRK_BIDIR }, /* NEC Picty760 (HP OEM) */ { 0x0409, 0xbef4, USBLP_QUIRK_BIDIR }, /* NEC Picty760 (HP OEM) */
@ -254,9 +255,8 @@ static int usblp_ctrl_msg(struct usblp *usblp, int request, int type, int dir, i
/* High byte has the interface index. /* High byte has the interface index.
Low byte has the alternate setting. Low byte has the alternate setting.
*/ */
if ((request == USBLP_REQ_GET_ID) && (type == USB_TYPE_CLASS)) { if ((request == USBLP_REQ_GET_ID) && (type == USB_TYPE_CLASS))
index = (usblp->ifnum<<8)|usblp->protocol[usblp->current_protocol].alt_setting; index = (usblp->ifnum<<8)|usblp->protocol[usblp->current_protocol].alt_setting;
}
retval = usb_control_msg(usblp->dev, retval = usb_control_msg(usblp->dev,
dir ? usb_rcvctrlpipe(usblp->dev, 0) : usb_sndctrlpipe(usblp->dev, 0), dir ? usb_rcvctrlpipe(usblp->dev, 0) : usb_sndctrlpipe(usblp->dev, 0),
@ -372,7 +372,7 @@ static int usblp_check_status(struct usblp *usblp, int err)
return newerr; return newerr;
} }
static int handle_bidir (struct usblp *usblp) static int handle_bidir(struct usblp *usblp)
{ {
if (usblp->bidir && usblp->used) { if (usblp->bidir && usblp->used) {
if (usblp_submit_read(usblp) < 0) if (usblp_submit_read(usblp) < 0)
@ -395,14 +395,13 @@ static int usblp_open(struct inode *inode, struct file *file)
if (minor < 0) if (minor < 0)
return -ENODEV; return -ENODEV;
mutex_lock (&usblp_mutex); mutex_lock(&usblp_mutex);
retval = -ENODEV; retval = -ENODEV;
intf = usb_find_interface(&usblp_driver, minor); intf = usb_find_interface(&usblp_driver, minor);
if (!intf) { if (!intf)
goto out; goto out;
} usblp = usb_get_intfdata(intf);
usblp = usb_get_intfdata (intf);
if (!usblp || !usblp->dev || !usblp->present) if (!usblp || !usblp->dev || !usblp->present)
goto out; goto out;
@ -433,18 +432,18 @@ static int usblp_open(struct inode *inode, struct file *file)
retval = -EIO; retval = -EIO;
} }
out: out:
mutex_unlock (&usblp_mutex); mutex_unlock(&usblp_mutex);
return retval; return retval;
} }
static void usblp_cleanup (struct usblp *usblp) static void usblp_cleanup(struct usblp *usblp)
{ {
printk(KERN_INFO "usblp%d: removed\n", usblp->minor); printk(KERN_INFO "usblp%d: removed\n", usblp->minor);
kfree(usblp->readbuf); kfree(usblp->readbuf);
kfree (usblp->device_id_string); kfree(usblp->device_id_string);
kfree (usblp->statusbuf); kfree(usblp->statusbuf);
kfree (usblp); kfree(usblp);
} }
static void usblp_unlink_urbs(struct usblp *usblp) static void usblp_unlink_urbs(struct usblp *usblp)
@ -458,14 +457,14 @@ static int usblp_release(struct inode *inode, struct file *file)
usblp->flags &= ~LP_ABORT; usblp->flags &= ~LP_ABORT;
mutex_lock (&usblp_mutex); mutex_lock(&usblp_mutex);
usblp->used = 0; usblp->used = 0;
if (usblp->present) { if (usblp->present) {
usblp_unlink_urbs(usblp); usblp_unlink_urbs(usblp);
usb_autopm_put_interface(usblp->intf); usb_autopm_put_interface(usblp->intf);
} else /* finish cleanup from disconnect */ } else /* finish cleanup from disconnect */
usblp_cleanup (usblp); usblp_cleanup(usblp);
mutex_unlock (&usblp_mutex); mutex_unlock(&usblp_mutex);
return 0; return 0;
} }
@ -495,190 +494,190 @@ static long usblp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
int twoints[2]; int twoints[2];
int retval = 0; int retval = 0;
mutex_lock (&usblp->mut); mutex_lock(&usblp->mut);
if (!usblp->present) { if (!usblp->present) {
retval = -ENODEV; retval = -ENODEV;
goto done; goto done;
} }
dbg("usblp_ioctl: cmd=0x%x (%c nr=%d len=%d dir=%d)", cmd, _IOC_TYPE(cmd), dbg("usblp_ioctl: cmd=0x%x (%c nr=%d len=%d dir=%d)", cmd, _IOC_TYPE(cmd),
_IOC_NR(cmd), _IOC_SIZE(cmd), _IOC_DIR(cmd) ); _IOC_NR(cmd), _IOC_SIZE(cmd), _IOC_DIR(cmd));
if (_IOC_TYPE(cmd) == 'P') /* new-style ioctl number */ if (_IOC_TYPE(cmd) == 'P') /* new-style ioctl number */
switch (_IOC_NR(cmd)) { switch (_IOC_NR(cmd)) {
case IOCNR_GET_DEVICE_ID: /* get the DEVICE_ID string */ case IOCNR_GET_DEVICE_ID: /* get the DEVICE_ID string */
if (_IOC_DIR(cmd) != _IOC_READ) { if (_IOC_DIR(cmd) != _IOC_READ) {
retval = -EINVAL; retval = -EINVAL;
goto done; goto done;
} }
length = usblp_cache_device_id_string(usblp); length = usblp_cache_device_id_string(usblp);
if (length < 0) { if (length < 0) {
retval = length; retval = length;
goto done; goto done;
} }
if (length > _IOC_SIZE(cmd)) if (length > _IOC_SIZE(cmd))
length = _IOC_SIZE(cmd); /* truncate */ length = _IOC_SIZE(cmd); /* truncate */
if (copy_to_user((void __user *) arg, if (copy_to_user((void __user *) arg,
usblp->device_id_string, usblp->device_id_string,
(unsigned long) length)) { (unsigned long) length)) {
retval = -EFAULT; retval = -EFAULT;
goto done; goto done;
} }
break; break;
case IOCNR_GET_PROTOCOLS: case IOCNR_GET_PROTOCOLS:
if (_IOC_DIR(cmd) != _IOC_READ || if (_IOC_DIR(cmd) != _IOC_READ ||
_IOC_SIZE(cmd) < sizeof(twoints)) { _IOC_SIZE(cmd) < sizeof(twoints)) {
retval = -EINVAL; retval = -EINVAL;
goto done; goto done;
} }
twoints[0] = usblp->current_protocol; twoints[0] = usblp->current_protocol;
twoints[1] = 0; twoints[1] = 0;
for (i = USBLP_FIRST_PROTOCOL; for (i = USBLP_FIRST_PROTOCOL;
i <= USBLP_LAST_PROTOCOL; i++) { i <= USBLP_LAST_PROTOCOL; i++) {
if (usblp->protocol[i].alt_setting >= 0) if (usblp->protocol[i].alt_setting >= 0)
twoints[1] |= (1<<i); twoints[1] |= (1<<i);
} }
if (copy_to_user((void __user *)arg, if (copy_to_user((void __user *)arg,
(unsigned char *)twoints, (unsigned char *)twoints,
sizeof(twoints))) { sizeof(twoints))) {
retval = -EFAULT; retval = -EFAULT;
goto done; goto done;
} }
break; break;
case IOCNR_SET_PROTOCOL: case IOCNR_SET_PROTOCOL:
if (_IOC_DIR(cmd) != _IOC_WRITE) { if (_IOC_DIR(cmd) != _IOC_WRITE) {
retval = -EINVAL; retval = -EINVAL;
goto done; goto done;
} }
#ifdef DEBUG #ifdef DEBUG
if (arg == -10) { if (arg == -10) {
usblp_dump(usblp); usblp_dump(usblp);
break; break;
} }
#endif #endif
usblp_unlink_urbs(usblp); usblp_unlink_urbs(usblp);
retval = usblp_set_protocol(usblp, arg); retval = usblp_set_protocol(usblp, arg);
if (retval < 0) { if (retval < 0) {
usblp_set_protocol(usblp, usblp_set_protocol(usblp,
usblp->current_protocol); usblp->current_protocol);
} }
break; break;
case IOCNR_HP_SET_CHANNEL: case IOCNR_HP_SET_CHANNEL:
if (_IOC_DIR(cmd) != _IOC_WRITE || if (_IOC_DIR(cmd) != _IOC_WRITE ||
le16_to_cpu(usblp->dev->descriptor.idVendor) != 0x03F0 || le16_to_cpu(usblp->dev->descriptor.idVendor) != 0x03F0 ||
usblp->quirks & USBLP_QUIRK_BIDIR) { usblp->quirks & USBLP_QUIRK_BIDIR) {
retval = -EINVAL; retval = -EINVAL;
goto done; goto done;
} }
err = usblp_hp_channel_change_request(usblp, err = usblp_hp_channel_change_request(usblp,
arg, &newChannel); arg, &newChannel);
if (err < 0) { if (err < 0) {
dev_err(&usblp->dev->dev, dev_err(&usblp->dev->dev,
"usblp%d: error = %d setting " "usblp%d: error = %d setting "
"HP channel\n", "HP channel\n",
usblp->minor, err); usblp->minor, err);
retval = -EIO; retval = -EIO;
goto done; goto done;
} }
dbg("usblp%d requested/got HP channel %ld/%d", dbg("usblp%d requested/got HP channel %ld/%d",
usblp->minor, arg, newChannel); usblp->minor, arg, newChannel);
break; break;
case IOCNR_GET_BUS_ADDRESS: case IOCNR_GET_BUS_ADDRESS:
if (_IOC_DIR(cmd) != _IOC_READ || if (_IOC_DIR(cmd) != _IOC_READ ||
_IOC_SIZE(cmd) < sizeof(twoints)) { _IOC_SIZE(cmd) < sizeof(twoints)) {
retval = -EINVAL; retval = -EINVAL;
goto done; goto done;
} }
twoints[0] = usblp->dev->bus->busnum; twoints[0] = usblp->dev->bus->busnum;
twoints[1] = usblp->dev->devnum; twoints[1] = usblp->dev->devnum;
if (copy_to_user((void __user *)arg, if (copy_to_user((void __user *)arg,
(unsigned char *)twoints, (unsigned char *)twoints,
sizeof(twoints))) { sizeof(twoints))) {
retval = -EFAULT; retval = -EFAULT;
goto done; goto done;
} }
dbg("usblp%d is bus=%d, device=%d", dbg("usblp%d is bus=%d, device=%d",
usblp->minor, twoints[0], twoints[1]); usblp->minor, twoints[0], twoints[1]);
break; break;
case IOCNR_GET_VID_PID: case IOCNR_GET_VID_PID:
if (_IOC_DIR(cmd) != _IOC_READ || if (_IOC_DIR(cmd) != _IOC_READ ||
_IOC_SIZE(cmd) < sizeof(twoints)) { _IOC_SIZE(cmd) < sizeof(twoints)) {
retval = -EINVAL; retval = -EINVAL;
goto done; goto done;
} }
twoints[0] = le16_to_cpu(usblp->dev->descriptor.idVendor); twoints[0] = le16_to_cpu(usblp->dev->descriptor.idVendor);
twoints[1] = le16_to_cpu(usblp->dev->descriptor.idProduct); twoints[1] = le16_to_cpu(usblp->dev->descriptor.idProduct);
if (copy_to_user((void __user *)arg, if (copy_to_user((void __user *)arg,
(unsigned char *)twoints, (unsigned char *)twoints,
sizeof(twoints))) { sizeof(twoints))) {
retval = -EFAULT; retval = -EFAULT;
goto done; goto done;
} }
dbg("usblp%d is VID=0x%4.4X, PID=0x%4.4X", dbg("usblp%d is VID=0x%4.4X, PID=0x%4.4X",
usblp->minor, twoints[0], twoints[1]); usblp->minor, twoints[0], twoints[1]);
break; break;
case IOCNR_SOFT_RESET: case IOCNR_SOFT_RESET:
if (_IOC_DIR(cmd) != _IOC_NONE) { if (_IOC_DIR(cmd) != _IOC_NONE) {
retval = -EINVAL; retval = -EINVAL;
goto done; goto done;
} }
retval = usblp_reset(usblp); retval = usblp_reset(usblp);
break; break;
default: default:
retval = -ENOTTY; retval = -ENOTTY;
} }
else /* old-style ioctl value */ else /* old-style ioctl value */
switch (cmd) { switch (cmd) {
case LPGETSTATUS: case LPGETSTATUS:
if ((retval = usblp_read_status(usblp, usblp->statusbuf))) { if ((retval = usblp_read_status(usblp, usblp->statusbuf))) {
if (printk_ratelimit()) if (printk_ratelimit())
printk(KERN_ERR "usblp%d:" printk(KERN_ERR "usblp%d:"
"failed reading printer status (%d)\n", "failed reading printer status (%d)\n",
usblp->minor, retval); usblp->minor, retval);
retval = -EIO; retval = -EIO;
goto done; goto done;
} }
status = *usblp->statusbuf; status = *usblp->statusbuf;
if (copy_to_user ((void __user *)arg, &status, sizeof(int))) if (copy_to_user((void __user *)arg, &status, sizeof(int)))
retval = -EFAULT; retval = -EFAULT;
break; break;
case LPABORT: case LPABORT:
if (arg) if (arg)
usblp->flags |= LP_ABORT; usblp->flags |= LP_ABORT;
else else
usblp->flags &= ~LP_ABORT; usblp->flags &= ~LP_ABORT;
break; break;
default: default:
retval = -ENOTTY; retval = -ENOTTY;
} }
done: done:
mutex_unlock (&usblp->mut); mutex_unlock(&usblp->mut);
return retval; return retval;
} }
@ -840,7 +839,7 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t len, lo
} }
done: done:
mutex_unlock (&usblp->mut); mutex_unlock(&usblp->mut);
return count; return count;
} }
@ -1023,7 +1022,7 @@ raise_urb:
* while you are sending print data, and you don't try to query the * while you are sending print data, and you don't try to query the
* printer status every couple of milliseconds, you will probably be OK. * printer status every couple of milliseconds, you will probably be OK.
*/ */
static unsigned int usblp_quirks (__u16 vendor, __u16 product) static unsigned int usblp_quirks(__u16 vendor, __u16 product)
{ {
int i; int i;
@ -1031,7 +1030,7 @@ static unsigned int usblp_quirks (__u16 vendor, __u16 product)
if (vendor == quirk_printers[i].vendorId && if (vendor == quirk_printers[i].vendorId &&
product == quirk_printers[i].productId) product == quirk_printers[i].productId)
return quirk_printers[i].quirks; return quirk_printers[i].quirks;
} }
return 0; return 0;
} }
@ -1061,7 +1060,7 @@ static struct usb_class_driver usblp_class = {
static ssize_t usblp_show_ieee1284_id(struct device *dev, struct device_attribute *attr, char *buf) static ssize_t usblp_show_ieee1284_id(struct device *dev, struct device_attribute *attr, char *buf)
{ {
struct usb_interface *intf = to_usb_interface(dev); struct usb_interface *intf = to_usb_interface(dev);
struct usblp *usblp = usb_get_intfdata (intf); struct usblp *usblp = usb_get_intfdata(intf);
if (usblp->device_id_string[0] == 0 && if (usblp->device_id_string[0] == 0 &&
usblp->device_id_string[1] == 0) usblp->device_id_string[1] == 0)
@ -1075,7 +1074,7 @@ static DEVICE_ATTR(ieee1284_id, S_IRUGO, usblp_show_ieee1284_id, NULL);
static int usblp_probe(struct usb_interface *intf, static int usblp_probe(struct usb_interface *intf,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
struct usb_device *dev = interface_to_usbdev (intf); struct usb_device *dev = interface_to_usbdev(intf);
struct usblp *usblp; struct usblp *usblp;
int protocol; int protocol;
int retval; int retval;
@ -1089,7 +1088,7 @@ static int usblp_probe(struct usb_interface *intf,
} }
usblp->dev = dev; usblp->dev = dev;
mutex_init(&usblp->wmut); mutex_init(&usblp->wmut);
mutex_init (&usblp->mut); mutex_init(&usblp->mut);
spin_lock_init(&usblp->lock); spin_lock_init(&usblp->lock);
init_waitqueue_head(&usblp->rwait); init_waitqueue_head(&usblp->rwait);
init_waitqueue_head(&usblp->wwait); init_waitqueue_head(&usblp->wwait);
@ -1153,7 +1152,7 @@ static int usblp_probe(struct usb_interface *intf,
usblp_check_status(usblp, 0); usblp_check_status(usblp, 0);
#endif #endif
usb_set_intfdata (intf, usblp); usb_set_intfdata(intf, usblp);
usblp->present = 1; usblp->present = 1;
@ -1177,7 +1176,7 @@ static int usblp_probe(struct usb_interface *intf,
return 0; return 0;
abort_intfdata: abort_intfdata:
usb_set_intfdata (intf, NULL); usb_set_intfdata(intf, NULL);
device_remove_file(&intf->dev, &dev_attr_ieee1284_id); device_remove_file(&intf->dev, &dev_attr_ieee1284_id);
abort: abort:
kfree(usblp->readbuf); kfree(usblp->readbuf);
@ -1340,35 +1339,35 @@ static int usblp_cache_device_id_string(struct usblp *usblp)
static void usblp_disconnect(struct usb_interface *intf) static void usblp_disconnect(struct usb_interface *intf)
{ {
struct usblp *usblp = usb_get_intfdata (intf); struct usblp *usblp = usb_get_intfdata(intf);
usb_deregister_dev(intf, &usblp_class); usb_deregister_dev(intf, &usblp_class);
if (!usblp || !usblp->dev) { if (!usblp || !usblp->dev) {
dev_err(&intf->dev, "bogus disconnect\n"); dev_err(&intf->dev, "bogus disconnect\n");
BUG (); BUG();
} }
device_remove_file(&intf->dev, &dev_attr_ieee1284_id); device_remove_file(&intf->dev, &dev_attr_ieee1284_id);
mutex_lock (&usblp_mutex); mutex_lock(&usblp_mutex);
mutex_lock (&usblp->mut); mutex_lock(&usblp->mut);
usblp->present = 0; usblp->present = 0;
wake_up(&usblp->wwait); wake_up(&usblp->wwait);
wake_up(&usblp->rwait); wake_up(&usblp->rwait);
usb_set_intfdata (intf, NULL); usb_set_intfdata(intf, NULL);
usblp_unlink_urbs(usblp); usblp_unlink_urbs(usblp);
mutex_unlock (&usblp->mut); mutex_unlock(&usblp->mut);
if (!usblp->used) if (!usblp->used)
usblp_cleanup (usblp); usblp_cleanup(usblp);
mutex_unlock (&usblp_mutex); mutex_unlock(&usblp_mutex);
} }
static int usblp_suspend(struct usb_interface *intf, pm_message_t message) static int usblp_suspend(struct usb_interface *intf, pm_message_t message)
{ {
struct usblp *usblp = usb_get_intfdata (intf); struct usblp *usblp = usb_get_intfdata(intf);
usblp_unlink_urbs(usblp); usblp_unlink_urbs(usblp);
#if 0 /* XXX Do we want this? What if someone is reading, should we fail? */ #if 0 /* XXX Do we want this? What if someone is reading, should we fail? */
@ -1382,10 +1381,10 @@ static int usblp_suspend(struct usb_interface *intf, pm_message_t message)
static int usblp_resume(struct usb_interface *intf) static int usblp_resume(struct usb_interface *intf)
{ {
struct usblp *usblp = usb_get_intfdata (intf); struct usblp *usblp = usb_get_intfdata(intf);
int r; int r;
r = handle_bidir (usblp); r = handle_bidir(usblp);
return r; return r;
} }
@ -1401,7 +1400,7 @@ static const struct usb_device_id usblp_ids[] = {
{ } /* Terminating entry */ { } /* Terminating entry */
}; };
MODULE_DEVICE_TABLE (usb, usblp_ids); MODULE_DEVICE_TABLE(usb, usblp_ids);
static struct usb_driver usblp_driver = { static struct usb_driver usblp_driver = {
.name = "usblp", .name = "usblp",
@ -1426,8 +1425,8 @@ static void __exit usblp_exit(void)
module_init(usblp_init); module_init(usblp_init);
module_exit(usblp_exit); module_exit(usblp_exit);
MODULE_AUTHOR( DRIVER_AUTHOR ); MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION( DRIVER_DESC ); MODULE_DESCRIPTION(DRIVER_DESC);
module_param(proto_bias, int, S_IRUGO | S_IWUSR); module_param(proto_bias, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(proto_bias, "Favourite protocol number"); MODULE_PARM_DESC(proto_bias, "Favourite protocol number");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");