diff mbox series

[2/2] HID: amd_sfh: Handle condition of "no sensors" for SFH1.1

Message ID 20220923061909.636337-3-Basavaraj.Natikar@amd.com (mailing list archive)
State Superseded
Delegated to: Jiri Kosina
Headers show
Series Updates to amd_sfh driver | expand

Commit Message

Basavaraj Natikar Sept. 23, 2022, 6:19 a.m. UTC
Add a check for num_hid_devices to handle special case in the situation
of "no sensors" for SFH1.1.

Fixes: 93ce5e0231d7 ("HID: amd_sfh: Implement SFH1.1 functionality")
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jiri Kosina Sept. 23, 2022, 12:05 p.m. UTC | #1
On Fri, 23 Sep 2022, Basavaraj Natikar wrote:

> Add a check for num_hid_devices to handle special case in the situation
> of "no sensors" for SFH1.1.

Could you please provide a little bit more verbose changelog here? Namely, 
what problem does it cause when we don't return ENODEV in 
!cl_data->num_hid_devices case (and thus why this patch is needed in the 
first place).

Thanks.
diff mbox series

Patch

diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c
index d840efb4a2e2..4da2f9f62aba 100644
--- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c
+++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c
@@ -110,6 +110,8 @@  static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)
 	amd_sfh1_1_set_desc_ops(mp2_ops);
 
 	cl_data->num_hid_devices = amd_sfh_get_sensor_num(privdata, &cl_data->sensor_idx[0]);
+	if (cl_data->num_hid_devices == 0)
+		return -ENODEV;
 
 	INIT_DELAYED_WORK(&cl_data->work, amd_sfh_work);
 	INIT_DELAYED_WORK(&cl_data->work_buffer, amd_sfh_work_buffer);