summaryrefslogtreecommitdiff
path: root/drivers/media/dvb/dvb-usb
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2012-06-18 23:42:53 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-08-04 07:56:36 -0300
commita0921af7eb2eced1639fc1e1befdf703e7bec95a (patch)
treef284c5b1fbef5987c75d3b70e803aa28623d084f /drivers/media/dvb/dvb-usb
parentb905a2a13307035a4a5c9a93a3607e51e6736db2 (diff)
[media] dvb_usb_v2: use identify_state() to resolve firmware name
Merge get_firmware_name() to identify_state(). It is wise to resolve firmware name in that routine as it does decision wether or not to load firmware at all. It is one very rarely needed callback less. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/dvb-usb')
-rw-r--r--drivers/media/dvb/dvb-usb/af9015.c2
-rw-r--r--drivers/media/dvb/dvb-usb/af9035.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dvb_usb.h11
-rw-r--r--drivers/media/dvb/dvb-usb/dvb_usb_init.c76
-rw-r--r--drivers/media/dvb/dvb-usb/ec168.c2
5 files changed, 41 insertions, 52 deletions
diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
index 101b399e76a1..6cecd755f1d9 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -324,7 +324,7 @@ static struct i2c_algorithm af9015_i2c_algo = {
.functionality = af9015_i2c_func,
};
-static int af9015_identify_state(struct dvb_usb_device *d)
+static int af9015_identify_state(struct dvb_usb_device *d, const char **name)
{
int ret;
u8 reply;
diff --git a/drivers/media/dvb/dvb-usb/af9035.c b/drivers/media/dvb/dvb-usb/af9035.c
index ba2a0c1a65a2..b030055d14a3 100644
--- a/drivers/media/dvb/dvb-usb/af9035.c
+++ b/drivers/media/dvb/dvb-usb/af9035.c
@@ -278,7 +278,7 @@ static struct i2c_algorithm af9035_i2c_algo = {
.functionality = af9035_i2c_functionality,
};
-static int af9035_identify_state(struct dvb_usb_device *d)
+static int af9035_identify_state(struct dvb_usb_device *d, const char **name)
{
int ret;
u8 wbuf[1] = { 1 };
diff --git a/drivers/media/dvb/dvb-usb/dvb_usb.h b/drivers/media/dvb/dvb-usb/dvb_usb.h
index 3a54fc3da702..aecba307105e 100644
--- a/drivers/media/dvb/dvb-usb/dvb_usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb_usb.h
@@ -197,12 +197,13 @@ struct dvb_usb_device_properties {
struct module *owner;
short *adapter_nr;
u8 bInterfaceNumber;
-
int size_of_priv;
+#define WARM 0
+#define COLD 1
+ int (*identify_state) (struct dvb_usb_device *, const char **);
const char *firmware;
- int (*get_firmware_name) (struct dvb_usb_device *, const char **);
-#define RECONNECTS_USB 1
+#define RECONNECTS_USB 1
int (*download_firmware) (struct dvb_usb_device *,
const struct firmware *);
@@ -219,10 +220,6 @@ struct dvb_usb_device_properties {
int (*streaming_ctrl) (struct dvb_usb_adapter *, int);
int (*fe_ioctl_override) (struct dvb_frontend *,
unsigned int, void *, unsigned int);
-
-#define WARM 0
-#define COLD 1
- int (*identify_state) (struct dvb_usb_device *);
int (*init) (struct dvb_usb_device *);
void (*disconnect) (struct dvb_usb_device *);
int (*get_rc_config) (struct dvb_usb_device *, struct dvb_usb_rc *);
diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_init.c b/drivers/media/dvb/dvb-usb/dvb_usb_init.c
index 2624daa94b4f..24e1f2970d8e 100644
--- a/drivers/media/dvb/dvb-usb/dvb_usb_init.c
+++ b/drivers/media/dvb/dvb-usb/dvb_usb_init.c
@@ -24,19 +24,10 @@ module_param_named(force_pid_filter_usage, dvb_usb_force_pid_filter_usage,
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)
+static int dvb_usbv2_download_firmware(struct dvb_usb_device *d, const char *name)
{
int ret;
- const struct firmware *fw = NULL;
- const char *name;
-
- /* resolve firmware name */
- name = d->props->firmware;
- if (d->props->get_firmware_name) {
- ret = d->props->get_firmware_name(d, &name);
- if (ret < 0)
- goto err;
- }
+ const struct firmware *fw;
if (!d->props->download_firmware) {
ret = -EINVAL;
@@ -395,7 +386,6 @@ static void dvb_usbv2_init_work(struct work_struct *work)
int ret;
struct dvb_usb_device *d =
container_of(work, struct dvb_usb_device, probe_work);
- bool cold = false;
d->work_pid = current->pid;
@@ -411,40 +401,42 @@ static void dvb_usbv2_init_work(struct work_struct *work)
}
if (d->props->identify_state) {
- ret = d->props->identify_state(d);
+ const char *name = NULL;
+ ret = d->props->identify_state(d, &name);
if (ret == 0) {
;
} else if (ret == COLD) {
- cold = true;
- ret = 0;
- } else {
- goto err_usb_driver_release_interface;
- }
- }
-
- if (cold) {
- pr_info("%s: found a '%s' in cold state\n",
- KBUILD_MODNAME, d->name);
- ret = dvb_usbv2_download_firmware(d);
- if (ret == 0) {
- /* device is warm, continue initialization */
- ;
- } else if (ret == RECONNECTS_USB) {
- /*
- * USB core will call disconnect() and then probe()
- * as device reconnects itself from the USB bus.
- * disconnect() will release all driver resources
- * and probe() is called for 'new' device. As 'new'
- * device is warm we should never go here again.
- */
- return;
+ pr_info("%s: found a '%s' in cold state\n",
+ KBUILD_MODNAME, d->name);
+
+ if (!name)
+ name = d->props->firmware;
+
+ ret = dvb_usbv2_download_firmware(d, name);
+ if (ret == 0) {
+ /* device is warm, continue initialization */
+ ;
+ } else if (ret == RECONNECTS_USB) {
+ /*
+ * USB core will call disconnect() and then
+ * probe() as device reconnects itself from the
+ * USB bus. disconnect() will release all driver
+ * resources and probe() is called for 'new'
+ * device. As 'new' device is warm we should
+ * never go here again.
+ */
+ return;
+ } else {
+ /* 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()
+ * finally calls disconnect() in order to free
+ * resources.
+ */
+ goto err_usb_driver_release_interface;
+ }
} else {
- /* Unexpected fatal error. We must unregister driver
- * manually from the device, because device is already
- * register by returning from probe() with success.
- * usb_driver_release_interface() finally calls
- * disconnect() in order to free resources.
- */
goto err_usb_driver_release_interface;
}
}
diff --git a/drivers/media/dvb/dvb-usb/ec168.c b/drivers/media/dvb/dvb-usb/ec168.c
index c05f09c529e3..1fb84728a27d 100644
--- a/drivers/media/dvb/dvb-usb/ec168.c
+++ b/drivers/media/dvb/dvb-usb/ec168.c
@@ -182,7 +182,7 @@ static struct i2c_algorithm ec168_i2c_algo = {
};
/* Callbacks for DVB USB */
-static int ec168_identify_state(struct dvb_usb_device *d)
+static int ec168_identify_state(struct dvb_usb_device *d, const char **name)
{
int ret;
u8 reply;