From patchwork Wed Jul 30 06:45:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 4646051 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5AFD39F36A for ; Wed, 30 Jul 2014 06:45:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 58C4A2012B for ; Wed, 30 Jul 2014 06:45:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 01E582009C for ; Wed, 30 Jul 2014 06:45:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752289AbaG3GpY (ORCPT ); Wed, 30 Jul 2014 02:45:24 -0400 Received: from mga14.intel.com ([192.55.52.115]:46895 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752052AbaG3GpX (ORCPT ); Wed, 30 Jul 2014 02:45:23 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 29 Jul 2014 23:38:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,762,1400050800"; d="scan'208";a="569286834" Received: from unknown (HELO [10.255.20.233]) ([10.255.20.233]) by fmsmga001.fm.intel.com with ESMTP; 29 Jul 2014 23:45:21 -0700 Message-ID: <1406702719.10148.3.camel@rzhang1-toshiba> Subject: Re: [PATCH] soc_button_array: fix the issue that button device can't be enumerated since 3.16-rc1 From: Zhang Rui To: Dmitry Torokhov Cc: "Rafael J. Wysocki" , yao.jin@intel.com, linux-input Date: Wed, 30 Jul 2014 14:45:19 +0800 In-Reply-To: <20140709165732.GD10364@core.coreip.homeip.net> References: <1404309504.8366.93.camel@rzhang1-toshiba> <1404309713.8366.94.camel@rzhang1-toshiba> <2556427.cdnVoQoSXY@vostro.rjw.lan> <20140709165732.GD10364@core.coreip.homeip.net> X-Mailer: Evolution 3.8.4-0ubuntu1 Mime-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, Dmitry, On Wed, 2014-07-09 at 09:57 -0700, Dmitry Torokhov wrote: > On Tue, Jul 08, 2014 at 10:50:04PM +0200, Rafael J. Wysocki wrote: > > On Wednesday, July 02, 2014 10:01:53 PM Zhang Rui wrote: > > > From c2ee1886ba230d9d93d2ea2f350b1dc1a2d5ead5 Mon Sep 17 00:00:00 2001 > > > From: Jin Yao > > > Date: Thu, 26 Jun 2014 10:26:44 +0800 > > > Subject: [PATCH] soc_button_array: fix the issue that button device can't be > > > enumerated since 3.16-rc1 > > > > Hi Rui, > > > > For 3.16 I'm afraid we need to add the missing device ID to the PNP list. > > It is too late to do the conversion at this point IMO and we can do it later. > > But for 3.17 this patch is the right way of doing things, right? This is the patch we should use for 3.17. Compared with the previous version, I just removed the soc_button_array id from acpi pnp id list, which was added in 3.16-rc5, as an urgent fix. Please review. From f09ff78ba75a9de0f6df333be6238a5b1bf36464 Mon Sep 17 00:00:00 2001 From: Jin Yao Date: Thu, 26 Jun 2014 10:26:44 +0800 Subject: [PATCH] convert soc_button_array driver to platform bus ACPI device enumeration mechanism changed a lot since 3.16-rc1. ACPI device objects with _HID will be enumerated to platform bus by default. For the existing PNP drivers that probe the PNPACPI devices, the device ids are listed explicitly in drivers/acpi/acpi_pnp.c. But ACPI folks will continue their effort on shrinking this id list by converting the PNP drivers to platform drivers, for the devices that don't belong to PNP bus in nature. convert soc_button_array driver from PNP bus to platform bus in this patch. Signed-off-by: Jin Yao Signed-off-by: Zhang Rui --- drivers/acpi/acpi_pnp.c | 2 -- drivers/input/misc/soc_button_array.c | 60 ++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c index 4ddb0dc..6703c1f 100644 --- a/drivers/acpi/acpi_pnp.c +++ b/drivers/acpi/acpi_pnp.c @@ -14,8 +14,6 @@ #include static const struct acpi_device_id acpi_pnp_device_ids[] = { - /* soc_button_array */ - {"PNP0C40"}, /* pata_isapnp */ {"PNP0600"}, /* Generic ESDI/IDE/ATA compatible hard disk controller */ /* floppy */ diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c index 5a6334b..16ca162 100644 --- a/drivers/input/misc/soc_button_array.c +++ b/drivers/input/misc/soc_button_array.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include /* * Definition of buttons on the tablet. The ACPI index of each button @@ -67,7 +67,7 @@ static int soc_button_lookup_gpio(struct device *dev, int acpi_index) } static struct platform_device * -soc_button_device_create(struct pnp_dev *pdev, +soc_button_device_create(struct platform_device *pdev, const struct soc_button_info *button_info, bool autorepeat) { @@ -135,30 +135,40 @@ soc_button_device_create(struct pnp_dev *pdev, return ERR_PTR(error); } -static void soc_button_remove(struct pnp_dev *pdev) +static int soc_button_remove(struct platform_device *pdev) { - struct soc_button_data *priv = pnp_get_drvdata(pdev); + struct soc_button_data *priv = platform_get_drvdata(pdev); + int i; for (i = 0; i < BUTTON_TYPES; i++) if (priv->children[i]) platform_device_unregister(priv->children[i]); + + return 0; } -static int soc_button_pnp_probe(struct pnp_dev *pdev, - const struct pnp_device_id *id) +static int soc_button_probe(struct platform_device *pdev) { - const struct soc_button_info *button_info = (void *)id->driver_data; + struct device *dev = &pdev->dev; + const struct acpi_device_id *id; + struct soc_button_info *button_info; struct soc_button_data *priv; struct platform_device *pd; int i; int error; + id = acpi_match_device(dev->driver->acpi_match_table, dev); + if (!id) + return -ENODEV; + + button_info = (struct soc_button_info *)id->driver_data; + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; - pnp_set_drvdata(pdev, priv); + platform_set_drvdata(pdev, priv); for (i = 0; i < BUTTON_TYPES; i++) { pd = soc_button_device_create(pdev, button_info, i == 0); @@ -189,30 +199,22 @@ static struct soc_button_info soc_button_PNP0C40[] = { { } }; -static const struct pnp_device_id soc_button_pnp_match[] = { - { .id = "PNP0C40", .driver_data = (long)soc_button_PNP0C40 }, - { .id = "" } +static const struct acpi_device_id soc_button_acpi_match[] = { + { "PNP0C40", (unsigned long)soc_button_PNP0C40 }, + { } }; -MODULE_DEVICE_TABLE(pnp, soc_button_pnp_match); -static struct pnp_driver soc_button_pnp_driver = { - .name = KBUILD_MODNAME, - .id_table = soc_button_pnp_match, - .probe = soc_button_pnp_probe, +MODULE_DEVICE_TABLE(acpi, soc_button_acpi_match); + +static struct platform_driver soc_button_driver = { + .probe = soc_button_probe, .remove = soc_button_remove, + .driver = { + .name = KBUILD_MODNAME, + .owner = THIS_MODULE, + .acpi_match_table = ACPI_PTR(soc_button_acpi_match), + }, }; - -static int __init soc_button_init(void) -{ - return pnp_register_driver(&soc_button_pnp_driver); -} - -static void __exit soc_button_exit(void) -{ - pnp_unregister_driver(&soc_button_pnp_driver); -} - -module_init(soc_button_init); -module_exit(soc_button_exit); +module_platform_driver(soc_button_driver); MODULE_LICENSE("GPL");