aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorThomas Renninger <trenn@suse.de>2010-10-01 04:53:59 -0400
committerLen Brown <len.brown@intel.com>2010-10-01 15:36:39 -0400
commit2b2ae7c7f8e25043793042eb9df88aa875b4cff8 (patch)
tree83daed7afd0d0b060219f8aff97a645dbf8027bc /drivers/acpi
parent899611ee7d373e5eeda08e9a8632684e1ebbbf00 (diff)
ACPI: Do not export hid/modalias sysfs file for ACPI objects without a HID
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: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/scan.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index b23825ecfa37..81aec8d66fd0 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -26,6 +26,9 @@ extern struct acpi_device *acpi_root;
26 26
27#define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent) 27#define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent)
28 28
29/* Should be const */
30static char* dummy_hid = "device";
31
29static LIST_HEAD(acpi_device_list); 32static LIST_HEAD(acpi_device_list);
30static LIST_HEAD(acpi_bus_id_list); 33static LIST_HEAD(acpi_bus_id_list);
31DEFINE_MUTEX(acpi_device_lock); 34DEFINE_MUTEX(acpi_device_lock);
@@ -49,6 +52,9 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
49 int count; 52 int count;
50 struct acpi_hardware_id *id; 53 struct acpi_hardware_id *id;
51 54
55 if (list_empty(&acpi_dev->pnp.ids))
56 return 0;
57
52 len = snprintf(modalias, size, "acpi:"); 58 len = snprintf(modalias, size, "acpi:");
53 size -= len; 59 size -= len;
54 60
@@ -202,13 +208,15 @@ static int acpi_device_setup_files(struct acpi_device *dev)
202 goto end; 208 goto end;
203 } 209 }
204 210
205 result = device_create_file(&dev->dev, &dev_attr_hid); 211 if (!list_empty(&dev->pnp.ids)) {
206 if (result) 212 result = device_create_file(&dev->dev, &dev_attr_hid);
207 goto end; 213 if (result)
214 goto end;
208 215
209 result = device_create_file(&dev->dev, &dev_attr_modalias); 216 result = device_create_file(&dev->dev, &dev_attr_modalias);
210 if (result) 217 if (result)
211 goto end; 218 goto end;
219 }
212 220
213 /* 221 /*
214 * If device has _EJ0, 'eject' file is created that is used to trigger 222 * 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)
316 struct acpi_device *acpi_dev = to_acpi_device(dev); 324 struct acpi_device *acpi_dev = to_acpi_device(dev);
317 int len; 325 int len;
318 326
327 if (list_empty(&acpi_dev->pnp.ids))
328 return 0;
329
319 if (add_uevent_var(env, "MODALIAS=")) 330 if (add_uevent_var(env, "MODALIAS="))
320 return -ENOMEM; 331 return -ENOMEM;
321 len = create_modalias(acpi_dev, &env->buf[env->buflen - 1], 332 len = create_modalias(acpi_dev, &env->buf[env->buflen - 1],
@@ -1014,6 +1025,9 @@ char *acpi_device_hid(struct acpi_device *device)
1014{ 1025{
1015 struct acpi_hardware_id *hid; 1026 struct acpi_hardware_id *hid;
1016 1027
1028 if (list_empty(&device->pnp.ids))
1029 return dummy_hid;
1030
1017 hid = list_first_entry(&device->pnp.ids, struct acpi_hardware_id, list); 1031 hid = list_first_entry(&device->pnp.ids, struct acpi_hardware_id, list);
1018 return hid->id; 1032 return hid->id;
1019} 1033}
@@ -1142,16 +1156,6 @@ static void acpi_device_set_id(struct acpi_device *device)
1142 acpi_add_id(device, ACPI_BUTTON_HID_SLEEPF); 1156 acpi_add_id(device, ACPI_BUTTON_HID_SLEEPF);
1143 break; 1157 break;
1144 } 1158 }
1145
1146 /*
1147 * We build acpi_devices for some objects that don't have _HID or _CID,
1148 * e.g., PCI bridges and slots. Drivers can't bind to these objects,
1149 * but we do use them indirectly by traversing the acpi_device tree.
1150 * This generic ID isn't useful for driver binding, but it provides
1151 * the useful property that "every acpi_device has an ID."
1152 */
1153 if (list_empty(&device->pnp.ids))
1154 acpi_add_id(device, "device");
1155} 1159}
1156 1160
1157static int acpi_device_set_context(struct acpi_device *device) 1161static int acpi_device_set_context(struct acpi_device *device)