Thread (10 messages) 10 messages, 4 authors, 2021-07-01

Re: [PATCH v10 2/5] regulator: hi6421v600-regulator: fix platform drvdata

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Date: 2021-06-29 19:32:05
Also in: lkml

Em Tue, 29 Jun 2021 16:11:01 +0100
Mark Brown [off-list ref] escreveu:
On Tue, Jun 29, 2021 at 12:31:28PM +0200, Mauro Carvalho Chehab wrote:
quoted
platform drvdata can't be used inside the regulator driver,
as this is already used by the MFD and SPMI drivers.  
Can you clarify what exactly is using which platform drvdata already?
This all feels very confused and I can't tell what the problem that's
being fixed is, if it's a real issue or how this fixes it.
I don't remember the dirty details anymore... It has been almost a year
since when I started doing that. The SPMI controller driver left staging
8 months ago.

I guess it is related with passing the parent's device to
devm_regulator_register() at the hi6421v600-regulator driver:

	struct regulator_config config = { };
...
	config.dev = pdev->dev.parent;
...
	rdev = devm_regulator_register(dev, &info->desc, &config);

This is needed by SPMI bus and the SPMI controller in order to use the 
right platform data when talking to the hardware.
quoted
 drivers/misc/hi6421v600-irq.c               |  9 ++--
 drivers/regulator/hi6421v600-regulator.c    | 49 +++++++++++----------
 drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 18 +++-----
 include/linux/mfd/hi6421-spmi-pmic.h        | 25 -----------  
I'm especially nervous about the core driver still being in staging
perhaps meaning there's some issue with it doing odd and confusing
things.
The only missing part in staging is the MFD driver. At the current way,
it is very simple (71 lines in total): it just declares a regmap, and has 
a single function on it:

	static int hi6421_spmi_pmic_probe(struct spmi_device *pdev)
	{
		struct device *dev = &pdev->dev;
		int ret;
		struct hi6421_spmi_pmic *ddata;
		ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
		if (!ddata)
			return -ENOMEM;
	
		ddata->regmap = devm_regmap_init_spmi_ext(pdev, &regmap_config);
		if (IS_ERR(ddata->regmap))
			return PTR_ERR(ddata->regmap);
	
		ddata->dev = dev;
	
		dev_set_drvdata(&pdev->dev, ddata);

		ret = devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE,
					   hi6421v600_devs, ARRAY_SIZE(hi6421v600_devs),
					   NULL, 0, NULL);
		if (ret < 0)
			dev_err(dev, "Failed to add child devices: %d\n", ret);

		return ret;
	}

You can see the full driver's code at:
	https://lore.kernel.org/lkml/8d871e2ccc544d11959c16d8312dbf03dd01b1c8.1624962269.git.mchehab+huawei@kernel.org/#Z30drivers:mfd:hi6421-spmi-pmic.c (local)

I'm not aware of anything left preventing it to leave staging.

Thanks,
Mauro
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help