Skip to contentSkip to conversation

HID:magicmouse: This fixes a connection problem with the magicmouse.

PATCH In review Justin P. Mattock 3 participants 8 messages May 11, 2010 – May 12, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID:magicmouse: This fixes a connection problem with the magicmouse.

With the latest HEAD, I've noticed that I needed to add: HIDRAW=y in order for my apple magicmouse to connect.
After receiving some posts, it seems this it not
the case(HIDRAW just relays HID events to userspace).

The bisect results of this issue resulted in commit:
HID:magicmouse: fix oops after device removal. (hash:28918c211d86b6eeb70182c523800c7bc442960c)

After examining this commit, I've noticed that HID_CONNECT_DEFAULT has also an entry in there of HID_CONNECT_HIDINPUT, not sure what "~" means, before HID_CONNECT_HIDINPUT, but after removing this(correct me if I'm wrong)"double" definition, I'm able to have my magicmouse connect without the need of HIDRAW, and also this in dmesg:

magicmouse 0005:05AC:030D.0004: claimed by neither input, hiddev nor hidraw magicmouse 0005:05AC:030D.0004: magicmouse hw start failed

and as well as the crash that the above commit fixes when waking up from suspend(mouse connects perfectly upon wakeup).

Please have a look, and if this works, take it
if theres another solution let me know.
(so I can enjoy the power of the magicmouse!!).

---
 drivers/hid/hid-magicmouse.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/hid/hid-magicmouse.c +1 -1
index 0d471fc..0de5e96 100644
@@ -354,7 +354,7 @@ static int magicmouse_probe(struct hid_device *hdev,
 		goto err_free;
 	}
 
-	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_HIDINPUT);
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
 	if (ret) {
 		dev_err(&hdev->dev, "magicmouse hw start failed\n");
 		goto err_free;
Signature · 1 line
1.6.5.GIT
#1 lore raw
Quoted 10 lines · Justin P. Mattock

With the latest HEAD, I've noticed that I needed to add: HIDRAW=y in order for my apple magicmouse to connect. After receiving some posts, it seems this it not the case(HIDRAW just relays HID events to userspace).

The bisect results of this issue resulted in commit: HID:magicmouse: fix oops after device removal. (hash:28918c211d86b6eeb70182c523800c7bc442960c)

After examining this commit, I've noticed that HID_CONNECT_DEFAULT has also an entry in there of HID_CONNECT_HIDINPUT, not sure what "~" means,

~ is zeroing out the HID_CONENCT_HIDINPUT bits from the connect mask, as magicmouse driver is handling the input itself.

Quoted 27 lines

before HID_CONNECT_HIDINPUT, but after removing this(correct me if I'm wrong)"double" definition, I'm able to have my magicmouse connect without the need of HIDRAW, and also this in dmesg:

magicmouse 0005:05AC:030D.0004: claimed by neither input, hiddev nor hidraw magicmouse 0005:05AC:030D.0004: magicmouse hw start failed

and as well as the crash that the above commit fixes when waking up from suspend(mouse connects perfectly upon wakeup).

Please have a look, and if this works, take it
if theres another solution let me know.
(so I can enjoy the power of the magicmouse!!).

---
 drivers/hid/hid-magicmouse.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/hid/hid-magicmouse.c +0 -0
index 0d471fc..0de5e96 100644

drivers/hid/hid-magicmouse.c static int magicmouse_probe(struct hid_device *hdev, · line 357

Quoted 5 lines
drivers/hid/hid-magicmouse.c +1 -1
@@ -354,7 +354,7 @@ static int magicmouse_probe(struct hid_device *hdev,
 		goto err_free;
 	}
 
-	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_HIDINPUT);
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);

This is not particularly right, as we'll end up having dangling input device.

The problem is, that when HIDRAW is not set, hid_hw_start() returns ENODEV as no subsystem has claimed the device, and probe routine bails out. Which is not what we want.

Does the testing patch below fix the problems you are seeing?

drivers/hid/hid-magicmouse.c +4 -1
index 0d471fc..f10d56a 100644
@@ -354,12 +354,15 @@ static int magicmouse_probe(struct hid_device *hdev,
 		goto err_free;
 	}
 
-	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_HIDINPUT);
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
 	if (ret) {
 		dev_err(&hdev->dev, "magicmouse hw start failed\n");
 		goto err_free;
 	}
 
+	/* we are handling the input ourselves */
+	hidinput_disconnect(hdev);
+
 	report = hid_register_report(hdev, HID_INPUT_REPORT, TOUCH_REPORT_ID);
 	if (!report) {
 		dev_err(&hdev->dev, "unable to register touch report\n");
Signature · 2 lines
Jiri Kosina
SUSE Labs, Novell Inc.
#2 lore raw
Quoted 11 lines · Jiri Kosina
Quoted 8 lines · Justin P. Mattock

With the latest HEAD, I've noticed that I needed to add: HIDRAW=y in order for my apple magicmouse to connect. After receiving some posts, it seems this it not the case(HIDRAW just relays HID events to userspace).

The bisect results of this issue resulted in commit: HID:magicmouse: fix oops after device removal. (hash:28918c211d86b6eeb70182c523800c7bc442960c)

Quoted 7 lines
Quoted 3 lines

After examining this commit, I've noticed that HID_CONNECT_DEFAULT has also an entry in there of HID_CONNECT_HIDINPUT, not sure what "~" means,

~ is zeroing out the HID_CONENCT_HIDINPUT bits from the connect mask, as magicmouse driver is handling the input itself.

ah.. cool thanks for that..(I still have lots to learn(so many expressions)).

Quoted 36 lines
Quoted 27 lines

before HID_CONNECT_HIDINPUT, but after removing this(correct me if I'm wrong)"double" definition, I'm able to have my magicmouse connect without the need of HIDRAW, and also this in dmesg:

magicmouse 0005:05AC:030D.0004: claimed by neither input, hiddev nor hidraw magicmouse 0005:05AC:030D.0004: magicmouse hw start failed

and as well as the crash that the above commit fixes when waking up from suspend(mouse connects perfectly upon wakeup).

Please have a look, and if this works, take it
if theres another solution let me know.
(so I can enjoy the power of the magicmouse!!).

---
  drivers/hid/hid-magicmouse.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
drivers/hid/hid-magicmouse.c +0 -0
index 0d471fc..0de5e96 100644

drivers/hid/hid-magicmouse.c static int magicmouse_probe(struct hid_device *hdev, · line 358

Quoted 6 lines
drivers/hid/hid-magicmouse.c +1 -1
@@ -354,7 +354,7 @@ static int magicmouse_probe(struct hid_device *hdev,
  		goto err_free;
  	}
 
-	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT&  ~HID_CONNECT_HIDINPUT);
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
 

This is not particularly right, as we'll end up having dangling input device.

Quoted 8 lines

The problem is, that when HIDRAW is not set, hid_hw_start() returns ENODEV as no subsystem has claimed the device, and probe routine bails out. Which is not what we want.

Does the testing patch below fix the problems you are seeing?

works good.. rebooted a few times
mouse connects. suspended a few times mouse reconnects.

Quoted 13 lines
drivers/hid/hid-magicmouse.c +1 -1
index 0d471fc..f10d56a 100644
@@ -354,12 +354,15 @@ static int magicmouse_probe(struct hid_device *hdev,
  		goto err_free;
  	}
 
-	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT&  ~HID_CONNECT_HIDINPUT);
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
  	if (ret) {

drivers/hid/hid-magicmouse.c static int magicmouse_probe(struct hid_device *hdev, · line 368

Quoted 10 lines
drivers/hid/hid-magicmouse.c +3 -0
  		dev_err(&hdev->dev, "magicmouse hw start failed\n");
  		goto err_free;
  	}
 
+	/* we are handling the input ourselves */
+	hidinput_disconnect(hdev);
+
  	report = hid_register_report(hdev, HID_INPUT_REPORT, TOUCH_REPORT_ID);
  	if (!report) {
  		dev_err(&hdev->dev, "unable to register touch report\n");

looks good over here.. If you'd like I can re-du this patch, add your sign off etc.. and re-send, or not worry.. either way this little quirk/problem is fixed.

Justin P. Mattock

#3 lore raw
Quoted 16 lines · Justin P. Mattock
Quoted 16 lines

drivers/hid/hid-magicmouse.c static int magicmouse_probe(struct hid_device *hdev, · line 358

Quoted 9 lines
drivers/hid/hid-magicmouse.c +1 -1
@@ -354,7 +354,7 @@ static int magicmouse_probe(struct hid_device *hdev,
  		goto err_free;
  	}
 
-	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT&  ~HID_CONNECT_HIDINPUT);
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
 

This is not particularly right, as we'll end up having dangling input device.

The problem is, that when HIDRAW is not set, hid_hw_start() returns ENODEV as no subsystem has claimed the device, and probe routine bails out. Which is not what we want.

Quoted 6 lines
Quoted 4 lines

Does the testing patch below fix the problems you are seeing?

works good.. rebooted a few times mouse connects. suspended a few times mouse reconnects.

I'd be glad if you could also double-check that device removal and re-connecting it works well as well with this patch.

Quoted 15 lines
Quoted 15 lines
drivers/hid/hid-magicmouse.c +1 -1
index 0d471fc..f10d56a 100644
@@ -354,12 +354,15 @@ static int magicmouse_probe(struct hid_device *hdev,
  		goto err_free;
  	}
 
-	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT&  ~HID_CONNECT_HIDINPUT);
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
  	if (ret) {
  		dev_err(&hdev->dev, "magicmouse hw start failed\n");
  		goto err_free;
  	}
 
Quoted 12 lines

drivers/hid/hid-magicmouse.c static int magicmouse_probe(struct hid_device *hdev, · line 368

Quoted 8 lines
drivers/hid/hid-magicmouse.c +3 -0
+	/* we are handling the input ourselves */
+	hidinput_disconnect(hdev);
+
  	report = hid_register_report(hdev, HID_INPUT_REPORT, TOUCH_REPORT_ID);
  	if (!report) {
  		dev_err(&hdev->dev, "unable to register touch report\n");

looks good over here.. If you'd like I can re-du this patch, add your sign off etc.. and re-send, or not worry.. either way this little quirk/problem is fixed.

No problem, once you confirm that device removal wasn't broken again and if I don't hear any objections from Michael, I will queue the patch myself.

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs, Novell Inc.
#4 lore raw
Quoted 56 lines · Jiri Kosina
Quoted 16 lines · Justin P. Mattock
Quoted 16 lines

drivers/hid/hid-magicmouse.c static int magicmouse_probe(struct hid_device *hdev, · line 358

Quoted 9 lines
drivers/hid/hid-magicmouse.c +1 -1
@@ -354,7 +354,7 @@ static int magicmouse_probe(struct hid_device *hdev,
  		goto err_free;
  	}
 
-	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT&  ~HID_CONNECT_HIDINPUT);
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
 

This is not particularly right, as we'll end up having dangling input device.

The problem is, that when HIDRAW is not set, hid_hw_start() returns ENODEV as no subsystem has claimed the device, and probe routine bails out. Which is not what we want.

Quoted 6 lines
Quoted 4 lines

Does the testing patch below fix the problems you are seeing?

works good.. rebooted a few times mouse connects. suspended a few times mouse reconnects.

I'd be glad if you could also double-check that device removal and re-connecting it works well as well with this patch.

Quoted 15 lines
Quoted 15 lines
drivers/hid/hid-magicmouse.c +1 -1
index 0d471fc..f10d56a 100644
@@ -354,12 +354,15 @@ static int magicmouse_probe(struct hid_device *hdev,
  		goto err_free;
  	}
 
-	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT&  ~HID_CONNECT_HIDINPUT);
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
  	if (ret) {
  		dev_err(&hdev->dev, "magicmouse hw start failed\n");
  		goto err_free;
  	}
 
Quoted 12 lines

drivers/hid/hid-magicmouse.c static int magicmouse_probe(struct hid_device *hdev, · line 368

Quoted 8 lines
drivers/hid/hid-magicmouse.c +3 -0
+	/* we are handling the input ourselves */
+	hidinput_disconnect(hdev);
+
  	report = hid_register_report(hdev, HID_INPUT_REPORT, TOUCH_REPORT_ID);
  	if (!report) {
  		dev_err(&hdev->dev, "unable to register touch report\n");

looks good over here.. If you'd like I can re-du this patch, add your sign off etc.. and re-send, or not worry.. either way this little quirk/problem is fixed.

Quoted 3 lines

No problem, once you confirm that device removal wasn't broken again and if I don't hear any objections from Michael, I will queue the patch myself.

It looks good to me. Thanks for doing this -- work has been busy this week, so I haven't had time to dig into the issue yet.

Michael

#5 lore raw
In reply to Jiri Kosina
Quoted 25 lines · Jiri Kosina
Quoted 22 lines · Justin P. Mattock
Quoted 22 lines

drivers/hid/hid-magicmouse.c static int magicmouse_probe(struct hid_device *hdev, · line 359

Quoted 10 lines
drivers/hid/hid-magicmouse.c +1 -1
@@ -354,7 +354,7 @@ static int magicmouse_probe(struct hid_device *hdev,
   		goto err_free;
   	}
 
-	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT&   ~HID_CONNECT_HIDINPUT);
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
 
 

This is not particularly right, as we'll end up having dangling input device.

The problem is, that when HIDRAW is not set, hid_hw_start() returns ENODEV as no subsystem has claimed the device, and probe routine bails out. Which is not what we want.

Does the testing patch below fix the problems you are seeing?

Quoted 7 lines
Quoted 3 lines

works good.. rebooted a few times mouse connects. suspended a few times mouse reconnects.

I'd be glad if you could also double-check that device removal and re-connecting it works well as well with this patch.

with test I did different techniques,
1) regular suspend(leave device on) 2)suspend then shut off device 3)shut off device then suspend
all of these techniques work properly (let me know if this is what you meant).

Quoted 28 lines
Quoted 15 lines
Quoted 15 lines
drivers/hid/hid-magicmouse.c +1 -1
index 0d471fc..f10d56a 100644
@@ -354,12 +354,15 @@ static int magicmouse_probe(struct hid_device *hdev,
   		goto err_free;
   	}
 
-	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT&   ~HID_CONNECT_HIDINPUT);
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
   	if (ret) {
   		dev_err(&hdev->dev, "magicmouse hw start failed\n");
   		goto err_free;
   	}
 
Quoted 13 lines

drivers/hid/hid-magicmouse.c static int magicmouse_probe(struct hid_device *hdev, · line 368

Quoted 9 lines
drivers/hid/hid-magicmouse.c +3 -0
+	/* we are handling the input ourselves */
+	hidinput_disconnect(hdev);
+
   	report = hid_register_report(hdev, HID_INPUT_REPORT, TOUCH_REPORT_ID);
   	if (!report) {
   		dev_err(&hdev->dev, "unable to register touch report\n");

looks good over here.. If you'd like I can re-du this patch, add your sign off etc.. and re-send, or not worry.. either way this little quirk/problem is fixed.

Quoted 7 lines

No problem, once you confirm that device removal wasn't broken again and if I don't hear any objections from Michael, I will queue the patch myself.

Thanks,

alright buddy,
looks good over here.

cheers.

Justin P. Mattock

#6 lore raw
Quoted 24 lines · Justin P. Mattock
Quoted 24 lines
Quoted 24 lines
Quoted 15 lines

drivers/hid/hid-magicmouse.c static int magicmouse_probe(struct hid_device · line 360

Quoted 12 lines
drivers/hid/hid-magicmouse.c +1 -1
@@ -354,7 +354,7 @@ static int magicmouse_probe(struct hid_device
 *hdev,
   		goto err_free;
   	}
 
-	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT&
 ~HID_CONNECT_HIDINPUT);
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
 

This is not particularly right, as we'll end up having dangling input device.

Quoted 6 lines

The problem is, that when HIDRAW is not set, hid_hw_start() returns ENODEV as no subsystem has claimed the device, and probe routine bails out. Which is not what we want.

Does the testing patch below fix the problems you are seeing?

works good.. rebooted a few times mouse connects. suspended a few times mouse reconnects.

Quoted 8 lines
Quoted 3 lines

I'd be glad if you could also double-check that device removal and re-connecting it works well as well with this patch.

with test I did different techniques,
1) regular suspend(leave device on) 2)suspend then shut off device 3)shut off device then suspend all of these techniques work properly

Thanks for reporting and testing, I have queued the patch.

Signature · 2 lines
Jiri Kosina
SUSE Labs, Novell Inc.
#7 lore raw
Quoted 34 lines · Jiri Kosina
Quoted 31 lines · Justin P. Mattock
Quoted 31 lines
Quoted 20 lines
Quoted 20 lines

drivers/hid/hid-magicmouse.c static int magicmouse_probe(struct hid_device · line 360

Quoted 13 lines
drivers/hid/hid-magicmouse.c +1 -1
@@ -354,7 +354,7 @@ static int magicmouse_probe(struct hid_device
 *hdev,
    		goto err_free;
    	}
 
-	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT&
 ~HID_CONNECT_HIDINPUT);
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
 

This is not particularly right, as we'll end up having dangling input device.

The problem is, that when HIDRAW is not set, hid_hw_start() returns ENODEV as no subsystem has claimed the device, and probe routine bails out. Which is not what we want.

Quoted 7 lines
Quoted 3 lines

Does the testing patch below fix the problems you are seeing?

works good.. rebooted a few times mouse connects. suspended a few times mouse reconnects.

I'd be glad if you could also double-check that device removal and re-connecting it works well as well with this patch.

Quoted 9 lines
Quoted 6 lines

with test I did different techniques,
1) regular suspend(leave device on) 2)suspend then shut off device 3)shut off device then suspend all of these techniques work properly

Thanks for reporting and testing, I have queued the patch.

cool...

Justin P. Mattock