From 4e60d951eaea98d400df5915429b7c78da2ec4c3 Mon Sep 17 00:00:00 2001 From: Antti Palosaari Date: Thu, 24 May 2012 14:44:21 -0300 Subject: [PATCH] [media] dvb_usb_v2: fix issues raised by checkpatch.pl Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/dvb-usb/dvb_usb.h | 42 +++-- drivers/media/dvb/dvb-usb/dvb_usb_common.h | 24 +-- drivers/media/dvb/dvb-usb/dvb_usb_dvb.c | 48 +++--- drivers/media/dvb/dvb-usb/dvb_usb_firmware.c | 105 +++++++----- drivers/media/dvb/dvb-usb/dvb_usb_i2c.c | 3 +- drivers/media/dvb/dvb-usb/dvb_usb_init.c | 160 +++++++++++------- drivers/media/dvb/dvb-usb/dvb_usb_remote.c | 139 +++++++--------- drivers/media/dvb/dvb-usb/dvb_usb_urb.c | 33 ++-- drivers/media/dvb/dvb-usb/usb_urb.c | 161 +++++++++++-------- 9 files changed, 399 insertions(+), 316 deletions(-) diff --git a/drivers/media/dvb/dvb-usb/dvb_usb.h b/drivers/media/dvb/dvb-usb/dvb_usb.h index c538e113bd58..149e45f034f8 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb.h +++ b/drivers/media/dvb/dvb-usb/dvb_usb.h @@ -27,18 +27,19 @@ /* debug */ #ifdef CONFIG_DVB_USB_DEBUG -#define dprintk(var,level,args...) \ - do { if ((var & level)) { printk(args); } } while (0) +#define dprintk(var, level, args...) \ + do { if ((var & level)) { printk(args); } } while (0) -#define debug_dump(b,l,func) {\ +#define debug_dump(b, l, func) {\ int loop_; \ - for (loop_ = 0; loop_ < l; loop_++) func("%02x ", b[loop_]); \ + for (loop_ = 0; loop_ < l; loop_++) \ + func("%02x ", b[loop_]); \ func("\n");\ } #define DVB_USB_DEBUG_STATUS #else #define dprintk(args...) -#define debug_dump(b,l,func) +#define debug_dump(b, l, func) #define DVB_USB_DEBUG_STATUS " (debugging is not enabled)" @@ -50,11 +51,14 @@ #endif #undef err -#define err(format, arg...) printk(KERN_ERR DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) +#define err(format, arg...) \ + printk(KERN_ERR DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) #undef info -#define info(format, arg...) printk(KERN_INFO DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) +#define info(format, arg...) \ + printk(KERN_INFO DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) #undef warn -#define warn(format, arg...) printk(KERN_WARNING DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) +#define warn(format, arg...) \ + printk(KERN_WARNING DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) /** * struct dvb_usb_device_description - name and its according USB IDs @@ -120,7 +124,8 @@ struct usb_data_stream_properties { /** * struct dvb_usb_adapter_properties - properties of a dvb-usb-adapter. - * A DVB-USB-Adapter is basically a dvb_adapter which is present on a USB-device. + * A DVB-USB-Adapter is basically a dvb_adapter which is present on a + * USB-device. * @caps: capabilities of the DVB USB device. * @pid_filter_count: number of PID filter position in the optional hardware * PID-filter. @@ -277,7 +282,8 @@ struct dvb_usb_device_properties { int usb_ctrl; #define RECONNECTS_USB 1 - int (*download_firmware) (struct dvb_usb_device *, const struct firmware *); + int (*download_firmware) (struct dvb_usb_device *, + const struct firmware *); int (*get_firmware_name) (struct dvb_usb_device *, const char **); int size_of_priv; @@ -351,7 +357,8 @@ struct usb_data_stream { * @pll_addr: I2C address of the tuner for programming * @pll_init: array containing the initialization buffer * @pll_desc: pointer to the appropriate struct dvb_pll_desc - * @tuner_pass_ctrl: called to (de)activate tuner passthru of the demod or the board + * @tuner_pass_ctrl: called to (de)activate tuner passthru of the demod or + * the board * * @dvb_adap: device's dvb_adapter. * @dmxdev: device's dmxdev. @@ -468,11 +475,13 @@ extern int dvb_usbv2_device_init(struct usb_interface *, extern void dvb_usbv2_device_exit(struct usb_interface *); /* the generic read/write method for device control */ -extern int dvb_usbv2_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16,int); +extern int dvb_usbv2_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16, + int); extern int dvb_usbv2_generic_write(struct dvb_usb_device *, u8 *, u16); /* commonly used remote control parsing */ -extern int dvb_usbv2_nec_rc_key_to_event(struct dvb_usb_device *, u8[], u32 *, int *); +extern int dvb_usbv2_nec_rc_key_to_event(struct dvb_usb_device *, u8[], u32 *, + int *); /* commonly used firmware download types and function */ struct hexline { @@ -482,8 +491,9 @@ struct hexline { u8 data[255]; u8 chk; }; -extern int usbv2_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type); -extern int dvb_usbv2_get_hexline(const struct firmware *fw, struct hexline *hx, int *pos); - +extern int usbv2_cypress_load_firmware(struct usb_device *udev, + const struct firmware *fw, int type); +extern int dvb_usbv2_get_hexline(const struct firmware *fw, struct hexline *hx, + int *pos); #endif diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_common.h b/drivers/media/dvb/dvb-usb/dvb_usb_common.h index dd275cdc1082..60f8ccba8dcd 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb_common.h +++ b/drivers/media/dvb/dvb-usb/dvb_usb_common.h @@ -3,7 +3,8 @@ * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) * see dvb-usb-init.c for copyright information. * - * a header file containing prototypes and types for internal use of the dvb-usb-lib + * a header file containing prototypes and types for internal use of the + * dvb-usb-lib */ #ifndef DVB_USB_COMMON_H #define DVB_USB_COMMON_H @@ -14,22 +15,23 @@ extern int dvb_usb_debug; extern int dvb_usb_disable_rc_polling; -#define deb_info(args...) dprintk(dvb_usb_debug,0x001,args) -#define deb_xfer(args...) dprintk(dvb_usb_debug,0x002,args) -#define deb_pll(args...) dprintk(dvb_usb_debug,0x004,args) -#define deb_ts(args...) dprintk(dvb_usb_debug,0x008,args) -#define deb_err(args...) dprintk(dvb_usb_debug,0x010,args) -#define deb_rc(args...) dprintk(dvb_usb_debug,0x020,args) -#define deb_fw(args...) dprintk(dvb_usb_debug,0x040,args) -#define deb_mem(args...) dprintk(dvb_usb_debug,0x080,args) -#define deb_uxfer(args...) dprintk(dvb_usb_debug,0x100,args) +#define deb_info(args...) dprintk(dvb_usb_debug, 0x001, args) +#define deb_xfer(args...) dprintk(dvb_usb_debug, 0x002, args) +#define deb_pll(args...) dprintk(dvb_usb_debug, 0x004, args) +#define deb_ts(args...) dprintk(dvb_usb_debug, 0x008, args) +#define deb_err(args...) dprintk(dvb_usb_debug, 0x010, args) +#define deb_rc(args...) dprintk(dvb_usb_debug, 0x020, args) +#define deb_fw(args...) dprintk(dvb_usb_debug, 0x040, args) +#define deb_mem(args...) dprintk(dvb_usb_debug, 0x080, args) +#define deb_uxfer(args...) dprintk(dvb_usb_debug, 0x100, args) /* commonly used methods */ extern int dvb_usb_download_firmware(struct dvb_usb_device *); extern int dvb_usb_device_power_ctrl(struct dvb_usb_device *d, int onoff); -extern int usb_urb_init(struct usb_data_stream *stream, struct usb_data_stream_properties *props); +extern int usb_urb_init(struct usb_data_stream *stream, + struct usb_data_stream_properties *props); extern int usb_urb_exit(struct usb_data_stream *stream); extern int usb_urb_submit(struct usb_data_stream *stream); extern int usb_urb_kill(struct usb_data_stream *stream); diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_dvb.c b/drivers/media/dvb/dvb-usb/dvb_usb_dvb.c index 41e3194b971e..832ef88ab248 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb_dvb.c +++ b/drivers/media/dvb/dvb-usb/dvb_usb_dvb.c @@ -30,7 +30,8 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) usb_urb_kill(&adap->fe_adap[adap->active_fe].stream); if (adap->props.fe[adap->active_fe].streaming_ctrl != NULL) { - ret = adap->props.fe[adap->active_fe].streaming_ctrl(adap, 0); + ret = adap->props.fe[adap->active_fe].streaming_ctrl( + adap, 0); if (ret < 0) { err("error while stopping stream."); return ret; @@ -48,7 +49,8 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) if (adap->props.fe[adap->active_fe].caps & DVB_USB_ADAP_HAS_PID_FILTER && adap->fe_adap[adap->active_fe].pid_filtering && adap->props.fe[adap->active_fe].pid_filter != NULL) - adap->props.fe[adap->active_fe].pid_filter(adap, dvbdmxfeed->index, dvbdmxfeed->pid, onoff); + adap->props.fe[adap->active_fe].pid_filter(adap, + dvbdmxfeed->index, dvbdmxfeed->pid, onoff); /* start the feed if this was the first feed and there is still a feed * for reception. @@ -62,7 +64,8 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) adap->props.fe[adap->active_fe].caps & DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF && adap->props.fe[adap->active_fe].pid_filter_ctrl != NULL) { - ret = adap->props.fe[adap->active_fe].pid_filter_ctrl(adap, + ret = adap->props.fe[adap->active_fe].pid_filter_ctrl( + adap, adap->fe_adap[adap->active_fe].pid_filtering); if (ret < 0) { err("could not handle pid_parser"); @@ -71,7 +74,8 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) } deb_ts("start feeding\n"); if (adap->props.fe[adap->active_fe].streaming_ctrl != NULL) { - ret = adap->props.fe[adap->active_fe].streaming_ctrl(adap, 1); + ret = adap->props.fe[adap->active_fe].streaming_ctrl( + adap, 1); if (ret < 0) { err("error while enabling fifo."); return ret; @@ -84,14 +88,16 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) static int dvb_usb_start_feed(struct dvb_demux_feed *dvbdmxfeed) { - deb_ts("start pid: 0x%04x, feedtype: %d\n", dvbdmxfeed->pid,dvbdmxfeed->type); - return dvb_usb_ctrl_feed(dvbdmxfeed,1); + deb_ts("start pid: 0x%04x, feedtype: %d\n", + dvbdmxfeed->pid, dvbdmxfeed->type); + return dvb_usb_ctrl_feed(dvbdmxfeed, 1); } static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) { - deb_ts("stop pid: 0x%04x, feedtype: %d\n", dvbdmxfeed->pid, dvbdmxfeed->type); - return dvb_usb_ctrl_feed(dvbdmxfeed,0); + deb_ts("stop pid: 0x%04x, feedtype: %d\n", + dvbdmxfeed->pid, dvbdmxfeed->type); + return dvb_usb_ctrl_feed(dvbdmxfeed, 0); } int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap) @@ -109,8 +115,9 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap) adap->dvb_adap.fe_ioctl_override = adap->props.fe_ioctl_override; if (adap->dev->props.read_mac_address) { - if (adap->dev->props.read_mac_address(adap->dev,adap->dvb_adap.proposed_mac) == 0) - info("MAC address: %pM",adap->dvb_adap.proposed_mac); + if (adap->dev->props.read_mac_address(adap->dev, + adap->dvb_adap.proposed_mac) == 0) + info("MAC address: %pM", adap->dvb_adap.proposed_mac); else err("MAC address reading failed."); } @@ -128,22 +135,24 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap) adap->demux.start_feed = dvb_usb_start_feed; adap->demux.stop_feed = dvb_usb_stop_feed; adap->demux.write_to_decoder = NULL; - if ((ret = dvb_dmx_init(&adap->demux)) < 0) { - err("dvb_dmx_init failed: error %d",ret); + ret = dvb_dmx_init(&adap->demux); + if (ret < 0) { + err("dvb_dmx_init failed: error %d", ret); goto err_dmx; } adap->dmxdev.filternum = adap->demux.filternum; adap->dmxdev.demux = &adap->demux.dmx; adap->dmxdev.capabilities = 0; - if ((ret = dvb_dmxdev_init(&adap->dmxdev, &adap->dvb_adap)) < 0) { - err("dvb_dmxdev_init failed: error %d",ret); + ret = dvb_dmxdev_init(&adap->dmxdev, &adap->dvb_adap); + if (ret < 0) { + err("dvb_dmxdev_init failed: error %d", ret); goto err_dmx_dev; } - if ((ret = dvb_net_init(&adap->dvb_adap, &adap->dvb_net, - &adap->demux.dmx)) < 0) { - err("dvb_net_init failed: error %d",ret); + ret = dvb_net_init(&adap->dvb_adap, &adap->dvb_net, &adap->demux.dmx); + if (ret < 0) { + err("dvb_net_init failed: error %d", ret); goto err_net_init; } @@ -225,7 +234,7 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap) for (i = 0; i < adap->props.num_frontends; i++) { if (adap->props.fe[i].frontend_attach == NULL) { - err("strange: '%s' #%d,%d " + err("strange: '%s' #%d,%d " \ "doesn't want to attach a frontend.", adap->dev->desc->name, adap->id, i); @@ -250,7 +259,8 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap) adap->fe_adap[i].fe_sleep = adap->fe_adap[i].fe->ops.sleep; adap->fe_adap[i].fe->ops.sleep = dvb_usb_fe_sleep; - if (dvb_register_frontend(&adap->dvb_adap, adap->fe_adap[i].fe)) { + if (dvb_register_frontend(&adap->dvb_adap, + adap->fe_adap[i].fe)) { err("Frontend %d registration failed.", i); dvb_frontend_detach(adap->fe_adap[i].fe); adap->fe_adap[i].fe = NULL; diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_firmware.c b/drivers/media/dvb/dvb-usb/dvb_usb_firmware.c index b9b169c8f0da..62bd865a6462 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb_firmware.c +++ b/drivers/media/dvb/dvb-usb/dvb_usb_firmware.c @@ -3,9 +3,11 @@ * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) * see dvb-usb-init.c for copyright information. * - * This file contains functions for downloading the firmware to Cypress FX 1 and 2 based devices. + * This file contains functions for downloading the firmware to Cypress FX 1 + * and 2 based devices. * - * FIXME: This part does actually not belong to dvb-usb, but to the usb-subsystem. + * FIXME: This part does actually not belong to dvb-usb, but to the + * usb-subsystem. */ #include "dvb_usb_common.h" @@ -13,58 +15,71 @@ struct usb_cypress_controller { int id; - const char *name; /* name of the usb controller */ - u16 cpu_cs_register; /* needs to be restarted, when the firmware has been downloaded. */ + /* name of the usb controller */ + const char *name; + /* needs to be restarted, when the firmware has been downloaded. */ + u16 cpu_cs_register; }; static struct usb_cypress_controller cypress[] = { - { .id = DEVICE_SPECIFIC, .name = "Device specific", .cpu_cs_register = 0 }, - { .id = CYPRESS_AN2135, .name = "Cypress AN2135", .cpu_cs_register = 0x7f92 }, - { .id = CYPRESS_AN2235, .name = "Cypress AN2235", .cpu_cs_register = 0x7f92 }, - { .id = CYPRESS_FX2, .name = "Cypress FX2", .cpu_cs_register = 0xe600 }, + { .id = DEVICE_SPECIFIC, .name = "Device specific", + .cpu_cs_register = 0 }, + { .id = CYPRESS_AN2135, .name = "Cypress AN2135", + .cpu_cs_register = 0x7f92 }, + { .id = CYPRESS_AN2235, .name = "Cypress AN2235", + .cpu_cs_register = 0x7f92 }, + { .id = CYPRESS_FX2, .name = "Cypress FX2", + .cpu_cs_register = 0xe600 }, }; /* * load a firmware packet to the device */ -static int usb_cypress_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 len) +static int usb_cypress_writemem(struct usb_device *udev, u16 addr, u8 *data, + u8 len) { - return usb_control_msg(udev, usb_sndctrlpipe(udev,0), + return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0xa0, USB_TYPE_VENDOR, addr, 0x00, data, len, 5000); } -int usbv2_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type) +int usbv2_cypress_load_firmware(struct usb_device *udev, + const struct firmware *fw, int type) { struct hexline hx; u8 reset; - int ret,pos=0; + int ret, pos = 0; /* stop the CPU */ reset = 1; - if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1) + ret = usb_cypress_writemem(udev, cypress[type].cpu_cs_register, + &reset, 1); + if (ret != 1) err("could not stop the USB controller CPU."); - while ((ret = dvb_usbv2_get_hexline(fw,&hx,&pos)) > 0) { - deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx.addr,hx.len,hx.chk); - ret = usb_cypress_writemem(udev,hx.addr,hx.data,hx.len); + while ((ret = dvb_usbv2_get_hexline(fw, &hx, &pos)) > 0) { + deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n", + hx.addr, hx.len, hx.chk); + ret = usb_cypress_writemem(udev, hx.addr, hx.data, hx.len); if (ret != hx.len) { - err("error while transferring firmware " + err("error while transferring firmware " \ "(transferred size: %d, block size: %d)", - ret,hx.len); + ret, hx.len); ret = -EINVAL; break; } } if (ret < 0) { - err("firmware download failed at %d with %d",pos,ret); + err("firmware download failed at %d with %d", pos, ret); return ret; } if (ret == 0) { /* restart the CPU */ reset = 0; - if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1) != 1) { + if (ret || usb_cypress_writemem(udev, + cypress[type].cpu_cs_register, + &reset, 1) != 1) { err("could not restart the USB controller CPU."); ret = -EINVAL; } @@ -85,32 +100,37 @@ int dvb_usb_download_firmware(struct dvb_usb_device *d) if (ret < 0) return ret; - if ((ret = request_firmware(&fw, name, &d->udev->dev)) != 0) { - err("did not find the firmware file. (%s) " - "Please see linux/Documentation/dvb/ for more details on firmware-problems. (%d)", - name,ret); + ret = request_firmware(&fw, name, &d->udev->dev); + if (ret != 0) { + err("did not find the firmware file. (%s) " \ + "Please see linux/Documentation/dvb/ for more" \ + " details on firmware-problems. (%d)", + name, ret); return ret; } info("downloading firmware from file '%s'", name); switch (d->props.usb_ctrl) { - case CYPRESS_AN2135: - case CYPRESS_AN2235: - case CYPRESS_FX2: - ret = usbv2_cypress_load_firmware(d->udev, fw, d->props.usb_ctrl); - break; - case DEVICE_SPECIFIC: - if (d->props.download_firmware) - ret = d->props.download_firmware(d, fw); - else { - err("BUG: driver didn't specified a download_firmware-callback, although it claims to have a DEVICE_SPECIFIC one."); - ret = -EINVAL; - } - break; - default: + case CYPRESS_AN2135: + case CYPRESS_AN2235: + case CYPRESS_FX2: + ret = usbv2_cypress_load_firmware(d->udev, fw, + d->props.usb_ctrl); + break; + case DEVICE_SPECIFIC: + if (d->props.download_firmware) + ret = d->props.download_firmware(d, fw); + else { + err("BUG: driver didn't specified a download_firmware" \ + "-callback, although it claims to have a" \ + " DEVICE_SPECIFIC one."); ret = -EINVAL; - break; + } + break; + default: + ret = -EINVAL; + break; } release_firmware(fw); @@ -125,7 +145,7 @@ int dvb_usbv2_get_hexline(const struct firmware *fw, struct hexline *hx, if (*pos >= fw->size) return 0; - memset(hx,0,sizeof(struct hexline)); + memset(hx, 0, sizeof(struct hexline)); hx->len = b[0]; @@ -136,12 +156,13 @@ int dvb_usbv2_get_hexline(const struct firmware *fw, struct hexline *hx, hx->type = b[3]; if (hx->type == 0x04) { - /* b[4] and b[5] are the Extended linear address record data field */ + /* b[4] and b[5] are the Extended linear address record data + * field */ hx->addr |= (b[4] << 24) | (b[5] << 16); /* hx->len -= 2; data_offs += 2; */ } - memcpy(hx->data,&b[data_offs],hx->len); + memcpy(hx->data, &b[data_offs], hx->len); hx->chk = b[hx->len + data_offs]; *pos += hx->len + 5; diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_i2c.c b/drivers/media/dvb/dvb-usb/dvb_usb_i2c.c index 273f4892da01..58e5a4182245 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb_i2c.c +++ b/drivers/media/dvb/dvb-usb/dvb_usb_i2c.c @@ -26,7 +26,8 @@ int dvb_usb_i2c_init(struct dvb_usb_device *d) i2c_set_adapdata(&d->i2c_adap, d); - if ((ret = i2c_add_adapter(&d->i2c_adap)) < 0) + ret = i2c_add_adapter(&d->i2c_adap); + if (ret < 0) err("could not add i2c adapter"); d->state |= DVB_USB_STATE_I2C; diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_init.c b/drivers/media/dvb/dvb-usb/dvb_usb_init.c index 9c03a3266be2..14cfc1e35144 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb_init.c +++ b/drivers/media/dvb/dvb-usb/dvb_usb_init.c @@ -6,8 +6,8 @@ * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) * * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, version 2. + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, version 2. * * see Documentation/dvb/README.dvb-usb for more information */ @@ -16,15 +16,20 @@ /* debug */ int dvb_usb_debug; module_param_named(debug, dvb_usb_debug, int, 0644); -MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,pll=4,ts=8,err=16,rc=32,fw=64,mem=128,uxfer=256 (or-able))." DVB_USB_DEBUG_STATUS); +MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,pll=4,ts=8"\ + ",err=16,rc=32,fw=64,mem=128,uxfer=256 (or-able))." + DVB_USB_DEBUG_STATUS); int dvb_usb_disable_rc_polling; module_param_named(disable_rc_polling, dvb_usb_disable_rc_polling, int, 0644); -MODULE_PARM_DESC(disable_rc_polling, "disable remote control polling (default: 0)."); +MODULE_PARM_DESC(disable_rc_polling, + "disable remote control polling (default: 0)."); static int dvb_usb_force_pid_filter_usage; -module_param_named(force_pid_filter_usage, dvb_usb_force_pid_filter_usage, int, 0444); -MODULE_PARM_DESC(force_pid_filter_usage, "force all dvb-usb-devices to use a PID filter, if any (default: 0)."); +module_param_named(force_pid_filter_usage, dvb_usb_force_pid_filter_usage, + int, 0444); +MODULE_PARM_DESC(force_pid_filter_usage, "force all dvb-usb-devices to use a" \ + " PID filter, if any (default: 0)."); static int dvb_usb_adapter_init(struct dvb_usb_device *d) { @@ -36,57 +41,77 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d) adap->dev = d; adap->id = n; - memcpy(&adap->props, &d->props.adapter[n], sizeof(struct dvb_usb_adapter_properties)); - - for (o = 0; o < adap->props.num_frontends; o++) { - struct dvb_usb_adapter_fe_properties *props = &adap->props.fe[o]; - /* speed - when running at FULL speed we need a HW PID filter */ - if (d->udev->speed == USB_SPEED_FULL && !(props->caps & DVB_USB_ADAP_HAS_PID_FILTER)) { - err("This USB2.0 device cannot be run on a USB1.1 port. (it lacks a hardware PID filter)"); - return -ENODEV; - } + memcpy(&adap->props, &d->props.adapter[n], + sizeof(struct dvb_usb_adapter_properties)); + + for (o = 0; o < adap->props.num_frontends; o++) { + struct dvb_usb_adapter_fe_properties *props = + &adap->props.fe[o]; + /* speed - when running at FULL speed we need a HW + * PID filter */ + if (d->udev->speed == USB_SPEED_FULL && + !(props->caps & DVB_USB_ADAP_HAS_PID_FILTER)) { + err("This USB2.0 device cannot be run on a" \ + " USB1.1 port. (it lacks a" \ + " hardware PID filter)"); + return -ENODEV; + } - if ((d->udev->speed == USB_SPEED_FULL && props->caps & DVB_USB_ADAP_HAS_PID_FILTER) || - (props->caps & DVB_USB_ADAP_NEED_PID_FILTERING)) { - info("will use the device's hardware PID filter (table count: %d).", props->pid_filter_count); - adap->fe_adap[o].pid_filtering = 1; - adap->fe_adap[o].max_feed_count = props->pid_filter_count; - } else { - info("will pass the complete MPEG2 transport stream to the software demuxer."); - adap->fe_adap[o].pid_filtering = 0; - adap->fe_adap[o].max_feed_count = 255; - } + if ((d->udev->speed == USB_SPEED_FULL && + props->caps & DVB_USB_ADAP_HAS_PID_FILTER) || + (props->caps & DVB_USB_ADAP_NEED_PID_FILTERING)) { + info("will use the device's hardware PID" \ + " filter (table count: %d).", + props->pid_filter_count); + adap->fe_adap[o].pid_filtering = 1; + adap->fe_adap[o].max_feed_count = + props->pid_filter_count; + } else { + info("will pass the complete MPEG2 transport" \ + " stream to the software demuxer."); + adap->fe_adap[o].pid_filtering = 0; + adap->fe_adap[o].max_feed_count = 255; + } - if (!adap->fe_adap[o].pid_filtering && - dvb_usb_force_pid_filter_usage && - props->caps & DVB_USB_ADAP_HAS_PID_FILTER) { - info("pid filter enabled by module option."); - adap->fe_adap[o].pid_filtering = 1; - adap->fe_adap[o].max_feed_count = props->pid_filter_count; - } + if (!adap->fe_adap[o].pid_filtering && + dvb_usb_force_pid_filter_usage && + props->caps & DVB_USB_ADAP_HAS_PID_FILTER) { + info("pid filter enabled by module option."); + adap->fe_adap[o].pid_filtering = 1; + adap->fe_adap[o].max_feed_count = + props->pid_filter_count; + } - if (props->size_of_priv > 0) { - adap->fe_adap[o].priv = kzalloc(props->size_of_priv, GFP_KERNEL); - if (adap->fe_adap[o].priv == NULL) { - err("no memory for priv for adapter %d fe %d.", n, o); - return -ENOMEM; + if (props->size_of_priv > 0) { + adap->fe_adap[o].priv = kzalloc(props->size_of_priv, GFP_KERNEL); + if (adap->fe_adap[o].priv == NULL) { + err("no memory for priv for adapter" \ + " %d fe %d.", n, o); + return -ENOMEM; + } } } - } if (adap->props.size_of_priv > 0) { - adap->priv = kzalloc(adap->props.size_of_priv, GFP_KERNEL); + adap->priv = kzalloc(adap->props.size_of_priv, + GFP_KERNEL); if (adap->priv == NULL) { err("no memory for priv for adapter %d.", n); return -ENOMEM; } } - if ((ret = dvb_usb_adapter_stream_init(adap)) || - (ret = dvb_usb_adapter_dvb_init(adap)) || - (ret = dvb_usb_adapter_frontend_init(adap))) { + ret = dvb_usb_adapter_stream_init(adap); + if (ret) + return ret; + + ret = dvb_usb_adapter_dvb_init(adap); + if (ret) + return ret; + + ret = dvb_usb_adapter_frontend_init(adap); + if (ret) return ret; - } /* use exclusive FE lock if there is multiple shared FEs */ if (adap->fe_adap[1].fe) @@ -101,8 +126,10 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d) * sometimes a timeout occures, this helps */ if (d->props.generic_bulk_ctrl_endpoint != 0) { - usb_clear_halt(d->udev, usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint)); - usb_clear_halt(d->udev, usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint)); + usb_clear_halt(d->udev, usb_sndbulkpipe(d->udev, + d->props.generic_bulk_ctrl_endpoint)); + usb_clear_halt(d->udev, usb_rcvbulkpipe(d->udev, + d->props.generic_bulk_ctrl_endpoint)); } return 0; @@ -150,7 +177,11 @@ static int dvb_usb_init(struct dvb_usb_device *d) /* check the capabilities and set appropriate variables */ dvb_usb_device_power_ctrl(d, 1); - if ((ret = dvb_usb_i2c_init(d)) || (ret = dvb_usb_adapter_init(d))) { + ret = dvb_usb_i2c_init(d); + if (ret == 0) + ret = dvb_usb_adapter_init(d); + + if (ret) { dvb_usb_exit(d); return ret; } @@ -158,7 +189,8 @@ static int dvb_usb_init(struct dvb_usb_device *d) if (d->props.init) d->props.init(d); - if ((ret = dvb_usb_remote_init(d))) + ret = dvb_usb_remote_init(d); + if (ret) err("could not initialize remote control."); dvb_usb_device_power_ctrl(d, 0); @@ -167,7 +199,9 @@ static int dvb_usb_init(struct dvb_usb_device *d) } /* determine the name and the state of the just found USB device */ -static struct dvb_usb_device_description *dvb_usb_find_device(struct usb_device *udev, struct dvb_usb_device_properties *props, bool *cold) +static struct dvb_usb_device_description *dvb_usb_find_device( + struct usb_device *udev, + struct dvb_usb_device_properties *props, bool *cold) { int i, j; struct dvb_usb_device_description *desc = NULL; @@ -175,11 +209,12 @@ static struct dvb_usb_device_description *dvb_usb_find_device(struct usb_device *cold = true; for (i = 0; i < props->num_device_descs; i++) { - for (j = 0; j < DVB_USB_ID_MAX_NUM && props->devices[i].cold_ids[j] != NULL; j++) { - deb_info("check for cold %x %x\n", props->devices[i].cold_ids[j]->idVendor, props->devices[i].cold_ids[j]->idProduct); - if (props->devices[i].cold_ids[j]->idVendor == le16_to_cpu(udev->descriptor.idVendor) && - props->devices[i].cold_ids[j]->idProduct == le16_to_cpu(udev->descriptor.idProduct)) { + deb_info("check for cold %x %x\n", + props->devices[i].cold_ids[j]->idVendor, + props->devices[i].cold_ids[j]->idProduct); + if (props->devices[i].cold_ids[j]->idVendor == le16_to_cpu(udev->descriptor.idVendor) && + props->devices[i].cold_ids[j]->idProduct == le16_to_cpu(udev->descriptor.idProduct)) { *cold = true; desc = &props->devices[i]; break; @@ -190,9 +225,12 @@ static struct dvb_usb_device_description *dvb_usb_find_device(struct usb_device break; for (j = 0; j < DVB_USB_ID_MAX_NUM && props->devices[i].warm_ids[j] != NULL; j++) { - deb_info("check for warm %x %x\n", props->devices[i].warm_ids[j]->idVendor, props->devices[i].warm_ids[j]->idProduct); + deb_info("check for warm %x %x\n", + props->devices[i].warm_ids[j]->idVendor, + props->devices[i].warm_ids[j]->idProduct); + if (props->devices[i].warm_ids[j]->idVendor == le16_to_cpu(udev->descriptor.idVendor) && - props->devices[i].warm_ids[j]->idProduct == le16_to_cpu(udev->descriptor.idProduct)) { + props->devices[i].warm_ids[j]->idProduct == le16_to_cpu(udev->descriptor.idProduct)) { *cold = false; desc = &props->devices[i]; break; @@ -210,7 +248,8 @@ int dvb_usb_device_power_ctrl(struct dvb_usb_device *d, int onoff) else d->powered--; - if (d->powered == 0 || (onoff && d->powered == 1)) { /* when switching from 1 to 0 or from 0 to 1 */ + if (d->powered == 0 || (onoff && d->powered == 1)) { + /* when switching from 1 to 0 or from 0 to 1 */ deb_info("power control: %d\n", onoff); if (d->props.power_ctrl) return d->props.power_ctrl(d, onoff); @@ -250,8 +289,12 @@ int dvb_usbv2_device_init(struct usb_interface *intf, } } - if ((desc = dvb_usb_find_device(udev, props, &cold)) == NULL) { - deb_err("something went very wrong, device was not found in current device list - let's see what comes next.\n"); + desc = dvb_usb_find_device(udev, props, &cold); + + if (desc == NULL) { + deb_err("something went very wrong, device was not found in" \ + " current device list - let's see what" \ + " comes next.\n"); ret = -ENODEV; goto err_kfree; } @@ -271,7 +314,8 @@ int dvb_usbv2_device_init(struct usb_interface *intf, } if (cold) { - info("found a '%s' in cold state, will try to load a firmware", desc->name); + info("found a '%s' in cold state, will try to load a firmware", + desc->name); ret = dvb_usb_download_firmware(d); if (ret == 0) { ; diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_remote.c b/drivers/media/dvb/dvb-usb/dvb_usb_remote.c index 1c6bef62473f..b445990644ae 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb_remote.c +++ b/drivers/media/dvb/dvb-usb/dvb_usb_remote.c @@ -3,7 +3,8 @@ * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) * see dvb-usb-init.c for copyright information. * - * This file contains functions for initializing the input-device and for handling remote-control-queries. + * This file contains functions for initializing the input-device and for + * handling remote-control-queries. */ #include "dvb_usb_common.h" #include @@ -112,73 +113,40 @@ static void legacy_dvb_usb_read_remote_control(struct work_struct *work) u32 event; int state; - /* TODO: need a lock here. We can simply skip checking for the remote control - if we're busy. */ + /* TODO: need a lock here. We can simply skip checking for the remote + control if we're busy. */ - /* when the parameter has been set to 1 via sysfs while the driver was running */ + /* when the parameter has been set to 1 via sysfs while the driver + was running */ if (dvb_usb_disable_rc_polling) return; - if (d->props.rc.legacy.rc_query(d,&event,&state)) { + if (d->props.rc.legacy.rc_query(d, &event, &state)) { err("error while querying for an remote control event."); goto schedule; } switch (state) { - case REMOTE_NO_KEY_PRESSED: - break; - case REMOTE_KEY_PRESSED: - deb_rc("key pressed\n"); - d->last_event = event; - case REMOTE_KEY_REPEAT: - deb_rc("key repeated\n"); - input_event(d->input_dev, EV_KEY, event, 1); - input_sync(d->input_dev); - input_event(d->input_dev, EV_KEY, d->last_event, 0); - input_sync(d->input_dev); - break; - default: - break; + case REMOTE_NO_KEY_PRESSED: + break; + case REMOTE_KEY_PRESSED: + deb_rc("key pressed\n"); + d->last_event = event; + case REMOTE_KEY_REPEAT: + deb_rc("key repeated\n"); + input_event(d->input_dev, EV_KEY, event, 1); + input_sync(d->input_dev); + input_event(d->input_dev, EV_KEY, d->last_event, 0); + input_sync(d->input_dev); + break; + default: + break; } -/* improved repeat handling ??? - switch (state) { - case REMOTE_NO_KEY_PRESSED: - deb_rc("NO KEY PRESSED\n"); - if (d->last_state != REMOTE_NO_KEY_PRESSED) { - deb_rc("releasing event %d\n",d->last_event); - input_event(d->rc_input_dev, EV_KEY, d->last_event, 0); - input_sync(d->rc_input_dev); - } - d->last_state = REMOTE_NO_KEY_PRESSED; - d->last_event = 0; - break; - case REMOTE_KEY_PRESSED: - deb_rc("KEY PRESSED\n"); - deb_rc("pressing event %d\n",event); - - input_event(d->rc_input_dev, EV_KEY, event, 1); - input_sync(d->rc_input_dev); - - d->last_event = event; - d->last_state = REMOTE_KEY_PRESSED; - break; - case REMOTE_KEY_REPEAT: - deb_rc("KEY_REPEAT\n"); - if (d->last_state != REMOTE_NO_KEY_PRESSED) { - deb_rc("repeating event %d\n",d->last_event); - input_event(d->rc_input_dev, EV_KEY, d->last_event, 2); - input_sync(d->rc_input_dev); - d->last_state = REMOTE_KEY_REPEAT; - } - default: - break; - } -*/ - schedule: - schedule_delayed_work(&d->rc_query_work,msecs_to_jiffies(d->props.rc.legacy.rc_interval)); + schedule_delayed_work(&d->rc_query_work, + msecs_to_jiffies(d->props.rc.legacy.rc_interval)); } static int legacy_dvb_usb_remote_init(struct dvb_usb_device *d) @@ -206,10 +174,12 @@ static int legacy_dvb_usb_remote_init(struct dvb_usb_device *d) for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) { deb_rc("setting bit for event %d item %d\n", d->props.rc.legacy.rc_map_table[i].keycode, i); - set_bit(d->props.rc.legacy.rc_map_table[i].keycode, input_dev->keybit); + set_bit(d->props.rc.legacy.rc_map_table[i].keycode, + input_dev->keybit); } - /* setting these two values to non-zero, we have to manage key repeats */ + /* setting these two values to non-zero, we have to manage key + repeats */ input_dev->rep[REP_PERIOD] = d->props.rc.legacy.rc_interval; input_dev->rep[REP_DELAY] = d->props.rc.legacy.rc_interval + 150; @@ -221,7 +191,8 @@ static int legacy_dvb_usb_remote_init(struct dvb_usb_device *d) rc_interval = d->props.rc.legacy.rc_interval; - INIT_DELAYED_WORK(&d->rc_query_work, legacy_dvb_usb_read_remote_control); + INIT_DELAYED_WORK(&d->rc_query_work, + legacy_dvb_usb_read_remote_control); info("schedule remote query interval to %d msecs.", rc_interval); schedule_delayed_work(&d->rc_query_work, @@ -243,8 +214,8 @@ static void dvb_usb_read_remote_control(struct work_struct *work) container_of(work, struct dvb_usb_device, rc_query_work.work); int err; - /* TODO: need a lock here. We can simply skip checking for the remote control - if we're busy. */ + /* TODO: need a lock here. We can simply skip checking for the remote + control if we're busy. */ /* when the parameter has been set to 1 via sysfs while the * driver was running, or when bulk mode is enabled after IR init @@ -254,7 +225,8 @@ static void dvb_usb_read_remote_control(struct work_struct *work) err = d->props.rc.core.rc_query(d); if (err) - err("error %d while querying for an remote control event.", err); + err("error %d while querying for an remote control event.", + err); schedule_delayed_work(&d->rc_query_work, msecs_to_jiffies(d->props.rc.core.rc_interval)); @@ -361,30 +333,31 @@ int dvb_usbv2_nec_rc_key_to_event(struct dvb_usb_device *d, *event = 0; *state = REMOTE_NO_KEY_PRESSED; switch (keybuf[0]) { - case DVB_USB_RC_NEC_EMPTY: + case DVB_USB_RC_NEC_EMPTY: + break; + case DVB_USB_RC_NEC_KEY_PRESSED: + if ((u8) ~keybuf[1] != keybuf[2] || + (u8) ~keybuf[3] != keybuf[4]) { + deb_err("remote control checksum failed.\n"); break; - case DVB_USB_RC_NEC_KEY_PRESSED: - if ((u8) ~keybuf[1] != keybuf[2] || - (u8) ~keybuf[3] != keybuf[4]) { - deb_err("remote control checksum failed.\n"); - break; + } + /* See if we can match the raw key code. */ + for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) + if (rc5_custom(&keymap[i]) == keybuf[1] && + rc5_data(&keymap[i]) == keybuf[3]) { + *event = keymap[i].keycode; + *state = REMOTE_KEY_PRESSED; + return 0; } - /* See if we can match the raw key code. */ - for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) - if (rc5_custom(&keymap[i]) == keybuf[1] && - rc5_data(&keymap[i]) == keybuf[3]) { - *event = keymap[i].keycode; - *state = REMOTE_KEY_PRESSED; - return 0; - } - deb_err("key mapping failed - no appropriate key found in keymapping\n"); - break; - case DVB_USB_RC_NEC_KEY_REPEATED: - *state = REMOTE_KEY_REPEAT; - break; - default: - deb_err("unknown type of remote status: %d\n",keybuf[0]); - break; + deb_err("key mapping failed - no appropriate key found in" \ + " keymapping\n"); + break; + case DVB_USB_RC_NEC_KEY_REPEATED: + *state = REMOTE_KEY_REPEAT; + break; + default: + deb_err("unknown type of remote status: %d\n", keybuf[0]); + break; } return 0; } diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_urb.c b/drivers/media/dvb/dvb-usb/dvb_usb_urb.c index c4b7845373e2..8c98924a625a 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb_urb.c +++ b/drivers/media/dvb/dvb-usb/dvb_usb_urb.c @@ -11,7 +11,7 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen, int delay_ms) { - int actlen,ret = -ENOMEM; + int actlen, ret = -ENOMEM; if (!d || wbuf == NULL || wlen == 0) return -EINVAL; @@ -21,18 +21,19 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, return -EINVAL; } - if ((ret = mutex_lock_interruptible(&d->usb_mutex))) + ret = mutex_lock_interruptible(&d->usb_mutex); + if (ret) return ret; deb_xfer(">>> "); - debug_dump(wbuf,wlen,deb_xfer); + debug_dump(wbuf, wlen, deb_xfer); - ret = usb_bulk_msg(d->udev,usb_sndbulkpipe(d->udev, - d->props.generic_bulk_ctrl_endpoint), wbuf,wlen,&actlen, - 2000); + ret = usb_bulk_msg(d->udev, usb_sndbulkpipe(d->udev, + d->props.generic_bulk_ctrl_endpoint), wbuf, wlen, + &actlen, 2000); if (ret) - err("bulk message failed: %d (%d/%d)",ret,wlen,actlen); + err("bulk message failed: %d (%d/%d)", ret, wlen, actlen); else ret = actlen != wlen ? -1 : 0; @@ -41,17 +42,17 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, if (delay_ms) msleep(delay_ms); - ret = usb_bulk_msg(d->udev,usb_rcvbulkpipe(d->udev, + ret = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint_response ? d->props.generic_bulk_ctrl_endpoint_response : - d->props.generic_bulk_ctrl_endpoint),rbuf,rlen,&actlen, - 2000); + d->props.generic_bulk_ctrl_endpoint), + rbuf, rlen, &actlen, 2000); if (ret) - err("recv bulk message failed: %d",ret); + err("recv bulk message failed: %d", ret); else { deb_xfer("<<< "); - debug_dump(rbuf,actlen,deb_xfer); + debug_dump(rbuf, actlen, deb_xfer); } } @@ -62,18 +63,20 @@ EXPORT_SYMBOL(dvb_usbv2_generic_rw); int dvb_usbv2_generic_write(struct dvb_usb_device *d, u8 *buf, u16 len) { - return dvb_usbv2_generic_rw(d,buf,len,NULL,0,0); + return dvb_usbv2_generic_rw(d, buf, len, NULL, 0, 0); } EXPORT_SYMBOL(dvb_usbv2_generic_write); -static void dvb_usb_data_complete(struct usb_data_stream *stream, u8 *buffer, size_t length) +static void dvb_usb_data_complete(struct usb_data_stream *stream, u8 *buffer, + size_t length) { struct dvb_usb_adapter *adap = stream->user_priv; if (adap->feedcount > 0 && adap->state & DVB_USB_ADAP_STATE_DVB) dvb_dmx_swfilter(&adap->demux, buffer, length); } -static void dvb_usb_data_complete_204(struct usb_data_stream *stream, u8 *buffer, size_t length) +static void dvb_usb_data_complete_204(struct usb_data_stream *stream, + u8 *buffer, size_t length) { struct dvb_usb_adapter *adap = stream->user_priv; if (adap->feedcount > 0 && adap->state & DVB_USB_ADAP_STATE_DVB) diff --git a/drivers/media/dvb/dvb-usb/usb_urb.c b/drivers/media/dvb/dvb-usb/usb_urb.c index bf1915367cb9..065f67c67538 100644 --- a/drivers/media/dvb/dvb-usb/usb_urb.c +++ b/drivers/media/dvb/dvb-usb/usb_urb.c @@ -18,55 +18,59 @@ static void usb_urb_complete(struct urb *urb) int i; u8 *b; - deb_uxfer("'%s' urb completed. status: %d, length: %d/%d, pack_num: %d, errors: %d\n", + deb_uxfer("'%s' urb completed. status: %d, length: %d/%d," \ + " pack_num: %d, errors: %d\n", ptype == PIPE_ISOCHRONOUS ? "isoc" : "bulk", - urb->status,urb->actual_length,urb->transfer_buffer_length, - urb->number_of_packets,urb->error_count); + urb->status, urb->actual_length, urb->transfer_buffer_length, + urb->number_of_packets, urb->error_count); switch (urb->status) { - case 0: /* success */ - case -ETIMEDOUT: /* NAK */ - break; - case -ECONNRESET: /* kill */ - case -ENOENT: - case -ESHUTDOWN: - return; - default: /* error */ - deb_ts("urb completition error %d.\n", urb->status); - break; + case 0: /* success */ + case -ETIMEDOUT: /* NAK */ + break; + case -ECONNRESET: /* kill */ + case -ENOENT: + case -ESHUTDOWN: + return; + default: /* error */ + deb_ts("urb completition error %d.\n", urb->status); + break; } b = (u8 *) urb->transfer_buffer; switch (ptype) { - case PIPE_ISOCHRONOUS: - for (i = 0; i < urb->number_of_packets; i++) { - - if (urb->iso_frame_desc[i].status != 0) - deb_ts("iso frame descriptor has an error: %d\n",urb->iso_frame_desc[i].status); - else if (urb->iso_frame_desc[i].actual_length > 0) - stream->complete(stream, b + urb->iso_frame_desc[i].offset, urb->iso_frame_desc[i].actual_length); - - urb->iso_frame_desc[i].status = 0; - urb->iso_frame_desc[i].actual_length = 0; - } - debug_dump(b,20,deb_uxfer); - break; - case PIPE_BULK: - if (urb->actual_length > 0) - stream->complete(stream, b, urb->actual_length); - break; - default: - err("unknown endpoint type in completition handler."); - return; + case PIPE_ISOCHRONOUS: + for (i = 0; i < urb->number_of_packets; i++) { + if (urb->iso_frame_desc[i].status != 0) + deb_ts("iso frame descriptor has an" \ + " error: %d\n", + urb->iso_frame_desc[i].status); + else if (urb->iso_frame_desc[i].actual_length > 0) + stream->complete(stream, + b + urb->iso_frame_desc[i].offset, + urb->iso_frame_desc[i].actual_length); + + urb->iso_frame_desc[i].status = 0; + urb->iso_frame_desc[i].actual_length = 0; + } + debug_dump(b, 20, deb_uxfer); + break; + case PIPE_BULK: + if (urb->actual_length > 0) + stream->complete(stream, b, urb->actual_length); + break; + default: + err("unknown endpoint type in completition handler."); + return; } - usb_submit_urb(urb,GFP_ATOMIC); + usb_submit_urb(urb, GFP_ATOMIC); } int usb_urb_kill(struct usb_data_stream *stream) { int i; for (i = 0; i < stream->urbs_submitted; i++) { - deb_ts("killing URB no. %d.\n",i); + deb_ts("killing URB no. %d.\n", i); /* stop the URB */ usb_kill_urb(stream->urb_list[i]); @@ -77,11 +81,13 @@ int usb_urb_kill(struct usb_data_stream *stream) int usb_urb_submit(struct usb_data_stream *stream) { - int i,ret; + int i, ret; for (i = 0; i < stream->urbs_initialized; i++) { - deb_ts("submitting URB no. %d\n",i); - if ((ret = usb_submit_urb(stream->urb_list[i],GFP_ATOMIC))) { - err("could not submit URB no. %d - get them all back",i); + deb_ts("submitting URB no. %d\n", i); + ret = usb_submit_urb(stream->urb_list[i], GFP_ATOMIC); + if (ret) { + err("could not submit URB no. %d - get them all back", + i); usb_urb_kill(stream); return ret; } @@ -95,7 +101,7 @@ static int usb_free_stream_buffers(struct usb_data_stream *stream) if (stream->state & USB_STATE_URB_BUF) { while (stream->buf_num) { stream->buf_num--; - deb_mem("freeing buffer %d\n",stream->buf_num); + deb_mem("freeing buffer %d\n", stream->buf_num); usb_free_coherent(stream->udev, stream->buf_size, stream->buf_list[stream->buf_num], stream->dma_addr[stream->buf_num]); @@ -107,26 +113,30 @@ static int usb_free_stream_buffers(struct usb_data_stream *stream) return 0; } -static int usb_allocate_stream_buffers(struct usb_data_stream *stream, int num, unsigned long size) +static int usb_allocate_stream_buffers(struct usb_data_stream *stream, int num, + unsigned long size) { stream->buf_num = 0; stream->buf_size = size; - deb_mem("all in all I will use %lu bytes for streaming\n",num*size); + deb_mem("all in all I will use %lu bytes for streaming\n", num * size); for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) { - deb_mem("allocating buffer %d\n",stream->buf_num); - if (( stream->buf_list[stream->buf_num] = - usb_alloc_coherent(stream->udev, size, GFP_ATOMIC, - &stream->dma_addr[stream->buf_num]) ) == NULL) { - deb_mem("not enough memory for urb-buffer allocation.\n"); + deb_mem("allocating buffer %d\n", stream->buf_num); + stream->buf_list[stream->buf_num] = usb_alloc_coherent( + stream->udev, size, GFP_ATOMIC, + &stream->dma_addr[stream->buf_num]); + if (stream->buf_list[stream->buf_num] == NULL) { + deb_mem("not enough memory for urb-buffer" \ + " allocation.\n"); usb_free_stream_buffers(stream); return -ENOMEM; } - deb_mem("buffer %d: %p (dma: %Lu)\n", - stream->buf_num, -stream->buf_list[stream->buf_num], (long long)stream->dma_addr[stream->buf_num]); - memset(stream->buf_list[stream->buf_num],0,size); + deb_mem("buffer %d: %p (dma: %llu)\n", + stream->buf_num, + stream->buf_list[stream->buf_num], + (long long)stream->dma_addr[stream->buf_num]); + memset(stream->buf_list[stream->buf_num], 0, size); stream->state |= USB_STATE_URB_BUF; } deb_mem("allocation successful\n"); @@ -138,8 +148,9 @@ static int usb_bulk_urb_init(struct usb_data_stream *stream) { int i, j; - if ((i = usb_allocate_stream_buffers(stream,stream->props.count, - stream->props.u.bulk.buffersize)) < 0) + i = usb_allocate_stream_buffers(stream, stream->props.count, + stream->props.u.bulk.buffersize); + if (i < 0) return i; /* allocate the URBs */ @@ -151,8 +162,9 @@ static int usb_bulk_urb_init(struct usb_data_stream *stream) usb_free_urb(stream->urb_list[j]); return -ENOMEM; } - usb_fill_bulk_urb( stream->urb_list[i], stream->udev, - usb_rcvbulkpipe(stream->udev,stream->props.endpoint), + usb_fill_bulk_urb(stream->urb_list[i], stream->udev, + usb_rcvbulkpipe(stream->udev, + stream->props.endpoint), stream->buf_list[i], stream->props.u.bulk.buffersize, usb_urb_complete, stream); @@ -166,10 +178,12 @@ static int usb_bulk_urb_init(struct usb_data_stream *stream) static int usb_isoc_urb_init(struct usb_data_stream *stream) { - int i,j; + int i, j; - if ((i = usb_allocate_stream_buffers(stream,stream->props.count, - stream->props.u.isoc.framesize*stream->props.u.isoc.framesperurb)) < 0) + i = usb_allocate_stream_buffers(stream, stream->props.count, + stream->props.u.isoc.framesize * + stream->props.u.isoc.framesperurb); + if (i < 0) return i; /* allocate the URBs */ @@ -177,7 +191,8 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream) struct urb *urb; int frame_offset = 0; - stream->urb_list[i] = usb_alloc_urb(stream->props.u.isoc.framesperurb, GFP_ATOMIC); + stream->urb_list[i] = usb_alloc_urb( + stream->props.u.isoc.framesperurb, GFP_ATOMIC); if (!stream->urb_list[i]) { deb_mem("not enough memory for urb_alloc_urb!\n"); for (j = 0; j < i; j++) @@ -190,7 +205,8 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream) urb->dev = stream->udev; urb->context = stream; urb->complete = usb_urb_complete; - urb->pipe = usb_rcvisocpipe(stream->udev,stream->props.endpoint); + urb->pipe = usb_rcvisocpipe(stream->udev, + stream->props.endpoint); urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; urb->interval = stream->props.u.isoc.interval; urb->number_of_packets = stream->props.u.isoc.framesperurb; @@ -200,7 +216,8 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream) for (j = 0; j < stream->props.u.isoc.framesperurb; j++) { urb->iso_frame_desc[j].offset = frame_offset; - urb->iso_frame_desc[j].length = stream->props.u.isoc.framesize; + urb->iso_frame_desc[j].length = + stream->props.u.isoc.framesize; frame_offset += stream->props.u.isoc.framesize; } @@ -209,14 +226,16 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream) return 0; } -int usb_urb_init(struct usb_data_stream *stream, struct usb_data_stream_properties *props) +int usb_urb_init(struct usb_data_stream *stream, + struct usb_data_stream_properties *props) { if (stream == NULL || props == NULL) return -EINVAL; memcpy(&stream->props, props, sizeof(*props)); - usb_clear_halt(stream->udev,usb_rcvbulkpipe(stream->udev,stream->props.endpoint)); + usb_clear_halt(stream->udev, usb_rcvbulkpipe(stream->udev, + stream->props.endpoint)); if (stream->complete == NULL) { err("there is no data callback - this doesn't make sense."); @@ -224,13 +243,13 @@ int usb_urb_init(struct usb_data_stream *stream, struct usb_data_stream_properti } switch (stream->props.type) { - case USB_BULK: - return usb_bulk_urb_init(stream); - case USB_ISOC: - return usb_isoc_urb_init(stream); - default: - err("unknown URB-type for data transfer."); - return -EINVAL; + case USB_BULK: + return usb_bulk_urb_init(stream); + case USB_ISOC: + return usb_isoc_urb_init(stream); + default: + err("unknown URB-type for data transfer."); + return -EINVAL; } } @@ -242,7 +261,7 @@ int usb_urb_exit(struct usb_data_stream *stream) for (i = 0; i < stream->urbs_initialized; i++) { if (stream->urb_list[i] != NULL) { - deb_mem("freeing URB no. %d.\n",i); + deb_mem("freeing URB no. %d.\n", i); /* free the URBs */ usb_free_urb(stream->urb_list[i]); } -- 2.30.2