From patchwork Fri Mar 11 20:54:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Garrett X-Patchwork-Id: 629181 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 p2BKtQb8017390 for ; Fri, 11 Mar 2011 20:55:38 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754163Ab1CKUzh (ORCPT ); Fri, 11 Mar 2011 15:55:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:29506 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751489Ab1CKUzh (ORCPT ); Fri, 11 Mar 2011 15:55:37 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2BKt6KB025785 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 11 Mar 2011 15:55:06 -0500 Received: from cavan.codon.org.uk (ovpn-113-71.phx2.redhat.com [10.3.113.71]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p2BKt42U018248 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Fri, 11 Mar 2011 15:55:05 -0500 Received: from 209-6-41-104.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.41.104] helo=localhost.localdomain) by cavan.codon.org.uk with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1Py9MT-0005pV-OT; Fri, 11 Mar 2011 20:55:01 +0000 From: Matthew Garrett To: linux-acpi@vger.kernel.org Cc: lenb@kernel.org, Matthew Garrett Subject: [PATCH] ACPI: Handle multiple button devices with the same name Date: Fri, 11 Mar 2011 15:54:48 -0500 Message-Id: <1299876888-6239-1-git-send-email-mjg@redhat.com> X-SA-Do-Not-Run: Yes X-SA-Exim-Connect-IP: 209.6.41.104 X-SA-Exim-Mail-From: mjg@redhat.com X-SA-Exim-Scanned: No (on cavan.codon.org.uk); SAEximRunCond expanded to false X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 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.6 (demeter1.kernel.org [140.211.167.41]); Fri, 11 Mar 2011 20:55:38 +0000 (UTC) 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;