From patchwork Fri Oct 1 08:53:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Renninger X-Patchwork-Id: 223102 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o918s8x5021680 for ; Fri, 1 Oct 2010 08:54:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754996Ab0JAIyG (ORCPT ); Fri, 1 Oct 2010 04:54:06 -0400 Received: from cantor.suse.de ([195.135.220.2]:42014 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754125Ab0JAIyE (ORCPT ); Fri, 1 Oct 2010 04:54:04 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 1CA0A9417A; Fri, 1 Oct 2010 10:54:02 +0200 (CEST) From: Thomas Renninger To: lenb@kernel.org Cc: Thomas Renninger , Zhang Rui , kay.sievers@vrfy.org, , Bjorn Helgaas Subject: [PATCH 1/2] ACPI: Do not export hid/modalias sysfs file for ACPI objects without a HID Date: Fri, 1 Oct 2010 10:53:59 +0200 Message-Id: <1285923240-31671-1-git-send-email-trenn@suse.de> X-Mailer: git-send-email 1.6.3 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 01 Oct 2010 08:54:09 +0000 (UTC) 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)