From: Jean Delvare <khali@linux-fr.org>
To: LMML <linux-media@vger.kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>,
Andy Walls <awalls@radix.net>, Hans Verkuil <hverkuil@xs4all.nl>,
Mike Isely <isely@pobox.com>
Subject: [PATCH 4/8] ir-kbd-i2c: Don't assume all IR receivers are supported
Date: Wed, 13 May 2009 21:50:11 +0200 [thread overview]
Message-ID: <20090513215011.4bb41d32@hyperion.delvare> (raw)
In-Reply-To: <20090513214559.0f009231@hyperion.delvare>
The code in ir_probe makes the dangerous assumption that all IR
receivers are supported by the driver. The new i2c model makes it
possible for bridge drivers to instantiate IR devices before they are
supported, therefore the ir-kbd-i2c drivers must be made more robust
to not spam the logs or even crash on unsupported IR devices. Simply,
the driver will not bind to the unsupported devices.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Andy Walls <awalls@radix.net>
---
linux/drivers/media/video/ir-kbd-i2c.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
--- v4l-dvb.orig/linux/drivers/media/video/ir-kbd-i2c.c 2009-04-07 21:35:53.000000000 +0200
+++ v4l-dvb/linux/drivers/media/video/ir-kbd-i2c.c 2009-04-07 22:49:10.000000000 +0200
@@ -307,7 +307,7 @@ static void ir_work(struct work_struct *
static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
IR_KEYTAB_TYPE *ir_codes = NULL;
- const char *name;
+ const char *name = NULL;
int ir_type;
struct IR_i2c *ir;
struct input_dev *input_dev;
@@ -389,8 +389,7 @@ static int ir_probe(struct i2c_client *c
ir_codes = ir_codes_avermedia_cardbus;
break;
default:
- /* shouldn't happen */
- printk(DEVNAME ": Huh? unknown i2c address (0x%02x)?\n", addr);
+ dprintk(1, DEVNAME ": Unsupported i2c address 0x%02x\n", addr);
err = -ENODEV;
goto err_out_free;
}
@@ -405,6 +404,14 @@ static int ir_probe(struct i2c_client *c
ir->get_key = init_data->get_key;
}
+ /* Make sure we are all setup before going on */
+ if (!name || !ir->get_key || !ir_codes) {
+ dprintk(1, DEVNAME ": Unsupported device at address 0x%02x\n",
+ addr);
+ err = -ENODEV;
+ goto err_out_free;
+ }
+
/* Sets name */
snprintf(ir->name, sizeof(ir->name), "i2c IR (%s)", name);
ir->ir_codes = ir_codes;
--
Jean Delvare
next prev parent reply other threads:[~2009-05-13 19:50 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-13 19:45 [PATCH 0/8] ir-kbd-i2c conversion to the new i2c binding model (v3) Jean Delvare
2009-05-13 19:48 ` [PATCH 1/8] ir-kbd-i2c: Don't use i2c_client.name for our own needs Jean Delvare
2009-05-13 19:48 ` [PATCH 2/8] ir-kbd-i2c: Switch to the new-style device binding model Jean Delvare
2009-05-13 19:49 ` [PATCH 3/8] ir-kbd-i2c: Use initialization data Jean Delvare
2009-05-13 19:50 ` Jean Delvare [this message]
2009-05-13 19:51 ` [PATCH 5/8] saa7134: Simplify handling of IR on MSI TV@nywhere Plus Jean Delvare
2009-05-13 19:52 ` [PATCH 6/8] saa7134: Simplify handling of IR on AVerMedia Cardbus E506R Jean Delvare
2009-05-13 19:55 ` [PATCH 7/8] ivtv: Probe more I2C addresses for IR devices Jean Delvare
2009-05-13 19:56 ` [PATCH 8/8] pvrusb2: Instantiate ir_video I2C device by default Jean Delvare
2009-05-17 21:56 ` Mike Isely
2009-05-14 19:25 ` [PATCH 0/8] ir-kbd-i2c conversion to the new i2c binding model (v3) Oldřich Jedlička
2009-05-14 19:26 ` Jean Delvare
2009-05-17 21:55 ` Mike Isely
2009-05-18 7:18 ` Jean Delvare
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090513215011.4bb41d32@hyperion.delvare \
--to=khali@linux-fr.org \
--cc=awalls@radix.net \
--cc=hverkuil@xs4all.nl \
--cc=isely@pobox.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox