* [PATCH] ACPI: Handle multiple button devices with the same name
@ 2011-03-11 20:54 Matthew Garrett
2011-03-23 4:56 ` Len Brown
0 siblings, 1 reply; 3+ messages in thread
From: Matthew Garrett @ 2011-03-11 20:54 UTC (permalink / raw)
To: linux-acpi; +Cc: lenb, Matthew Garrett
It's valid for ACPI to have multiple devices with the same name. It's not
valid for us to create multiple identical directories in /proc. Let's
put some effort into uniqueness.
Signed-off-by: Matthew Garrett <mjg@redhat.com>
---
drivers/acpi/button.c | 41 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 40 insertions(+), 1 deletions(-)
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 76bbb78..747db93 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -161,10 +161,15 @@ static struct proc_dir_entry *acpi_power_dir;
static struct proc_dir_entry *acpi_sleep_dir;
static struct proc_dir_entry *acpi_lid_dir;
+static int acpi_power_buttons;
+static int acpi_sleep_buttons;
+static int acpi_lid_buttons;
+
static int acpi_button_add_fs(struct acpi_device *device)
{
struct acpi_button *button = acpi_driver_data(device);
struct proc_dir_entry *entry = NULL;
+ char name[10];
switch (button->type) {
case ACPI_BUTTON_TYPE_POWER:
@@ -190,7 +195,41 @@ static int acpi_button_add_fs(struct acpi_device *device)
if (!entry)
return -ENODEV;
- acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry);
+ switch (button->type) {
+ case ACPI_BUTTON_TYPE_POWER:
+ if (!acpi_power_buttons) {
+ acpi_device_dir(device) =
+ proc_mkdir(acpi_device_bid(device), entry);
+ } else {
+ snprintf(name, sizeof(name), "%s_%d",
+ acpi_device_bid(device), acpi_power_buttons);
+ acpi_device_dir(device) = proc_mkdir(name, entry);
+ }
+ acpi_power_buttons++;
+ break;
+ case ACPI_BUTTON_TYPE_SLEEP:
+ if (!acpi_sleep_buttons) {
+ acpi_device_dir(device) =
+ proc_mkdir(acpi_device_bid(device), entry);
+ } else {
+ snprintf(name, sizeof(name), "%s_%d",
+ acpi_device_bid(device), acpi_sleep_buttons);
+ acpi_device_dir(device) = proc_mkdir(name, entry);
+ }
+ acpi_sleep_buttons++;
+ break;
+ case ACPI_BUTTON_TYPE_LID:
+ if (!acpi_lid_buttons) {
+ acpi_device_dir(device) =
+ proc_mkdir(acpi_device_bid(device), entry);
+ } else {
+ snprintf(name, sizeof(name), "%s_%d",
+ acpi_device_bid(device), acpi_lid_buttons);
+ acpi_device_dir(device) = proc_mkdir(name, entry);
+ }
+ acpi_lid_buttons++;
+ break;
+ }
if (!acpi_device_dir(device))
return -ENODEV;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ACPI: Handle multiple button devices with the same name
2011-03-11 20:54 [PATCH] ACPI: Handle multiple button devices with the same name Matthew Garrett
@ 2011-03-23 4:56 ` Len Brown
2011-03-23 10:59 ` Matthew Garrett
0 siblings, 1 reply; 3+ messages in thread
From: Len Brown @ 2011-03-23 4:56 UTC (permalink / raw)
To: Matthew Garrett; +Cc: linux-acpi
> It's valid for ACPI to have multiple devices with the same name. It's not
> valid for us to create multiple identical directories in /proc. Let's
> put some effort into uniqueness.
I chose the patch that deletes this code instead.
thanks,
Len Brown, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ACPI: Handle multiple button devices with the same name
2011-03-23 4:56 ` Len Brown
@ 2011-03-23 10:59 ` Matthew Garrett
0 siblings, 0 replies; 3+ messages in thread
From: Matthew Garrett @ 2011-03-23 10:59 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
On Wed, Mar 23, 2011 at 12:56:59AM -0400, Len Brown wrote:
> > It's valid for ACPI to have multiple devices with the same name. It's not
> > valid for us to create multiple identical directories in /proc. Let's
> > put some effort into uniqueness.
>
> I chose the patch that deletes this code instead.
Works for me.
--
Matthew Garrett | mjg59@srcf.ucam.org
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-03-23 10:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-11 20:54 [PATCH] ACPI: Handle multiple button devices with the same name Matthew Garrett
2011-03-23 4:56 ` Len Brown
2011-03-23 10:59 ` Matthew Garrett
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).