[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aAEkBOSQRoYXxcIB@smile.fi.intel.com>
Date: Thu, 17 Apr 2025 18:53:40 +0300
From: Andy Shevchenko <andy@...nel.org>
To: Ivan Vecera <ivecera@...hat.com>
Cc: netdev@...r.kernel.org, Vadim Fedorenko <vadim.fedorenko@...ux.dev>,
Arkadiusz Kubalewski <arkadiusz.kubalewski@...el.com>,
Jiri Pirko <jiri@...nulli.us>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Prathosh Satish <Prathosh.Satish@...rochip.com>,
Lee Jones <lee@...nel.org>, Kees Cook <kees@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Michal Schmidt <mschmidt@...hat.com>, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH v3 net-next 4/8] mfd: zl3073x: Add support for devlink
device info
On Wed, Apr 16, 2025 at 06:21:40PM +0200, Ivan Vecera wrote:
> Use devlink_alloc() to alloc zl3073x_dev structure, register the device
> as a devlink device and add devlink callback to provide devlink device
> info.
...
> /**
> * zl3073x_devm_alloc - allocates zl3073x device structure
> * @dev: pointer to device structure
> @@ -124,12 +204,18 @@ static const struct regmap_config zl3073x_regmap_config = {
> struct zl3073x_dev *zl3073x_devm_alloc(struct device *dev)
> {
> struct zl3073x_dev *zldev;
> + struct devlink *devlink;
> int rc;
>
> - zldev = devm_kzalloc(dev, sizeof(*zldev), GFP_KERNEL);
> - if (!zldev)
> + devlink = devlink_alloc(&zl3073x_devlink_ops, sizeof(*zldev), dev);
> + if (!devlink)
> return ERR_PTR(-ENOMEM);
>
> + /* Add devres action to free devlink device */
> + if (devm_add_action_or_reset(dev, zl3073x_devlink_free, devlink))
> + return ERR_PTR(-ENOMEM);
Please, do not shadow the error codes. You might miss something. Shadowing
error codes needs a good justification.
> + zldev = devlink_priv(devlink);
> zldev->dev = dev;
> }
...
> + /* Add devres action to unregister devlink device */
> + rc = devm_add_action_or_reset(zldev->dev, zl3073x_devlink_unregister,
> + devlink);
> + if (rc)
> + return rc;
The code is even inconsistent in one patch!
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists