From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752403AbdFOLrQ (ORCPT ); Thu, 15 Jun 2017 07:47:16 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:44828 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751972AbdFOLrP (ORCPT ); Thu, 15 Jun 2017 07:47:15 -0400 Date: Thu, 15 Jun 2017 13:47:04 +0200 From: Sebastian Reichel To: "H. Nikolaus Schaller" Cc: Grygorii Strashko , NeilBrown , Rob Herring , Mark Rutland , Russell King , Marek Belisko , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-pm@vger.kernel.org, letux-kernel@openphoenux.org, notasas@gmail.com, linux-omap@vger.kernel.org Subject: Re: [PATCH v6 3/4] power: supply: twl4030-charger: move irq allocation to just before irqs are enabled Message-ID: <20170615114704.odpislk5a4nsigtv@earth> References: <0eeffa7a6ab8e4213f518e2caf6982d2b77dc0b2.1497432355.git.hns@goldelico.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="k7sxcplenkf75emn" Content-Disposition: inline In-Reply-To: <0eeffa7a6ab8e4213f518e2caf6982d2b77dc0b2.1497432355.git.hns@goldelico.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --k7sxcplenkf75emn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Wed, Jun 14, 2017 at 11:25:55AM +0200, H. Nikolaus Schaller wrote: > This avoids a potential race if irqs are enabled and triggered too early > before the worker is properly set up. >=20 > Suggested-by: Grygorii Strashko > Signed-off-by: H. Nikolaus Schaller > --- > drivers/power/supply/twl4030_charger.c | 28 ++++++++++++++-------------- > 1 file changed, 14 insertions(+), 14 deletions(-) >=20 > diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/suppl= y/twl4030_charger.c > index 1fbbe0cc216a..3bebeecb4a1f 100644 > --- a/drivers/power/supply/twl4030_charger.c > +++ b/drivers/power/supply/twl4030_charger.c > @@ -984,6 +984,16 @@ static int twl4030_bci_probe(struct platform_device = *pdev) > =20 > platform_set_drvdata(pdev, bci); > =20 > + if (bci->dev->of_node) { > + struct device_node *phynode; > + > + phynode =3D of_find_compatible_node(bci->dev->of_node->parent, > + NULL, "ti,twl4030-usb"); > + if (phynode) > + bci->transceiver =3D devm_usb_get_phy_by_node( > + bci->dev, phynode, &bci->usb_nb); > + } > + The notifier is not that much different from an irq. I see the call can access at least the iio channel (so iio channel should be registered first). I suspect worker and power-supply should also be initialized/registered first. Best location seems to be directly before requesting the irqs. > bci->channel_vac =3D devm_iio_channel_get(&pdev->dev, "vac"); > if (IS_ERR(bci->channel_vac)) { > bci->channel_vac =3D NULL; > @@ -1006,6 +1016,10 @@ static int twl4030_bci_probe(struct platform_devic= e *pdev) > return ret; > } > =20 > + INIT_WORK(&bci->work, twl4030_bci_usb_work); > + INIT_DELAYED_WORK(&bci->current_worker, twl4030_current_worker); > + > + bci->usb_nb.notifier_call =3D twl4030_bci_usb_ncb; You should configure the notifier block *before* registering it. > ret =3D devm_request_threaded_irq(&pdev->dev, bci->irq_chg, NULL, > twl4030_charger_interrupt, IRQF_ONESHOT, pdev->name, > bci); > @@ -1023,20 +1037,6 @@ static int twl4030_bci_probe(struct platform_devic= e *pdev) > return ret; > } > =20 > - INIT_WORK(&bci->work, twl4030_bci_usb_work); > - INIT_DELAYED_WORK(&bci->current_worker, twl4030_current_worker); > - > - bci->usb_nb.notifier_call =3D twl4030_bci_usb_ncb; > - if (bci->dev->of_node) { > - struct device_node *phynode; > - > - phynode =3D of_find_compatible_node(bci->dev->of_node->parent, > - NULL, "ti,twl4030-usb"); > - if (phynode) > - bci->transceiver =3D devm_usb_get_phy_by_node( > - bci->dev, phynode, &bci->usb_nb); > - } > - > /* Enable interrupts now. */ > reg =3D ~(u32)(TWL4030_ICHGLOW | TWL4030_ICHGEOC | TWL4030_TBATOR2 | > TWL4030_TBATOR1 | TWL4030_BATSTS); -- Sebastian --k7sxcplenkf75emn Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAllCc7UACgkQ2O7X88g7 +pr4+g/9EwqRqoVSXxtPsq0Df0xwR3FdYw1lz9PAD8emgyiRwGAVkHWEyJZsJwZy 8ccvkSgZmsi/Q9kSYjN9MDY96yt+qaboZsuEtDC9ecsocvt6p/akjgM5Zzy6m1Ms 5cj/bTImQc8vSstzdt24DLh1KhDclAjUhNBV3AodEPl4g2Gq686LEqpWjd0VGQkY gq77aV3aYtBX7itBMoX4Bc0xX29QhCcS0TtyvDZKCVSIzlX6fs57/N20J3ucbq3f MjujX1ynkxY5DfzwzseZ9nnzH4ukFhI3CKbA1gkqsXrWrMAEwcvon1MpbQbI7rRX a2JG9lckAhWNeixEtwb1NdWXv3aI1u2ARm63Eh2iHh2vrIw4UKM3ghbzhq8wVL83 TXv6mVmJIeiwr4M1BtwCEN5oidlmhQgoO7fWEIEPkbXAE6vAzhaTr7F+NlVI3/WP vZpT+QGgIL3+hgjo+iraCsADvMBcIy6EVIy0ODAZ/CXN0VVgaQkJpr7ACM5p7toG LN2IwFPjFsRUWruVq9Lf/6RSEJzVjcqPmvbxTMP+NPON4hOpASiARQ7COeGGsRpl lUrijZdjKDnDQZxptfzbOtoPLadvCH1WBfNK9EIYzyBUZnbqf0WtNMqbvugZL++G /LHZDFZUs/K9aoKc5ntwNKPizCj/89uUBzFdq6dFvMt2DEduIG0= =TbWi -----END PGP SIGNATURE----- --k7sxcplenkf75emn--