From mboxrd@z Thu Jan 1 00:00:00 1970 From: Javier Martinez Canillas Subject: Re: [RFC v2 01/13] usb: misc: usb3503: Clean up on driver unbind Date: Thu, 5 May 2016 14:32:16 -0400 Message-ID: References: <1462451666-17945-1-git-send-email-k.kozlowski@samsung.com> <1462451666-17945-2-git-send-email-k.kozlowski@samsung.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Return-path: Received: from lists.s-osg.org ([54.187.51.154]:49340 "EHLO lists.s-osg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753506AbcEEScc (ORCPT ); Thu, 5 May 2016 14:32:32 -0400 In-Reply-To: <1462451666-17945-2-git-send-email-k.kozlowski@samsung.com> Sender: linux-pm-owner@vger.kernel.org List-Id: linux-pm@vger.kernel.org To: Krzysztof Kozlowski , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-mmc@vger.kernel.org, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, Ulf Hansson , Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , Greg Kroah-Hartman , Mark Brown Cc: tjakobi@math.uni-bielefeld.de, m.szyprowski@samsung.com, hverkuil@xs4all.nl, Bartlomiej Zolnierkiewicz Hello Krzysztof Patch looks good to me, I just have a trivial comment below. On 05/05/2016 08:34 AM, Krzysztof Kozlowski wrote: > The driver should clean up after itself by unpreparing the clock when it > is unbound. > > Signed-off-by: Krzysztof Kozlowski > --- > drivers/usb/misc/usb3503.c | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > > diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c > index b45cb77c0744..a464636675a6 100644 > --- a/drivers/usb/misc/usb3503.c > +++ b/drivers/usb/misc/usb3503.c > @@ -330,6 +330,19 @@ static int usb3503_i2c_probe(struct i2c_client *i2c, > return usb3503_probe(hub); > } > > +static int usb3503_i2c_remove(struct i2c_client *i2c) > +{ > + struct usb3503 *hub; > + > + hub = i2c_get_clientdata(i2c); > + if (hub) { > + if (hub->clk) > + clk_disable_unprepare(hub->clk); > + } I think the following is simpler and easier to read: if (hub && hub->clk) clk_disable_unprepare(hub->clk); > + > + return 0; > +} > + > static int usb3503_platform_probe(struct platform_device *pdev) > { > struct usb3503 *hub; > @@ -342,6 +355,19 @@ static int usb3503_platform_probe(struct platform_device *pdev) > return usb3503_probe(hub); > } > > +static int usb3503_platform_remove(struct platform_device *pdev) > +{ > + struct usb3503 *hub; > + > + hub = platform_get_drvdata(pdev); > + if (hub) { > + if (hub->clk) > + clk_disable_unprepare(hub->clk); > + } > + Ditto. > + return 0; > +} > + > #ifdef CONFIG_PM_SLEEP > static int usb3503_i2c_suspend(struct device *dev) > { > @@ -395,6 +421,7 @@ static struct i2c_driver usb3503_i2c_driver = { > .of_match_table = of_match_ptr(usb3503_of_match), > }, > .probe = usb3503_i2c_probe, > + .remove = usb3503_i2c_remove, > .id_table = usb3503_id, > }; > > @@ -404,6 +431,7 @@ static struct platform_driver usb3503_platform_driver = { > .of_match_table = of_match_ptr(usb3503_of_match), > }, > .probe = usb3503_platform_probe, > + .remove = usb3503_platform_remove, > }; > > static int __init usb3503_init(void) > Reviewed-by: Javier Martinez Canillas Best regards, -- Javier Martinez Canillas Open Source Group Samsung Research America