linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] hid-magicmouse: Fix oops after device removal.
@ 2010-03-09  0:38 Michael Poole
  2010-03-09  7:48 ` Dmitry Torokhov
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Poole @ 2010-03-09  0:38 UTC (permalink / raw)
  To: linux-input, Jiri Kosina
  Cc: Benjamin Tissoires, Dmitry Torokhov, Stephane Chatty

>From 57c6af4c2dadcce71566995baa15593103ab33aa Mon Sep 17 00:00:00 2001
From: Michael Poole <mdpoole@troilus.org>
Date: Mon, 8 Mar 2010 19:09:26 -0500
Subject: [PATCH 1/1] hid-magicmouse: Fix oops after device removal.

Ask the HID core not to register an input device for the mouse.
Fix an oops after removing the device, due to leaving the new
input device registered.

Signed-off-by: Michael Poole <mdpoole@troilus.org>
---
 drivers/hid/hid-magicmouse.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index 4a3a94f..2e7d701 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -353,7 +353,7 @@ static int magicmouse_probe(struct hid_device *hdev,
 		goto err_free;
 	}
 
-	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_HIDINPUT);
 	if (ret) {
 		dev_err(&hdev->dev, "magicmouse hw start failed\n");
 		goto err_free;
@@ -409,7 +409,10 @@ err_free:
 
 static void magicmouse_remove(struct hid_device *hdev)
 {
+	struct magicmouse_sc *msc;
+	msc = hid_get_drvdata(hdev);
 	hid_hw_stop(hdev);
+	input_unregister_device(msc->input);
 	kfree(hid_get_drvdata(hdev));
 }
 
-- 
1.7.0.2

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

* Re: [PATCH 1/1] hid-magicmouse: Fix oops after device removal.
  2010-03-09  0:38 [PATCH 1/1] hid-magicmouse: Fix oops after device removal Michael Poole
@ 2010-03-09  7:48 ` Dmitry Torokhov
  2010-03-09 11:32   ` Michael Poole
  2010-03-09 11:47   ` [PATCH v2] " Michael Poole
  0 siblings, 2 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2010-03-09  7:48 UTC (permalink / raw)
  To: Michael Poole
  Cc: linux-input, Jiri Kosina, Benjamin Tissoires, Stephane Chatty

On Mon, Mar 08, 2010 at 07:38:38PM -0500, Michael Poole wrote:
> From 57c6af4c2dadcce71566995baa15593103ab33aa Mon Sep 17 00:00:00 2001
> From: Michael Poole <mdpoole@troilus.org>
> Date: Mon, 8 Mar 2010 19:09:26 -0500
> Subject: [PATCH 1/1] hid-magicmouse: Fix oops after device removal.
> 
> Ask the HID core not to register an input device for the mouse.
> Fix an oops after removing the device, due to leaving the new
> input device registered.
> 
> Signed-off-by: Michael Poole <mdpoole@troilus.org>
> ---
>  drivers/hid/hid-magicmouse.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
> index 4a3a94f..2e7d701 100644
> --- a/drivers/hid/hid-magicmouse.c
> +++ b/drivers/hid/hid-magicmouse.c
> @@ -353,7 +353,7 @@ static int magicmouse_probe(struct hid_device *hdev,
>  		goto err_free;
>  	}
>  
> -	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
> +	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_HIDINPUT);
>  	if (ret) {
>  		dev_err(&hdev->dev, "magicmouse hw start failed\n");
>  		goto err_free;
> @@ -409,7 +409,10 @@ err_free:
>  
>  static void magicmouse_remove(struct hid_device *hdev)
>  {
> +	struct magicmouse_sc *msc;

Blank lines between variable definitions and code are always
appreciated. but also coudl be written as:

	struct magicmouse_sc *msc = hid_get_drvdata(dev);

> +	msc = hid_get_drvdata(hdev);
>  	hid_hw_stop(hdev);
> +	input_unregister_device(msc->input);
>  	kfree(hid_get_drvdata(hdev));

You have msc already sho that should be 'kfree(msc);'.
>  }
>  

-- 
Dmitry

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

* Re: [PATCH 1/1] hid-magicmouse: Fix oops after device removal.
  2010-03-09  7:48 ` Dmitry Torokhov
@ 2010-03-09 11:32   ` Michael Poole
  2010-03-09 11:47   ` [PATCH v2] " Michael Poole
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Poole @ 2010-03-09 11:32 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, Jiri Kosina, Benjamin Tissoires, Stephane Chatty

Dmitry Torokhov writes:

>>  static void magicmouse_remove(struct hid_device *hdev)
>>  {
>> +	struct magicmouse_sc *msc;
>
> Blank lines between variable definitions and code are always
> appreciated. but also coudl be written as:
>
> 	struct magicmouse_sc *msc = hid_get_drvdata(dev);
>
>> +	msc = hid_get_drvdata(hdev);
>>  	hid_hw_stop(hdev);
>> +	input_unregister_device(msc->input);
>>  	kfree(hid_get_drvdata(hdev));
>
> You have msc already sho that should be 'kfree(msc);'.

I'll fix both of these and resubmit.  Thanks for the review.

Michael



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

* [PATCH v2] hid-magicmouse: Fix oops after device removal.
  2010-03-09  7:48 ` Dmitry Torokhov
  2010-03-09 11:32   ` Michael Poole
@ 2010-03-09 11:47   ` Michael Poole
  2010-03-09 12:37     ` Jiri Kosina
  2010-03-09 17:36     ` Dmitry Torokhov
  1 sibling, 2 replies; 6+ messages in thread
From: Michael Poole @ 2010-03-09 11:47 UTC (permalink / raw)
  To: Dmitry Torokhov, Jiri Kosina
  Cc: linux-input, Benjamin Tissoires, Stephane Chatty

>From 7466c15f196621c44b01e3e1f8abd61099e48989 Mon Sep 17 00:00:00 2001
From: Michael Poole <mdpoole@troilus.org>
Date: Tue, 9 Mar 2010 06:46:09 -0500
Subject: [PATCH v2] hid-magicmouse: Fix oops after device removal.

Ask the HID core not to register an input device for the mouse.
Fix an oops after removing the device, due to leaving the new
input device registered.

Signed-off-by: Michael Poole <mdpoole@troilus.org>
---
 drivers/hid/hid-magicmouse.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index 4a3a94f..c174b64 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -353,7 +353,7 @@ static int magicmouse_probe(struct hid_device *hdev,
 		goto err_free;
 	}
 
-	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_HIDINPUT);
 	if (ret) {
 		dev_err(&hdev->dev, "magicmouse hw start failed\n");
 		goto err_free;
@@ -409,8 +409,11 @@ err_free:
 
 static void magicmouse_remove(struct hid_device *hdev)
 {
+	struct magicmouse_sc *msc = hid_get_drvdata(hdev);
+
 	hid_hw_stop(hdev);
-	kfree(hid_get_drvdata(hdev));
+	input_unregister_device(msc->input);
+	kfree(msc);
 }
 
 static const struct hid_device_id magic_mice[] = {
-- 
1.7.0.2


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

* Re: [PATCH v2] hid-magicmouse: Fix oops after device removal.
  2010-03-09 11:47   ` [PATCH v2] " Michael Poole
@ 2010-03-09 12:37     ` Jiri Kosina
  2010-03-09 17:36     ` Dmitry Torokhov
  1 sibling, 0 replies; 6+ messages in thread
From: Jiri Kosina @ 2010-03-09 12:37 UTC (permalink / raw)
  To: Michael Poole
  Cc: Dmitry Torokhov, linux-input, Benjamin Tissoires, Stephane Chatty

On Tue, 9 Mar 2010, Michael Poole wrote:

> Ask the HID core not to register an input device for the mouse.
> Fix an oops after removing the device, due to leaving the new
> input device registered.
> 
> Signed-off-by: Michael Poole <mdpoole@troilus.org>
> ---
>  drivers/hid/hid-magicmouse.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
> index 4a3a94f..c174b64 100644
> --- a/drivers/hid/hid-magicmouse.c
> +++ b/drivers/hid/hid-magicmouse.c
> @@ -353,7 +353,7 @@ static int magicmouse_probe(struct hid_device *hdev,
>  		goto err_free;
>  	}
>  
> -	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
> +	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_HIDINPUT);
>  	if (ret) {
>  		dev_err(&hdev->dev, "magicmouse hw start failed\n");
>  		goto err_free;
> @@ -409,8 +409,11 @@ err_free:
>  
>  static void magicmouse_remove(struct hid_device *hdev)
>  {
> +	struct magicmouse_sc *msc = hid_get_drvdata(hdev);
> +
>  	hid_hw_stop(hdev);
> -	kfree(hid_get_drvdata(hdev));
> +	input_unregister_device(msc->input);
> +	kfree(msc);
>  }
>  
>  static const struct hid_device_id magic_mice[] = {

Applied, thank you Michael.

-- 
Jiri Kosina
SUSE Labs, Novell Inc.

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

* Re: [PATCH v2] hid-magicmouse: Fix oops after device removal.
  2010-03-09 11:47   ` [PATCH v2] " Michael Poole
  2010-03-09 12:37     ` Jiri Kosina
@ 2010-03-09 17:36     ` Dmitry Torokhov
  1 sibling, 0 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2010-03-09 17:36 UTC (permalink / raw)
  To: Michael Poole
  Cc: Jiri Kosina, linux-input, Benjamin Tissoires, Stephane Chatty

On Tue, Mar 09, 2010 at 06:47:35AM -0500, Michael Poole wrote:
> From 7466c15f196621c44b01e3e1f8abd61099e48989 Mon Sep 17 00:00:00 2001
> From: Michael Poole <mdpoole@troilus.org>
> Date: Tue, 9 Mar 2010 06:46:09 -0500
> Subject: [PATCH v2] hid-magicmouse: Fix oops after device removal.
> 
> Ask the HID core not to register an input device for the mouse.
> Fix an oops after removing the device, due to leaving the new
> input device registered.
> 
> Signed-off-by: Michael Poole <mdpoole@troilus.org>

Yep, looks good, thank you for making the change.

> ---
>  drivers/hid/hid-magicmouse.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
> index 4a3a94f..c174b64 100644
> --- a/drivers/hid/hid-magicmouse.c
> +++ b/drivers/hid/hid-magicmouse.c
> @@ -353,7 +353,7 @@ static int magicmouse_probe(struct hid_device *hdev,
>  		goto err_free;
>  	}
>  
> -	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
> +	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_HIDINPUT);
>  	if (ret) {
>  		dev_err(&hdev->dev, "magicmouse hw start failed\n");
>  		goto err_free;
> @@ -409,8 +409,11 @@ err_free:
>  
>  static void magicmouse_remove(struct hid_device *hdev)
>  {
> +	struct magicmouse_sc *msc = hid_get_drvdata(hdev);
> +
>  	hid_hw_stop(hdev);
> -	kfree(hid_get_drvdata(hdev));
> +	input_unregister_device(msc->input);
> +	kfree(msc);
>  }
>  
>  static const struct hid_device_id magic_mice[] = {
> -- 
> 1.7.0.2
> 

-- 
Dmitry

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

end of thread, other threads:[~2010-03-09 17:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-09  0:38 [PATCH 1/1] hid-magicmouse: Fix oops after device removal Michael Poole
2010-03-09  7:48 ` Dmitry Torokhov
2010-03-09 11:32   ` Michael Poole
2010-03-09 11:47   ` [PATCH v2] " Michael Poole
2010-03-09 12:37     ` Jiri Kosina
2010-03-09 17:36     ` Dmitry Torokhov

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).