aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorJin Yao <yao.jin@linux.intel.com>2014-09-22 13:31:14 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2014-09-24 19:27:24 -0400
commit042e1c79166b9250edd8262bea84e1703f27ad2e (patch)
tree2a734d6d5d8025e19611bdef4d5786856ad14ca9 /drivers/input
parent05f7588c3c1641f64af93dc042947bbac35f39f6 (diff)
Input: soc_button_array - convert 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. Signed-off-by: Jin Yao <yao.jin@intel.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/misc/soc_button_array.c60
1 files changed, 31 insertions, 29 deletions
diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
index e34dfc29beb3..735604753568 100644
--- a/drivers/input/misc/soc_button_array.c
+++ b/drivers/input/misc/soc_button_array.c
@@ -18,7 +18,7 @@
18#include <linux/gpio/consumer.h> 18#include <linux/gpio/consumer.h>
19#include <linux/gpio_keys.h> 19#include <linux/gpio_keys.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/pnp.h> 21#include <linux/acpi.h>
22 22
23/* 23/*
24 * Definition of buttons on the tablet. The ACPI index of each button 24 * 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)
67} 67}
68 68
69static struct platform_device * 69static struct platform_device *
70soc_button_device_create(struct pnp_dev *pdev, 70soc_button_device_create(struct platform_device *pdev,
71 const struct soc_button_info *button_info, 71 const struct soc_button_info *button_info,
72 bool autorepeat) 72 bool autorepeat)
73{ 73{
@@ -138,30 +138,40 @@ err_free_mem:
138 return ERR_PTR(error); 138 return ERR_PTR(error);
139} 139}
140 140
141static void soc_button_remove(struct pnp_dev *pdev) 141static int soc_button_remove(struct platform_device *pdev)
142{ 142{
143 struct soc_button_data *priv = pnp_get_drvdata(pdev); 143 struct soc_button_data *priv = platform_get_drvdata(pdev);
144
144 int i; 145 int i;
145 146
146 for (i = 0; i < BUTTON_TYPES; i++) 147 for (i = 0; i < BUTTON_TYPES; i++)
147 if (priv->children[i]) 148 if (priv->children[i])
148 platform_device_unregister(priv->children[i]); 149 platform_device_unregister(priv->children[i]);
150
151 return 0;
149} 152}
150 153
151static int soc_button_pnp_probe(struct pnp_dev *pdev, 154static int soc_button_probe(struct platform_device *pdev)
152 const struct pnp_device_id *id)
153{ 155{
154 const struct soc_button_info *button_info = (void *)id->driver_data; 156 struct device *dev = &pdev->dev;
157 const struct acpi_device_id *id;
158 struct soc_button_info *button_info;
155 struct soc_button_data *priv; 159 struct soc_button_data *priv;
156 struct platform_device *pd; 160 struct platform_device *pd;
157 int i; 161 int i;
158 int error; 162 int error;
159 163
164 id = acpi_match_device(dev->driver->acpi_match_table, dev);
165 if (!id)
166 return -ENODEV;
167
168 button_info = (struct soc_button_info *)id->driver_data;
169
160 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 170 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
161 if (!priv) 171 if (!priv)
162 return -ENOMEM; 172 return -ENOMEM;
163 173
164 pnp_set_drvdata(pdev, priv); 174 platform_set_drvdata(pdev, priv);
165 175
166 for (i = 0; i < BUTTON_TYPES; i++) { 176 for (i = 0; i < BUTTON_TYPES; i++) {
167 pd = soc_button_device_create(pdev, button_info, i == 0); 177 pd = soc_button_device_create(pdev, button_info, i == 0);
@@ -192,30 +202,22 @@ static struct soc_button_info soc_button_PNP0C40[] = {
192 { } 202 { }
193}; 203};
194 204
195static const struct pnp_device_id soc_button_pnp_match[] = { 205static const struct acpi_device_id soc_button_acpi_match[] = {
196 { .id = "PNP0C40", .driver_data = (long)soc_button_PNP0C40 }, 206 { "PNP0C40", (unsigned long)soc_button_PNP0C40 },
197 { .id = "" } 207 { }
198}; 208};
199MODULE_DEVICE_TABLE(pnp, soc_button_pnp_match);
200 209
201static struct pnp_driver soc_button_pnp_driver = { 210MODULE_DEVICE_TABLE(acpi, soc_button_acpi_match);
202 .name = KBUILD_MODNAME, 211
203 .id_table = soc_button_pnp_match, 212static struct platform_driver soc_button_driver = {
204 .probe = soc_button_pnp_probe, 213 .probe = soc_button_probe,
205 .remove = soc_button_remove, 214 .remove = soc_button_remove,
215 .driver = {
216 .name = KBUILD_MODNAME,
217 .owner = THIS_MODULE,
218 .acpi_match_table = ACPI_PTR(soc_button_acpi_match),
219 },
206}; 220};
207 221module_platform_driver(soc_button_driver);
208static int __init soc_button_init(void)
209{
210 return pnp_register_driver(&soc_button_pnp_driver);
211}
212
213static void __exit soc_button_exit(void)
214{
215 pnp_unregister_driver(&soc_button_pnp_driver);
216}
217
218module_init(soc_button_init);
219module_exit(soc_button_exit);
220 222
221MODULE_LICENSE("GPL"); 223MODULE_LICENSE("GPL");