From: Krzysztof Kozlowski <krzk@kernel.org>
To: Matti Vaittinen <mazziesaccount@gmail.com>,
Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Cc: Lee Jones <lee@kernel.org>, Conor Dooley <conor+dt@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 4/6] regulator: bd96801: ROHM BD96801 PMIC regulators
Date: Tue, 2 Apr 2024 18:14:33 +0200 [thread overview]
Message-ID: <9d302a8a-a8bf-4a26-b1fb-44db6a5f5eac@kernel.org> (raw)
In-Reply-To: <3a6839e2663bd064100af41f6df0cace746cf2e4.1712058690.git.mazziesaccount@gmail.com>
On 02/04/2024 15:10, Matti Vaittinen wrote:
> The ROHM BD96801 "Scalable PMIC" is an automotive grade PMIC which can
> scale to different applications by allowing chaining of PMICs. The PMIC
> also supports various protection features which can be configured either
> to fire IRQs - or to shut down power outputs when failure is detected.
>
...
> +
> +static int initialize_pmic_data(struct device *dev,
> + struct bd96801_pmic_data *pdata)
> +{
> + int r, i;
> +
> + *pdata = bd96801_data;
> +
> + /*
> + * Allocate and initialize IRQ data for all of the regulators. We
> + * wish to modify IRQ information independently for each driver
> + * instance.
> + */
> + for (r = 0; r < BD96801_NUM_REGULATORS; r++) {
> + const struct bd96801_irqinfo *template;
> + struct bd96801_irqinfo *new;
> + int num_infos;
> +
> + template = pdata->regulator_data[r].irq_desc.irqinfo;
> + num_infos = pdata->regulator_data[r].irq_desc.num_irqs;
> +
> + new = devm_kzalloc(dev, num_infos * sizeof(*new), GFP_KERNEL);
Aren't you open coding devm_kcalloc?
> + if (!new)
> + return -ENOMEM;
> +
> + pdata->regulator_data[r].irq_desc.irqinfo = new;
> +
> + for (i = 0; i < num_infos; i++)
> + new[i] = template[i];
> + }
> +
> + return 0;
> +}
> +
...
> +static int bd96801_probe(struct platform_device *pdev)
> +{
> + struct device *parent;
> + int i, ret, irq;
> + void *retp;
> + struct regulator_config config = {};
> + struct bd96801_regulator_data *rdesc;
> + struct bd96801_pmic_data *pdata;
> + struct regulator_dev *ldo_errs_rdev_arr[BD96801_NUM_LDOS];
> + int ldo_errs_arr[BD96801_NUM_LDOS];
> + int temp_notif_ldos = 0;
> + struct regulator_dev *all_rdevs[BD96801_NUM_REGULATORS];
> + bool use_errb;
> +
> + parent = pdev->dev.parent;
> +
> + pdata = devm_kzalloc(&pdev->dev, sizeof(bd96801_data), GFP_KERNEL);
This and assignment in initialize_pmic_data() could be probably
devm_kmemdup() which would be a bit more obvious for the reader.
> + if (!pdata)
> + return -ENOMEM;
> +
> + if (initialize_pmic_data(&pdev->dev, pdata))
> + return -ENOMEM;
> +
> + pdata->regmap = dev_get_regmap(parent, NULL);
> + if (!pdata->regmap) {
> + dev_err(&pdev->dev, "No register map found\n");
> + return -ENODEV;
> + }
> +
> + rdesc = &pdata->regulator_data[0];
> +
> + config.driver_data = pdata;
> + config.regmap = pdata->regmap;
> + config.dev = parent;
> +
> + ret = of_property_match_string(pdev->dev.parent->of_node,
> + "interrupt-names", "errb");
This does not guarantee that interrupts are properly set up. Don't you
have some state shared between parent and this device where you could
mark that interrupts are OK?
> + if (ret < 0)
> + use_errb = false;
> + else
> + use_errb = true;
> +
...
> +
> + if (use_errb)
> + return bd96801_global_errb_irqs(pdev, all_rdevs,
> + ARRAY_SIZE(all_rdevs));
> +
> + return 0;
> +}
> +
> +static struct platform_driver bd96801_regulator = {
> + .driver = {
> + .name = "bd96801-pmic"
> + },
> + .probe = bd96801_probe,
> +};
> +
> +module_platform_driver(bd96801_regulator);
> +
> +MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>");
> +MODULE_DESCRIPTION("BD96801 voltage regulator driver");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS("platform:bd96801-pmic");
Just add platform device ID table with MODULE_DEVICE_TABLE(). You should
not need MODULE_ALIAS() in normal cases. MODULE_ALIAS() is not a
substitute for incomplete ID table.
Best regards,
Krzysztof
next prev parent reply other threads:[~2024-04-02 16:14 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-02 13:07 [RFC PATCH 0/6] Support ROHM BD96801 scalable PMIC Matti Vaittinen
2024-04-02 13:07 ` [RFC PATCH 1/6] dt-bindings: ROHM BD96801 PMIC regulators Matti Vaittinen
2024-04-02 13:08 ` [RFC PATCH 2/6] dt-bindings: mfd: bd96801 PMIC core Matti Vaittinen
2024-04-02 13:08 ` [RFC PATCH 3/6] mfd: support ROHM BD96801 " Matti Vaittinen
2024-04-11 14:38 ` Lee Jones
2024-04-12 5:40 ` Matti Vaittinen
2024-04-12 5:50 ` Matti Vaittinen
2024-04-12 7:23 ` Lee Jones
2024-04-12 8:58 ` Matti Vaittinen
2024-04-17 12:24 ` Lee Jones
2024-04-02 13:10 ` [RFC PATCH 4/6] regulator: bd96801: ROHM BD96801 PMIC regulators Matti Vaittinen
2024-04-02 16:14 ` Krzysztof Kozlowski [this message]
2024-04-03 7:38 ` Matti Vaittinen
2024-04-03 14:24 ` Krzysztof Kozlowski
2024-04-02 13:11 ` [RFC PATCH 5/6] watchdog: ROHM BD96801 PMIC WDG driver Matti Vaittinen
2024-04-02 16:15 ` Krzysztof Kozlowski
2024-04-02 17:11 ` Guenter Roeck
2024-04-03 6:34 ` Matti Vaittinen
2024-04-03 12:41 ` Guenter Roeck
2024-04-03 12:47 ` Matti Vaittinen
2024-04-03 13:26 ` Guenter Roeck
2024-04-02 13:12 ` [RFC PATCH 6/6] MAINTAINERS: Add ROHM BD96801 'scalable PMIC' entries Matti Vaittinen
2024-04-04 7:26 ` [RFC PATCH 0/6] Support ROHM BD96801 scalable PMIC Matti Vaittinen
2024-04-04 12:09 ` Mark Brown
2024-04-04 13:15 ` Matti Vaittinen
2024-04-05 9:19 ` Matti Vaittinen
2024-04-05 21:27 ` Mark Brown
2024-04-22 10:52 ` Matti Vaittinen
2024-05-09 5:08 ` Mark Brown
2024-05-09 7:03 ` Matti Vaittinen
2024-05-09 15:38 ` Mark Brown
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=9d302a8a-a8bf-4a26-b1fb-44db6a5f5eac@kernel.org \
--to=krzk@kernel.org \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=mazziesaccount@gmail.com \
/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