[PATCH v4 2/7] nvmem: qcom-spmi-sdam: Migrate to devm_spmi_subdevice_alloc_and_add()
Uwe Kleine-König
u.kleine-koenig at baylibre.com
Tue Sep 16 06:24:56 PDT 2025
Hello,
On Tue, Sep 16, 2025 at 10:44:40AM +0200, AngeloGioacchino Del Regno wrote:
> @@ -119,19 +128,24 @@ static int sdam_probe(struct platform_device *pdev)
> if (!sdam)
> return -ENOMEM;
>
> - sdam->regmap = dev_get_regmap(pdev->dev.parent, NULL);
> - if (!sdam->regmap) {
> - dev_err(&pdev->dev, "Failed to get regmap handle\n");
> - return -ENXIO;
> - }
> + sparent = to_spmi_device(dev->parent);
> + sub_sdev = devm_spmi_subdevice_alloc_and_add(dev, sparent);
> + if (IS_ERR(sub_sdev))
> + return PTR_ERR(sub_sdev);
>
> - rc = of_property_read_u32(pdev->dev.of_node, "reg", &sdam->base);
> + rc = of_property_read_u32(dev->of_node, "reg", &sdam_regmap_config.reg_base);
It's a bit ugly that you pass the address of an unsigned int as u32*.
But this isn't new, so fine for me. (Also for all Linux archs we have
sizeof(unsigned int) == 4, so AFAICT it's safe anyhow.)
> if (rc < 0) {
> dev_err(&pdev->dev, "Failed to get SDAM base, rc=%d\n", rc);
> return -EINVAL;
> }
>
> - rc = regmap_read(sdam->regmap, sdam->base + SDAM_SIZE, &val);
> + sdam->regmap = devm_regmap_init_spmi_ext(&sub_sdev->sdev, &sdam_regmap_config);
> + if (IS_ERR(sdam->regmap)) {
> + dev_err(&pdev->dev, "Failed to get regmap handle\n");
dev_err_probe()
> + return PTR_ERR(sdam->regmap);
> + }
> +
> + rc = regmap_read(sdam->regmap, SDAM_SIZE, &val);
> if (rc < 0) {
> dev_err(&pdev->dev, "Failed to read SDAM_SIZE rc=%d\n", rc);
> return -EINVAL;
> @@ -159,7 +173,7 @@ static int sdam_probe(struct platform_device *pdev)
> }
> dev_dbg(&pdev->dev,
> "SDAM base=%#x size=%u registered successfully\n",
> - sdam->base, sdam->size);
> + sdam_regmap_config.reg_base, sdam->size);
>
> return 0;
> }
> @@ -181,3 +195,4 @@ module_platform_driver(sdam_driver);
>
> MODULE_DESCRIPTION("QCOM SPMI SDAM driver");
> MODULE_LICENSE("GPL v2");
> +MODULE_IMPORT_NS("SPMI");
If it's exactly the files that #include <linux/spmi.h> should have that
namespace import, you can put the MODULE_IMPORT_NS into that header.
Best regards
Uwe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-phy/attachments/20250916/63f3ee5f/attachment.sig>
More information about the linux-phy
mailing list