All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] HID: wacom: Fix invalid power_supply_powers calls
@ 2012-02-05 22:35 Przemo Firszt
  2012-02-06 12:27 ` Jiri Kosina
  0 siblings, 1 reply; 7+ messages in thread
From: Przemo Firszt @ 2012-02-05 22:35 UTC (permalink / raw)
  To: chris, pinglinux, jkosina, linuxwacom-devel, linux-input,
	linux-kernel
  Cc: Przemo Firszt

power_supply_powers calls added in 35b4c01e29bdd9632dabf9784ed3486333f00427
have to be called after power device is created. This patch also fixes the
second call - it has to be "ac" instead of "battery"

Signed-off-by: Przemo Firszt <przemo@firszt.eu>
Signed-off-by: Chris Bagwell <chris@cnpbagwell.com>
---
 drivers/hid/hid-wacom.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
index b47e58b..acab74c 100644
--- a/drivers/hid/hid-wacom.c
+++ b/drivers/hid/hid-wacom.c
@@ -531,7 +531,6 @@ static int wacom_probe(struct hid_device *hdev,
 	wdata->battery.type = POWER_SUPPLY_TYPE_BATTERY;
 	wdata->battery.use_for_apm = 0;
 
-	power_supply_powers(&wdata->battery, &hdev->dev);
 
 	ret = power_supply_register(&hdev->dev, &wdata->battery);
 	if (ret) {
@@ -540,6 +539,8 @@ static int wacom_probe(struct hid_device *hdev,
 		goto err_battery;
 	}
 
+	power_supply_powers(&wdata->battery, &hdev->dev);
+
 	wdata->ac.properties = wacom_ac_props;
 	wdata->ac.num_properties = ARRAY_SIZE(wacom_ac_props);
 	wdata->ac.get_property = wacom_ac_get_property;
@@ -547,14 +548,14 @@ static int wacom_probe(struct hid_device *hdev,
 	wdata->ac.type = POWER_SUPPLY_TYPE_MAINS;
 	wdata->ac.use_for_apm = 0;
 
-	power_supply_powers(&wdata->battery, &hdev->dev);
-
 	ret = power_supply_register(&hdev->dev, &wdata->ac);
 	if (ret) {
 		hid_warn(hdev,
 			 "can't create ac battery attribute, err: %d\n", ret);
 		goto err_ac;
 	}
+
+	power_supply_powers(&wdata->ac, &hdev->dev);
 #endif
 	return 0;
 
-- 
1.7.6.4


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

* Re: [PATCH] HID: wacom: Fix invalid power_supply_powers calls
  2012-02-05 22:35 [PATCH] HID: wacom: Fix invalid power_supply_powers calls Przemo Firszt
@ 2012-02-06 12:27 ` Jiri Kosina
  2012-02-06 12:34   ` przemo
  0 siblings, 1 reply; 7+ messages in thread
From: Jiri Kosina @ 2012-02-06 12:27 UTC (permalink / raw)
  To: Przemo Firszt
  Cc: chris, pinglinux, linuxwacom-devel, linux-input, linux-kernel,
	Jeremy Fitzhardinge

On Sun, 5 Feb 2012, Przemo Firszt wrote:

> power_supply_powers calls added in 35b4c01e29bdd9632dabf9784ed3486333f00427
> have to be called after power device is created. This patch also fixes the
> second call - it has to be "ac" instead of "battery"
> 
> Signed-off-by: Przemo Firszt <przemo@firszt.eu>
> Signed-off-by: Chris Bagwell <chris@cnpbagwell.com>

[ adding Jeremy to CC ]

> ---
>  drivers/hid/hid-wacom.c |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
> index b47e58b..acab74c 100644
> --- a/drivers/hid/hid-wacom.c
> +++ b/drivers/hid/hid-wacom.c
> @@ -531,7 +531,6 @@ static int wacom_probe(struct hid_device *hdev,
>  	wdata->battery.type = POWER_SUPPLY_TYPE_BATTERY;
>  	wdata->battery.use_for_apm = 0;
>  
> -	power_supply_powers(&wdata->battery, &hdev->dev);
>  
>  	ret = power_supply_register(&hdev->dev, &wdata->battery);
>  	if (ret) {
> @@ -540,6 +539,8 @@ static int wacom_probe(struct hid_device *hdev,
>  		goto err_battery;
>  	}
>  
> +	power_supply_powers(&wdata->battery, &hdev->dev);
> +
>  	wdata->ac.properties = wacom_ac_props;
>  	wdata->ac.num_properties = ARRAY_SIZE(wacom_ac_props);
>  	wdata->ac.get_property = wacom_ac_get_property;
> @@ -547,14 +548,14 @@ static int wacom_probe(struct hid_device *hdev,
>  	wdata->ac.type = POWER_SUPPLY_TYPE_MAINS;
>  	wdata->ac.use_for_apm = 0;
>  
> -	power_supply_powers(&wdata->battery, &hdev->dev);
> -
>  	ret = power_supply_register(&hdev->dev, &wdata->ac);
>  	if (ret) {
>  		hid_warn(hdev,
>  			 "can't create ac battery attribute, err: %d\n", ret);
>  		goto err_ac;
>  	}
> +
> +	power_supply_powers(&wdata->ac, &hdev->dev);
>  #endif
>  	return 0;

Hmm, seems valid. How did you notice? Have you seen crashes because of 
wild pointers?

Thanks,

-- 
Jiri Kosina
SUSE Labs

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

* Re: [PATCH] HID: wacom: Fix invalid power_supply_powers calls
  2012-02-06 12:27 ` Jiri Kosina
@ 2012-02-06 12:34   ` przemo
  2012-02-06 12:42     ` Jiri Kosina
  0 siblings, 1 reply; 7+ messages in thread
From: przemo @ 2012-02-06 12:34 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Przemo Firszt, chris, pinglinux, linuxwacom-devel, linux-input,
	linux-kernel, Jeremy Fitzhardinge

> On Sun, 5 Feb 2012, Przemo Firszt wrote:
[..]
> Hmm, seems valid. How did you notice? Have you seen crashes because of
> wild pointers?

Hi Jiri,
Yes, the driver was unusable - 100% crashes during connection.

Chris came up with the solution, I did coding & testing.

The crash details are here:  http://pastebin.com/ZVNZWaPs

regards,
Przemo


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

* Re: [PATCH] HID: wacom: Fix invalid power_supply_powers calls
  2012-02-06 12:34   ` przemo
@ 2012-02-06 12:42     ` Jiri Kosina
  2012-02-06 17:34       ` Jeremy Fitzhardinge
  0 siblings, 1 reply; 7+ messages in thread
From: Jiri Kosina @ 2012-02-06 12:42 UTC (permalink / raw)
  To: Przemo Firszt
  Cc: chris, pinglinux, linuxwacom-devel, linux-input, linux-kernel,
	Jeremy Fitzhardinge

On Mon, 6 Feb 2012, przemo@firszt.eu wrote:

> > Hmm, seems valid. How did you notice? Have you seen crashes because of
> > wild pointers?
> 
> Hi Jiri,
> Yes, the driver was unusable - 100% crashes during connection.

Okay, I thought that'd be the case.

> Chris came up with the solution, I did coding & testing.
> 
> The crash details are here:  http://pastebin.com/ZVNZWaPs

Thank you. Will be pushing to Linus soon.

-- 
Jiri Kosina
SUSE Labs

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

* Re: [PATCH] HID: wacom: Fix invalid power_supply_powers calls
  2012-02-06 12:42     ` Jiri Kosina
@ 2012-02-06 17:34       ` Jeremy Fitzhardinge
  2012-02-06 17:44         ` przemo
  0 siblings, 1 reply; 7+ messages in thread
From: Jeremy Fitzhardinge @ 2012-02-06 17:34 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Przemo Firszt, chris, pinglinux, linuxwacom-devel, linux-input,
	linux-kernel

On 02/06/2012 04:42 AM, Jiri Kosina wrote:
> On Mon, 6 Feb 2012, przemo@firszt.eu wrote:
>
>>> Hmm, seems valid. How did you notice? Have you seen crashes because of
>>> wild pointers?
>> Hi Jiri,
>> Yes, the driver was unusable - 100% crashes during connection.
> Okay, I thought that'd be the case.

Very sorry about that.  I don't have a device to test with, so I should
have reviewed the code extra carefully.

Does the same bug apply to the Wii changes, which were of the same form?

    J

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

* Re: [PATCH] HID: wacom: Fix invalid power_supply_powers calls
  2012-02-06 17:34       ` Jeremy Fitzhardinge
@ 2012-02-06 17:44         ` przemo
  2012-02-07 12:43           ` Jiri Kosina
  0 siblings, 1 reply; 7+ messages in thread
From: przemo @ 2012-02-06 17:44 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Jiri Kosina, Przemo Firszt, chris, pinglinux, linuxwacom-devel,
	linux-input, linux-kernel

> On 02/06/2012 04:42 AM, Jiri Kosina wrote:
>> On Mon, 6 Feb 2012, przemo@firszt.eu wrote:
>>
>>>> Hmm, seems valid. How did you notice? Have you seen crashes because of
>>>> wild pointers?
>>> Hi Jiri,
>>> Yes, the driver was unusable - 100% crashes during connection.
>> Okay, I thought that'd be the case.
>
> Very sorry about that.  I don't have a device to test with, so I should
> have reviewed the code extra carefully.
>
> Does the same bug apply to the Wii changes, which were of the same form?
>
Hi Jeremy,
The wii code looks the same, so probably it's affected as well. Can you
make a patch?

power_supply_powers call in wiimote driver:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=drivers/hid/hid-wiimote-core.c#l1229

regards,
Przemo Firszt


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

* Re: [PATCH] HID: wacom: Fix invalid power_supply_powers calls
  2012-02-06 17:44         ` przemo
@ 2012-02-07 12:43           ` Jiri Kosina
  0 siblings, 0 replies; 7+ messages in thread
From: Jiri Kosina @ 2012-02-07 12:43 UTC (permalink / raw)
  To: Przemo Firszt
  Cc: Jeremy Fitzhardinge, chris, pinglinux, linuxwacom-devel,
	linux-input, linux-kernel

On Mon, 6 Feb 2012, przemo@firszt.eu wrote:

> >>>> Hmm, seems valid. How did you notice? Have you seen crashes because of
> >>>> wild pointers?
> >>> Hi Jiri,
> >>> Yes, the driver was unusable - 100% crashes during connection.
> >> Okay, I thought that'd be the case.
> >
> > Very sorry about that.  I don't have a device to test with, so I should
> > have reviewed the code extra carefully.
> >
> > Does the same bug apply to the Wii changes, which were of the same form?
> >
> Hi Jeremy,
> The wii code looks the same, so probably it's affected as well. Can you
> make a patch?
> 
> power_supply_powers call in wiimote driver:
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=drivers/hid/hid-wiimote-core.c#l1229

I have now queued the patch below for the same pile as well.
Thanks for spotting it.


From: Jiri Kosina <jkosina@suse.cz>
Subject: [PATCH] HID: wiimote: fix invalid power_supply_powers call

Analogically to d7cb3dbd1 ("HID: wacom: Fix invalid power_supply_powers
calls"), fix also the same occurence in wiimote driver.

Reported-by: przemo@firszt.eu
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
---
 drivers/hid/hid-wiimote-core.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c
index fc253b4..cac3589 100644
--- a/drivers/hid/hid-wiimote-core.c
+++ b/drivers/hid/hid-wiimote-core.c
@@ -1226,14 +1226,14 @@ static int wiimote_hid_probe(struct hid_device *hdev,
 	wdata->battery.type = POWER_SUPPLY_TYPE_BATTERY;
 	wdata->battery.use_for_apm = 0;
 
-	power_supply_powers(&wdata->battery, &hdev->dev);
-
 	ret = power_supply_register(&wdata->hdev->dev, &wdata->battery);
 	if (ret) {
 		hid_err(hdev, "Cannot register battery device\n");
 		goto err_battery;
 	}
 
+	power_supply_powers(&wdata->battery, &hdev->dev);
+
 	ret = wiimote_leds_create(wdata);
 	if (ret)
 		goto err_free;

-- 
Jiri Kosina
SUSE Labs

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

end of thread, other threads:[~2012-02-07 12:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-05 22:35 [PATCH] HID: wacom: Fix invalid power_supply_powers calls Przemo Firszt
2012-02-06 12:27 ` Jiri Kosina
2012-02-06 12:34   ` przemo
2012-02-06 12:42     ` Jiri Kosina
2012-02-06 17:34       ` Jeremy Fitzhardinge
2012-02-06 17:44         ` przemo
2012-02-07 12:43           ` Jiri Kosina

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.