diff mbox

[12/14] usb: dwc2: simplify optional reset handling

Message ID 20170130114116.22089-12-p.zabel@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Philipp Zabel Jan. 30, 2017, 11:41 a.m. UTC
As of commit bb475230b8e5 ("reset: make optional functions really
optional"), the reset framework API calls use NULL pointers to describe
optional, non-present reset controls.

This allows to return errors from devm_reset_control_get_optional and to
call reset_control_(de)assert unconditionally.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Dinh Nguyen <dinguyen@opensource.altera.com>
Cc: John Youn <johnyoun@synopsys.com>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/dwc2/platform.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

Comments

John Youn Jan. 31, 2017, 12:28 a.m. UTC | #1
Hi Philipp,

On 1/30/2017 3:42 AM, Philipp Zabel wrote:
> As of commit bb475230b8e5 ("reset: make optional functions really

Where can I find this? It's not in mainline.

John


> optional"), the reset framework API calls use NULL pointers to describe
> optional, non-present reset controls.
>
> This allows to return errors from devm_reset_control_get_optional and to
> call reset_control_(de)assert unconditionally.
>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> Cc: Dinh Nguyen <dinguyen@opensource.altera.com>
> Cc: John Youn <johnyoun@synopsys.com>
> Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  drivers/usb/dwc2/platform.c | 18 ++++--------------
>  1 file changed, 4 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
> index 4fc8c603afb8b..c6aa2710cecfe 100644
> --- a/drivers/usb/dwc2/platform.c
> +++ b/drivers/usb/dwc2/platform.c
> @@ -214,20 +214,11 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
>  	hsotg->reset = devm_reset_control_get_optional(hsotg->dev, "dwc2");
>  	if (IS_ERR(hsotg->reset)) {
>  		ret = PTR_ERR(hsotg->reset);
> -		switch (ret) {
> -		case -ENOENT:
> -		case -ENOTSUPP:
> -			hsotg->reset = NULL;
> -			break;
> -		default:
> -			dev_err(hsotg->dev, "error getting reset control %d\n",
> -				ret);
> -			return ret;
> -		}
> +		dev_err(hsotg->dev, "error getting reset control %d\n", ret);
> +		return ret;
>  	}
>
> -	if (hsotg->reset)
> -		reset_control_deassert(hsotg->reset);
> +	reset_control_deassert(hsotg->reset);
>
>  	/* Set default UTMI width */
>  	hsotg->phyif = GUSBCFG_PHYIF16;
> @@ -326,8 +317,7 @@ static int dwc2_driver_remove(struct platform_device *dev)
>  	if (hsotg->ll_hw_enabled)
>  		dwc2_lowlevel_hw_disable(hsotg);
>
> -	if (hsotg->reset)
> -		reset_control_assert(hsotg->reset);
> +	reset_control_assert(hsotg->reset);
>
>  	return 0;
>  }
>
John Youn Jan. 31, 2017, 12:39 a.m. UTC | #2
On 1/30/2017 4:28 PM, John Youn wrote:
> Hi Philipp,
>
> On 1/30/2017 3:42 AM, Philipp Zabel wrote:
>> As of commit bb475230b8e5 ("reset: make optional functions really
>
> Where can I find this? It's not in mainline.
>

Never mind. I found on arm-soc per your reply elsewhere.

Acked-by: John Youn <johnyoun@synopsys.com>

Regards,
John


>
>
>> optional"), the reset framework API calls use NULL pointers to describe
>> optional, non-present reset controls.
>>
>> This allows to return errors from devm_reset_control_get_optional and to
>> call reset_control_(de)assert unconditionally.
>>
>> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
>> Cc: Dinh Nguyen <dinguyen@opensource.altera.com>
>> Cc: John Youn <johnyoun@synopsys.com>
>> Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> ---
>>  drivers/usb/dwc2/platform.c | 18 ++++--------------
>>  1 file changed, 4 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
>> index 4fc8c603afb8b..c6aa2710cecfe 100644
>> --- a/drivers/usb/dwc2/platform.c
>> +++ b/drivers/usb/dwc2/platform.c
>> @@ -214,20 +214,11 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
>>  	hsotg->reset = devm_reset_control_get_optional(hsotg->dev, "dwc2");
>>  	if (IS_ERR(hsotg->reset)) {
>>  		ret = PTR_ERR(hsotg->reset);
>> -		switch (ret) {
>> -		case -ENOENT:
>> -		case -ENOTSUPP:
>> -			hsotg->reset = NULL;
>> -			break;
>> -		default:
>> -			dev_err(hsotg->dev, "error getting reset control %d\n",
>> -				ret);
>> -			return ret;
>> -		}
>> +		dev_err(hsotg->dev, "error getting reset control %d\n", ret);
>> +		return ret;
>>  	}
>>
>> -	if (hsotg->reset)
>> -		reset_control_deassert(hsotg->reset);
>> +	reset_control_deassert(hsotg->reset);
>>
>>  	/* Set default UTMI width */
>>  	hsotg->phyif = GUSBCFG_PHYIF16;
>> @@ -326,8 +317,7 @@ static int dwc2_driver_remove(struct platform_device *dev)
>>  	if (hsotg->ll_hw_enabled)
>>  		dwc2_lowlevel_hw_disable(hsotg);
>>
>> -	if (hsotg->reset)
>> -		reset_control_assert(hsotg->reset);
>> +	reset_control_assert(hsotg->reset);
>>
>>  	return 0;
>>  }
>>
>
>
Felipe Balbi April 10, 2017, 10:21 a.m. UTC | #3
Hi,

Philipp Zabel <p.zabel@pengutronix.de> writes:
> As of commit bb475230b8e5 ("reset: make optional functions really
> optional"), the reset framework API calls use NULL pointers to describe
> optional, non-present reset controls.
>
> This allows to return errors from devm_reset_control_get_optional and to
> call reset_control_(de)assert unconditionally.
>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> Cc: Dinh Nguyen <dinguyen@opensource.altera.com>
> Cc: John Youn <johnyoun@synopsys.com>
> Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

doesn't apply to testing/next. Care to rebase and resend? Also, please
Cc linux-usb ;-)
Philipp Zabel April 10, 2017, 10:36 a.m. UTC | #4
Hi Felipe,

On Mon, 2017-04-10 at 13:21 +0300, Felipe Balbi wrote:
> Hi,
> 
> Philipp Zabel <p.zabel@pengutronix.de> writes:
> > As of commit bb475230b8e5 ("reset: make optional functions really
> > optional"), the reset framework API calls use NULL pointers to describe
> > optional, non-present reset controls.
> >
> > This allows to return errors from devm_reset_control_get_optional and to
> > call reset_control_(de)assert unconditionally.
> >
> > Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> > Cc: Dinh Nguyen <dinguyen@opensource.altera.com>
> > Cc: John Youn <johnyoun@synopsys.com>
> > Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> doesn't apply to testing/next. Care to rebase and resend?

v2 is already applied as commit 5a6e4f46abd5 ("usb: dwc2: simplify
optional reset handling"), as far as I can tell.

> Also, please Cc linux-usb ;-)

I messed up the Cc: list on the first submission, but v2 should have
made it to linux-usb.

regards
Philipp
Felipe Balbi April 10, 2017, 11:23 a.m. UTC | #5
Hi,

Philipp Zabel <p.zabel@pengutronix.de> writes:
>> Philipp Zabel <p.zabel@pengutronix.de> writes:
>> > As of commit bb475230b8e5 ("reset: make optional functions really
>> > optional"), the reset framework API calls use NULL pointers to describe
>> > optional, non-present reset controls.
>> >
>> > This allows to return errors from devm_reset_control_get_optional and to
>> > call reset_control_(de)assert unconditionally.
>> >
>> > Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
>> > Cc: Dinh Nguyen <dinguyen@opensource.altera.com>
>> > Cc: John Youn <johnyoun@synopsys.com>
>> > Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
>> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> 
>> doesn't apply to testing/next. Care to rebase and resend?
>
> v2 is already applied as commit 5a6e4f46abd5 ("usb: dwc2: simplify
> optional reset handling"), as far as I can tell.

indeed, heh :-)

>> Also, please Cc linux-usb ;-)
>
> I messed up the Cc: list on the first submission, but v2 should have
> made it to linux-usb.

cool, thanks
diff mbox

Patch

diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 4fc8c603afb8b..c6aa2710cecfe 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -214,20 +214,11 @@  static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
 	hsotg->reset = devm_reset_control_get_optional(hsotg->dev, "dwc2");
 	if (IS_ERR(hsotg->reset)) {
 		ret = PTR_ERR(hsotg->reset);
-		switch (ret) {
-		case -ENOENT:
-		case -ENOTSUPP:
-			hsotg->reset = NULL;
-			break;
-		default:
-			dev_err(hsotg->dev, "error getting reset control %d\n",
-				ret);
-			return ret;
-		}
+		dev_err(hsotg->dev, "error getting reset control %d\n", ret);
+		return ret;
 	}
 
-	if (hsotg->reset)
-		reset_control_deassert(hsotg->reset);
+	reset_control_deassert(hsotg->reset);
 
 	/* Set default UTMI width */
 	hsotg->phyif = GUSBCFG_PHYIF16;
@@ -326,8 +317,7 @@  static int dwc2_driver_remove(struct platform_device *dev)
 	if (hsotg->ll_hw_enabled)
 		dwc2_lowlevel_hw_disable(hsotg);
 
-	if (hsotg->reset)
-		reset_control_assert(hsotg->reset);
+	reset_control_assert(hsotg->reset);
 
 	return 0;
 }