summaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2012-06-20 00:32:53 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-08-04 07:56:37 -0300
commit831511bdeee8b956fc9399f61fc9b25bd808429f (patch)
tree35313549cfb3b1dc7888a7f9f5f87b40beedb4b5 /drivers/media/dvb
parent9f6f82ee61b23f0234fc83be363483bc4a65d99c (diff)
[media] dvb_usb_v2: multiple small tweaks around the code
Naming, small code changes, debug writings, etc. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/dvb-usb/anysee.c4
-rw-r--r--drivers/media/dvb/dvb-usb/dvb_usb.h111
-rw-r--r--drivers/media/dvb/dvb-usb/dvb_usb_core.c91
-rw-r--r--drivers/media/dvb/dvb-usb/usb_urb.c36
4 files changed, 109 insertions, 133 deletions
diff --git a/drivers/media/dvb/dvb-usb/anysee.c b/drivers/media/dvb/dvb-usb/anysee.c
index 2655034b86a..9de0004c06d 100644
--- a/drivers/media/dvb/dvb-usb/anysee.c
+++ b/drivers/media/dvb/dvb-usb/anysee.c
@@ -1264,7 +1264,7 @@ static int anysee_init(struct dvb_usb_device *d)
return 0;
}
-static void anysee_disconnect(struct dvb_usb_device *d)
+static void anysee_exit(struct dvb_usb_device *d)
{
return anysee_ci_release(d);
}
@@ -1287,7 +1287,7 @@ static struct dvb_usb_device_properties anysee_props = {
.get_rc_config = anysee_get_rc_config,
.frontend_ctrl = anysee_frontend_ctrl,
.streaming_ctrl = anysee_streaming_ctrl,
- .disconnect = anysee_disconnect,
+ .exit = anysee_exit,
.num_adapters = 1,
.adapter = {
diff --git a/drivers/media/dvb/dvb-usb/dvb_usb.h b/drivers/media/dvb/dvb-usb/dvb_usb.h
index a87a9ff579c..56bf3a7f085 100644
--- a/drivers/media/dvb/dvb-usb/dvb_usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb_usb.h
@@ -10,10 +10,8 @@
#ifndef DVB_USB_H
#define DVB_USB_H
-#include <linux/input.h>
-#include <linux/usb.h>
+#include <linux/usb/input.h>
#include <linux/firmware.h>
-#include <linux/mutex.h>
#include <media/rc-core.h>
#include "dvb_frontend.h"
@@ -65,15 +63,35 @@
.rc_map = (rc), \
})
+struct dvb_usb_device;
+struct dvb_usb_adapter;
+
struct dvb_usb_driver_info {
const char *name;
const char *rc_map;
const struct dvb_usb_device_properties *props;
};
-struct dvb_usb_device;
-struct dvb_usb_adapter;
-struct usb_data_stream;
+/**
+ * struct dvb_rc properties of remote controller, using rc-core
+ * @rc_codes: name of rc codes table
+ * @protocol: type of protocol(s) currently used by the driver
+ * @allowed_protos: protocol(s) supported by the driver
+ * @driver_type: Used to point if a device supports raw mode
+ * @change_protocol: callback to change protocol
+ * @rc_query: called to query an event event.
+ * @rc_interval: time in ms between two queries.
+ * @bulk_mode: device supports bulk mode for RC (disable polling mode)
+ */
+struct dvb_usb_rc {
+ char *map_name;
+ u64 allowed_protos;
+ int (*change_protocol)(struct rc_dev *dev, u64 rc_type);
+ int (*query) (struct dvb_usb_device *d);
+ unsigned int interval;
+ const enum rc_driver_type driver_type;
+ bool bulk_mode;
+};
/**
* Properties of USB streaming - TODO this structure should be somewhere else
@@ -83,13 +101,13 @@ struct usb_data_stream;
struct usb_data_stream_properties {
#define USB_BULK 1
#define USB_ISOC 2
- int type;
- int count;
- int endpoint;
+ u8 type;
+ u8 count;
+ u8 endpoint;
union {
struct {
- int buffersize; /* per URB */
+ unsigned int buffersize; /* per URB */
} bulk;
struct {
int framesperurb;
@@ -124,10 +142,9 @@ struct dvb_usb_adapter_properties {
#define DVB_USB_ADAP_HAS_PID_FILTER 0x01
#define DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF 0x02
#define DVB_USB_ADAP_NEED_PID_FILTERING 0x04
- int caps;
- int size_of_priv;
+ u8 caps;
- int pid_filter_count;
+ u8 pid_filter_count;
int (*pid_filter_ctrl) (struct dvb_usb_adapter *, int);
int (*pid_filter) (struct dvb_usb_adapter *, int, u16, int);
@@ -135,27 +152,6 @@ struct dvb_usb_adapter_properties {
};
/**
- * struct dvb_rc properties of remote controller, using rc-core
- * @rc_codes: name of rc codes table
- * @protocol: type of protocol(s) currently used by the driver
- * @allowed_protos: protocol(s) supported by the driver
- * @driver_type: Used to point if a device supports raw mode
- * @change_protocol: callback to change protocol
- * @rc_query: called to query an event event.
- * @rc_interval: time in ms between two queries.
- * @bulk_mode: device supports bulk mode for RC (disable polling mode)
- */
-struct dvb_usb_rc {
- char *map_name;
- u64 allowed_protos;
- int (*change_protocol)(struct rc_dev *dev, u64 rc_type);
- int (*query) (struct dvb_usb_device *d);
- int interval;
- const enum rc_driver_type driver_type;
- bool bulk_mode;
-};
-
-/**
* struct dvb_usb_device_properties - properties of a dvb-usb-device
* @owner: owner of the dvb_adapter
* @usb_ctrl: which USB device-side controller is in use. Needed for firmware
@@ -196,8 +192,11 @@ struct dvb_usb_device_properties {
const char *driver_name;
struct module *owner;
short *adapter_nr;
+
u8 bInterfaceNumber;
- int size_of_priv;
+ unsigned int size_of_priv;
+ u8 generic_bulk_ctrl_endpoint;
+ u8 generic_bulk_ctrl_endpoint_response;
#define WARM 0
#define COLD 1
@@ -207,11 +206,12 @@ struct dvb_usb_device_properties {
int (*download_firmware) (struct dvb_usb_device *,
const struct firmware *);
- int num_adapters;
- int (*get_adapter_count) (struct dvb_usb_device *);
- struct dvb_usb_adapter_properties adapter[MAX_NO_OF_ADAPTER_PER_DEVICE];
+ struct i2c_algorithm *i2c_algo;
- int (*power_ctrl) (struct dvb_usb_device *, int);
+ unsigned int num_adapters;
+ struct dvb_usb_adapter_properties adapter[MAX_NO_OF_ADAPTER_PER_DEVICE];
+ int (*get_adapter_count) (struct dvb_usb_device *);
+ int (*power_ctrl) (struct dvb_usb_device *, int);
int (*read_config) (struct dvb_usb_device *d);
int (*read_mac_address) (struct dvb_usb_adapter *, u8 []);
int (*frontend_attach) (struct dvb_usb_adapter *);
@@ -221,18 +221,13 @@ struct dvb_usb_device_properties {
int (*fe_ioctl_override) (struct dvb_frontend *,
unsigned int, void *, unsigned int);
int (*init) (struct dvb_usb_device *);
- void (*disconnect) (struct dvb_usb_device *);
+ void (*exit) (struct dvb_usb_device *);
int (*get_rc_config) (struct dvb_usb_device *, struct dvb_usb_rc *);
#define DVB_USB_FE_TS_TYPE_188 0
#define DVB_USB_FE_TS_TYPE_204 1
#define DVB_USB_FE_TS_TYPE_RAW 2
int (*get_stream_config) (struct dvb_frontend *, u8 *,
struct usb_data_stream_properties *);
-
- struct i2c_algorithm *i2c_algo;
-
- int generic_bulk_ctrl_endpoint;
- int generic_bulk_ctrl_endpoint_response;
};
/**
@@ -247,12 +242,12 @@ struct dvb_usb_device_properties {
*/
#define MAX_NO_URBS_FOR_DATA_STREAM 10
struct usb_data_stream {
- struct usb_device *udev;
- struct usb_data_stream_properties props;
+ struct usb_device *udev;
+ struct usb_data_stream_properties props;
#define USB_STATE_INIT 0x00
#define USB_STATE_URB_BUF 0x01
- int state;
+ u8 state;
void (*complete) (struct usb_data_stream *, u8 *, size_t);
@@ -297,26 +292,23 @@ struct usb_data_stream {
struct dvb_usb_adapter {
const struct dvb_usb_adapter_properties *props;
struct usb_data_stream stream;
- u8 id;
+ u8 id;
u8 ts_type;
- int pid_filtering;
- int feed_count;
- int max_feed_count;
-
- /* sync frontend and streaming as those are different tasks */
- struct mutex sync_mutex;
+ bool pid_filtering;
+ u8 feed_count;
+ u8 max_feed_count;
+ s8 active_fe;
/* dvb */
struct dvb_adapter dvb_adap;
struct dmxdev dmxdev;
struct dvb_demux demux;
struct dvb_net dvb_net;
+ struct mutex sync_mutex;
struct dvb_frontend *fe[MAX_NO_OF_FE_PER_ADAP];
int (*fe_init[MAX_NO_OF_FE_PER_ADAP]) (struct dvb_frontend *);
int (*fe_sleep[MAX_NO_OF_FE_PER_ADAP]) (struct dvb_frontend *);
-
- int active_fe;
};
/**
@@ -346,11 +338,12 @@ struct dvb_usb_device {
const struct dvb_usb_device_properties *props;
const char *name;
const char *rc_map;
- struct dvb_usb_rc rc;
+
struct usb_device *udev;
+ struct usb_interface *intf;
+ struct dvb_usb_rc rc;
struct work_struct probe_work;
pid_t work_pid;
- struct usb_interface *intf;
int powered;
/* locking */
diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_core.c b/drivers/media/dvb/dvb-usb/dvb_usb_core.c
index f3e1ec2c473..42473e1dbac 100644
--- a/drivers/media/dvb/dvb-usb/dvb_usb_core.c
+++ b/drivers/media/dvb/dvb-usb/dvb_usb_core.c
@@ -12,22 +12,22 @@
* see Documentation/dvb/README.dvb-usb for more information
*/
#include "dvb_usb_common.h"
-#include <linux/usb/input.h>
int dvb_usbv2_disable_rc_polling;
module_param_named(disable_rc_polling, dvb_usbv2_disable_rc_polling, int, 0644);
MODULE_PARM_DESC(disable_rc_polling,
- "disable remote control polling (default: 0).");
+ "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_PARM_DESC(force_pid_filter_usage, "force all DVB USB devices to use a " \
+ "PID filter, if any (default: 0)");
static int dvb_usbv2_download_firmware(struct dvb_usb_device *d, const char *name)
{
int ret;
const struct firmware *fw;
+ pr_debug("%s:\n", __func__);
if (!d->props->download_firmware) {
ret = -EINVAL;
@@ -36,10 +36,10 @@ static int dvb_usbv2_download_firmware(struct dvb_usb_device *d, const char *nam
ret = request_firmware(&fw, name, &d->udev->dev);
if (ret < 0) {
- pr_err("%s: did not find the firmware file. (%s) " \
+ pr_err("%s: Did not find the firmware file '%s'. " \
"Please see linux/Documentation/dvb/ for " \
- "more details on firmware-problems. (%d)\n",
- KBUILD_MODNAME, name, ret);
+ "more details on firmware-problems. Status " \
+ "%d\n", KBUILD_MODNAME, name, ret);
goto err;
}
@@ -47,9 +47,7 @@ static int dvb_usbv2_download_firmware(struct dvb_usb_device *d, const char *nam
name);
ret = d->props->download_firmware(d, fw);
-
release_firmware(fw);
-
if (ret < 0)
goto err;
@@ -62,7 +60,6 @@ err:
static int dvb_usbv2_i2c_init(struct dvb_usb_device *d)
{
int ret;
-
pr_debug("%s:\n", __func__);
if (!d->props->i2c_algo)
@@ -103,29 +100,27 @@ static void dvb_usb_read_remote_control(struct work_struct *work)
struct dvb_usb_device, rc_query_work.work);
int ret;
- /* 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
+ /*
+ * When the parameter has been set to 1 via sysfs while the
+ * driver was running, or when bulk mode is enabled after IR init.
*/
if (dvb_usbv2_disable_rc_polling || d->rc.bulk_mode)
return;
ret = d->rc.query(d);
- if (ret < 0)
- pr_err("%s: error %d while querying for an remote control " \
- "event\n", KBUILD_MODNAME, ret);
+ if (ret < 0) {
+ pr_err("%s: rc.query() failed=%d\n", KBUILD_MODNAME, ret);
+ return; /* stop polling */
+ }
schedule_delayed_work(&d->rc_query_work,
- msecs_to_jiffies(d->rc.interval));
+ msecs_to_jiffies(d->rc.interval));
}
static int dvb_usbv2_remote_init(struct dvb_usb_device *d)
{
int ret;
struct rc_dev *dev;
-
pr_debug("%s:\n", __func__);
if (dvb_usbv2_disable_rc_polling || !d->props->get_rc_config)
@@ -142,7 +137,7 @@ static int dvb_usbv2_remote_init(struct dvb_usb_device *d)
}
dev->dev.parent = &d->udev->dev;
- dev->input_name = "IR-receiver inside an USB DVB receiver";
+ dev->input_name = d->name;
usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys));
strlcat(d->rc_phys, "/ir0", sizeof(d->rc_phys));
dev->input_phys = d->rc_phys;
@@ -153,13 +148,10 @@ static int dvb_usbv2_remote_init(struct dvb_usb_device *d)
dev->allowed_protos = d->rc.allowed_protos;
dev->change_protocol = d->rc.change_protocol;
dev->priv = d;
- /* select used keymap */
if (d->rc.map_name)
dev->map_name = d->rc.map_name;
- else if (d->rc_map)
- dev->map_name = d->rc_map;
else
- dev->map_name = RC_MAP_EMPTY; /* keep rc enabled */
+ dev->map_name = d->rc_map;
ret = rc_register_device(dev);
if (ret < 0) {
@@ -235,9 +227,8 @@ int dvb_usbv2_adapter_stream_init(struct dvb_usb_adapter *adap)
int dvb_usbv2_adapter_stream_exit(struct dvb_usb_adapter *adap)
{
pr_debug("%s: adap=%d\n", __func__, adap->id);
- usb_urb_exitv2(&adap->stream);
- return 0;
+ return usb_urb_exitv2(&adap->stream);
}
static inline int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed,
@@ -369,7 +360,7 @@ int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap)
if (ret < 0) {
pr_debug("%s: dvb_register_adapter() failed=%d\n", __func__,
ret);
- goto err;
+ goto err_dvb_register_adapter;
}
adap->dvb_adap.priv = adap;
@@ -378,7 +369,7 @@ int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap)
ret = d->props->read_mac_address(adap,
adap->dvb_adap.proposed_mac);
if (ret < 0)
- goto err_dmx;
+ goto err_dvb_dmx_init;
pr_info("%s: MAC address: %pM\n", KBUILD_MODNAME,
adap->dvb_adap.proposed_mac);
@@ -387,8 +378,7 @@ int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap)
adap->demux.dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING;
adap->demux.priv = adap;
adap->demux.filternum = 0;
- if (adap->demux.filternum < adap->max_feed_count)
- adap->demux.filternum = adap->max_feed_count;
+ adap->demux.filternum = adap->max_feed_count;
adap->demux.feednum = adap->demux.filternum;
adap->demux.start_feed = dvb_usb_start_feed;
adap->demux.stop_feed = dvb_usb_stop_feed;
@@ -396,7 +386,7 @@ int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap)
ret = dvb_dmx_init(&adap->demux);
if (ret < 0) {
pr_err("%s: dvb_dmx_init() failed=%d\n", KBUILD_MODNAME, ret);
- goto err_dmx;
+ goto err_dvb_dmx_init;
}
adap->dmxdev.filternum = adap->demux.filternum;
@@ -406,25 +396,25 @@ int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap)
if (ret < 0) {
pr_err("%s: dvb_dmxdev_init() failed=%d\n", KBUILD_MODNAME,
ret);
- goto err_dmx_dev;
+ goto err_dvb_dmxdev_init;
}
ret = dvb_net_init(&adap->dvb_adap, &adap->dvb_net, &adap->demux.dmx);
if (ret < 0) {
pr_err("%s: dvb_net_init() failed=%d\n", KBUILD_MODNAME, ret);
- goto err_net_init;
+ goto err_dvb_net_init;
}
mutex_init(&adap->sync_mutex);
return 0;
-err_net_init:
+err_dvb_net_init:
dvb_dmxdev_release(&adap->dmxdev);
-err_dmx_dev:
+err_dvb_dmxdev_init:
dvb_dmx_release(&adap->demux);
-err_dmx:
+err_dvb_dmx_init:
dvb_unregister_adapter(&adap->dvb_adap);
-err:
+err_dvb_register_adapter:
adap->dvb_adap.priv = NULL;
return ret;
}
@@ -468,7 +458,7 @@ err:
return ret;
}
-static int dvb_usb_fe_wakeup(struct dvb_frontend *fe)
+static int dvb_usb_fe_init(struct dvb_frontend *fe)
{
int ret;
struct dvb_usb_adapter *adap = fe->dvb->priv;
@@ -560,10 +550,9 @@ int dvb_usbv2_adapter_frontend_init(struct dvb_usb_adapter *adap)
for (i = 0; i < MAX_NO_OF_FE_PER_ADAP && adap->fe[i]; i++) {
adap->fe[i]->id = i;
-
/* re-assign sleep and wakeup functions */
adap->fe_init[i] = adap->fe[i]->ops.init;
- adap->fe[i]->ops.init = dvb_usb_fe_wakeup;
+ adap->fe[i]->ops.init = dvb_usb_fe_init;
adap->fe_sleep[i] = adap->fe[i]->ops.sleep;
adap->fe[i]->ops.sleep = dvb_usb_fe_sleep;
@@ -699,7 +688,6 @@ err:
static int dvb_usbv2_adapter_exit(struct dvb_usb_device *d)
{
int i;
-
pr_debug("%s:\n", __func__);
for (i = MAX_NO_OF_ADAPTER_PER_DEVICE - 1; i >= 0; i--) {
@@ -727,7 +715,8 @@ static int dvb_usbv2_exit(struct dvb_usb_device *d)
static int dvb_usbv2_init(struct dvb_usb_device *d)
{
- int ret = 0;
+ int ret;
+ pr_debug("%s:\n", __func__);
dvb_usbv2_device_power_ctrl(d, 1);
@@ -770,7 +759,6 @@ err:
* is this routine. Due to that we delay actual operation using workqueue
* and return always success here.
*/
-
static void dvb_usbv2_init_work(struct work_struct *work)
{
int ret;
@@ -778,7 +766,6 @@ static void dvb_usbv2_init_work(struct work_struct *work)
container_of(work, struct dvb_usb_device, probe_work);
d->work_pid = current->pid;
-
pr_debug("%s: work_pid=%d\n", __func__, d->work_pid);
if (d->props->size_of_priv) {
@@ -817,7 +804,8 @@ static void dvb_usbv2_init_work(struct work_struct *work)
*/
return;
} else {
- /* Unexpected error. We must unregister driver
+ /*
+ * Unexpected error. We must unregister driver
* manually from the device, because device is
* already register by returning from probe()
* with success. usb_driver_release_interface()
@@ -844,7 +832,6 @@ static void dvb_usbv2_init_work(struct work_struct *work)
err_usb_driver_release_interface:
pr_info("%s: '%s' error while loading driver (%d)\n", KBUILD_MODNAME,
d->name, ret);
- /* it finally calls disconnect() which frees mem */
usb_driver_release_interface(to_usb_driver(d->intf->dev.driver),
d->intf);
pr_debug("%s: failed=%d\n", __func__, ret);
@@ -909,8 +896,7 @@ EXPORT_SYMBOL(dvb_usbv2_probe);
void dvb_usbv2_disconnect(struct usb_interface *intf)
{
struct dvb_usb_device *d = usb_get_intfdata(intf);
- const char *name;
-
+ const char *name = d->name;
pr_debug("%s: pid=%d work_pid=%d\n", __func__, current->pid,
d->work_pid);
@@ -918,10 +904,9 @@ void dvb_usbv2_disconnect(struct usb_interface *intf)
if (d->work_pid != current->pid)
cancel_work_sync(&d->probe_work);
- if (d->props->disconnect)
- d->props->disconnect(d);
+ if (d->props->exit)
+ d->props->exit(d);
- name = d->name;
dvb_usbv2_exit(d);
pr_info("%s: '%s' successfully deinitialized and disconnected\n",
@@ -933,7 +918,6 @@ int dvb_usbv2_suspend(struct usb_interface *intf, pm_message_t msg)
{
struct dvb_usb_device *d = usb_get_intfdata(intf);
int i;
-
pr_debug("%s:\n", __func__);
/* stop remote controller poll */
@@ -955,7 +939,6 @@ int dvb_usbv2_resume(struct usb_interface *intf)
{
struct dvb_usb_device *d = usb_get_intfdata(intf);
int i;
-
pr_debug("%s:\n", __func__);
/* start streaming */
diff --git a/drivers/media/dvb/dvb-usb/usb_urb.c b/drivers/media/dvb/dvb-usb/usb_urb.c
index 32e80be2168..d860dac2a83 100644
--- a/drivers/media/dvb/dvb-usb/usb_urb.c
+++ b/drivers/media/dvb/dvb-usb/usb_urb.c
@@ -38,7 +38,7 @@ static void usb_urb_complete(struct urb *urb)
case -ESHUTDOWN:
return;
default: /* error */
- pr_debug("%s: URB completition failed=%d\n", __func__,
+ pr_debug("%s: urb completition failed=%d\n", __func__,
urb->status);
break;
}
@@ -76,7 +76,7 @@ int usb_urb_killv2(struct usb_data_stream *stream)
{
int i;
for (i = 0; i < stream->urbs_submitted; i++) {
- pr_debug("%s: kill URB=%d\n", __func__, i);
+ pr_debug("%s: kill urb=%d\n", __func__, i);
/* stop the URB */
usb_kill_urb(stream->urb_list[i]);
}
@@ -96,10 +96,10 @@ int usb_urb_submitv2(struct usb_data_stream *stream,
}
for (i = 0; i < stream->urbs_initialized; i++) {
- pr_debug("%s: submit URB=%d\n", __func__, i);
+ pr_debug("%s: submit urb=%d\n", __func__, i);
ret = usb_submit_urb(stream->urb_list[i], GFP_ATOMIC);
if (ret) {
- pr_err("%s: could not submit URB no. %d - get them " \
+ pr_err("%s: could not submit urb no. %d - get them " \
"all back\n", KBUILD_MODNAME, i);
usb_urb_killv2(stream);
return ret;
@@ -115,9 +115,9 @@ int usb_urb_free_urbs(struct usb_data_stream *stream)
usb_urb_killv2(stream);
- for (i = 0; i < stream->urbs_initialized; i++) {
- if (stream->urb_list[i] != NULL) {
- pr_debug("%s: free URB=%d\n", __func__, i);
+ for (i = stream->urbs_initialized - 1; i >= 0; i--) {
+ if (stream->urb_list[i]) {
+ pr_debug("%s: free urb=%d\n", __func__, i);
/* free the URBs */
usb_free_urb(stream->urb_list[i]);
}
@@ -133,7 +133,7 @@ static int usb_urb_alloc_bulk_urbs(struct usb_data_stream *stream)
/* allocate the URBs */
for (i = 0; i < stream->props.count; i++) {
- pr_debug("%s: alloc URB=%d\n", __func__, i);
+ pr_debug("%s: alloc urb=%d\n", __func__, i);
stream->urb_list[i] = usb_alloc_urb(0, GFP_ATOMIC);
if (!stream->urb_list[i]) {
pr_debug("%s: failed\n", __func__);
@@ -164,7 +164,7 @@ static int usb_urb_alloc_isoc_urbs(struct usb_data_stream *stream)
for (i = 0; i < stream->props.count; i++) {
struct urb *urb;
int frame_offset = 0;
- pr_debug("%s: alloc URB=%d\n", __func__, i);
+ pr_debug("%s: alloc urb=%d\n", __func__, i);
stream->urb_list[i] = usb_alloc_urb(
stream->props.u.isoc.framesperurb, GFP_ATOMIC);
if (!stream->urb_list[i]) {
@@ -229,17 +229,17 @@ int usb_alloc_stream_buffers(struct usb_data_stream *stream, int num,
__func__, num * size);
for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) {
- pr_debug("%s: alloc buf=%d\n", __func__, 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) {
- pr_debug("%s: failed\n", __func__);
+ if (!stream->buf_list[stream->buf_num]) {
+ pr_debug("%s: alloc buf=%d failed\n", __func__,
+ stream->buf_num);
usb_free_stream_buffers(stream);
return -ENOMEM;
}
- pr_debug("%s: buf %d: %p (dma %llu)\n", __func__,
+ pr_debug("%s: alloc buf=%d %p (dma %llu)\n", __func__,
stream->buf_num,
stream->buf_list[stream->buf_num],
(long long)stream->dma_addr[stream->buf_num]);
@@ -255,7 +255,7 @@ int usb_urb_reconfig(struct usb_data_stream *stream,
{
int buf_size;
- if (props == NULL)
+ if (!props)
return 0;
/* check allocated buffers are large enough for the request */
@@ -293,7 +293,7 @@ int usb_urb_reconfig(struct usb_data_stream *stream,
return 0;
}
- pr_debug("%s: re-alloc URBs\n", __func__);
+ pr_debug("%s: re-alloc urbs\n", __func__);
usb_urb_free_urbs(stream);
memcpy(&stream->props, props, sizeof(*props));
@@ -310,7 +310,7 @@ int usb_urb_initv2(struct usb_data_stream *stream,
{
int ret;
- if (stream == NULL || props == NULL)
+ if (!stream || !props)
return -EINVAL;
memcpy(&stream->props, props, sizeof(*props));
@@ -318,7 +318,7 @@ int usb_urb_initv2(struct usb_data_stream *stream,
usb_clear_halt(stream->udev, usb_rcvbulkpipe(stream->udev,
stream->props.endpoint));
- if (stream->complete == NULL) {
+ if (!stream->complete) {
pr_err("%s: there is no data callback - this doesn't make " \
"sense\n", KBUILD_MODNAME);
return -EINVAL;
@@ -341,7 +341,7 @@ int usb_urb_initv2(struct usb_data_stream *stream,
return usb_urb_alloc_isoc_urbs(stream);
default:
- pr_err("%s: unknown URB-type for data transfer\n",
+ pr_err("%s: unknown urb-type for data transfer\n",
KBUILD_MODNAME);
return -EINVAL;
}