From: Bjorn Helgaas <bjorn.helgaas@hp.com>
To: "David Härdeman" <david@hardeman.nu>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
linux-input@vger.kernel.org, jbarnes@virtuousgeek.org,
"Len Brown" <lenb@kernel.org>
Subject: [PATCH 2/2] Winbond: convert from ACPI to PNP driver
Date: Thu, 9 Jul 2009 15:40:27 -0600 [thread overview]
Message-ID: <200907091540.28283.bjorn.helgaas@hp.com> (raw)
In-Reply-To: <200907091538.21685.bjorn.helgaas@hp.com>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 7049 bytes --]
diff --git a/drivers/input/misc/winbond-cir.c b/drivers/input/misc/winbond-cir.c
index f97271b..9b5c985 100644
--- a/drivers/input/misc/winbond-cir.c
+++ b/drivers/input/misc/winbond-cir.c
@@ -45,7 +45,7 @@
*/
#include <linux/module.h>
-#include <linux/acpi.h>
+#include <linux/pnp.h>
#include <linux/interrupt.h>
#include <linux/timer.h>
#include <linux/input.h>
@@ -161,7 +161,6 @@ enum wbcir_protocol {
/* Misc */
#define WBCIR_ACPI_NAME "Winbond CIR"
-#define WBCIR_ACPI_CLASS "CIR"
#define WBCIR_ID_FAMILY 0xF1 /* Family ID for the WPCD376I */
#define WBCIR_ID_CHIP 0x04 /* Chip ID for the WPCD376I */
#define IR_KEYPRESS_TIMEOUT 250 /* FIXME: should be per-protocol? */
@@ -937,8 +936,8 @@ wbcir_parse_nec(struct device *dev, struct wbcir_data *data)
static irqreturn_t
wbcir_irq_handler(int irqno, void *cookie)
{
- struct acpi_device *device = cookie;
- struct wbcir_data *data = acpi_driver_data(device);
+ struct pnp_dev *device = cookie;
+ struct wbcir_data *data = pnp_get_drvdata(device);
struct device *dev = &device->dev;
u8 status;
unsigned long flags;
@@ -1021,11 +1020,11 @@ out:
*
*****************************************************************************/
-static int
-wbcir_shutdown(struct acpi_device *device)
+static void
+wbcir_shutdown(struct pnp_dev *device)
{
struct device *dev = &device->dev;
- struct wbcir_data *data = acpi_driver_data(device);
+ struct wbcir_data *data = pnp_get_drvdata(device);
int do_wake = 1;
u8 match[11];
u8 mask[11];
@@ -1197,20 +1196,19 @@ finish:
/* Disable interrupts */
outb(WBCIR_IRQ_NONE, data->sbase + WBCIR_REG_SP3_IER);
-
- return 0;
}
static int
-wbcir_suspend(struct acpi_device *device, pm_message_t state)
+wbcir_suspend(struct pnp_dev *device, pm_message_t state)
{
- return wbcir_shutdown(device);
+ wbcir_shutdown(device);
+ return 0;
}
static int
-wbcir_resume(struct acpi_device *device)
+wbcir_resume(struct pnp_dev *device)
{
- struct wbcir_data *data = acpi_driver_data(device);
+ struct wbcir_data *data = pnp_get_drvdata(device);
/* Clear BUFF_EN, Clear END_EN, Clear MATCH_EN */
wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_EV_EN, 0x00, 0x07);
@@ -1237,8 +1235,8 @@ static ssize_t
wbcir_show_last_scancode(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct acpi_device *device = container_of(dev, struct acpi_device, dev);
- struct wbcir_data *data = acpi_driver_data(device);
+ struct pnp_dev *device = container_of(dev, struct pnp_dev, dev);
+ struct wbcir_data *data = pnp_get_drvdata(device);
return sprintf(buf, "0x%08X\n", data->last_scancode);
}
@@ -1261,56 +1259,6 @@ static struct attribute_group wbcir_attribute_group = {
.attrs = wbcir_attributes,
};
-static acpi_status
-wbcir_walk_resources(struct acpi_resource *resource, void *context)
-{
- struct wbcir_data *data = context;
-
- switch (resource->type) {
-
- case ACPI_RESOURCE_TYPE_IO:
- if (!data->ebase) {
- if (resource->data.io.address_length !=
- EHFUNC_IOMEM_LEN)
- goto error;
- data->ebase = resource->data.io.minimum;
- } else if (!data->wbase) {
- if (resource->data.io.address_length !=
- WAKEUP_IOMEM_LEN)
- goto error;
- data->wbase = resource->data.io.minimum;
- } else if (!data->sbase) {
- if (resource->data.io.address_length !=
- SP_IOMEM_LEN)
- goto error;
- data->sbase = resource->data.io.minimum;
- } else {
- goto error;
- }
- break;
-
- case ACPI_RESOURCE_TYPE_IRQ:
- if (resource->data.irq.interrupt_count != 1)
- goto error;
- else if (!data->irq)
- data->irq = resource->data.irq.interrupts[0];
- else
- goto error;
- break;
-
- case ACPI_RESOURCE_TYPE_END_TAG:
- break;
-
- default:
- goto error;
- }
-
- return AE_OK;
-
-error:
- return AE_ERROR;
-}
-
static void
wbcir_cfg_ceir(struct wbcir_data *data)
{
@@ -1345,28 +1293,36 @@ wbcir_cfg_ceir(struct wbcir_data *data)
}
static int
-wbcir_add(struct acpi_device *device)
+wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
{
struct device *dev = &device->dev;
struct wbcir_data *data;
- acpi_status status;
int err;
+ if (!(pnp_port_len(device, 0) == EHFUNC_IOMEM_LEN &&
+ pnp_port_len(device, 1) == WAKEUP_IOMEM_LEN &&
+ pnp_port_len(device, 2) == SP_IOMEM_LEN)) {
+ dev_err(dev, "Invalid resources\n");
+ return -ENODEV;
+ }
+
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data) {
err = -ENOMEM;
goto exit;
}
- device->driver_data = data;
+ pnp_set_drvdata(device, data);
- status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
- wbcir_walk_resources, data);
+ data->ebase = pnp_port_start(device, 0);
+ data->wbase = pnp_port_start(device, 1);
+ data->sbase = pnp_port_start(device, 2);
+ data->irq = pnp_irq(device, 0);
- if (ACPI_FAILURE(status) || data->wbase == 0 || data->ebase == 0 ||
+ if (data->wbase == 0 || data->ebase == 0 ||
data->sbase == 0 || data->irq == 0) {
err = -ENODEV;
- dev_err(dev, "Invalid ACPI resources\n");
+ dev_err(dev, "Invalid resources\n");
goto exit_free_data;
}
@@ -1579,15 +1535,15 @@ exit_release_wbase:
release_region(data->wbase, WAKEUP_IOMEM_LEN);
exit_free_data:
kfree(data);
- device->driver_data = NULL;
+ pnp_set_drvdata(device, NULL);
exit:
return err;
}
-static int
-wbcir_remove(struct acpi_device *device, int type)
+static void
+wbcir_remove(struct pnp_dev *device)
{
- struct wbcir_data *data = acpi_driver_data(device);
+ struct wbcir_data *data = pnp_get_drvdata(device);
struct wbcir_keyentry *key;
struct wbcir_keyentry *keytmp;
@@ -1631,29 +1587,23 @@ wbcir_remove(struct acpi_device *device, int type)
kfree(data);
- device->driver_data = NULL;
-
- return 0;
+ pnp_set_drvdata(device, NULL);
}
-static const struct acpi_device_id wbcir_ids[] = {
+static const struct pnp_device_id wbcir_ids[] = {
{ "WEC1022", 0 },
{ "", 0 }
};
-MODULE_DEVICE_TABLE(acpi, wbcir_ids);
-
-static struct acpi_driver wbcir_driver = {
- .name = WBCIR_ACPI_NAME,
- .class = WBCIR_ACPI_CLASS,
- .ids = wbcir_ids,
- .ops = {
- .add = wbcir_add,
- .remove = wbcir_remove,
- .suspend = wbcir_suspend,
- .resume = wbcir_resume,
- .shutdown = wbcir_shutdown
- },
- .owner = THIS_MODULE
+MODULE_DEVICE_TABLE(pnp, wbcir_ids);
+
+static struct pnp_driver wbcir_driver = {
+ .name = WBCIR_ACPI_NAME,
+ .id_table = wbcir_ids,
+ .probe = wbcir_probe,
+ .remove = wbcir_remove,
+ .suspend = wbcir_suspend,
+ .resume = wbcir_resume,
+ .shutdown = wbcir_shutdown
};
static int __init
@@ -1671,7 +1621,7 @@ wbcir_init(void)
return -EINVAL;
}
- ret = acpi_bus_register_driver(&wbcir_driver);
+ ret = pnp_register_driver(&wbcir_driver);
if (ret)
printk(KERN_ERR DRVNAME ": Unable to register driver\n");
@@ -1681,7 +1631,7 @@ wbcir_init(void)
static void __exit
wbcir_exit(void)
{
- acpi_bus_unregister_driver(&wbcir_driver);
+ pnp_unregister_driver(&wbcir_driver);
}
MODULE_AUTHOR("David Härdeman <david@hardeman.nu>");
next prev parent reply other threads:[~2009-07-09 21:40 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-27 5:18 [PATCH 0/2] Winbond IR driver David Härdeman
2009-06-27 5:18 ` [PATCH 1/2] ACPI: reintroduce acpi_device_ops .shutdown method David Härdeman
2009-06-30 21:10 ` Andrew Morton
2009-06-30 23:11 ` Bjorn Helgaas
2009-07-01 8:20 ` David Härdeman
2009-07-08 16:52 ` Bjorn Helgaas
2009-07-09 21:38 ` [PATCH 0/2] Winbond driver as PNP Bjorn Helgaas
2009-07-09 21:39 ` [PATCH 1/2] PNP: add .shutdown method Bjorn Helgaas
2009-07-09 21:40 ` Bjorn Helgaas [this message]
2009-07-10 7:55 ` [PATCH 0/2] Winbond driver as PNP David Härdeman
2009-07-10 16:01 ` Bjorn Helgaas
2009-06-27 5:18 ` [PATCH 2/2] Add a driver for the Winbond WPCD376I IR functionality David Härdeman
2009-06-30 21:23 ` Andrew Morton
2009-07-01 7:47 ` David Härdeman
2009-07-01 18:06 ` Andrew Morton
2009-07-01 21:45 ` David Härdeman
2009-07-01 21:47 ` David Härdeman
2009-07-01 21:53 ` Jesse Barnes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200907091540.28283.bjorn.helgaas@hp.com \
--to=bjorn.helgaas@hp.com \
--cc=akpm@linux-foundation.org \
--cc=david@hardeman.nu \
--cc=jbarnes@virtuousgeek.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®