From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Okan Sahin <okan.sahin@analog.com>
Cc: Lee Jones <lee@kernel.org>, Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Caleb Connolly <caleb.connolly@linaro.org>,
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>,
William Breathitt Gray <william.gray@linaro.org>,
Ramona Bolboaca <ramona.bolboaca@analog.com>,
ChiYuan Huang <cy_huang@richtek.com>,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
linux-iio@vger.kernel.org
Subject: Re: [PATCH v3 1/5] drivers: mfd: Add ADI MAX77541/MAX77540 PMIC Support
Date: Wed, 18 Jan 2023 10:16:17 +0200 [thread overview]
Message-ID: <Y8eq0GtVZfVdNKYn@smile.fi.intel.com> (raw)
In-Reply-To: <20230118063822.14521-2-okan.sahin@analog.com>
On Wed, Jan 18, 2023 at 09:38:08AM +0300, Okan Sahin wrote:
> MFD driver for MAX77541/MAX77540 to enable its sub
> devices.
>
> The MAX77541 is a multi-function devices. It includes
> buck converter and ADC.
>
> The MAX77540 is a high-efficiency buck converter
> with two 3A switching phases.
>
> They have same regmap except for ADC part of MAX77541.
...
> +/*
> + * Copyright (c) 2022 Analog Devices, Inc.
Happy New Year!
> + * Mfd core driver for the MAX77540 and MAX77541
MFD
> + */
...
> + ret = devm_regmap_add_irq_chip(dev, max77541->regmap, irq,
> + IRQF_ONESHOT | IRQF_SHARED, 0,
> + &max77541_buck_irq_chip,
> + &max77541->irq_buck);
> + if (ret)
> + return ret;
> +
> + if (max77541->id == MAX77541) {
> + ret = devm_regmap_add_irq_chip(dev, max77541->regmap, irq,
> + IRQF_ONESHOT | IRQF_SHARED, 0,
> + &max77541_adc_irq_chip,
> + &max77541->irq_adc);
> + if (ret)
> + return ret;
> + }
> + return ret;
return 0;
...
> + return devm_mfd_add_devices(dev, -1, max77540_devs,
PLATFORM_DEVID_NONE ?
> + ARRAY_SIZE(max77540_devs),
> + NULL, 0, NULL);
...
> + return devm_mfd_add_devices(dev, -1, max77541_devs,
Ditto.
> + ARRAY_SIZE(max77541_devs),
> + NULL, 0, NULL);
...
> +static int max77541_i2c_probe(struct i2c_client *client,
> + const struct i2c_device_id *id)
No id, please. I.o.w. you should use ->probe_new().
> +{
> + struct device *dev = &client->dev;
> + struct max77541 *max77541;
> + const void *match;
> +
> + max77541 = devm_kzalloc(&client->dev, sizeof(*max77541), GFP_KERNEL);
> + if (!max77541)
> + return -ENOMEM;
> +
> + i2c_set_clientdata(client, max77541);
> + max77541->i2c = client;
> +
> + match = device_get_match_data(dev);
> + if (match)
> + max77541->id = (enum max7754x_ids)match;
This is dangerous if your enum has 0 as a valid value.
Instead, use pointers in the driver_data, like
&chip_info chip[MAX77540]
> + else if (id)
> + max77541->id = id->driver_data;
> + else
It's better to check the ID range here.
Or since the change recommended above, check for NULL.
> + return -ENODEV;
> +
> + max77541->chip = &chip[max77541->id];
> +
> + max77541->regmap = devm_regmap_init_i2c(client,
> + &max77541_regmap_config);
> + if (IS_ERR(max77541->regmap))
> + return dev_err_probe(dev, PTR_ERR(max77541->regmap),
> + "Failed to allocate register map\n");
> +
> + return max77541_pmic_setup(dev);
> +}
...
> +/*BITS OF REGISTERS*/
Missing spaces.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2023-01-18 9:00 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-18 6:38 [PATCH v3 0/5] Add MAX77541/MAX77540 PMIC Support Okan Sahin
2023-01-18 6:38 ` [PATCH v3 1/5] drivers: mfd: Add ADI " Okan Sahin
2023-01-18 8:16 ` Andy Shevchenko [this message]
2023-01-19 14:27 ` Lee Jones
2023-01-19 15:06 ` Andy Shevchenko
2023-01-19 15:06 ` William Breathitt Gray
2023-01-18 6:38 ` [PATCH v3 2/5] dt-bindings: mfd: Add ADI MAX77541/MAX77540 Okan Sahin
2023-01-18 8:22 ` Krzysztof Kozlowski
2023-01-31 12:02 ` Sahin, Okan
2023-01-31 16:44 ` Krzysztof Kozlowski
2023-01-31 21:28 ` Sahin, Okan
2023-02-01 7:25 ` Krzysztof Kozlowski
2023-02-01 7:46 ` Sahin, Okan
2023-02-01 8:08 ` Krzysztof Kozlowski
2023-01-18 13:10 ` Rob Herring
2023-01-18 6:38 ` [PATCH v3 3/5] drivers: regulator: Add ADI MAX77541/MAX77540 Regulator Support Okan Sahin
2023-01-18 8:19 ` Andy Shevchenko
2023-01-31 7:20 ` Sahin, Okan
2023-01-31 9:27 ` Sahin, Okan
2023-01-31 12:26 ` Andy Shevchenko
2023-01-31 13:23 ` Sahin, Okan
2023-01-31 13:29 ` Andy Shevchenko
2023-01-31 13:59 ` Sahin, Okan
2023-01-31 14:13 ` Andy Shevchenko
2023-01-31 14:38 ` Sahin, Okan
2023-01-31 13:32 ` Mark Brown
2023-01-31 12:24 ` Andy Shevchenko
2023-01-31 13:12 ` Sahin, Okan
2023-01-31 13:26 ` Andy Shevchenko
2023-01-18 6:38 ` [PATCH v3 4/5] dt-bindings: regulator: Add ADI MAX77541/MAX77540 Regulator Okan Sahin
2023-01-18 8:33 ` Krzysztof Kozlowski
2023-01-18 6:38 ` [PATCH v3 5/5] drivers: iio: adc: Add ADI MAX77541 ADC Support Okan Sahin
2023-01-18 8:23 ` Andy Shevchenko
2023-01-21 17:55 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y8eq0GtVZfVdNKYn@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=broonie@kernel.org \
--cc=caleb.connolly@linaro.org \
--cc=cy_huang@richtek.com \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lars@metafoo.de \
--cc=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=okan.sahin@analog.com \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=ramona.bolboaca@analog.com \
--cc=robh+dt@kernel.org \
--cc=william.gray@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox