[media] dvb_usb_v2: get rid of dvb_usb_device state
authorAntti Palosaari <crope@iki.fi>
Fri, 15 Jun 2012 04:38:28 +0000 (01:38 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sat, 4 Aug 2012 10:56:33 +0000 (07:56 -0300)
Remove state from struct dvb_usb_device as we can live without.
Add some debug logs.

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_init.c

index 62097f38bb16fb6c72318307d1df676dcde027f9..8ec8deefaf6ab5ad2f1a1b0f6f8ba18996f38d95 100644 (file)
@@ -324,12 +324,6 @@ struct dvb_usb_device {
        struct work_struct probe_work;
        pid_t work_pid;
        struct usb_interface *intf;
-
-#define DVB_USB_STATE_INIT        0x000
-#define DVB_USB_STATE_I2C         0x001
-#define DVB_USB_STATE_DVB         0x002
-       int state;
-
        int powered;
 
        /* locking */
index 5da4233501f01639868dc721ae7b5c5df54e759e..1297b95aff48aaa1a1fff4e680ee58a2b951a037 100644 (file)
@@ -72,26 +72,24 @@ static int dvb_usbv2_i2c_init(struct dvb_usb_device *d)
 {
        int ret;
 
-       if (!d->props->i2c_algo) {
-               ret = 0;
-               goto err;
-       }
+       pr_debug("%s:\n", __func__);
+
+       if (!d->props->i2c_algo)
+               return 0;
 
        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;
-
        i2c_set_adapdata(&d->i2c_adap, d);
 
        ret = i2c_add_adapter(&d->i2c_adap);
        if (ret < 0) {
-               pr_err("%s: i2c_add_adapter() failed\n", KBUILD_MODNAME);
+               d->i2c_adap.algo = NULL;
+               pr_err("%s: i2c_add_adapter() failed=%d\n", KBUILD_MODNAME,
+                               ret);
                goto err;
        }
 
-       d->state |= DVB_USB_STATE_I2C;
-
        return 0;
 err:
        pr_debug("%s: failed=%d\n", __func__, ret);
@@ -100,10 +98,10 @@ err:
 
 static int dvb_usbv2_i2c_exit(struct dvb_usb_device *d)
 {
-       if (d->state & DVB_USB_STATE_I2C)
-               i2c_del_adapter(&d->i2c_adap);
+       pr_debug("%s:\n", __func__);
 
-       d->state &= ~DVB_USB_STATE_I2C;
+       if (d->i2c_adap.algo)
+               i2c_del_adapter(&d->i2c_adap);
 
        return 0;
 }
@@ -282,7 +280,6 @@ static int dvb_usbv2_adapter_init(struct dvb_usb_device *d)
                        adap->dvb_adap.mfe_shared = 1;
 
                d->num_adapters_initialized++;
-               d->state |= DVB_USB_STATE_DVB;
        }
 
        return 0;
@@ -304,7 +301,6 @@ static int dvb_usbv2_adapter_exit(struct dvb_usb_device *d)
        }
 
        d->num_adapters_initialized = 0;
-       d->state &= ~DVB_USB_STATE_DVB;
 
        return 0;
 }
@@ -312,12 +308,11 @@ static int dvb_usbv2_adapter_exit(struct dvb_usb_device *d)
 /* general initialization functions */
 static int dvb_usbv2_exit(struct dvb_usb_device *d)
 {
-       pr_debug("%s: state before exiting everything: %x\n", __func__, d->state);
+       pr_debug("%s:\n", __func__);
+
        dvb_usbv2_remote_exit(d);
        dvb_usbv2_adapter_exit(d);
        dvb_usbv2_i2c_exit(d);
-       pr_debug("%s: state should be zero now: %x\n", __func__, d->state);
-       d->state = DVB_USB_STATE_INIT;
        kfree(d->priv);
        kfree(d);
 
@@ -328,9 +323,6 @@ static int dvb_usbv2_init(struct dvb_usb_device *d)
 {
        int ret = 0;
 
-       d->state = DVB_USB_STATE_INIT;
-
-       /* check the capabilities and set appropriate variables */
        dvb_usbv2_device_power_ctrl(d, 1);
 
        if (d->props->read_config) {