linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] HID: wacom: Fix wacom_probe error handling
@ 2012-09-17  8:53 Axel Lin
  2012-09-17 20:17 ` Ping Cheng
  2012-09-18 22:09 ` Przemo Firszt
  0 siblings, 2 replies; 4+ messages in thread
From: Axel Lin @ 2012-09-17  8:53 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Przemo Firszt, Ping Cheng, linux-input

OLEDs/LED are not critical for tablet functioning thus ignore OLED/LED
initialisation failures.

This patch does clean up all the sysfs attribute files in error paths.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/hid/hid-wacom.c |   23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
index a0fafac..2f60da9 100644
--- a/drivers/hid/hid-wacom.c
+++ b/drivers/hid/hid-wacom.c
@@ -858,11 +858,9 @@ OLED_INIT(7);
 	if (hdev->product == USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) {
 		sprintf(hdev->name, "%s", "Wacom Intuos4 WL");
 		ret = wacom_initialize_leds(hdev);
-		if (ret) {
+		if (ret)
 			hid_warn(hdev,
 				 "can't create led attribute, err: %d\n", ret);
-			goto destroy_leds;
-		}
 	}
 
 	wdata->battery.properties = wacom_battery_props;
@@ -875,8 +873,8 @@ OLED_INIT(7);
 
 	ret = power_supply_register(&hdev->dev, &wdata->battery);
 	if (ret) {
-		hid_warn(hdev, "can't create sysfs battery attribute, err: %d\n",
-			 ret);
+		hid_err(hdev, "can't create sysfs battery attribute, err: %d\n",
+			ret);
 		goto err_battery;
 	}
 
@@ -891,8 +889,8 @@ OLED_INIT(7);
 
 	ret = power_supply_register(&hdev->dev, &wdata->ac);
 	if (ret) {
-		hid_warn(hdev,
-			 "can't create ac battery attribute, err: %d\n", ret);
+		hid_err(hdev,
+			"can't create ac battery attribute, err: %d\n", ret);
 		goto err_ac;
 	}
 
@@ -902,10 +900,17 @@ OLED_INIT(7);
 err_ac:
 	power_supply_unregister(&wdata->battery);
 err_battery:
+	wacom_destroy_leds(hdev);
+	device_remove_file(&hdev->dev, &dev_attr_oled0_img);
+	device_remove_file(&hdev->dev, &dev_attr_oled1_img);
+	device_remove_file(&hdev->dev, &dev_attr_oled2_img);
+	device_remove_file(&hdev->dev, &dev_attr_oled3_img);
+	device_remove_file(&hdev->dev, &dev_attr_oled4_img);
+	device_remove_file(&hdev->dev, &dev_attr_oled5_img);
+	device_remove_file(&hdev->dev, &dev_attr_oled6_img);
+	device_remove_file(&hdev->dev, &dev_attr_oled7_img);
 	device_remove_file(&hdev->dev, &dev_attr_speed);
 	hid_hw_stop(hdev);
-destroy_leds:
-	wacom_destroy_leds(hdev);
 err_free:
 	kfree(wdata);
 	return ret;
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH v2] HID: wacom: Fix wacom_probe error handling
  2012-09-17  8:53 [PATCH v2] HID: wacom: Fix wacom_probe error handling Axel Lin
@ 2012-09-17 20:17 ` Ping Cheng
  2012-09-18 22:09 ` Przemo Firszt
  1 sibling, 0 replies; 4+ messages in thread
From: Ping Cheng @ 2012-09-17 20:17 UTC (permalink / raw)
  To: Axel Lin, Jiri Kosina, eduard@hasenleithner.at
  Cc: Przemo Firszt, linux-input@vger.kernel.org

If device_remove_file is needed for hid-wacom.c, it should be considered for wacm_sys.c as well. 

Eduard, what do you think?

Ping

-----Original Message-----
From: Axel Lin [mailto:axel.lin@gmail.com] 
Sent: Monday, September 17, 2012 1:54 AM
To: Jiri Kosina
Cc: Przemo Firszt; Ping Cheng; linux-input@vger.kernel.org
Subject: [PATCH v2] HID: wacom: Fix wacom_probe error handling

OLEDs/LED are not critical for tablet functioning thus ignore OLED/LED initialisation failures.

This patch does clean up all the sysfs attribute files in error paths.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/hid/hid-wacom.c |   23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index a0fafac..2f60da9 100644
--- a/drivers/hid/hid-wacom.c
+++ b/drivers/hid/hid-wacom.c
@@ -858,11 +858,9 @@ OLED_INIT(7);
 	if (hdev->product == USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) {
 		sprintf(hdev->name, "%s", "Wacom Intuos4 WL");
 		ret = wacom_initialize_leds(hdev);
-		if (ret) {
+		if (ret)
 			hid_warn(hdev,
 				 "can't create led attribute, err: %d\n", ret);
-			goto destroy_leds;
-		}
 	}
 
 	wdata->battery.properties = wacom_battery_props; @@ -875,8 +873,8 @@ OLED_INIT(7);
 
 	ret = power_supply_register(&hdev->dev, &wdata->battery);
 	if (ret) {
-		hid_warn(hdev, "can't create sysfs battery attribute, err: %d\n",
-			 ret);
+		hid_err(hdev, "can't create sysfs battery attribute, err: %d\n",
+			ret);
 		goto err_battery;
 	}
 
@@ -891,8 +889,8 @@ OLED_INIT(7);
 
 	ret = power_supply_register(&hdev->dev, &wdata->ac);
 	if (ret) {
-		hid_warn(hdev,
-			 "can't create ac battery attribute, err: %d\n", ret);
+		hid_err(hdev,
+			"can't create ac battery attribute, err: %d\n", ret);
 		goto err_ac;
 	}
 
@@ -902,10 +900,17 @@ OLED_INIT(7);
 err_ac:
 	power_supply_unregister(&wdata->battery);
 err_battery:
+	wacom_destroy_leds(hdev);
+	device_remove_file(&hdev->dev, &dev_attr_oled0_img);
+	device_remove_file(&hdev->dev, &dev_attr_oled1_img);
+	device_remove_file(&hdev->dev, &dev_attr_oled2_img);
+	device_remove_file(&hdev->dev, &dev_attr_oled3_img);
+	device_remove_file(&hdev->dev, &dev_attr_oled4_img);
+	device_remove_file(&hdev->dev, &dev_attr_oled5_img);
+	device_remove_file(&hdev->dev, &dev_attr_oled6_img);
+	device_remove_file(&hdev->dev, &dev_attr_oled7_img);
 	device_remove_file(&hdev->dev, &dev_attr_speed);
 	hid_hw_stop(hdev);
-destroy_leds:
-	wacom_destroy_leds(hdev);
 err_free:
 	kfree(wdata);
 	return ret;
--
1.7.9.5




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] HID: wacom: Fix wacom_probe error handling
  2012-09-17  8:53 [PATCH v2] HID: wacom: Fix wacom_probe error handling Axel Lin
  2012-09-17 20:17 ` Ping Cheng
@ 2012-09-18 22:09 ` Przemo Firszt
  2012-09-19 11:42   ` Jiri Kosina
  1 sibling, 1 reply; 4+ messages in thread
From: Przemo Firszt @ 2012-09-18 22:09 UTC (permalink / raw)
  To: Axel Lin; +Cc: Jiri Kosina, Ping Cheng, linux-input

On Mon, 2012-09-17 at 16:53 +0800, Axel Lin wrote:
> OLEDs/LED are not critical for tablet functioning thus ignore OLED/LED
> initialisation failures.
> 
> This patch does clean up all the sysfs attribute files in error paths.
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
>  drivers/hid/hid-wacom.c |   23 ++++++++++++++---------
>  1 file changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
> index a0fafac..2f60da9 100644
> --- a/drivers/hid/hid-wacom.c
> +++ b/drivers/hid/hid-wacom.c
> @@ -858,11 +858,9 @@ OLED_INIT(7);
>  	if (hdev->product == USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) {
>  		sprintf(hdev->name, "%s", "Wacom Intuos4 WL");
>  		ret = wacom_initialize_leds(hdev);
> -		if (ret) {
> +		if (ret)
>  			hid_warn(hdev,
>  				 "can't create led attribute, err: %d\n", ret);
> -			goto destroy_leds;
> -		}
>  	}
>  
>  	wdata->battery.properties = wacom_battery_props;
> @@ -875,8 +873,8 @@ OLED_INIT(7);
>  
>  	ret = power_supply_register(&hdev->dev, &wdata->battery);
>  	if (ret) {
> -		hid_warn(hdev, "can't create sysfs battery attribute, err: %d\n",
> -			 ret);
> +		hid_err(hdev, "can't create sysfs battery attribute, err: %d\n",
> +			ret);
>  		goto err_battery;
>  	}
>  
> @@ -891,8 +889,8 @@ OLED_INIT(7);
>  
>  	ret = power_supply_register(&hdev->dev, &wdata->ac);
>  	if (ret) {
> -		hid_warn(hdev,
> -			 "can't create ac battery attribute, err: %d\n", ret);
> +		hid_err(hdev,
> +			"can't create ac battery attribute, err: %d\n", ret);
>  		goto err_ac;
>  	}
>  
> @@ -902,10 +900,17 @@ OLED_INIT(7);
>  err_ac:
>  	power_supply_unregister(&wdata->battery);
>  err_battery:
> +	wacom_destroy_leds(hdev);
> +	device_remove_file(&hdev->dev, &dev_attr_oled0_img);
> +	device_remove_file(&hdev->dev, &dev_attr_oled1_img);
> +	device_remove_file(&hdev->dev, &dev_attr_oled2_img);
> +	device_remove_file(&hdev->dev, &dev_attr_oled3_img);
> +	device_remove_file(&hdev->dev, &dev_attr_oled4_img);
> +	device_remove_file(&hdev->dev, &dev_attr_oled5_img);
> +	device_remove_file(&hdev->dev, &dev_attr_oled6_img);
> +	device_remove_file(&hdev->dev, &dev_attr_oled7_img);
>  	device_remove_file(&hdev->dev, &dev_attr_speed);
>  	hid_hw_stop(hdev);
> -destroy_leds:
> -	wacom_destroy_leds(hdev);
>  err_free:
>  	kfree(wdata);
>  	return ret;

Tested-by: Przemo Firszt <przemo@firszt.eu>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] HID: wacom: Fix wacom_probe error handling
  2012-09-18 22:09 ` Przemo Firszt
@ 2012-09-19 11:42   ` Jiri Kosina
  0 siblings, 0 replies; 4+ messages in thread
From: Jiri Kosina @ 2012-09-19 11:42 UTC (permalink / raw)
  To: Przemo Firszt; +Cc: Axel Lin, Ping Cheng, linux-input

On Tue, 18 Sep 2012, Przemo Firszt wrote:

> > OLEDs/LED are not critical for tablet functioning thus ignore OLED/LED
> > initialisation failures.
> > 
> > This patch does clean up all the sysfs attribute files in error paths.
> > 
> > Signed-off-by: Axel Lin <axel.lin@gmail.com>
> > ---
> >  drivers/hid/hid-wacom.c |   23 ++++++++++++++---------
> >  1 file changed, 14 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
> > index a0fafac..2f60da9 100644
> > --- a/drivers/hid/hid-wacom.c
> > +++ b/drivers/hid/hid-wacom.c
> > @@ -858,11 +858,9 @@ OLED_INIT(7);
> >  	if (hdev->product == USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) {
> >  		sprintf(hdev->name, "%s", "Wacom Intuos4 WL");
> >  		ret = wacom_initialize_leds(hdev);
> > -		if (ret) {
> > +		if (ret)
> >  			hid_warn(hdev,
> >  				 "can't create led attribute, err: %d\n", ret);
> > -			goto destroy_leds;
> > -		}
> >  	}
> >  
> >  	wdata->battery.properties = wacom_battery_props;
> > @@ -875,8 +873,8 @@ OLED_INIT(7);
> >  
> >  	ret = power_supply_register(&hdev->dev, &wdata->battery);
> >  	if (ret) {
> > -		hid_warn(hdev, "can't create sysfs battery attribute, err: %d\n",
> > -			 ret);
> > +		hid_err(hdev, "can't create sysfs battery attribute, err: %d\n",
> > +			ret);
> >  		goto err_battery;
> >  	}
> >  
> > @@ -891,8 +889,8 @@ OLED_INIT(7);
> >  
> >  	ret = power_supply_register(&hdev->dev, &wdata->ac);
> >  	if (ret) {
> > -		hid_warn(hdev,
> > -			 "can't create ac battery attribute, err: %d\n", ret);
> > +		hid_err(hdev,
> > +			"can't create ac battery attribute, err: %d\n", ret);
> >  		goto err_ac;
> >  	}
> >  
> > @@ -902,10 +900,17 @@ OLED_INIT(7);
> >  err_ac:
> >  	power_supply_unregister(&wdata->battery);
> >  err_battery:
> > +	wacom_destroy_leds(hdev);
> > +	device_remove_file(&hdev->dev, &dev_attr_oled0_img);
> > +	device_remove_file(&hdev->dev, &dev_attr_oled1_img);
> > +	device_remove_file(&hdev->dev, &dev_attr_oled2_img);
> > +	device_remove_file(&hdev->dev, &dev_attr_oled3_img);
> > +	device_remove_file(&hdev->dev, &dev_attr_oled4_img);
> > +	device_remove_file(&hdev->dev, &dev_attr_oled5_img);
> > +	device_remove_file(&hdev->dev, &dev_attr_oled6_img);
> > +	device_remove_file(&hdev->dev, &dev_attr_oled7_img);
> >  	device_remove_file(&hdev->dev, &dev_attr_speed);
> >  	hid_hw_stop(hdev);
> > -destroy_leds:
> > -	wacom_destroy_leds(hdev);
> >  err_free:
> >  	kfree(wdata);
> >  	return ret;
> 
> Tested-by: Przemo Firszt <przemo@firszt.eu>

Thanks to both of you. Applied.

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-09-19 11:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-17  8:53 [PATCH v2] HID: wacom: Fix wacom_probe error handling Axel Lin
2012-09-17 20:17 ` Ping Cheng
2012-09-18 22:09 ` Przemo Firszt
2012-09-19 11:42   ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).