diff options
Diffstat (limited to 'drivers/media/video/ir-kbd-i2c.c')
-rw-r--r-- | drivers/media/video/ir-kbd-i2c.c | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c index 83b59a195230..de0060fa33f1 100644 --- a/drivers/media/video/ir-kbd-i2c.c +++ b/drivers/media/video/ir-kbd-i2c.c | |||
@@ -271,20 +271,16 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
271 | const char *name = NULL; | 271 | const char *name = NULL; |
272 | u64 ir_type = IR_TYPE_UNKNOWN; | 272 | u64 ir_type = IR_TYPE_UNKNOWN; |
273 | struct IR_i2c *ir; | 273 | struct IR_i2c *ir; |
274 | struct rc_dev *rc; | 274 | struct rc_dev *rc = NULL; |
275 | struct i2c_adapter *adap = client->adapter; | 275 | struct i2c_adapter *adap = client->adapter; |
276 | unsigned short addr = client->addr; | 276 | unsigned short addr = client->addr; |
277 | int err; | 277 | int err; |
278 | 278 | ||
279 | ir = kzalloc(sizeof(struct IR_i2c),GFP_KERNEL); | 279 | ir = kzalloc(sizeof(struct IR_i2c), GFP_KERNEL); |
280 | rc = rc_allocate_device(); | 280 | if (!ir) |
281 | if (!ir || !rc) { | 281 | return -ENOMEM; |
282 | err = -ENOMEM; | ||
283 | goto err_out_free; | ||
284 | } | ||
285 | 282 | ||
286 | ir->c = client; | 283 | ir->c = client; |
287 | ir->rc = rc; | ||
288 | ir->polling_interval = DEFAULT_POLLING_INTERVAL; | 284 | ir->polling_interval = DEFAULT_POLLING_INTERVAL; |
289 | i2c_set_clientdata(client, ir); | 285 | i2c_set_clientdata(client, ir); |
290 | 286 | ||
@@ -333,6 +329,8 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
333 | client->dev.platform_data; | 329 | client->dev.platform_data; |
334 | 330 | ||
335 | ir_codes = init_data->ir_codes; | 331 | ir_codes = init_data->ir_codes; |
332 | rc = init_data->rc_dev; | ||
333 | |||
336 | name = init_data->name; | 334 | name = init_data->name; |
337 | if (init_data->type) | 335 | if (init_data->type) |
338 | ir_type = init_data->type; | 336 | ir_type = init_data->type; |
@@ -366,6 +364,19 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
366 | } | 364 | } |
367 | } | 365 | } |
368 | 366 | ||
367 | if (!rc) { | ||
368 | /* | ||
369 | * If platform_data doesn't specify rc_dev, initilize it | ||
370 | * internally | ||
371 | */ | ||
372 | rc = rc_allocate_device(); | ||
373 | if (!rc) { | ||
374 | err = -ENOMEM; | ||
375 | goto err_out_free; | ||
376 | } | ||
377 | } | ||
378 | ir->rc = rc; | ||
379 | |||
369 | /* Make sure we are all setup before going on */ | 380 | /* Make sure we are all setup before going on */ |
370 | if (!name || !ir->get_key || !ir_type || !ir_codes) { | 381 | if (!name || !ir->get_key || !ir_type || !ir_codes) { |
371 | dprintk(1, ": Unsupported device at address 0x%02x\n", | 382 | dprintk(1, ": Unsupported device at address 0x%02x\n", |
@@ -382,12 +393,21 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
382 | dev_name(&adap->dev), | 393 | dev_name(&adap->dev), |
383 | dev_name(&client->dev)); | 394 | dev_name(&client->dev)); |
384 | 395 | ||
385 | /* init + register input device */ | 396 | /* |
397 | * Initialize input_dev fields | ||
398 | * It doesn't make sense to allow overriding them via platform_data | ||
399 | */ | ||
386 | rc->input_id.bustype = BUS_I2C; | 400 | rc->input_id.bustype = BUS_I2C; |
387 | rc->input_name = ir->name; | ||
388 | rc->input_phys = ir->phys; | 401 | rc->input_phys = ir->phys; |
389 | rc->map_name = ir->ir_codes; | 402 | rc->input_name = ir->name; |
390 | rc->driver_name = MODULE_NAME; | 403 | |
404 | /* | ||
405 | * Initialize the other fields of rc_dev | ||
406 | */ | ||
407 | rc->map_name = ir->ir_codes; | ||
408 | rc->allowed_protos = ir_type; | ||
409 | if (!rc->driver_name) | ||
410 | rc->driver_name = MODULE_NAME; | ||
391 | 411 | ||
392 | err = rc_register_device(rc); | 412 | err = rc_register_device(rc); |
393 | if (err) | 413 | if (err) |
@@ -403,6 +423,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
403 | return 0; | 423 | return 0; |
404 | 424 | ||
405 | err_out_free: | 425 | err_out_free: |
426 | /* Only frees rc if it were allocated internally */ | ||
406 | rc_free_device(rc); | 427 | rc_free_device(rc); |
407 | kfree(ir); | 428 | kfree(ir); |
408 | return err; | 429 | return err; |