HID: hid-sensor-hub: Clear HID_CLAIMED_INPUT bit earlier
Subsystems (2)
PATCH 1/2 HID: hid-sensor-hub: Clear HID_CLAIMED_INPUT bit earlier
Clear HID_CLAIMED_INPUT bit of hdev->claimed, this prevents calling hidinput_disconnect() in hid_disconnect(), which is called by hid_hw_stop().
We need to clear HID_CLAIMED_INPUT bit earlier rather than in sensor_hub_remove() because we also call hid_hw_stop() in sensor_hub_probe error handling.
Also adds comments for why we set hdev->claimed = HID_CLAIMED_INPUT.
---
Hi srinivas,
I don't have this hardware, I'd appreciate if you can test these patches. Axel
drivers/hid/hid-sensor-hub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hid/hid-sensor-hub.c +3 -1
@@ -539,8 +539,11 @@ static int sensor_hub_probe(struct hid_device *hdev, }INIT_LIST_HEAD (&hdev->inputs); +/* We don't use hidinput but hid_hw_start() fails if nothing is +* claimed. So spoof claimed input. */ hdev->claimed =HID_CLAIMED_INPUT ; ret =hid_hw_start (hdev,0 ); + hdev->claimed &= ~HID_CLAIMED_INPUT ;if (ret) {hid_err (hdev,"hw start failed\n" ); goto err_free;
@@ -627,7 +630,6 @@ static void sensor_hub_remove(struct hid_device *hdev)int i;hid_dbg (hdev," hardware removed\n" ); - hdev->claimed &= ~HID_CLAIMED_INPUT ;hid_hw_stop (hdev);hid_hw_close (hdev);spin_lock_irqsave (&data->lock, flags);
Signature · 1 line
1.7.9.5
PATCH 2/2 HID: hid-sensor-hub: Fix sensor_hub_probe error handling
Fix below issues in sensor_hub_probe error handling:
1. In the case of goto err_close, hid_hw_stop(hdev) is called twice. Fix it.
2. If fails to allocate MFD device name, we also need to free all successfully allocated names in previous iterations.
--- drivers/hid/hid-sensor-hub.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/hid/hid-sensor-hub.c +1 -3
@@ -584,7 +584,7 @@ static int sensor_hub_probe(struct hid_device *hdev,hid_err (hdev,"Failed MFD device name\n" ); ret = -ENOMEM ; - goto err_free_cells; + goto err_free_names; } sd->hid_sensor_hub_client_devs[ sd->hid_sensor_client_cnt].name = name;
@@ -608,10 +608,8 @@ static int sensor_hub_probe(struct hid_device *hdev, err_free_names:for (i =0 ; i < sd->hid_sensor_client_cnt ; ++i)kfree (sd->hid_sensor_hub_client_devs[i].name); -err_free_cells:kfree (sd->hid_sensor_hub_client_devs); err_close: -hid_hw_stop (hdev);hid_hw_close (hdev); err_stop_hw:hid_hw_stop (hdev);
Signature · 1 line
1.7.9.5
RE: [PATCH 2/2] HID: hid-sensor-hub: Fix sensor_hub_probe error handling
Agreed. It works.
Thanks,
Srinivas
-----Original Message-----
From: Axel Lin [mailto:[email protected]]
Sent: Wednesday, September 12, 2012 6:40 PM
To: Jiri Kosina
Cc: Pandruvada, Srinivas; Jonathan Cameron; [email protected]; [email protected]
Subject: [PATCH 2/2] HID: hid-sensor-hub: Fix sensor_hub_probe error handling
Fix below issues in sensor_hub_probe error handling:
1. In the case of goto err_close, hid_hw_stop(hdev) is called twice. Fix it.
2. If fails to allocate MFD device name, we also need to free all successfully allocated names in previous iterations.
--- drivers/hid/hid-sensor-hub.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/hid/hid-sensor-hub.c +1 -1
@@ -584,7 +584,7 @@ static int sensor_hub_probe(struct hid_device *hdev,hid_err (hdev,"Failed MFD device name\n" ); ret = -ENOMEM ; - goto err_free_cells; + goto err_free_names; } sd->hid_sensor_hub_client_devs[ sd->hid_sensor_client_cnt].name = name; @@ -608,10 +608,8 @@ static int sensor_hub_probe(struct hid_device *hdev,
err_free_names:
for (i = 0; i < sd->hid_sensor_client_cnt ; ++i)
kfree(sd->hid_sensor_hub_client_devs[i].name);
-err_free_cells:
kfree(sd->hid_sensor_hub_client_devs);
err_close:
- hid_hw_stop(hdev);
hid_hw_close(hdev);
err_stop_hw:
hid_hw_stop(hdev);
--
1.7.9.5
2012/9/13 Axel Lin <[email protected]>:
Quoted 23 lines
Clear
HID_CLAIMED_INPUTbit ofhdev->claimed, this prevents callinghidinput_disconnect()inhid_disconnect(), which is called byhid_hw_stop().We need to clear
HID_CLAIMED_INPUTbit earlier rather than insensor_hub_remove()because we also callhid_hw_stop()insensor_hub_probeerror handling.Also adds comments for why we set
hdev->claimed=HID_CLAIMED_INPUT.Signed-off-by Axel Lin <[email protected]>---
Hi srinivas,
I don't have this hardware, I'd appreciate if you can test these patches. Axeldrivers/hid/hid-sensor-hub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/hid/hid-sensor-hub.c +0
-0
drivers/hid/hid-sensor-hub.c static int sensor_hub_probe(struct hid_device *hdev, · line 545
Quoted 7 lines
drivers/hid/hid-sensor-hub.c +2
-0@@ -539,8 +539,11 @@ static int sensor_hub_probe(struct hid_device *hdev, }INIT_LIST_HEAD (&hdev->inputs); +/* We don't use hidinput but hid_hw_start() fails if nothing is +* claimed. So spoof claimed input. */ hdev->claimed =HID_CLAIMED_INPUT ; ret =hid_hw_start (hdev,0 );
I check the implementation of hid_hw_start again, it looks hid_hw_start allows connect_mask to be 0.
So we don't need setting "hdev->claimed = HID_CLAIMED_INPUT;" here. Comments?
Axel
Hi Axel,
We don't need this anymore as when connect_mask is 0, the hid_connect will not be called. So we don't need hdev->claimed = HID_CLAIMED_INPUT anymore.
Thanks for the review.
-Srinivas
-----Original Message-----
From: Axel Lin [mailto:[email protected]]
Sent: Thursday, September 13, 2012 6:25 AM
To: Jiri Kosina
Cc: Pandruvada, Srinivas; Jonathan Cameron; [email protected]; [email protected]
Subject: Re: [PATCH 1/2] HID: hid-sensor-hub: Clear HID_CLAIMED_INPUT bit earlier
2012/9/13 Axel Lin <[email protected]>:
Quoted 23 lines
Clear
HID_CLAIMED_INPUTbit ofhdev->claimed, this prevents callinghidinput_disconnect()inhid_disconnect(), which is called byhid_hw_stop().We need to clear
HID_CLAIMED_INPUTbit earlier rather than insensor_hub_remove()because we also callhid_hw_stop()insensor_hub_probeerror handling.Also adds comments for why we set
hdev->claimed=HID_CLAIMED_INPUT.Signed-off-by Axel Lin <[email protected]>---
Hi srinivas,
I don't have this hardware, I'd appreciate if you can test these patches. Axeldrivers/hid/hid-sensor-hub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/hid/hid-sensor-hub.cindex 4ac759c..50bc8c7 100644
drivers/hid/hid-sensor-hub.c static int sensor_hub_probe(struct hid_device *hdev, · line 545
Quoted 7 lines
drivers/hid/hid-sensor-hub.c +2
-0@@ -539,8 +539,11 @@ static int sensor_hub_probe(struct hid_device *hdev, }INIT_LIST_HEAD (&hdev->inputs); +/* We don't use hidinput but hid_hw_start() fails if nothing is +* claimed. So spoof claimed input. */ hdev->claimed =HID_CLAIMED_INPUT ; ret =hid_hw_start (hdev,0 );
I check the implementation of hid_hw_start again, it looks hid_hw_start allows connect_mask to be 0. So we don't need setting "hdev->claimed = HID_CLAIMED_INPUT;" here.
Comments?
Axel
2012/9/14 Pandruvada, Srinivas <[email protected]>:
Quoted 5 lines
Hi Axel,
We don't need this anymore as when
connect_maskis 0, thehid_connectwill not be called. So we don't needhdev->claimed=HID_CLAIMED_INPUTanymore.
Okay. I'm going to resend the patch for this serial. Axel