diff mbox series

[for-next,2/2] HID: amd_sfh: Handle condition of "no sensors"

Message ID 20220723061033.1377061-3-Basavaraj.Natikar@amd.com (mailing list archive)
State Mainlined
Commit 5d4d0f15657535f6a122ab26d47230b5c2b944af
Delegated to: Jiri Kosina
Headers show
Series Fixes to amd_sfh driver | expand

Commit Message

Basavaraj Natikar July 23, 2022, 6:10 a.m. UTC
Add a check for num_hid_devices to handle special case the situation
of "no sensors".

Fixes: 4b2c53d93a4b ("SFH:Transport Driver to add support of AMD Sensor Fusion Hub (SFH)")
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
 drivers/hid/amd-sfh-hid/amd_sfh_client.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_client.c b/drivers/hid/amd-sfh-hid/amd_sfh_client.c
index f95e623040f3..8275bba63611 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_client.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_client.c
@@ -225,6 +225,8 @@  int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
 	mp2_ops->resume = amd_sfh_resume;
 
 	cl_data->num_hid_devices = amd_mp2_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);