public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ACPI: Do not export hid/modalias sysfs file for ACPI objects without a HID
@ 2010-10-01  8:53 Thomas Renninger
  2010-10-01  8:54 ` [PATCH 2/2] ACPI/PNP: A HID value of an object never changes -> make it const Thomas Renninger
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Thomas Renninger @ 2010-10-01  8:53 UTC (permalink / raw)
  To: lenb; +Cc: Thomas Renninger, Zhang Rui, kay.sievers, linux-acpi,
	Bjorn Helgaas

Boot and compile tested.
The fact that pnp.ids can now be empty needs testing on some
further machines, though.

This should handle a "modprobe is wrongly called by udev" issue:
https://bugzilla.kernel.org/show_bug.cgi?id=19162

Modaliase files in
/sys/devices/LNXSYSTM:00/
went down from 113 to 71 on my tested system.

This is a sysfs change, but userspace must already be able to handle it.

Also do not fill up pnp.ids list with a "struct hid"
entry. This comment:
     * This generic ID isn't useful for driver binding, but it provides
     * the useful property that "every acpi_device has an ID."
is still half way true:
Best you never touch pnp.ids list directly or make sure it can be empty,
instead use:
char *acpi_device_hid()
which always returns a value ("device" as a dummy if the object
has no hid).

Signed-off-by: Thomas Renninger <trenn@suse.de>
CC: Zhang Rui <rui.zhang@intel.com>
CC: kay.sievers@vrfy.org
CC: <linux-acpi@vger.kernel.org>
CC: Bjorn Helgaas <bjorn.helgaas@hp.com>
---
 drivers/acpi/scan.c |   36 ++++++++++++++++++++----------------
 1 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index b23825e..d281afb 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -26,6 +26,9 @@ extern struct acpi_device *acpi_root;
 
 #define ACPI_IS_ROOT_DEVICE(device)    (!(device)->parent)
 
+/* Should be const */
+static char* dummy_hid = "device";
+
 static LIST_HEAD(acpi_device_list);
 static LIST_HEAD(acpi_bus_id_list);
 DEFINE_MUTEX(acpi_device_lock);
@@ -49,6 +52,9 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
 	int count;
 	struct acpi_hardware_id *id;
 
+	if (list_empty(&acpi_dev->pnp.ids))
+		return 0;
+
 	len = snprintf(modalias, size, "acpi:");
 	size -= len;
 
@@ -202,13 +208,15 @@ static int acpi_device_setup_files(struct acpi_device *dev)
 			goto end;
 	}
 
-	result = device_create_file(&dev->dev, &dev_attr_hid);
-	if (result)
-		goto end;
+	if (!list_empty(&dev->pnp.ids)) {
+		result = device_create_file(&dev->dev, &dev_attr_hid);
+		if (result)
+			goto end;
 
-	result = device_create_file(&dev->dev, &dev_attr_modalias);
-	if (result)
-		goto end;
+		result = device_create_file(&dev->dev, &dev_attr_modalias);
+		if (result)
+			goto end;
+	}
 
         /*
          * If device has _EJ0, 'eject' file is created that is used to trigger
@@ -316,6 +324,9 @@ static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env)
 	struct acpi_device *acpi_dev = to_acpi_device(dev);
 	int len;
 
+	if (list_empty(&acpi_dev->pnp.ids))
+		return 0;
+
 	if (add_uevent_var(env, "MODALIAS="))
 		return -ENOMEM;
 	len = create_modalias(acpi_dev, &env->buf[env->buflen - 1],
@@ -1013,6 +1024,9 @@ static int acpi_dock_match(struct acpi_device *device)
 char *acpi_device_hid(struct acpi_device *device)
 {
 	struct acpi_hardware_id *hid;
+	
+	if (list_empty(&device->pnp.ids))
+		return dummy_hid;
 
 	hid = list_first_entry(&device->pnp.ids, struct acpi_hardware_id, list);
 	return hid->id;
@@ -1142,16 +1156,6 @@ static void acpi_device_set_id(struct acpi_device *device)
 		acpi_add_id(device, ACPI_BUTTON_HID_SLEEPF);
 		break;
 	}
-
-	/*
-	 * We build acpi_devices for some objects that don't have _HID or _CID,
-	 * e.g., PCI bridges and slots.  Drivers can't bind to these objects,
-	 * but we do use them indirectly by traversing the acpi_device tree.
-	 * This generic ID isn't useful for driver binding, but it provides
-	 * the useful property that "every acpi_device has an ID."
-	 */
-	if (list_empty(&device->pnp.ids))
-		acpi_add_id(device, "device");
 }
 
 static int acpi_device_set_context(struct acpi_device *device)
-- 
1.6.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] ACPI/PNP: A HID value of an object never changes -> make it const
  2010-10-01  8:53 [PATCH 1/2] ACPI: Do not export hid/modalias sysfs file for ACPI objects without a HID Thomas Renninger
@ 2010-10-01  8:54 ` Thomas Renninger
  2010-10-01 19:49   ` Len Brown
  2010-10-01 19:48 ` [PATCH 1/2] ACPI: Do not export hid/modalias sysfs file for ACPI objects without a HID Len Brown
  2010-10-08  0:26 ` Zhang Rui
  2 siblings, 1 reply; 6+ messages in thread
From: Thomas Renninger @ 2010-10-01  8:54 UTC (permalink / raw)
  To: lenb; +Cc: Thomas Renninger, Zhang Rui, kay.sievers, linux-acpi,
	Bjorn Helgaas

Signed-off-by: Thomas Renninger <trenn@suse.de>
CC: Zhang Rui <rui.zhang@intel.com>
CC: kay.sievers@vrfy.org
CC: <linux-acpi@vger.kernel.org>
CC: Bjorn Helgaas <bjorn.helgaas@hp.com>
---
 drivers/acpi/button.c      |    4 ++--
 drivers/acpi/scan.c        |    5 ++---
 drivers/pnp/base.h         |    5 +++--
 drivers/pnp/core.c         |    3 ++-
 drivers/pnp/driver.c       |    2 +-
 drivers/pnp/pnpacpi/core.c |    2 +-
 include/acpi/acpi_bus.h    |    2 +-
 7 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 1575a9b..71ef9cd 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -338,7 +338,8 @@ static int acpi_button_add(struct acpi_device *device)
 {
 	struct acpi_button *button;
 	struct input_dev *input;
-	char *hid, *name, *class;
+	const char *hid = acpi_device_hid(device);
+	char *name, *class;
 	int error;
 
 	button = kzalloc(sizeof(struct acpi_button), GFP_KERNEL);
@@ -353,7 +354,6 @@ static int acpi_button_add(struct acpi_device *device)
 		goto err_free_button;
 	}
 
-	hid = acpi_device_hid(device);
 	name = acpi_device_name(device);
 	class = acpi_device_class(device);
 
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index d281afb..f9b3da2 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -26,8 +26,7 @@ extern struct acpi_device *acpi_root;
 
 #define ACPI_IS_ROOT_DEVICE(device)    (!(device)->parent)
 
-/* Should be const */
-static char* dummy_hid = "device";
+static const char* dummy_hid = "device";
 
 static LIST_HEAD(acpi_device_list);
 static LIST_HEAD(acpi_bus_id_list);
@@ -1021,7 +1020,7 @@ static int acpi_dock_match(struct acpi_device *device)
 	return acpi_get_handle(device->handle, "_DCK", &tmp);
 }
 
-char *acpi_device_hid(struct acpi_device *device)
+const char *acpi_device_hid(struct acpi_device *device)
 {
 	struct acpi_hardware_id *hid;
 	
diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h
index 0bab84e..19bc736 100644
--- a/drivers/pnp/base.h
+++ b/drivers/pnp/base.h
@@ -12,11 +12,12 @@ void pnp_unregister_protocol(struct pnp_protocol *protocol);
 
 #define PNP_EISA_ID_MASK 0x7fffffff
 void pnp_eisa_id_to_string(u32 id, char *str);
-struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *, int id, char *pnpid);
+struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *, int id,
+			      const char *pnpid);
 struct pnp_card *pnp_alloc_card(struct pnp_protocol *, int id, char *pnpid);
 
 int pnp_add_device(struct pnp_dev *dev);
-struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id);
+struct pnp_id *pnp_add_id(struct pnp_dev *dev, const char *id);
 
 int pnp_add_card(struct pnp_card *card);
 void pnp_remove_card(struct pnp_card *card);
diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c
index 88b3cde..c79ee1d 100644
--- a/drivers/pnp/core.c
+++ b/drivers/pnp/core.c
@@ -124,7 +124,8 @@ static void pnp_release_device(struct device *dmdev)
 	kfree(dev);
 }
 
-struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, char *pnpid)
+struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id,
+			      const char *pnpid)
 {
 	struct pnp_dev *dev;
 	struct pnp_id *dev_id;
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c
index cd11b11..d1dbb9d 100644
--- a/drivers/pnp/driver.c
+++ b/drivers/pnp/driver.c
@@ -236,7 +236,7 @@ void pnp_unregister_driver(struct pnp_driver *drv)
  * @dev: pointer to the desired device
  * @id: pointer to an EISA id string
  */
-struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id)
+struct pnp_id *pnp_add_id(struct pnp_dev *dev, const char *id)
 {
 	struct pnp_id *dev_id, *ptr;
 
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index dc4e32e..4aafcf8 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -59,7 +59,7 @@ static inline int __init is_exclusive_device(struct acpi_device *dev)
 #define TEST_ALPHA(c) \
 	if (!('@' <= (c) || (c) <= 'Z')) \
 		return 0
-static int __init ispnpidacpi(char *id)
+static int __init ispnpidacpi(const char *id)
 {
 	TEST_ALPHA(id[0]);
 	TEST_ALPHA(id[1]);
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 4de84ce..a47bb90 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -184,7 +184,7 @@ struct acpi_device_pnp {
 
 #define acpi_device_bid(d)	((d)->pnp.bus_id)
 #define acpi_device_adr(d)	((d)->pnp.bus_address)
-char *acpi_device_hid(struct acpi_device *device);
+const char *acpi_device_hid(struct acpi_device *device);
 #define acpi_device_name(d)	((d)->pnp.device_name)
 #define acpi_device_class(d)	((d)->pnp.device_class)
 
-- 
1.6.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] ACPI: Do not export hid/modalias sysfs file for ACPI objects without a HID
  2010-10-01  8:53 [PATCH 1/2] ACPI: Do not export hid/modalias sysfs file for ACPI objects without a HID Thomas Renninger
  2010-10-01  8:54 ` [PATCH 2/2] ACPI/PNP: A HID value of an object never changes -> make it const Thomas Renninger
@ 2010-10-01 19:48 ` Len Brown
  2010-10-08  0:26 ` Zhang Rui
  2 siblings, 0 replies; 6+ messages in thread
From: Len Brown @ 2010-10-01 19:48 UTC (permalink / raw)
  To: Thomas Renninger; +Cc: Zhang Rui, kay.sievers, linux-acpi, Bjorn Helgaas

applied to acpi-test

thanks,
Len Brown, Intel Open Source Technology Center


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] ACPI/PNP: A HID value of an object never changes -> make it const
  2010-10-01  8:54 ` [PATCH 2/2] ACPI/PNP: A HID value of an object never changes -> make it const Thomas Renninger
@ 2010-10-01 19:49   ` Len Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Len Brown @ 2010-10-01 19:49 UTC (permalink / raw)
  To: Thomas Renninger; +Cc: Zhang Rui, kay.sievers, linux-acpi, Bjorn Helgaas

applied to acpi-test

thanks,
Len Brown, Intel Open Source Technology Center


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] ACPI: Do not export hid/modalias sysfs file for ACPI objects without a HID
  2010-10-01  8:53 [PATCH 1/2] ACPI: Do not export hid/modalias sysfs file for ACPI objects without a HID Thomas Renninger
  2010-10-01  8:54 ` [PATCH 2/2] ACPI/PNP: A HID value of an object never changes -> make it const Thomas Renninger
  2010-10-01 19:48 ` [PATCH 1/2] ACPI: Do not export hid/modalias sysfs file for ACPI objects without a HID Len Brown
