Re: [PATCH v3 2/4] virt: vmgenid: change implementation to use a platform driver
From: Krzysztof Kozlowski
Date: Mon Mar 25 2024 - 17:54:12 EST
On 25/03/2024 20:53, Sudan Landge wrote:
> Re-implement vmgenid as a platform driver in preparation
> for adding devicetree bindings support in next commits.
>
> Signed-off-by: Sudan Landge <sudanl@xxxxxxxxxx>
> ---
> drivers/virt/vmgenid.c | 101 ++++++++++++++++++++++++++++++-----------
> 1 file changed, 74 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/virt/vmgenid.c b/drivers/virt/vmgenid.c
> index ea956df02874..d5394c706bd9 100644
> --- a/drivers/virt/vmgenid.c
> +++ b/drivers/virt/vmgenid.c
> @@ -11,6 +11,8 @@
> #include <linux/module.h>
> #include <linux/acpi.h>
> #include <linux/random.h>
> +#include <acpi/actypes.h>
> +#include <linux/platform_device.h>
Do not add headers to the end of lists.
>
> ACPI_MODULE_NAME("vmgenid");
>
..
>
> -static struct acpi_driver vmgenid_driver = {
> - .name = "vmgenid",
> - .ids = vmgenid_ids,
> - .owner = THIS_MODULE,
> - .ops = {
> - .add = vmgenid_add,
> - .notify = vmgenid_notify
> - }
> +static struct platform_driver vmgenid_plaform_driver = {
> + .probe = vmgenid_add,
> + .driver = {
> + .name = "vmgenid",
> + .acpi_match_table = ACPI_PTR(vmgenid_ids),
ACPI_PTR does not make sense. If this can be compile tested !ACPI, then
this is wrong. If this cannot be compile tested, then this is redundant
and confusing so... also wrong.
> + .owner = THIS_MODULE,
> + },
> };
>
> -module_acpi_driver(vmgenid_driver);
> +static int vmgenid_platform_device_init(void)
> +{
> + return platform_driver_register(&vmgenid_plaform_driver);
> +}
> +
> +static void vmgenid_platform_device_exit(void)
> +{
> + platform_driver_unregister(&vmgenid_plaform_driver);
> +}
> +
> +module_init(vmgenid_platform_device_init)
> +module_exit(vmgenid_platform_device_exit)
Why this cannot be module_platform_driver?
Best regards,
Krzysztof