From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8405EC4361B for ; Wed, 9 Dec 2020 20:39:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4BAE323C91 for ; Wed, 9 Dec 2020 20:39:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387921AbgLIUis (ORCPT ); Wed, 9 Dec 2020 15:38:48 -0500 Received: from mga09.intel.com ([134.134.136.24]:61104 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728553AbgLIUii (ORCPT ); Wed, 9 Dec 2020 15:38:38 -0500 IronPort-SDR: wneR72WwgG8cfUCN+AC8awbiCRPqei/PjSn9SzSsHtvs3Rq54yrxjvEx5WmvRf//4cwKB2N9B0 22jUNxueF2ng== X-IronPort-AV: E=McAfee;i="6000,8403,9830"; a="174291096" X-IronPort-AV: E=Sophos;i="5.78,405,1599548400"; d="scan'208";a="174291096" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2020 12:36:45 -0800 IronPort-SDR: 0jcpJbiAaVOWNy7RPYMj08XrSpSIbn9Io7H/9x6USd35wrZu1B5oAArnRjxHsIjyLXsc8/1ulk bB/1+P4n18cA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,405,1599548400"; d="scan'208";a="318900937" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 09 Dec 2020 12:36:44 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 9B483252; Wed, 9 Dec 2020 22:36:43 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Peng Hao , Arnd Bergmann Subject: [PATCH v2 4/5] misc: pvpanic: Combine ACPI and platform drivers Date: Wed, 9 Dec 2020 22:36:41 +0200 Message-Id: <20201209203642.27648-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201209203642.27648-1-andriy.shevchenko@linux.intel.com> References: <20201209203642.27648-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is nothing special in the driver that requires to have a special ACPI driver for it. Combine both into simple platform driver. Cc: Peng Hao Cc: Arnd Bergmann Signed-off-by: Andy Shevchenko --- v2: no changes drivers/misc/pvpanic.c | 130 ++++++----------------------------------- 1 file changed, 17 insertions(+), 113 deletions(-) diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic.c index e16a5e51006e..fcab2efd0c45 100644 --- a/drivers/misc/pvpanic.c +++ b/drivers/misc/pvpanic.c @@ -8,7 +8,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include +#include #include #include #include @@ -49,101 +49,16 @@ static struct notifier_block pvpanic_panic_nb = { .priority = 1, /* let this called before broken drm_fb_helper */ }; -#ifdef CONFIG_ACPI -static int pvpanic_add(struct acpi_device *device); -static int pvpanic_remove(struct acpi_device *device); - -static const struct acpi_device_id pvpanic_device_ids[] = { - { "QEMU0001", 0 }, - { "", 0 } -}; -MODULE_DEVICE_TABLE(acpi, pvpanic_device_ids); - -static struct acpi_driver pvpanic_driver = { - .name = "pvpanic", - .class = "QEMU", - .ids = pvpanic_device_ids, - .ops = { - .add = pvpanic_add, - .remove = pvpanic_remove, - }, - .owner = THIS_MODULE, -}; - -static acpi_status -pvpanic_walk_resources(struct acpi_resource *res, void *context) -{ - struct resource r; - - if (acpi_dev_resource_io(res, &r)) { -#ifdef CONFIG_HAS_IOPORT_MAP - base = ioport_map(r.start, resource_size(&r)); - return AE_OK; -#else - return AE_ERROR; -#endif - } else if (acpi_dev_resource_memory(res, &r)) { - base = ioremap(r.start, resource_size(&r)); - return AE_OK; - } - - return AE_ERROR; -} - -static int pvpanic_add(struct acpi_device *device) -{ - int ret; - - ret = acpi_bus_get_status(device); - if (ret < 0) - return ret; - - if (!device->status.enabled || !device->status.functional) - return -ENODEV; - - acpi_walk_resources(device->handle, METHOD_NAME__CRS, - pvpanic_walk_resources, NULL); - - if (!base) - return -ENODEV; - - atomic_notifier_chain_register(&panic_notifier_list, - &pvpanic_panic_nb); - - return 0; -} - -static int pvpanic_remove(struct acpi_device *device) -{ - - atomic_notifier_chain_unregister(&panic_notifier_list, - &pvpanic_panic_nb); - iounmap(base); - - return 0; -} - -static int pvpanic_register_acpi_driver(void) -{ - return acpi_bus_register_driver(&pvpanic_driver); -} - -static void pvpanic_unregister_acpi_driver(void) -{ - acpi_bus_unregister_driver(&pvpanic_driver); -} -#else -static int pvpanic_register_acpi_driver(void) -{ - return -ENODEV; -} - -static void pvpanic_unregister_acpi_driver(void) {} -#endif - static int pvpanic_mmio_probe(struct platform_device *pdev) { - base = devm_platform_ioremap_resource(pdev, 0); + struct device *dev = &pdev->dev; + struct resource *res; + + res = platform_get_mem_or_io(pdev, 0); + if (res && resource_type(res) == IORESOURCE_IO) + base = devm_ioport_map(dev, res->start, resource_size(res)); + else + base = devm_ioremap_resource(dev, res); if (IS_ERR(base)) return PTR_ERR(base); @@ -167,30 +82,19 @@ static const struct of_device_id pvpanic_mmio_match[] = { {} }; +static const struct acpi_device_id pvpanic_device_ids[] = { + { "QEMU0001", 0 }, + { "", 0 } +}; +MODULE_DEVICE_TABLE(acpi, pvpanic_device_ids); + static struct platform_driver pvpanic_mmio_driver = { .driver = { .name = "pvpanic-mmio", .of_match_table = pvpanic_mmio_match, + .acpi_match_table = pvpanic_device_ids, }, .probe = pvpanic_mmio_probe, .remove = pvpanic_mmio_remove, }; - -static int __init pvpanic_mmio_init(void) -{ - if (acpi_disabled) - return platform_driver_register(&pvpanic_mmio_driver); - else - return pvpanic_register_acpi_driver(); -} - -static void __exit pvpanic_mmio_exit(void) -{ - if (acpi_disabled) - platform_driver_unregister(&pvpanic_mmio_driver); - else - pvpanic_unregister_acpi_driver(); -} - -module_init(pvpanic_mmio_init); -module_exit(pvpanic_mmio_exit); +module_platform_driver(pvpanic_mmio_driver); -- 2.29.2