@ 2010-10-08  0:26 ` Zhang Rui
  2010-10-08  7:27   ` Thomas Renninger
  2 siblings, 1 reply; 6+ messages in thread
From: Zhang Rui @ 2010-10-08  0:26 UTC (permalink / raw)
  To: Thomas Renninger
  Cc: lenb@kernel.org, kay.sievers@vrfy.org, linux-acpi@vger.kernel.org,
	Bjorn Helgaas

On Fri, 2010-10-01 at 16:53 +0800, Thomas Renninger wrote:
> Boot and compile tested.
> The fact that pnp.ids can now be empty needs testing on some
> further machines, though.
> 
> This should handle a "modprobe is wrongly called by udev" issue:
> https://bugzilla.kernel.org/show_bug.cgi?id=19162
> 
> Modaliase files in
> /sys/devices/LNXSYSTM:00/
> went down from 113 to 71 on my tested system.
> 
> This is a sysfs change, but userspace must already be able to handle it.
> 
> Also do not fill up pnp.ids list with a "struct hid"
> entry. This comment:
>      * This generic ID isn't useful for driver binding, but it provides
>      * the useful property that "every acpi_device has an ID."
> is still half way true:
> Best you never touch pnp.ids list directly or make sure it can be empty,
> instead use:
> char *acpi_device_hid()
> which always returns a value ("device" as a dummy if the object
> has no hid).
> 
> Signed-off-by: Thomas Renninger <trenn@suse.de>
> CC: Zhang Rui <rui.zhang@intel.com>
> CC: kay.sievers@vrfy.org
> CC: <linux-acpi@vger.kernel.org>
> CC: Bjorn Helgaas <bjorn.helgaas@hp.com>
> ---
>  drivers/acpi/scan.c |   36 ++++++++++++++++++++----------------
>  1 files changed, 20 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
> index b23825e..d281afb 100644
> --- a/drivers/acpi/scan.c
> +++ b/drivers/acpi/scan.c
> @@ -26,6 +26,9 @@ extern struct acpi_device *acpi_root;
>  
>  #define ACPI_IS_ROOT_DEVICE(device)    (!(device)->parent)
>  
> +/* Should be const */
> +static char* dummy_hid = "device";
> +
>  static LIST_HEAD(acpi_device_list);
>  static LIST_HEAD(acpi_bus_id_list);
>  DEFINE_MUTEX(acpi_device_lock);
> @@ -49,6 +52,9 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
>  	int count;
>  	struct acpi_hardware_id *id;
>  
> +	if (list_empty(&acpi_dev->pnp.ids))
> +		return 0;
> +
>  	len = snprintf(modalias, size, "acpi:");
>  	size -= len;
>  
> @@ -202,13 +208,15 @@ static int acpi_device_setup_files(struct acpi_device *dev)
>  			goto end;
>  	}
>  
> -	result = device_create_file(&dev->dev, &dev_attr_hid);
> -	if (result)
> -		goto end;
> +	if (!list_empty(&dev->pnp.ids)) {
> +		result = device_create_file(&dev->dev, &dev_attr_hid);
> +		if (result)
> +			goto end;
>  
> -	result = device_create_file(&dev->dev, &dev_attr_modalias);
> -	if (result)
> -		goto end;
> +		result = device_create_file(&dev->dev, &dev_attr_modalias);
> +		if (result)
> +			goto end;
> +	}
>  

the "hid" attribute exports the first entry of the device.pnp..ids list,
while "modalias" exports all the entries.
now it seems that the "hid" file is redundant, right?

thanks,
rui



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] ACPI: Do not export hid/modalias sysfs file for ACPI objects without a HID
  2010-10-08  0:26 ` Zhang Rui
@ 2010-10-08  7:27   ` Thomas Renninger
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Renninger @ 2010-10-08  7:27 UTC (permalink / raw)
  To: Zhang Rui
  Cc: lenb@kernel.org, kay.sievers@vrfy.org, linux-acpi@vger.kernel.org,
	Bjorn Helgaas

On Friday 08 October 2010 02:26:21 Zhang Rui wrote:
> On Fri, 2010-10-01 at 16:53 +0800, Thomas Renninger wrote:
> > Boot and compile tested.
> > The fact that pnp.ids can now be empty needs testing on some
> > further machines, though.
...
> > -	result = device_create_file(&dev->dev, &dev_attr_hid);
> > -	if (result)
> > -		goto end;
> > +	if (!list_empty(&dev->pnp.ids)) {
> > +		result = device_create_file(&dev->dev, &dev_attr_hid);
> > +		if (result)
> > +			goto end;
> >  
> > -	result = device_create_file(&dev->dev, &dev_attr_modalias);
> > -	if (result)
> > -		goto end;
> > +		result = device_create_file(&dev->dev, &dev_attr_modalias);
> > +		if (result)
> > +			goto end;
> > +	}
> >  
> 
> the "hid" attribute exports the first entry of the device.pnp..ids list,
> while "modalias" exports all the entries.
> now it seems that the "hid" file is redundant, right?
Yep. You need some parsing, but udev is already doing that.
But it's sysfs api..., you'd need to add a:
printk_once("Deprecated HID file accessed by %s, use modalias instead\n",
              current->comm);
and deprecate that for some years.

    Thomas

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-10-08  7:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-01  8:53 [PATCH 1/2] ACPI: Do not export hid/modalias sysfs file for ACPI objects without a HID Thomas Renninger
2010-10-01  8:54 ` [PATCH 2/2] ACPI/PNP: A HID value of an object never changes -> make it const Thomas Renninger
2010-10-01 19:49   ` Len Brown
2010-10-01 19:48 ` [PATCH 1/2] ACPI: Do not export hid/modalias sysfs file for ACPI objects without a HID Len Brown
2010-10-08  0:26 ` Zhang Rui
2010-10-08  7:27   ` Thomas Renninger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox