Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2006510imu; Thu, 24 Jan 2019 05:49:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN4kpuShSjzm+mhp0avbeXSf3uKh6sYat82rgjlo0q39wKgPlmi3oigE+HvwC+Bsn3wntx6b X-Received: by 2002:a62:6f88:: with SMTP id k130mr6526566pfc.234.1548337780717; Thu, 24 Jan 2019 05:49:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548337780; cv=none; d=google.com; s=arc-20160816; b=RXCEQaD19V5qugz9W4FMZzq5wqvO3KOQtW4YbLF8X4IS4eP51sU2WtRsO80nFBVmYv p1CcjXoqCCG5VHajkkQZXQgoUFPwtfjgG/AYpQ55X/YSWJJpBRd6Ys+4mgh9aufOTJSH gmHhoftlT296i2Q4Rna6Gak50YTC5LKxEzNgTABWTPKlpBfUg1h9MKWWSCFj9sN6K9pA dY3Mjg2V/zWQWlUkNNiqVAm/u3ndMzJ7Hb8vLZOGKPiRew4ANzX9Qo+5uP0aJyiHOZxV qly75EFFNwSCkVluaOpiihY46leOdhSEHiPOO2U8izMrZyfJtN7wQEUCki+UFmGL5yKC bNOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=7APLEfGUyr7yurxye093lKwqBsnqEuz+LXHUBxtflBY=; b=Yewl/Te7iX3e7kipJmqwA12ZGClHoJyJmEJBLDW86qBu5GlqLQgyY3DbM5yt1j1/KB LqbLGO5Q1mD4dTwbsVmqWKaAlMTp0A6y5UluLPA+evuK5YBgIXunY4BSqQBZISAFQixo Nf7joroz7mE6VBS6yMz8nLwUnh5mubzbaqHGVtZPKMph5bGOWd7V1a0y7SnPPfNfYDmo r6vKr6dA3You80ic0I9ct0oBWfF03eLB2pqCVNyqxBOE9kOVlCgv4+mGxpoLHZROctd4 UDDrgSkwmIiQZZB0A6sldZVmKEE1emjqGY621NepK6EmV0bjPAcmP5LqcW6ykDVL/Utj iYPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=peIbEjvB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v32si20484151plb.369.2019.01.24.05.49.25; Thu, 24 Jan 2019 05:49:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=peIbEjvB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728170AbfAXNrU (ORCPT + 99 others); Thu, 24 Jan 2019 08:47:20 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:38702 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727799AbfAXNrU (ORCPT ); Thu, 24 Jan 2019 08:47:20 -0500 Received: by mail-pf1-f194.google.com with SMTP id q1so3013638pfi.5 for ; Thu, 24 Jan 2019 05:47:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7APLEfGUyr7yurxye093lKwqBsnqEuz+LXHUBxtflBY=; b=peIbEjvBJRZwcGMYxSvdlJNKZVGUl869qwixNSs9Pp5T+I0RxGmB73ITEJu2nGKi0G f7n+6hLv3Y1I4yE68F8ir7wtFm+d8Uc/VtXJyNzI4q/cyjYLLlG/gWHoPKJXwCky0w62 x8YMTATcC4326ZGzTvsT3U0UTtJcBRlajPNPliaW9OrFh0upCY2MzhI3e/3tEF9tudGp YyH6I3eVLxnk8fOxUPpMU3a92TqQYrnKzO26+rmK4SGFb9/jSh7dICl0r8wqeHzeDAiV d/+QXm7McN/Vtx4LWLO+TlntZce2U77cZK5IfEBwF2j2oASS3Zmxij3dMysfd63otFz/ NLag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7APLEfGUyr7yurxye093lKwqBsnqEuz+LXHUBxtflBY=; b=cXjurHv69QshzRTJTueldzMX9HG9j8kcXnPnm/iu6Xk1mLJ4bJQo4k7tg5B6dzBcHE XkmTBEb3m3UZryoLd3dbcmqybqW4/P1QB8T6YbgHN0FE3l3bZUPsWzcnbmb+Zv9eWGjz uRtZmstvm5wtB/fkvHuunNb86jYwCKqTHUbCGGi3mC0d8NQ9PguYDW4ktD+CNRucpi8e brx77BFMLUKNEhHFn7fOsAEITDTm/KKZt18I6sp8wVywB3i/cb33Sdgf3QEd727UcI2k /0dSjXPIANSJe7dpTxXq/jsZuL1TtbdKPL4QU+wejkB/FOIt+4IRlNkU32WD57zLJT+D d4dA== X-Gm-Message-State: AJcUukdahup2sSqiwR+6KikHjHE7yKTucrcxvoPvkjtjoLbN4ve+E0dj 3WPYumLXx8UIDwj5usUZs9B8xGOS4W1WQTsF8FU= X-Received: by 2002:a62:34c6:: with SMTP id b189mr6703996pfa.229.1548337639166; Thu, 24 Jan 2019 05:47:19 -0800 (PST) MIME-Version: 1.0 References: <1548348038-69560-1-git-send-email-peng.hao2@zte.com.cn> <1548348038-69560-3-git-send-email-peng.hao2@zte.com.cn> In-Reply-To: <1548348038-69560-3-git-send-email-peng.hao2@zte.com.cn> From: Andy Shevchenko Date: Thu, 24 Jan 2019 15:47:08 +0200 Message-ID: Subject: Re: [PATCH V4 2/6] misc/pvpanic: Add pvpanic driver framework To: Peng Hao Cc: Greg Kroah-Hartman , Arnd Bergmann , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 24, 2019 at 10:17 AM Peng Hao wrote: > > Add pvpanic driver framework. Follow-up patches will split the original > pvpanic acpi/of driver as the two separate files and modify code to > adapt the framework. > This one has run-time bisectability issues. > Signed-off-by: Peng Hao > --- > drivers/misc/pvpanic/pvpanic.c | 158 +++++++---------------------------------- > 1 file changed, 27 insertions(+), 131 deletions(-) > > diff --git a/drivers/misc/pvpanic/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c > index 595ac06..f44a884 100644 > --- a/drivers/misc/pvpanic/pvpanic.c > +++ b/drivers/misc/pvpanic/pvpanic.c > @@ -8,11 +8,9 @@ > > #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > > -#include > +#include > #include > #include > -#include > -#include > #include > #include > > @@ -43,59 +41,25 @@ > .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) > +static int pvpanic_platform_probe(struct platform_device *pdev) > { > - struct resource r; > - > - if (acpi_dev_resource_io(res, &r)) { > - base = ioport_map(r.start, resource_size(&r)); > - return AE_OK; > - } 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; > + struct device *dev = &pdev->dev; > + struct resource *res; > + > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > + if (res) { > + base = devm_ioremap_resource(dev, res); > + if (IS_ERR(base)) > + return -ENODEV; > + } else { > + res = platform_get_resource(pdev, IORESOURCE_IO, 0); > + if (!res) > + return -ENODEV; > + > + base = ioport_map(res->start, resource_size(res)); > + if (!base) > + return -ENODEV; > + } > > atomic_notifier_chain_register(&panic_notifier_list, > &pvpanic_panic_nb); > @@ -103,90 +67,22 @@ static int pvpanic_add(struct acpi_device *device) > return 0; > } > > -static int pvpanic_remove(struct acpi_device *device) > +static int pvpanic_platform_remove(struct platform_device *pdev) > { > - > 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) > -{ > - struct resource *mem; > - > - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); > - if (!mem) > - return -EINVAL; > - > - base = devm_ioremap_resource(&pdev->dev, mem); > - if (IS_ERR(base)) > - return PTR_ERR(base); > - > - atomic_notifier_chain_register(&panic_notifier_list, > - &pvpanic_panic_nb); > - > - return 0; > -} > - > -static int pvpanic_mmio_remove(struct platform_device *pdev) > -{ > - > - atomic_notifier_chain_unregister(&panic_notifier_list, > - &pvpanic_panic_nb); > + iounmap(base); > > return 0; > } > > -static const struct of_device_id pvpanic_mmio_match[] = { > - { .compatible = "qemu,pvpanic-mmio", }, > - {} > -}; > - > -static struct platform_driver pvpanic_mmio_driver = { > +static struct platform_driver pvpanic_driver = { > + .probe = pvpanic_platform_probe, > + .remove = pvpanic_platform_remove, > .driver = { > - .name = "pvpanic-mmio", > - .of_match_table = pvpanic_mmio_match, > - }, > - .probe = pvpanic_mmio_probe, > - .remove = pvpanic_mmio_remove, > + .name = "pvpanic", > + } > }; > > -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_driver); > -- > 1.8.3.1 > -- With Best Regards, Andy Shevchenko