aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dvb-usb
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2012-06-18 22:42:53 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-08-04 06:56:36 -0400
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 = {
324 .functionality = af9015_i2c_func, 324 .functionality = af9015_i2c_func,
325}; 325};
326 326
327static int af9015_identify_state(struct dvb_usb_device *d) 327static int af9015_identify_state(struct dvb_usb_device *d, const char **name)
328{ 328{
329 int ret; 329 int ret;
330 u8 reply; 330 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 = {
278 .functionality = af9035_i2c_functionality, 278 .functionality = af9035_i2c_functionality,
279}; 279};
280 280
281static int af9035_identify_state(struct dvb_usb_device *d) 281static int af9035_identify_state(struct dvb_usb_device *d, const char **name)
282{ 282{
283 int ret; 283 int ret;
284 u8 wbuf[1] = { 1 }; 284 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 {
197 struct module *owner; 197 struct module *owner;
198 short *adapter_nr; 198 short *adapter_nr;
199 u8 bInterfaceNumber; 199 u8 bInterfaceNumber;
200
201 int size_of_priv; 200 int size_of_priv;
202 201
202#define WARM 0
203#define COLD 1
204 int (*identify_state) (struct dvb_usb_device *, const char **);
203 const char *firmware; 205 const char *firmware;
204 int (*get_firmware_name) (struct dvb_usb_device *, const char **); 206#define RECONNECTS_USB 1
205#define RECONNECTS_USB 1
206 int (*download_firmware) (struct dvb_usb_device *, 207 int (*download_firmware) (struct dvb_usb_device *,
207 const struct firmware *); 208 const struct firmware *);
208 209
@@ -219,10 +220,6 @@ struct dvb_usb_device_properties {
219 int (*streaming_ctrl) (struct dvb_usb_adapter *, int); 220 int (*streaming_ctrl) (struct dvb_usb_adapter *, int);
220 int (*fe_ioctl_override) (struct dvb_frontend *, 221 int (*fe_ioctl_override) (struct dvb_frontend *,
221 unsigned int, void *, unsigned int); 222 unsigned int, void *, unsigned int);
222
223#define WARM 0
224#define COLD 1
225 int (*identify_state) (struct dvb_usb_device *);
226 int (*init) (struct dvb_usb_device *); 223 int (*init) (struct dvb_usb_device *);
227 void (*disconnect) (struct dvb_usb_device *); 224 void (*disconnect) (struct dvb_usb_device *);
228 int (*get_rc_config) (struct dvb_usb_device *, struct dvb_usb_rc *); 225 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,
24MODULE_PARM_DESC(force_pid_filter_usage, "force all dvb-usb-devices to use a" \ 24MODULE_PARM_DESC(force_pid_filter_usage, "force all dvb-usb-devices to use a" \
25 " PID filter, if any (default: 0)."); 25 " PID filter, if any (default: 0).");
26 26
27static int dvb_usbv2_download_firmware(struct dvb_usb_device *d) 27static int dvb_usbv2_download_firmware(struct dvb_usb_device *d, const char *name)
28{ 28{
29 int ret; 29 int ret;
30 const struct firmware *fw = NULL; 30 const struct firmware *fw;
31 const char *name;
32
33 /* resolve firmware name */
34 name = d->props->firmware;
35 if (d->props->get_firmware_name) {
36 ret = d->props->get_firmware_name(d, &name);
37 if (ret < 0)
38 goto err;
39 }
40 31
41 if (!d->props->download_firmware) { 32 if (!d->props->download_firmware) {
42 ret = -EINVAL; 33 ret = -EINVAL;
@@ -395,7 +386,6 @@ static void dvb_usbv2_init_work(struct work_struct *work)
395 int ret; 386 int ret;
396 struct dvb_usb_device *d = 387 struct dvb_usb_device *d =
397 container_of(work, struct dvb_usb_device, probe_work); 388 container_of(work, struct dvb_usb_device, probe_work);
398 bool cold = false;
399 389
400 d->work_pid = current->pid; 390 d->work_pid = current->pid;
401 391
@@ -411,40 +401,42 @@ static void dvb_usbv2_init_work(struct work_struct *work)
411 } 401 }
412 402
413 if (d->props->identify_state) { 403 if (d->props->identify_state) {
414 ret = d->props->identify_state(d); 404 const char *name = NULL;
405 ret = d->props->identify_state(d, &name);
415 if (ret == 0) { 406 if (ret == 0) {
416 ; 407 ;
417 } else if (ret == COLD) { 408 } else if (ret == COLD) {
418 cold = true; 409 pr_info("%s: found a '%s' in cold state\n",
419 ret = 0; 410 KBUILD_MODNAME, d->name);
420 } else { 411
421 goto err_usb_driver_release_interface; 412 if (!name)
422 } 413 name = d->props->firmware;
423 } 414
424 415 ret = dvb_usbv2_download_firmware(d, name);
425 if (cold) { 416 if (ret == 0) {
426 pr_info("%s: found a '%s' in cold state\n", 417 /* device is warm, continue initialization */
427 KBUILD_MODNAME, d->name); 418 ;
428 ret = dvb_usbv2_download_firmware(d); 419 } else if (ret == RECONNECTS_USB) {
429 if (ret == 0) { 420 /*
430 /* device is warm, continue initialization */ 421 * USB core will call disconnect() and then
431 ; 422 * probe() as device reconnects itself from the
432 } else if (ret == RECONNECTS_USB) { 423 * USB bus. disconnect() will release all driver
433 /* 424 * resources and probe() is called for 'new'
434 * USB core will call disconnect() and then probe() 425 * device. As 'new' device is warm we should
435 * as device reconnects itself from the USB bus. 426 * never go here again.
436 * disconnect() will release all driver resources 427 */
437 * and probe() is called for 'new' device. As 'new' 428 return;
438 * device is warm we should never go here again. 429 } else {
439 */ 430 /* Unexpected error. We must unregister driver
440 return; 431 * manually from the device, because device is
432 * already register by returning from probe()
433 * with success. usb_driver_release_interface()
434 * finally calls disconnect() in order to free
435 * resources.
436 */
437 goto err_usb_driver_release_interface;
438 }
441 } else { 439 } else {
442 /* Unexpected fatal error. We must unregister driver
443 * manually from the device, because device is already
444 * register by returning from probe() with success.
445 * usb_driver_release_interface() finally calls
446 * disconnect() in order to free resources.
447 */
448 goto err_usb_driver_release_interface; 440 goto err_usb_driver_release_interface;
449 } 441 }
450 } 442 }
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 = {
182}; 182};
183 183
184/* Callbacks for DVB USB */ 184/* Callbacks for DVB USB */
185static int ec168_identify_state(struct dvb_usb_device *d) 185static int ec168_identify_state(struct dvb_usb_device *d, const char **name)
186{ 186{
187 int ret; 187 int ret;
188 u8 reply; 188 u8 reply;