aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorJarod Wilson <jarod@redhat.com>2011-01-19 16:10:14 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-01-31 09:18:04 -0500
commit7f2a06deaa22104a4cf4c0cc3d7c44c7e3228ef3 (patch)
treef2e9417bc951c6ae5f721a9283952c816174fec9 /drivers/media
parent86ee65948886e53b9fd336dec400f4b8f1704f7f (diff)
[media] hdpvr: fix up i2c device registration
We have to actually call i2c_new_device() once for each of the rx and tx addresses. Also improve error-handling and device remove i2c cleanup. Reviewed-by: Andy Walls <awalls@md.metrocast.net> Signed-off-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/hdpvr/hdpvr-core.c24
-rw-r--r--drivers/media/video/hdpvr/hdpvr-i2c.c30
-rw-r--r--drivers/media/video/hdpvr/hdpvr.h3
3 files changed, 41 insertions, 16 deletions
diff --git a/drivers/media/video/hdpvr/hdpvr-core.c b/drivers/media/video/hdpvr/hdpvr-core.c
index a6572e5ae369..a27d93b503a5 100644
--- a/drivers/media/video/hdpvr/hdpvr-core.c
+++ b/drivers/media/video/hdpvr/hdpvr-core.c
@@ -283,6 +283,7 @@ static int hdpvr_probe(struct usb_interface *interface,
283 struct hdpvr_device *dev; 283 struct hdpvr_device *dev;
284 struct usb_host_interface *iface_desc; 284 struct usb_host_interface *iface_desc;
285 struct usb_endpoint_descriptor *endpoint; 285 struct usb_endpoint_descriptor *endpoint;
286 struct i2c_client *client;
286 size_t buffer_size; 287 size_t buffer_size;
287 int i; 288 int i;
288 int retval = -ENOMEM; 289 int retval = -ENOMEM;
@@ -381,13 +382,21 @@ static int hdpvr_probe(struct usb_interface *interface,
381#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 382#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
382 retval = hdpvr_register_i2c_adapter(dev); 383 retval = hdpvr_register_i2c_adapter(dev);
383 if (retval < 0) { 384 if (retval < 0) {
384 v4l2_err(&dev->v4l2_dev, "registering i2c adapter failed\n"); 385 v4l2_err(&dev->v4l2_dev, "i2c adapter register failed\n");
385 goto error; 386 goto error;
386 } 387 }
387 388
388 retval = hdpvr_register_i2c_ir(dev); 389 client = hdpvr_register_ir_rx_i2c(dev);
389 if (retval < 0) 390 if (!client) {
390 v4l2_err(&dev->v4l2_dev, "registering i2c IR devices failed\n"); 391 v4l2_err(&dev->v4l2_dev, "i2c IR RX device register failed\n");
392 goto reg_fail;
393 }
394
395 client = hdpvr_register_ir_tx_i2c(dev);
396 if (!client) {
397 v4l2_err(&dev->v4l2_dev, "i2c IR TX device register failed\n");
398 goto reg_fail;
399 }
391#endif 400#endif
392 401
393 /* let the user know what node this device is now attached to */ 402 /* let the user know what node this device is now attached to */
@@ -395,6 +404,10 @@ static int hdpvr_probe(struct usb_interface *interface,
395 video_device_node_name(dev->video_dev)); 404 video_device_node_name(dev->video_dev));
396 return 0; 405 return 0;
397 406
407reg_fail:
408#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
409 i2c_del_adapter(&dev->i2c_adapter);
410#endif
398error: 411error:
399 if (dev) { 412 if (dev) {
400 /* Destroy single thread */ 413 /* Destroy single thread */
@@ -424,6 +437,9 @@ static void hdpvr_disconnect(struct usb_interface *interface)
424 mutex_lock(&dev->io_mutex); 437 mutex_lock(&dev->io_mutex);
425 hdpvr_cancel_queue(dev); 438 hdpvr_cancel_queue(dev);
426 mutex_unlock(&dev->io_mutex); 439 mutex_unlock(&dev->io_mutex);
440#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
441 i2c_del_adapter(&dev->i2c_adapter);
442#endif
427 video_unregister_device(dev->video_dev); 443 video_unregister_device(dev->video_dev);
428 atomic_dec(&dev_nr); 444 atomic_dec(&dev_nr);
429} 445}
diff --git a/drivers/media/video/hdpvr/hdpvr-i2c.c b/drivers/media/video/hdpvr/hdpvr-i2c.c
index 89b71faeaac2..e53fa55d56a1 100644
--- a/drivers/media/video/hdpvr/hdpvr-i2c.c
+++ b/drivers/media/video/hdpvr/hdpvr-i2c.c
@@ -31,26 +31,34 @@
31#define Z8F0811_IR_RX_I2C_ADDR 0x71 31#define Z8F0811_IR_RX_I2C_ADDR 0x71
32 32
33 33
34static struct i2c_board_info hdpvr_i2c_board_info = { 34struct i2c_client *hdpvr_register_ir_tx_i2c(struct hdpvr_device *dev)
35 I2C_BOARD_INFO("ir_tx_z8f0811_hdpvr", Z8F0811_IR_TX_I2C_ADDR), 35{
36 I2C_BOARD_INFO("ir_rx_z8f0811_hdpvr", Z8F0811_IR_RX_I2C_ADDR), 36 struct IR_i2c_init_data *init_data = &dev->ir_i2c_init_data;
37}; 37 struct i2c_board_info hdpvr_ir_tx_i2c_board_info = {
38 I2C_BOARD_INFO("ir_tx_z8f0811_hdpvr", Z8F0811_IR_TX_I2C_ADDR),
39 };
40
41 init_data->name = "HD-PVR";
42 hdpvr_ir_tx_i2c_board_info.platform_data = init_data;
38 43
39int hdpvr_register_i2c_ir(struct hdpvr_device *dev) 44 return i2c_new_device(&dev->i2c_adapter, &hdpvr_ir_tx_i2c_board_info);
45}
46
47struct i2c_client *hdpvr_register_ir_rx_i2c(struct hdpvr_device *dev)
40{ 48{
41 struct i2c_client *c;
42 struct IR_i2c_init_data *init_data = &dev->ir_i2c_init_data; 49 struct IR_i2c_init_data *init_data = &dev->ir_i2c_init_data;
50 struct i2c_board_info hdpvr_ir_rx_i2c_board_info = {
51 I2C_BOARD_INFO("ir_rx_z8f0811_hdpvr", Z8F0811_IR_RX_I2C_ADDR),
52 };
43 53
44 /* Our default information for ir-kbd-i2c.c to use */ 54 /* Our default information for ir-kbd-i2c.c to use */
45 init_data->ir_codes = RC_MAP_HAUPPAUGE_NEW; 55 init_data->ir_codes = RC_MAP_HAUPPAUGE_NEW;
46 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 56 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
47 init_data->type = RC_TYPE_RC5; 57 init_data->type = RC_TYPE_RC5;
48 init_data->name = "HD PVR"; 58 init_data->name = "HD-PVR";
49 hdpvr_i2c_board_info.platform_data = init_data; 59 hdpvr_ir_rx_i2c_board_info.platform_data = init_data;
50
51 c = i2c_new_device(&dev->i2c_adapter, &hdpvr_i2c_board_info);
52 60
53 return (c == NULL) ? -ENODEV : 0; 61 return i2c_new_device(&dev->i2c_adapter, &hdpvr_ir_rx_i2c_board_info);
54} 62}
55 63
56static int hdpvr_i2c_read(struct hdpvr_device *dev, int bus, 64static int hdpvr_i2c_read(struct hdpvr_device *dev, int bus,
diff --git a/drivers/media/video/hdpvr/hdpvr.h b/drivers/media/video/hdpvr/hdpvr.h
index ee74e3be9a6a..072f23c570f3 100644
--- a/drivers/media/video/hdpvr/hdpvr.h
+++ b/drivers/media/video/hdpvr/hdpvr.h
@@ -313,7 +313,8 @@ int hdpvr_cancel_queue(struct hdpvr_device *dev);
313/* i2c adapter registration */ 313/* i2c adapter registration */
314int hdpvr_register_i2c_adapter(struct hdpvr_device *dev); 314int hdpvr_register_i2c_adapter(struct hdpvr_device *dev);
315 315
316int hdpvr_register_i2c_ir(struct hdpvr_device *dev); 316struct i2c_client *hdpvr_register_ir_rx_i2c(struct hdpvr_device *dev);
317struct i2c_client *hdpvr_register_ir_tx_i2c(struct hdpvr_device *dev);
317 318
318/*========================================================================*/ 319/*========================================================================*/
319/* buffer management */ 320/* buffer management */