From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lothar =?UTF-8?B?V2HDn21hbm4=?= Date: Tue, 20 Jun 2017 13:26:37 +0200 Subject: [U-Boot] [PATCH v7 06/10] usb: host: ehci-generic: add error path and .remove callback In-Reply-To: References: <1497952751-28477-1-git-send-email-patrice.chotard@st.com> <1497952751-28477-7-git-send-email-patrice.chotard@st.com> Message-ID: <20170620132637.4aefebc1@karo-electronics.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de Hi, On Tue, 20 Jun 2017 12:09:22 +0200 Marek Vasut wrote: > On 06/20/2017 11:59 AM, patrice.chotard at st.com wrote: > > From: Patrice Chotard > >=20 > > Use an array to save enabled clocks reference and deasserted resets > > in order to respectively disabled and asserted them in case of error > > during probe() or during driver removal. > >=20 > > Signed-off-by: Patrice Chotard >=20 > Nitpicks below >=20 > > --- > >=20 > > v7: _ replace clk_count() and reset_count() by ofnode_count_phandle_wit= h_args() > >=20 > > v6: _ none > >=20 > > v5: _ none > >=20 > > v4: _ update the memory allocation for deasserted resets and enabled > > clocks reference list. Replace lists by arrays. > > _ usage of new RESET and CLOCK methods clk_count(), reset_count(), > > reset_assert_all() and clk_disable_all(). > >=20 > > v3: _ keep enabled clocks and deasserted resets reference in list in or= der to > > disable clock or assert resets in error path or in .remove callback > > _ use struct generic_ehci * instead of struct udevice * as parameter f= or > > ehci_release_resets() and ehci_release_clocks() > >=20 > > drivers/usb/host/ehci-generic.c | 125 ++++++++++++++++++++++++++++++++= -------- > > 1 file changed, 101 insertions(+), 24 deletions(-) > >=20 > > diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-ge= neric.c > > index 2116ae1..388b242 100644 > > --- a/drivers/usb/host/ehci-generic.c > > +++ b/drivers/usb/host/ehci-generic.c > > @@ -11,6 +11,8 @@ > > #include > > #include "ehci.h" > > =20 > > +#include > > + > > /* > > * Even though here we don't explicitly use "struct ehci_ctrl" > > * ehci_register() expects it to be the first thing that resides in > > @@ -18,43 +20,119 @@ > > */ > > struct generic_ehci { > > struct ehci_ctrl ctrl; > > + struct clk *clocks; > > + struct reset_ctl *resets; > > + int clock_count; > > + int reset_count; > > }; > > =20 > > static int ehci_usb_probe(struct udevice *dev) > > { > > + struct generic_ehci *priv =3D dev_get_priv(dev); > > struct ehci_hccr *hccr; > > struct ehci_hcor *hcor; > > - int i; > > - > > - for (i =3D 0; ; i++) { > > - struct clk clk; > > - int ret; > > - > > - ret =3D clk_get_by_index(dev, i, &clk); > > - if (ret < 0) > > - break; > > - if (clk_enable(&clk)) > > - error("failed to enable clock %d\n", i); > > - clk_free(&clk); > > - } > > + int i, err, ret, clock_nb, reset_nb; > > + > > + err =3D 0; > > + priv->clock_count =3D 0; > > + clock_nb =3D ofnode_count_phandle_with_args(dev_ofnode(dev), "clocks", > > + "#clock-cells"); > > + if (clock_nb > 0) { > > + priv->clocks =3D devm_kmalloc(dev, sizeof(struct clk) * clock_nb, > > + GFP_KERNEL); >=20 > devm_kzalloc() > devm_kcalloc(dev, clock_nb, sizeof()...) Lothar Wa=C3=9Fmann