[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Vc-GTs-Hb3n3aV6ZrsMzU7xnmdOsa+nOYnkQpznTgSC3g@mail.gmail.com>
Date: Thu, 24 Jan 2019 15:54:52 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Peng Hao <peng.hao2@....com.cn>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Arnd Bergmann <arnd@...db.de>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH V4 4/6] misc/pvpanic: add pvpanic acpi driver
On Thu, Jan 24, 2019 at 10:17 AM Peng Hao <peng.hao2@....com.cn> wrote:
>
> Make pvpanic acpi driver as separate file and modify code
> in order to adapt the framework.
This should be patch 2 in this series to avoid run-time bisectability issues.
>
> Signed-off-by: Peng Hao <peng.hao2@....com.cn>
> ---
> drivers/misc/pvpanic/Kconfig | 13 +++++++
> drivers/misc/pvpanic/Makefile | 1 +
> drivers/misc/pvpanic/pvpanic-acpi.c | 77 +++++++++++++++++++++++++++++++++++++
> 3 files changed, 91 insertions(+)
> create mode 100644 drivers/misc/pvpanic/pvpanic-acpi.c
>
> diff --git a/drivers/misc/pvpanic/Kconfig b/drivers/misc/pvpanic/Kconfig
> index 3e612c6..1dcfe20 100644
> --- a/drivers/misc/pvpanic/Kconfig
> +++ b/drivers/misc/pvpanic/Kconfig
> @@ -5,3 +5,16 @@ config PVPANIC
> This driver provides support for the pvpanic device. pvpanic is
> a paravirtualized device provided by QEMU; it lets a virtual machine
> (guest) communicate panic events to the host.
> +
> +if PVPANIC
> +
> +config PVPANIC_ACPI
> + tristate "pvpanic acpi driver"
> + depends on ACPI
> + default PVPANIC
> + help
> + This driver is one specific driver for pvpanic driver framework.
> + It provides an acpi device as pvpanic device.
> +
> +endif
> +
> diff --git a/drivers/misc/pvpanic/Makefile b/drivers/misc/pvpanic/Makefile
> index 6394224..c5b73ca 100644
> --- a/drivers/misc/pvpanic/Makefile
> +++ b/drivers/misc/pvpanic/Makefile
> @@ -3,3 +3,4 @@
> # Copyright (c) 2018 ZTE Ltd.
>
> obj-$(CONFIG_PVPANIC) += pvpanic.o
> +obj-$(CONFIG_PVPANIC_ACPI) += pvpanic-acpi.o
> diff --git a/drivers/misc/pvpanic/pvpanic-acpi.c b/drivers/misc/pvpanic/pvpanic-acpi.c
> new file mode 100644
> index 0000000..8d10924
> --- /dev/null
> +++ b/drivers/misc/pvpanic/pvpanic-acpi.c
> @@ -0,0 +1,77 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * pvpanic acpi driver.
> + *
> + * Copyright (C) 2019 ZTE Ltd.
> + * Author: Peng Hao
> + */
> +#include <linux/acpi.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/types.h>
> +#include "pvpanic.h"
> +
> +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;
> + int ret = 0;
> + struct device *dev = context;
> +
> + memset(&r, 0, sizeof(r));
> + if (acpi_dev_resource_io(res, &r) || acpi_dev_resource_memory(res, &r))
> + ret = pvpanic_add_device(dev, &r);
> +
> + if (!ret)
> + return AE_OK;
> +
> + return AE_ERROR;
> +}
> +static int pvpanic_add(struct acpi_device *device)
> +{
> + int ret;
> + acpi_status status;
> +
> + ret = acpi_bus_get_status(device);
> + if (ret < 0)
> + return ret;
> +
> + if (!device->status.enabled || !device->status.functional)
> + return -ENODEV;
> +
> + status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
> + pvpanic_walk_resources, &device->dev);
> +
> + if (ACPI_FAILURE(status))
> + return -ENODEV;
> +
> + return 0;
> +}
> +
> +static int pvpanic_remove(struct acpi_device *device)
> +{
> + pvpanic_remove_device();
> + return 0;
> +}
> +
> +module_acpi_driver(pvpanic_driver);
> --
> 1.8.3.1
>
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists