NAK: [SRU][F:linux-bluefield][PATCH v1 1/1] UBUNTU: SAUCE: pwr-mlxbf.c: Improve driver dependencies

Tim Gardner tim.gardner at canonical.com
Tue Jul 26 18:47:57 UTC 2022


On 7/5/22 09:04, Asmaa Mnebhi wrote:
> Buglink: https://bugs.launchpad.net/bugs/1980750
> 
> Instead of using SOFTDEP, return -EPROBE_DEFER if the
> gpio driver is not loaded yet.
> Flush work when driver is removed.
> 
> Signed-off-by: Asmaa Mnebhi <asmaa at nvidia.com>
> ---
>   drivers/power/reset/pwr-mlxbf.c | 30 +++++++++++++++++++++---------
>   1 file changed, 21 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/power/reset/pwr-mlxbf.c b/drivers/power/reset/pwr-mlxbf.c
> index fe3a8c42f1a0..0bad4178ab40 100644
> --- a/drivers/power/reset/pwr-mlxbf.c
> +++ b/drivers/power/reset/pwr-mlxbf.c
> @@ -15,7 +15,7 @@
>   #include <linux/reboot.h>
>   #include <linux/types.h>
>   
> -#define DRV_VERSION "1.0"
> +#define DRV_VERSION "1.1"
>   
>   const char *rst_pwr_hid = "MLNXBF24";
>   const char *low_pwr_hid = "MLNXBF29";
> @@ -52,7 +52,7 @@ pwr_mlxbf_probe(struct platform_device *pdev)
>   	const char *hid;
>   	int irq, err;
>   
> -	priv = devm_kzalloc(dev, sizeof(struct pwr_mlxbf), GFP_KERNEL);
> +	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>   	if (!priv)
>   		return -ENOMEM;
>   
> @@ -63,21 +63,33 @@ pwr_mlxbf_probe(struct platform_device *pdev)
>   	hid = acpi_device_hid(adev);
>   	priv->hid = hid;
>   
> -	irq = acpi_dev_gpio_irq_get(ACPI_COMPANION(&pdev->dev), 0);
> -	if (irq < 0) {
> -		dev_err(&pdev->dev, "Error getting %s irq.\n", priv->hid);
> -		return -ENODEV;
> +	irq = acpi_dev_gpio_irq_get(ACPI_COMPANION(dev), 0);
> +	if (irq == -EPROBE_DEFER) {
> +		return -EPROBE_DEFER;
> +	} else if (irq < 0) {
> +		dev_err(dev, "Error getting %s irq.\n", priv->hid);
> +		return -ENXIO;
>   	}
>   
>   	INIT_WORK(&priv->send_work, pwr_mlxbf_send_work);
>   
> -	err = devm_request_irq(&pdev->dev, irq, pwr_mlxbf_irq, 0, hid, priv);
> +	err = devm_request_irq(dev, irq, pwr_mlxbf_irq, 0, hid, priv);
>   	if (err)
> -		dev_err(&pdev->dev, "Failed request of %s irq\n", priv->hid);
> +		dev_err(dev, "Failed request of %s irq\n", priv->hid);
>   
>   	return err;
>   }
>   
> +static int
> +pwr_mlxbf_remove(struct platform_device *pdev)
> +{
> +	struct pwr_mlxbf *priv = platform_get_drvdata(pdev);
> +
> +	flush_work(&priv->send_work);
> +
> +	return 0;
> +}
> +
>   static const struct acpi_device_id __maybe_unused pwr_mlxbf_acpi_match[] = {
>   	{ "MLNXBF24", 0 },
>   	{ "MLNXBF29", 0 },
> @@ -91,11 +103,11 @@ static struct platform_driver pwr_mlxbf_driver = {
>   		.acpi_match_table = pwr_mlxbf_acpi_match,
>   	},
>   	.probe    = pwr_mlxbf_probe,
> +	.remove = pwr_mlxbf_remove,
>   };
>   
>   module_platform_driver(pwr_mlxbf_driver);
>   
> -MODULE_SOFTDEP("pre: gpio_mlxbf2");
>   MODULE_DESCRIPTION("Mellanox BlueField power driver");
>   MODULE_AUTHOR("Asmaa Mnebhi <asmaa at nvidia.com>");
>   MODULE_LICENSE("Dual BSD/GPL");

There are 3 unrelated changes in this patch, each of which deserve their 
own patch.

1) Changing a driver version number. These should generally be called 
out as separate patches with an informative commit message.
2) Zero allocating memory.
3) The actual meat of the patch which is to improve driver dependencies.

rtg

-- 
-----------
Tim Gardner
Canonical, Inc



More information about the kernel-team mailing list