From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Linux Media Mailing List <linux-media@vger.kernel.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>, linux-input@vger.kernel.org
Subject: [PATCH] V4L/DVB: ir: Add a link to associate /sys/class/ir/irrcv with the input device
Date: Thu, 11 Mar 2010 12:46:19 -0300 [thread overview]
Message-ID: <4B99104B.3090307@redhat.com> (raw)
In order to allow userspace programs to autoload an IR table, a link is
needed to point to the corresponding input device.
$ tree /sys/class/irrcv/irrcv0
/sys/class/irrcv/irrcv0
|-- current_protocol
|-- input -> ../../../pci0000:00/0000:00:0b.1/usb1/1-3/input/input22
|-- power
| `-- wakeup
|-- subsystem -> ../../../../class/irrcv
`-- uevent
It is now easy to associate an irrcv device with the corresponding
device node, at the input interface.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c
index bf5fbcd..7de32e7 100644
--- a/drivers/media/IR/ir-sysfs.c
+++ b/drivers/media/IR/ir-sysfs.c
@@ -138,6 +138,7 @@ int ir_register_class(struct input_dev *input_dev)
{
int rc;
struct kobject *kobj;
+ const char *path;
struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
int devno = find_first_zero_bit(&ir_core_dev_number,
@@ -152,13 +153,26 @@ int ir_register_class(struct input_dev *input_dev)
"irrcv%d", devno);
kobj = &ir_dev->class_dev->kobj;
- printk(KERN_WARNING "Creating IR device %s\n", kobject_name(kobj));
rc = sysfs_create_group(kobj, &ir_dev->attr);
if (unlikely(rc < 0)) {
device_destroy(ir_input_class, input_dev->dev.devt);
return -ENOMEM;
}
+ rc = sysfs_create_link(kobj, &input_dev->dev.kobj, "input");
+ if (unlikely(rc < 0)) {
+ sysfs_remove_group(kobj, &ir_dev->attr);
+ device_destroy(ir_input_class, input_dev->dev.devt);
+ return -ENOMEM;
+ }
+
+ path = kobject_get_path(&input_dev->dev.kobj, GFP_KERNEL);
+ printk(KERN_INFO "%s: %s associated with sysfs %s\n",
+ kobject_name(kobj),
+ input_dev->name ? input_dev->name : "Unspecified device",
+ path ? path : "N/A");
+ kfree(path);
+
ir_dev->devno = devno;
set_bit(devno, &ir_core_dev_number);
@@ -181,6 +195,8 @@ void ir_unregister_class(struct input_dev *input_dev)
kobj = &ir_dev->class_dev->kobj;
+ sysfs_remove_link(kobj, "input");
+
sysfs_remove_group(kobj, &ir_dev->attr);
device_destroy(ir_input_class, input_dev->dev.devt);
--
1.6.6.1
next reply other threads:[~2010-03-11 15:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-11 15:46 Mauro Carvalho Chehab [this message]
2010-03-11 17:52 ` [PATCH] V4L/DVB: ir: Add a link to associate /sys/class/ir/irrcv with the input device Dmitry Torokhov
2010-03-11 22:05 ` Mauro Carvalho Chehab
2010-03-12 4:32 ` Mauro Carvalho Chehab
2010-03-13 8:41 ` Dmitry Torokhov
2010-03-13 20:59 ` Mauro Carvalho Chehab
2010-03-14 6:37 ` Dmitry Torokhov
2010-03-14 18:22 ` Mauro Carvalho Chehab
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=4B99104B.3090307@redhat.com \
--to=mchehab@redhat.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-media@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).