From patchwork Wed Mar 17 17:35:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 86482 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2HHaBLh004734 for ; Wed, 17 Mar 2010 17:36:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755105Ab0CQRfL (ORCPT ); Wed, 17 Mar 2010 13:35:11 -0400 Received: from g6t0184.atlanta.hp.com ([15.193.32.61]:24502 "EHLO g6t0184.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751677Ab0CQRfD (ORCPT ); Wed, 17 Mar 2010 13:35:03 -0400 Received: from g5t0030.atlanta.hp.com (g5t0030.atlanta.hp.com [16.228.8.142]) by g6t0184.atlanta.hp.com (Postfix) with ESMTP id 702B5C094; Wed, 17 Mar 2010 17:35:01 +0000 (UTC) Received: from ldl (ldl.fc.hp.com [15.11.146.30]) by g5t0030.atlanta.hp.com (Postfix) with ESMTP id 8A8F71418A; Wed, 17 Mar 2010 17:35:00 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl (Postfix) with ESMTP id 68D87CF004B; Wed, 17 Mar 2010 11:35:00 -0600 (MDT) Received: from ldl ([127.0.0.1]) by localhost (ldl.fc.hp.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id z9szq33O-JjP; Wed, 17 Mar 2010 11:35:00 -0600 (MDT) Received: from eh.fc.hp.com (eh.fc.hp.com [15.11.146.105]) by ldl (Postfix) with ESMTP id 53632CF0010; Wed, 17 Mar 2010 11:35:00 -0600 (MDT) Received: from bob.kio (localhost [127.0.0.1]) by eh.fc.hp.com (Postfix) with ESMTP id 3CD1626189; Wed, 17 Mar 2010 11:35:00 -0600 (MDT) Subject: [PATCH 1/3] hpet: convert to PNP driver To: Clemens Ladisch From: Bjorn Helgaas Cc: linux-acpi@vger.kernel.org, Vojtech Pavlik , linux-kernel@vger.kernel.org, "Venkatesh Pallipadi \(Venki\)" Date: Wed, 17 Mar 2010 11:35:00 -0600 Message-ID: <20100317173500.31124.53755.stgit@bob.kio> In-Reply-To: <20100317173329.31124.69795.stgit@bob.kio> References: <20100317173329.31124.69795.stgit@bob.kio> User-Agent: StGit/0.15 MIME-Version: 1.0 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.3 (demeter.kernel.org [140.211.167.41]); Wed, 17 Mar 2010 17:36:11 +0000 (UTC) diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index e481c59..65a9aa8 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -40,7 +41,6 @@ #include #include -#include #include /* @@ -899,100 +899,53 @@ int hpet_alloc(struct hpet_data *hdp) return 0; } -static acpi_status hpet_resources(struct acpi_resource *res, void *data) +static int hpet_pnp_add(struct pnp_dev *dev, const struct pnp_device_id *dev_id) { - struct hpet_data *hdp; - acpi_status status; - struct acpi_resource_address64 addr; - - hdp = data; - - status = acpi_resource_to_address64(res, &addr); - - if (ACPI_SUCCESS(status)) { - hdp->hd_phys_address = addr.minimum; - hdp->hd_address = ioremap(addr.minimum, addr.address_length); - - if (hpet_is_known(hdp)) { - iounmap(hdp->hd_address); - return AE_ALREADY_EXISTS; - } - } else if (res->type == ACPI_RESOURCE_TYPE_FIXED_MEMORY32) { - struct acpi_resource_fixed_memory32 *fixmem32; - - fixmem32 = &res->data.fixed_memory32; - if (!fixmem32) - return AE_NO_MEMORY; + struct hpet_data data; + struct resource *mem, *irq; + int i; - hdp->hd_phys_address = fixmem32->address; - hdp->hd_address = ioremap(fixmem32->address, - HPET_RANGE_SIZE); + memset(&data, 0, sizeof(data)); - if (hpet_is_known(hdp)) { - iounmap(hdp->hd_address); - return AE_ALREADY_EXISTS; - } - } else if (res->type == ACPI_RESOURCE_TYPE_EXTENDED_IRQ) { - struct acpi_resource_extended_irq *irqp; - int i, irq; + mem = pnp_get_resource(dev, IORESOURCE_MEM, 0); + if (!mem) + return -ENODEV; - irqp = &res->data.extended_irq; + data.hd_phys_address = mem->start; - for (i = 0; i < irqp->interrupt_count; i++) { - irq = acpi_register_gsi(NULL, irqp->interrupts[i], - irqp->triggering, irqp->polarity); - if (irq < 0) - return AE_ERROR; + if (hpet_is_known(&data)) + return -EBUSY; - hdp->hd_irq[hdp->hd_nirqs] = irq; - hdp->hd_nirqs++; - } + i = 0; + while (data.hd_nirqs < ARRAY_SIZE(data.hd_irq)) { + irq = pnp_get_resource(dev, IORESOURCE_IRQ, i++); + if (pnp_resource_valid(irq) && pnp_resource_enabled(irq)) + data.hd_irq[data.hd_nirqs++] = irq->start; } - - return AE_OK; -} - -static int hpet_acpi_add(struct acpi_device *device) -{ - acpi_status result; - struct hpet_data data; - - memset(&data, 0, sizeof(data)); - - result = - acpi_walk_resources(device->handle, METHOD_NAME__CRS, - hpet_resources, &data); - - if (ACPI_FAILURE(result)) + if (!data.hd_nirqs) return -ENODEV; - if (!data.hd_address || !data.hd_nirqs) { - printk("%s: no address or irqs in _CRS\n", __func__); - return -ENODEV; - } + data.hd_address = ioremap(mem->start, resource_size(mem)); return hpet_alloc(&data); } -static int hpet_acpi_remove(struct acpi_device *device, int type) +static void hpet_pnp_remove(struct pnp_dev *dev) { /* XXX need to unregister clocksource, dealloc mem, etc */ - return -EINVAL; } -static const struct acpi_device_id hpet_device_ids[] = { +static const struct pnp_device_id hpet_device_ids[] = { {"PNP0103", 0}, {"", 0}, }; MODULE_DEVICE_TABLE(acpi, hpet_device_ids); -static struct acpi_driver hpet_acpi_driver = { +static struct pnp_driver hpet_pnp_driver = { .name = "hpet", - .ids = hpet_device_ids, - .ops = { - .add = hpet_acpi_add, - .remove = hpet_acpi_remove, - }, + .id_table = hpet_device_ids, + .probe = hpet_pnp_add, + .remove = hpet_pnp_remove, }; static struct miscdevice hpet_misc = { HPET_MINOR, "hpet", &hpet_fops }; @@ -1007,7 +960,7 @@ static int __init hpet_init(void) sysctl_header = register_sysctl_table(dev_root); - result = acpi_bus_register_driver(&hpet_acpi_driver); + result = pnp_register_driver(&hpet_pnp_driver); if (result < 0) { if (sysctl_header) unregister_sysctl_table(sysctl_header); @@ -1020,13 +973,11 @@ static int __init hpet_init(void) static void __exit hpet_exit(void) { - acpi_bus_unregister_driver(&hpet_acpi_driver); + pnp_unregister_driver(&hpet_pnp_driver); if (sysctl_header) unregister_sysctl_table(sysctl_header); misc_deregister(&hpet_misc); - - return; } module_init(hpet_init);