[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YbIwfzND2R4WyQO7@shell.armlinux.org.uk>
Date: Thu, 9 Dec 2021 16:36:15 +0000
From: "Russell King (Oracle)" <linux@...linux.org.uk>
To: Ilkka Koskinen <ilkka@...amperecomputing.com>
Cc: lorenzo.pieralisi@....com, guohanjun@...wei.com,
sudeep.holla@....com, rafael@...nel.org, lenb@...nel.org,
robert.moore@...el.com, linux-acpi@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
devel@...ica.org, patches@...erecomputing.com,
scott@...amperecomputing.com, darren@...amperecomputing.com
Subject: Re: [PATCH 2/2] ACPI: AGDI: Add driver for Arm Generic Diagnostic
Dump and Reset device
Hi,
On Thu, Dec 02, 2021 at 06:43:11PM -0800, Ilkka Koskinen wrote:
> +static int __init agdi_init(void)
> +{
> + int ret;
> + acpi_status status;
> + struct acpi_table_agdi *agdi_table;
> + struct agdi_data *pdata;
> + struct platform_device *pdev;
> +
> + if (acpi_disabled)
> + return 0;
> +
> + status = acpi_get_table(ACPI_SIG_AGDI, 0,
> + (struct acpi_table_header **) &agdi_table);
> + if (ACPI_FAILURE(status))
> + return -ENODEV;
> +
> + pdata = kzalloc(sizeof(*pdata), GFP_ATOMIC);
Why does this need to be GFP_ATOMIC? Also, struct agdi_data is a single
int in size, why do you need to kzalloc() it?
> + if (!pdata) {
> + ret = -ENOMEM;
> + goto err_put_table;
> + }
> +
> + if (agdi_table->flags & ACPI_AGDI_SIGNALING_MODE) {
> + pr_warn("Interrupt signaling is not supported");
> + ret = -ENODEV;
> + goto err_free_pdata;
> + }
> +
> + pdata->sdei_event = agdi_table->sdei_event;
> +
> + pdev = platform_device_register_data(NULL, "agdi", 0, pdata, sizeof(*pdata));
platform_device_register_data() uses kmemdup() internally with the
platform data, meaning it takes a copy of the platform data. There is
no need for the pdata allocation to persist past this point. Hence,
given that it is a single int in size, you may as well put
"struct agdi_data" on the stack.
Thanks.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Powered by blists - more mailing lists