]> git.karo-electronics.de Git - linux-beck.git/commitdiff
[media] dvb_usb_v2: pass device name too using (struct usb_device_id)
authorAntti Palosaari <crope@iki.fi>
Thu, 24 May 2012 23:00:28 +0000 (20:00 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sat, 4 Aug 2012 10:56:21 +0000 (07:56 -0300)
Pass all the needed data to the DVB USB core using
(struct usb_device_id) .driver_info. That simplifies
old code a lot and saves memory as all device IDs and
names are not defined inside (struct dvb_usb_device_properties)
as earlier.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/dvb/dvb-usb/dvb_usb.h
drivers/media/dvb/dvb-usb/dvb_usb_dvb.c
drivers/media/dvb/dvb-usb/dvb_usb_i2c.c
drivers/media/dvb/dvb-usb/dvb_usb_init.c

index 149e45f034f864f869523ac44b511963a3866d18..dc9d09bce107bb89bc3c7e46fbab2e76a9a6f594 100644 (file)
 #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
- * @name: real name of the box, regardless which DVB USB device class is in use
- * @cold_ids: array of struct usb_device_id which describe the device in
- *  pre-firmware state
- * @warm_ids: array of struct usb_device_id which describe the device in
- *  post-firmware state
- *
- * Each DVB USB device class can have one or more actual devices, this struct
- * assigns a name to it.
- */
-struct dvb_usb_device_description {
+struct dvb_usb_driver_info {
        const char *name;
-
-#define DVB_USB_ID_MAX_NUM 15
-       struct usb_device_id *cold_ids[DVB_USB_ID_MAX_NUM];
-       struct usb_device_id *warm_ids[DVB_USB_ID_MAX_NUM];
+       const struct dvb_usb_device_properties *props;
 };
 
 static inline u8 rc5_custom(struct rc_map_table *key)
@@ -262,10 +248,6 @@ enum dvb_usb_mode {
  *  the generic_bulk_ctrl_endpoint. When this is non-zero, this will be used
  *  instead of the generic_bulk_ctrl_endpoint when reading usb responses in
  *  the dvb_usb_generic_rw helper function.
- *
- * @num_device_descs: number of struct dvb_usb_device_description in @devices
- * @devices: array of struct dvb_usb_device_description compatibles with these
- *  properties.
  */
 #define MAX_NO_OF_ADAPTER_PER_DEVICE 2
 struct dvb_usb_device_properties {
@@ -309,9 +291,6 @@ struct dvb_usb_device_properties {
 
        int generic_bulk_ctrl_endpoint;
        int generic_bulk_ctrl_endpoint_response;
-
-       int num_device_descs;
-       struct dvb_usb_device_description devices[12];
 };
 
 /**
@@ -437,7 +416,7 @@ struct dvb_usb_adapter {
  */
 struct dvb_usb_device {
        struct dvb_usb_device_properties props;
-       struct dvb_usb_device_description *desc;
+       const char *name;
 
        struct usb_device *udev;
 
index 832ef88ab24874a7aa20146bca72532a7cc13bc3..85db3f46e77dbf2cbe7ea2268b1be9bb0c86d48d 100644 (file)
@@ -103,7 +103,7 @@ static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
 int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap)
 {
        int i;
-       int ret = dvb_register_adapter(&adap->dvb_adap, adap->dev->desc->name,
+       int ret = dvb_register_adapter(&adap->dvb_adap, adap->dev->name,
                                       adap->dev->props.owner,
                                       &adap->dev->udev->dev,
                                       adap->dev->props.adapter_nr);
@@ -236,7 +236,7 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap)
                if (adap->props.fe[i].frontend_attach == NULL) {
                        err("strange: '%s' #%d,%d " \
                            "doesn't want to attach a frontend.",
-                           adap->dev->desc->name, adap->id, i);
+                           adap->dev->name, adap->id, i);
 
                        return 0;
                }
@@ -246,7 +246,7 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap)
                        /* only print error when there is no FE at all */
                        if (i == 0)
                                err("no frontend was attached by '%s'",
-                                       adap->dev->desc->name);
+                                       adap->dev->name);
 
                        return 0;
                }
index 58e5a41822451a7a7a242b5548103e4d9e954ad4..6b272c861b4a47e774e2404d79fe8c4098808d21 100644 (file)
@@ -19,7 +19,7 @@ int dvb_usb_i2c_init(struct dvb_usb_device *d)
                return -EINVAL;
        }
 
-       strlcpy(d->i2c_adap.name, d->desc->name, sizeof(d->i2c_adap.name));
+       strlcpy(d->i2c_adap.name, d->name, sizeof(d->i2c_adap.name));
        d->i2c_adap.algo      = d->props.i2c_algo;
        d->i2c_adap.algo_data = NULL;
        d->i2c_adap.dev.parent = &d->udev->dev;
index 14cfc1e35144e5391b2f0fd643820772c4bb8b74..3314f36208ff06fb85ae9ee6ae1770abeacba893 100644 (file)
@@ -198,49 +198,6 @@ static int dvb_usb_init(struct dvb_usb_device *d)
        return 0;
 }
 
-/* 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)
-{
-       int i, j;
-       struct dvb_usb_device_description *desc = NULL;
-
-       *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)) {
-                               *cold = true;
-                               desc = &props->devices[i];
-                               break;
-                       }
-               }
-
-               if (desc != NULL)
-                       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);
-
-                       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)) {
-                               *cold = false;
-                               desc = &props->devices[i];
-                               break;
-                       }
-               }
-       }
-
-       return desc;
-}
-
 int dvb_usb_device_power_ctrl(struct dvb_usb_device *d, int onoff)
 {
        if (onoff)
@@ -265,11 +222,11 @@ int dvb_usbv2_device_init(struct usb_interface *intf,
 {
        struct usb_device *udev = interface_to_usbdev(intf);
        struct dvb_usb_device *d = NULL;
-       struct dvb_usb_device_description *desc = NULL;
-       struct dvb_usb_device_properties *props =
-                       (struct dvb_usb_device_properties *) id->driver_info;
+       struct dvb_usb_driver_info *driver_info =
+                       (struct dvb_usb_driver_info *) id->driver_info;
+       const struct dvb_usb_device_properties *props = driver_info->props;
        int ret = -ENOMEM;
-       bool cold;
+       bool cold = false;
 
        d = kzalloc(sizeof(struct dvb_usb_device), GFP_KERNEL);
        if (d == NULL) {
@@ -278,6 +235,7 @@ int dvb_usbv2_device_init(struct usb_interface *intf,
        }
 
        d->udev = udev;
+       d->name = driver_info->name;
        memcpy(&d->props, props, sizeof(struct dvb_usb_device_properties));
 
        if (d->props.size_of_priv > 0) {
@@ -289,18 +247,6 @@ int dvb_usbv2_device_init(struct usb_interface *intf,
                }
        }
 
-       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;
-       }
-
-       d->desc = desc;
-
        if (d->props.identify_state) {
                ret = d->props.identify_state(d);
                if (ret == 0) {
@@ -315,7 +261,7 @@ 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);
+                               d->name);
                ret = dvb_usb_download_firmware(d);
                if (ret == 0) {
                        ;
@@ -327,16 +273,16 @@ int dvb_usbv2_device_init(struct usb_interface *intf,
                }
        }
 
-       info("found a '%s' in warm state.", desc->name);
+       info("found a '%s' in warm state.", d->name);
 
        usb_set_intfdata(intf, d);
 
        ret = dvb_usb_init(d);
 
        if (ret == 0)
-               info("%s successfully initialized and connected.", desc->name);
+               info("%s successfully initialized and connected.", d->name);
        else
-               info("%s error while loading driver (%d)", desc->name, ret);
+               info("%s error while loading driver (%d)", d->name, ret);
 
        return 0;
 
@@ -351,15 +297,14 @@ EXPORT_SYMBOL(dvb_usbv2_device_init);
 void dvb_usbv2_device_exit(struct usb_interface *intf)
 {
        struct dvb_usb_device *d = usb_get_intfdata(intf);
-       const char *name = "generic DVB-USB module";
+       const char *name;
 
        usb_set_intfdata(intf, NULL);
-       if (d != NULL && d->desc != NULL) {
-               name = d->desc->name;
+       if (d) {
+               name = d->name;
                dvb_usb_exit(d);
        }
        info("%s successfully deinitialized and disconnected.", name);
-
 }
 EXPORT_SYMBOL(dvb_usbv2_device_exit);