From patchwork Tue Aug 7 00:36:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yasuaki Ishimatsu X-Patchwork-Id: 1282121 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id B1B1BDF288 for ; Tue, 7 Aug 2012 00:36:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756457Ab2HGAg0 (ORCPT ); Mon, 6 Aug 2012 20:36:26 -0400 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:35614 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756424Ab2HGAgZ (ORCPT ); Mon, 6 Aug 2012 20:36:25 -0400 Received: from m2.gw.fujitsu.co.jp (unknown [10.0.50.72]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id 3401A3EE0AE; Tue, 7 Aug 2012 09:36:24 +0900 (JST) Received: from smail (m2 [127.0.0.1]) by outgoing.m2.gw.fujitsu.co.jp (Postfix) with ESMTP id 1918945DE55; Tue, 7 Aug 2012 09:36:24 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (s2.gw.fujitsu.co.jp [10.0.50.92]) by m2.gw.fujitsu.co.jp (Postfix) with ESMTP id F3FE045DE50; Tue, 7 Aug 2012 09:36:23 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id E1F7B1DB803C; Tue, 7 Aug 2012 09:36:23 +0900 (JST) Received: from g01jpexchkw09.g01.fujitsu.local (g01jpexchkw09.g01.fujitsu.local [10.0.194.48]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 9E9C5E08003; Tue, 7 Aug 2012 09:36:23 +0900 (JST) Received: from [127.0.0.1] (10.124.101.33) by g01jpexchkw09.g01.fujitsu.local (10.0.194.48) with Microsoft SMTP Server id 14.2.309.2; Tue, 7 Aug 2012 09:36:22 +0900 X-SecurityPolicyCheck: OK by SHieldMailChecker v1.7.4 Message-ID: <502062FB.7030502@jp.fujitsu.com> Date: Tue, 7 Aug 2012 09:36:11 +0900 From: Yasuaki Ishimatsu User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: , , CC: , Subject: [PATCH v4] create sun sysfs file Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Even if a device has _SUN method, there is no way to know the slot unique-ID. Thus the patch creates "sun" file in sysfs so that we can recognize it. Reviewed-by: Toshi Kani Signed-off-by: Yasuaki Ishimatsu --- drivers/acpi/scan.c | 24 ++++++++++++++++++++++++ include/acpi/acpi_bus.h | 1 + 2 files changed, 25 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-3.5/include/acpi/acpi_bus.h =================================================================== --- linux-3.5.orig/include/acpi/acpi_bus.h 2012-07-30 10:06:49.722171575 +0900 +++ linux-3.5/include/acpi/acpi_bus.h 2012-08-07 08:57:45.678204360 +0900 @@ -209,6 +209,7 @@ struct acpi_device_pnp { struct list_head ids; /* _HID and _CIDs */ acpi_device_name device_name; /* Driver-determined */ acpi_device_class device_class; /* " */ + unsigned long sun; /* _SUN */ }; #define acpi_device_bid(d) ((d)->pnp.bus_id) Index: linux-3.5/drivers/acpi/scan.c =================================================================== --- linux-3.5.orig/drivers/acpi/scan.c 2012-07-30 10:06:49.713171688 +0900 +++ linux-3.5/drivers/acpi/scan.c 2012-08-07 09:01:38.196203659 +0900 @@ -192,10 +192,20 @@ end: } static DEVICE_ATTR(path, 0444, acpi_device_path_show, NULL); +static ssize_t +acpi_device_sun_show(struct device *dev, struct device_attribute *attr, + char *buf) { + struct acpi_device *acpi_dev = to_acpi_device(dev); + + return sprintf(buf, "%lu\n", acpi_dev->pnp.sun); +} +static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL); + static int acpi_device_setup_files(struct acpi_device *dev) { acpi_status status; acpi_handle temp; + unsigned long long sun; int result = 0; /* @@ -217,6 +227,16 @@ static int acpi_device_setup_files(struc goto end; } + status = acpi_evaluate_integer(dev->handle, "_SUN", NULL, &sun); + if (ACPI_SUCCESS(status)) { + dev->pnp.sun = (unsigned long)sun; + result = device_create_file(&dev->dev, &dev_attr_sun); + if (result) + goto end; + } else { + dev->pnp.sun = (unsigned long)-1; + } + /* * If device has _EJ0, 'eject' file is created that is used to trigger * hot-removal function from userland. @@ -241,6 +261,10 @@ static void acpi_device_remove_files(str if (ACPI_SUCCESS(status)) device_remove_file(&dev->dev, &dev_attr_eject); + status = acpi_get_handle(dev->handle, "_SUN", &temp); + if (ACPI_SUCCESS(status)) + device_remove_file(&dev->dev, &dev_attr_sun); + device_remove_file(&dev->dev, &dev_attr_modalias); device_remove_file(&dev->dev, &dev_attr_hid); if (dev->handle)