Commit 9a4cc5ac authored by Jean Delvare's avatar Jean Delvare Committed by Mauro Carvalho Chehab

V4L/DVB (11846): ir-kbd-i2c: Don't assume all IR receivers are supported

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: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 4d7a2d67
...@@ -298,7 +298,7 @@ static void ir_work(struct work_struct *work) ...@@ -298,7 +298,7 @@ static void ir_work(struct work_struct *work)
static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
{ {
IR_KEYTAB_TYPE *ir_codes = NULL; IR_KEYTAB_TYPE *ir_codes = NULL;
const char *name; const char *name = NULL;
int ir_type; int ir_type;
struct IR_i2c *ir; struct IR_i2c *ir;
struct input_dev *input_dev; struct input_dev *input_dev;
...@@ -380,8 +380,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -380,8 +380,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
ir_codes = ir_codes_avermedia_cardbus; ir_codes = ir_codes_avermedia_cardbus;
break; break;
default: default:
/* shouldn't happen */ dprintk(1, DEVNAME ": Unsupported i2c address 0x%02x\n", addr);
printk(DEVNAME ": Huh? unknown i2c address (0x%02x)?\n", addr);
err = -ENODEV; err = -ENODEV;
goto err_out_free; goto err_out_free;
} }
...@@ -396,6 +395,14 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -396,6 +395,14 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
ir->get_key = init_data->get_key; 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 */ /* Sets name */
snprintf(ir->name, sizeof(ir->name), "i2c IR (%s)", name); snprintf(ir->name, sizeof(ir->name), "i2c IR (%s)", name);
ir->ir_codes = ir_codes; ir->ir_codes = ir_codes;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment