[PATCH v3 1/2] regulator: mt6360: Add support for MT6360 regulator

Gene Chen gene.chen.richtek at gmail.com
Tue Aug 25 05:13:43 EDT 2020


Mark Brown <broonie at kernel.org> 於 2020年8月24日 週一 下午7:05寫道:



>
> On Mon, Aug 24, 2020 at 06:23:19PM +0800, Gene Chen wrote:
> > Mark Brown <broonie at kernel.org> 於 2020年8月20日 週四 下午7:45寫道:
>
> > > This device only exists in the context of a single parent device, there
> > > should be no need for a compatible string here - this is just a detail
> > > of how Linux does things.  The MFD should just instntiate the platform
> > > device.
>
> > Trying to autoload module without of_id_table will cause run-time error:
> > ueventd: LoadWithAliases was unable to load
> > of:NregulatorT(null)Cmediatek,mt6360-regulator
>
> You shouldn't have this described in the device tree at all, like I say
> the MFD should just instantiate the platform device.

After I replace of_device_id by platform_device_id as below, I can
autoload module.
But I can't get of_node to parse init_data.
Should I use dev->parent->of_node and set
regulator_desc.regulator_node to parse each regulator definition in
device tree?

diff --git a/drivers/mfd/mt6360-core.c b/drivers/mfd/mt6360-core.c
index e995220..444dc8e 100644
--- a/drivers/mfd/mt6360-core.c
+++ b/drivers/mfd/mt6360-core.c
@@ -328,7 +328,7 @@ static const struct mfd_cell mt6360_devs[] = {
        OF_MFD_CELL("mt6360-led", mt6360_led_resources,
                    NULL, 0, 0, "mediatek,mt6360-led"),
        OF_MFD_CELL("mt6360-regulator", mt6360_regulator_resources,
-                   NULL, 0, 0, "mediatek,mt6360-regulator"),
+                   NULL, 0, 0, NULL),
        OF_MFD_CELL("mt6360-tcpc", NULL,
                    NULL, 0, 0, "mediatek,mt6360-tcpc"),
 };
diff --git a/drivers/regulator/mt6360-regulator.c
b/drivers/regulator/mt6360-regulator.c
index 97c16a2..d525bf1 100644
--- a/drivers/regulator/mt6360-regulator.c
+++ b/drivers/regulator/mt6360-regulator.c
@@ -438,11 +438,18 @@ static int mt6360_regulator_probe(struct
platform_device *pdev)
        return 0;
 }

+static const struct platform_device_id mt6360_regulator_id[] = {
+       { "mt6360-regulator", },
+       { },
+};
+MODULE_DEVICE_TABLE(platform, mt6360_regulator_id);
+
 static struct platform_driver mt6360_regulator_driver = {
        .driver = {
                .name = "mt6360-regulator",
        },
        .probe = mt6360_regulator_probe,
+       .id_table = mt6360_regulator_id,
 };



More information about the Linux-mediatek mailing list