Skip to content

Commit

Permalink
V4L/DVB: ir-core: export driver name used by IR via uevent
Browse files Browse the repository at this point in the history
Now, both driver and keytable names are exported to userspace. This
will help userspace to decide when a table need to be replaced
by another one.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Mauro Carvalho Chehab committed May 18, 2010
1 parent 9c89a18 commit 727e625
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 15 deletions.
7 changes: 6 additions & 1 deletion drivers/media/IR/ir-keytable.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ EXPORT_SYMBOL_GPL(ir_g_keycode_from_table);
*/
int ir_input_register(struct input_dev *input_dev,
const struct ir_scancode_table *rc_tab,
const struct ir_dev_props *props)
const struct ir_dev_props *props,
const char *driver_name)
{
struct ir_input_dev *ir_dev;
struct ir_scancode *keymap = rc_tab->scan;
Expand All @@ -419,6 +420,10 @@ int ir_input_register(struct input_dev *input_dev,

spin_lock_init(&ir_dev->rc_tab.lock);

ir_dev->driver_name = kmalloc(strlen(driver_name) + 1, GFP_KERNEL);
if (!ir_dev->driver_name)
return -ENOMEM;
strcpy(ir_dev->driver_name, driver_name);
ir_dev->rc_tab.name = rc_tab->name;
ir_dev->rc_tab.size = ir_roundup_tablesize(rc_tab->size);
ir_dev->rc_tab.scan = kzalloc(ir_dev->rc_tab.size *
Expand Down
2 changes: 2 additions & 0 deletions drivers/media/IR/ir-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ static int ir_dev_uevent(struct device *device, struct kobj_uevent_env *env)

if (ir_dev->rc_tab.name)
ADD_HOTPLUG_VAR("NAME=\"%s\"", ir_dev->rc_tab.name);
if (ir_dev->driver_name)
ADD_HOTPLUG_VAR("DRV_NAME=\"%s\"", ir_dev->driver_name);

return 0;
}
Expand Down
4 changes: 3 additions & 1 deletion drivers/media/dvb/dm1105/dm1105.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
#include "z0194a.h"
#include "ds3000.h"

#define MODULE_NAME "dm1105"

#define UNSET (-1U)

#define DM1105_BOARD_NOAUTO UNSET
Expand Down Expand Up @@ -628,7 +630,7 @@ int __devinit dm1105_ir_init(struct dm1105_dev *dm1105)

INIT_WORK(&dm1105->ir.work, dm1105_emit_key);

err = ir_input_register(input_dev, ir_codes, NULL);
err = ir_input_register(input_dev, ir_codes, NULL, MODULE_NAME);

return err;
}
Expand Down
4 changes: 3 additions & 1 deletion drivers/media/dvb/mantis/mantis_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "mantis_reg.h"
#include "mantis_uart.h"

#define MODULE_NAME "mantis_core"

static struct ir_scancode mantis_ir_table[] = {
{ 0x29, KEY_POWER },
{ 0x28, KEY_FAVORITES },
Expand Down Expand Up @@ -126,7 +128,7 @@ int mantis_input_init(struct mantis_pci *mantis)
rc->id.version = 1;
rc->dev = mantis->pdev->dev;

err = ir_input_register(rc, &ir_mantis, NULL);
err = ir_input_register(rc, &ir_mantis, NULL, MODULE_NAME);
if (err) {
dprintk(MANTIS_ERROR, 1, "IR device registration failed, ret = %d", err);
input_free_device(rc);
Expand Down
4 changes: 3 additions & 1 deletion drivers/media/dvb/ttpci/budget-ci.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
#include "tda1002x.h"
#include "tda827x.h"

#define MODULE_NAME "budget_ci"

/*
* Regarding DEBIADDR_IR:
* Some CI modules hang if random addresses are read.
Expand Down Expand Up @@ -254,7 +256,7 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
budget_ci->ir.timer_keyup.function = msp430_ir_keyup;
budget_ci->ir.timer_keyup.data = (unsigned long) &budget_ci->ir;
budget_ci->ir.last_raw = 0xffff; /* An impossible value */
error = ir_input_register(input_dev, ir_codes, NULL);
error = ir_input_register(input_dev, ir_codes, NULL, MODULE_NAME);
if (error) {
printk(KERN_ERR "budget_ci: could not init driver for IR device (code %d)\n", error);
return error;
Expand Down
4 changes: 3 additions & 1 deletion drivers/media/video/bt8xx/bttv-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ module_param(ir_rc5_key_timeout, int, 0644);

#define DEVNAME "bttv-input"

#define MODULE_NAME "bttv"

/* ---------------------------------------------------------------------- */

static void ir_handle_key(struct bttv *btv)
Expand Down Expand Up @@ -390,7 +392,7 @@ int bttv_input_init(struct bttv *btv)
bttv_ir_start(btv, ir);

/* all done */
err = ir_input_register(btv->remote->dev, ir_codes, NULL);
err = ir_input_register(btv->remote->dev, ir_codes, NULL, MODULE_NAME);
if (err)
goto err_out_stop;

Expand Down
5 changes: 4 additions & 1 deletion drivers/media/video/cx231xx/cx231xx-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ static unsigned int ir_debug;
module_param(ir_debug, int, 0644);
MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]");

#define MODULE_NAME "cx231xx"

#define i2cdprintk(fmt, arg...) \
if (ir_debug) { \
printk(KERN_DEBUG "%s/ir: " fmt, ir->name , ## arg); \
Expand Down Expand Up @@ -217,7 +219,8 @@ int cx231xx_ir_init(struct cx231xx *dev)
cx231xx_ir_start(ir);

/* all done */
err = ir_input_register(ir->input, dev->board.ir_codes, NULL);
err = ir_input_register(ir->input, dev->board.ir_codes,
NULL, MODULE_NAME);
if (err)
goto err_out_stop;

Expand Down
4 changes: 3 additions & 1 deletion drivers/media/video/cx23885/cx23885-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@

#define RC5_EXTENDED_COMMAND_OFFSET 64

#define MODULE_NAME "cx23885"

static inline unsigned int rc5_command(u32 rc5_baseband)
{
return RC5_INSTR(rc5_baseband) +
Expand Down Expand Up @@ -398,7 +400,7 @@ int cx23885_input_init(struct cx23885_dev *dev)
dev->ir_input = ir;
cx23885_input_ir_start(dev);

ret = ir_input_register(ir->dev, ir_codes, NULL);
ret = ir_input_register(ir->dev, ir_codes, NULL, MODULE_NAME);
if (ret)
goto err_out_stop;

Expand Down
4 changes: 3 additions & 1 deletion drivers/media/video/cx88/cx88-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "cx88.h"
#include <media/ir-common.h>

#define MODULE_NAME "cx88xx"

/* ---------------------------------------------------------------------- */

struct cx88_IR {
Expand Down Expand Up @@ -384,7 +386,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
cx88_ir_start(core, ir);

/* all done */
err = ir_input_register(ir->input, ir_codes, NULL);
err = ir_input_register(ir->input, ir_codes, NULL, MODULE_NAME);
if (err)
goto err_out_stop;

Expand Down
4 changes: 3 additions & 1 deletion drivers/media/video/em28xx/em28xx-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ static unsigned int ir_debug;
module_param(ir_debug, int, 0644);
MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]");

#define MODULE_NAME "em28xx"

#define i2cdprintk(fmt, arg...) \
if (ir_debug) { \
printk(KERN_DEBUG "%s/ir: " fmt, ir->name , ## arg); \
Expand Down Expand Up @@ -474,7 +476,7 @@ int em28xx_ir_init(struct em28xx *dev)

/* all done */
err = ir_input_register(ir->input, dev->board.ir_codes,
&ir->props);
&ir->props, MODULE_NAME);
if (err)
goto err_out_stop;

Expand Down
8 changes: 4 additions & 4 deletions drivers/media/video/ir-kbd-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ module_param(hauppauge, int, 0644); /* Choose Hauppauge remote */
MODULE_PARM_DESC(hauppauge, "Specify Hauppauge remote: 0=black, 1=grey (defaults to 0)");


#define DEVNAME "ir-kbd-i2c"
#define MODULE_NAME "ir-kbd-i2c"
#define dprintk(level, fmt, arg...) if (debug >= level) \
printk(KERN_DEBUG DEVNAME ": " fmt , ## arg)
printk(KERN_DEBUG MODULE_NAME ": " fmt , ## arg)

/* ----------------------------------------------------------------------- */

Expand Down Expand Up @@ -447,11 +447,11 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
input_dev->name = ir->name;
input_dev->phys = ir->phys;

err = ir_input_register(ir->input, ir->ir_codes, NULL);
err = ir_input_register(ir->input, ir->ir_codes, NULL, MODULE_NAME);
if (err)
goto err_out_free;

printk(DEVNAME ": %s detected at %s [%s]\n",
printk(MODULE_NAME ": %s detected at %s [%s]\n",
ir->input->name, ir->input->phys, adap->name);

/* start polling via eventd */
Expand Down
4 changes: 3 additions & 1 deletion drivers/media/video/saa7134/saa7134-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include "saa7134-reg.h"
#include "saa7134.h"

#define MODULE_NAME "saa7134"

static unsigned int disable_ir;
module_param(disable_ir, int, 0444);
MODULE_PARM_DESC(disable_ir,"disable infrared remote support");
Expand Down Expand Up @@ -730,7 +732,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
dev->remote = ir;
saa7134_ir_start(dev, ir);

err = ir_input_register(ir->dev, ir_codes, NULL);
err = ir_input_register(ir->dev, ir_codes, NULL, MODULE_NAME);
if (err)
goto err_out_stop;

Expand Down
4 changes: 3 additions & 1 deletion include/media/ir-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct ir_dev_props {

struct ir_input_dev {
struct device dev; /* device */
char *driver_name; /* Name of the driver module */
struct ir_scancode_table rc_tab; /* scan/key table */
unsigned long devno; /* device number */
const struct ir_dev_props *props; /* Device properties */
Expand All @@ -62,7 +63,8 @@ u32 ir_g_keycode_from_table(struct input_dev *input_dev,

int ir_input_register(struct input_dev *dev,
const struct ir_scancode_table *ir_codes,
const struct ir_dev_props *props);
const struct ir_dev_props *props,
const char *driver_name);
void ir_input_unregister(struct input_dev *input_dev);

/* Routines from ir-sysfs.c */
Expand Down

0 comments on commit 727e625

Please sign in to comment.