From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761822AbcIXJRC convert rfc822-to-8bit (ORCPT ); Sat, 24 Sep 2016 05:17:02 -0400 Received: from smtp2-g21.free.fr ([212.27.42.2]:3379 "EHLO smtp2-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761755AbcIXJQz (ORCPT ); Sat, 24 Sep 2016 05:16:55 -0400 Date: Sat, 24 Sep 2016 10:59:27 +0200 From: Jean-Francois Moine To: Chen-Yu Tsai Cc: Mark Rutland , Rob Herring , devicetree , linux-arm-kernel , linux-kernel , linux-sunxi Subject: Re: [PATCH 3/3] regulator: axp20x: simplify device access Message-Id: <20160924105927.794f768afbe30e53616cf95f@free.fr> In-Reply-To: References: X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; armv7l-unknown-linux-gnueabihf) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 24 Sep 2016 16:29:11 +0800 Chen-Yu Tsai wrote: [snip] > > static int axp20x_regulator_probe(struct platform_device *pdev) > > { > > + struct device *dev = pdev->dev.parent; > > There are 2 struct device's in play in this function, 1 from the parent, > and 1 for the platform device for this regulator sub-device. > > > struct regulator_dev *rdev; > > - struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); > > + struct axp20x_dev *axp20x = dev_get_drvdata(dev); > > const struct regulator_desc *regulators; > > struct regulator_config config = { > > - .dev = pdev->dev.parent, > > + .dev = dev, > > .regmap = axp20x->regmap, > > .driver_data = axp20x, > > }; > > @@ -532,7 +533,7 @@ static int axp20x_regulator_probe(struct platform_device *pdev) > > dcdc5_ix = AXP22X_DCDC5; > > dc1sw_ix = AXP22X_DC1SW; > > dc5ldo_ix = AXP22X_DC5LDO; > > - drivevbus = of_property_read_bool(pdev->dev.parent->of_node, > > + drivevbus = of_property_read_bool(dev->of_node, > > "x-powers,drive-vbus-en"); > > break; > > case AXP806_ID: > > @@ -555,13 +556,13 @@ static int axp20x_regulator_probe(struct platform_device *pdev) > > dc5ldo_ix = AXP809_DC5LDO; > > break; > > default: > > - dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n", > > + dev_err(dev, "Unsupported AXP variant: %ld\n", > > So this one is incorrect. You should use this device's struct, > not the parent. It's possible the mfd driver supports a PMIC, > but the regulator driver is still missing. Why do you need a regulator driver? The 'regulator' node in the DT is not a real device. It is just a container and it could be removed without any problem. -- Ken ar c'hentań | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jean-Francois Moine Subject: Re: [PATCH 3/3] regulator: axp20x: simplify device access Date: Sat, 24 Sep 2016 10:59:27 +0200 Message-ID: <20160924105927.794f768afbe30e53616cf95f@free.fr> References: Reply-To: moinejf-GANU6spQydw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Sender: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org In-Reply-To: List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , To: Chen-Yu Tsai Cc: Mark Rutland , Rob Herring , devicetree , linux-arm-kernel , linux-kernel , linux-sunxi List-Id: devicetree@vger.kernel.org On Sat, 24 Sep 2016 16:29:11 +0800 Chen-Yu Tsai wrote: [snip] > > static int axp20x_regulator_probe(struct platform_device *pdev) > > { > > + struct device *dev =3D pdev->dev.parent; >=20 > There are 2 struct device's in play in this function, 1 from the parent, > and 1 for the platform device for this regulator sub-device. >=20 > > struct regulator_dev *rdev; > > - struct axp20x_dev *axp20x =3D dev_get_drvdata(pdev->dev.parent)= ; > > + struct axp20x_dev *axp20x =3D dev_get_drvdata(dev); > > const struct regulator_desc *regulators; > > struct regulator_config config =3D { > > - .dev =3D pdev->dev.parent, > > + .dev =3D dev, > > .regmap =3D axp20x->regmap, > > .driver_data =3D axp20x, > > }; > > @@ -532,7 +533,7 @@ static int axp20x_regulator_probe(struct platform_d= evice *pdev) > > dcdc5_ix =3D AXP22X_DCDC5; > > dc1sw_ix =3D AXP22X_DC1SW; > > dc5ldo_ix =3D AXP22X_DC5LDO; > > - drivevbus =3D of_property_read_bool(pdev->dev.parent->o= f_node, > > + drivevbus =3D of_property_read_bool(dev->of_node, > > "x-powers,drive-vbus-= en"); > > break; > > case AXP806_ID: > > @@ -555,13 +556,13 @@ static int axp20x_regulator_probe(struct platform= _device *pdev) > > dc5ldo_ix =3D AXP809_DC5LDO; > > break; > > default: > > - dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n", > > + dev_err(dev, "Unsupported AXP variant: %ld\n", >=20 > So this one is incorrect. You should use this device's struct, > not the parent. It's possible the mfd driver supports a PMIC, > but the regulator driver is still missing. Why do you need a regulator driver? The 'regulator' node in the DT is not a real device. It is just a container and it could be removed without any problem. --=20 Ken ar c'henta=C3=B1 | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ --=20 You received this message because you are subscribed to the Google Groups "= linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an e= mail to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/d/optout. From mboxrd@z Thu Jan 1 00:00:00 1970 From: moinejf@free.fr (Jean-Francois Moine) Date: Sat, 24 Sep 2016 10:59:27 +0200 Subject: [PATCH 3/3] regulator: axp20x: simplify device access In-Reply-To: References: Message-ID: <20160924105927.794f768afbe30e53616cf95f@free.fr> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Sat, 24 Sep 2016 16:29:11 +0800 Chen-Yu Tsai wrote: [snip] > > static int axp20x_regulator_probe(struct platform_device *pdev) > > { > > + struct device *dev = pdev->dev.parent; > > There are 2 struct device's in play in this function, 1 from the parent, > and 1 for the platform device for this regulator sub-device. > > > struct regulator_dev *rdev; > > - struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); > > + struct axp20x_dev *axp20x = dev_get_drvdata(dev); > > const struct regulator_desc *regulators; > > struct regulator_config config = { > > - .dev = pdev->dev.parent, > > + .dev = dev, > > .regmap = axp20x->regmap, > > .driver_data = axp20x, > > }; > > @@ -532,7 +533,7 @@ static int axp20x_regulator_probe(struct platform_device *pdev) > > dcdc5_ix = AXP22X_DCDC5; > > dc1sw_ix = AXP22X_DC1SW; > > dc5ldo_ix = AXP22X_DC5LDO; > > - drivevbus = of_property_read_bool(pdev->dev.parent->of_node, > > + drivevbus = of_property_read_bool(dev->of_node, > > "x-powers,drive-vbus-en"); > > break; > > case AXP806_ID: > > @@ -555,13 +556,13 @@ static int axp20x_regulator_probe(struct platform_device *pdev) > > dc5ldo_ix = AXP809_DC5LDO; > > break; > > default: > > - dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n", > > + dev_err(dev, "Unsupported AXP variant: %ld\n", > > So this one is incorrect. You should use this device's struct, > not the parent. It's possible the mfd driver supports a PMIC, > but the regulator driver is still missing. Why do you need a regulator driver? The 'regulator' node in the DT is not a real device. It is just a container and it could be removed without any problem. -- Ken ar c'henta? | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/