[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <272301e5-6561-499a-91eb-615fed4727fa@kernel.org>
Date: Fri, 9 May 2025 09:03:45 +0200
From: Krzysztof Kozlowski <krzk@...nel.org>
To: Pawel Dembicki <paweldembicki@...il.com>, linux-hwmon@...r.kernel.org
Cc: Jean Delvare <jdelvare@...e.com>, Guenter Roeck <linux@...ck-us.net>,
Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, Jonathan Corbet <corbet@....net>,
Noah Wang <noahwang.wang@...look.com>,
Naresh Solanki <naresh.solanki@...ements.com>,
Fabio Estevam <festevam@...il.com>, Michal Simek <michal.simek@....com>,
Grant Peltier <grantpeltier93@...il.com>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Shen Lichuan <shenlichuan@...o.com>, Peter Zijlstra <peterz@...radead.org>,
Greg KH <gregkh@...uxfoundation.org>, Charles Hsu <ythsu0511@...il.com>,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org
Subject: Re: [PATCH v2 1/5] hwmon: pmbus: mpq8785: Prepare driver for multiple
device support
On 09/05/2025 08:51, Pawel Dembicki wrote:
> Refactor the driver to support multiple Monolithic Power Systems devices.
> Introduce chip ID handling based on device tree matching.
>
> No functional changes intended.
>
> Signed-off-by: Pawel Dembicki <paweldembicki@...il.com>
>
> ---
> v2:
> - no changes done
> ---
> drivers/hwmon/pmbus/mpq8785.c | 38 +++++++++++++++++++++++++++--------
> 1 file changed, 30 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/hwmon/pmbus/mpq8785.c b/drivers/hwmon/pmbus/mpq8785.c
> index 331c274ca892..00ec21b081cb 100644
> --- a/drivers/hwmon/pmbus/mpq8785.c
> +++ b/drivers/hwmon/pmbus/mpq8785.c
> @@ -8,6 +8,8 @@
> #include <linux/of_device.h>
> #include "pmbus.h"
>
> +enum chips { mpq8785 };
Use Linux coding style, so:
1. missing wrapping after/before each {}
2. missing descriptive name for the type (mpq8785_chips)
3. CAPITALICS see Linux coding style - there is a chapter exactly about
this.
> +
> static int mpq8785_identify(struct i2c_client *client,
> struct pmbus_driver_info *info)
> {
> @@ -53,26 +55,46 @@ static struct pmbus_driver_info mpq8785_info = {
> PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
> PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
> PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP,
> - .identify = mpq8785_identify,
> -};
> -
> -static int mpq8785_probe(struct i2c_client *client)
> -{
> - return pmbus_do_probe(client, &mpq8785_info);
> };
>
> static const struct i2c_device_id mpq8785_id[] = {
> - { "mpq8785" },
> + { "mpq8785", mpq8785 },
> { },
> };
> MODULE_DEVICE_TABLE(i2c, mpq8785_id);
>
> static const struct of_device_id __maybe_unused mpq8785_of_match[] = {
> - { .compatible = "mps,mpq8785" },
> + { .compatible = "mps,mpq8785", .data = (void *)mpq8785 },
> {}
> };
> MODULE_DEVICE_TABLE(of, mpq8785_of_match);
>
> +static int mpq8785_probe(struct i2c_client *client)
> +{
> + struct device *dev = &client->dev;
> + struct pmbus_driver_info *info;
> + enum chips chip_id;
> +
> + info = devm_kmemdup(dev, &mpq8785_info, sizeof(*info), GFP_KERNEL);
> + if (!info)
> + return -ENOMEM;
> +
> + if (dev->of_node)
> + chip_id = (uintptr_t)of_device_get_match_data(dev);
(kernel_ulong_t) instead
> + else
> + chip_id = i2c_match_id(mpq8785_id, client)->driver_data;
Do not open-code i2c_get_match_data().
Best regards,
Krzysztof
Powered by blists - more mailing lists