Skip to content

Commit 696455e

Browse files
basuamdJiri Kosina
authored andcommitted
HID: amd_sfh: Add sensor name by index for debug info
Adding get sensor name for debug info. This will make debug messages clearer. Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent b5d7f43 commit 696455e

3 files changed

Lines changed: 35 additions & 10 deletions

File tree

drivers/hid/amd-sfh-hid/amd_sfh_client.c

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,24 @@ u32 amd_sfh_wait_for_response(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts)
141141
return sensor_sts;
142142
}
143143

144+
const char *get_sensor_name(int idx)
145+
{
146+
switch (idx) {
147+
case accel_idx:
148+
return "accelerometer";
149+
case gyro_idx:
150+
return "gyroscope";
151+
case mag_idx:
152+
return "magnetometer";
153+
case als_idx:
154+
return "ALS";
155+
case HPD_IDX:
156+
return "HPD";
157+
default:
158+
return "unknown sensor type";
159+
}
160+
}
161+
144162
int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
145163
{
146164
struct amd_input_data *in_data = &privdata->in_data;
@@ -219,13 +237,16 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
219237
(privdata, cl_data->sensor_idx[i], SENSOR_DISABLED);
220238
if (status != SENSOR_ENABLED)
221239
cl_data->sensor_sts[i] = SENSOR_DISABLED;
222-
dev_dbg(dev, "sid 0x%x status 0x%x\n",
223-
cl_data->sensor_idx[i], cl_data->sensor_sts[i]);
240+
dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
241+
cl_data->sensor_idx[i],
242+
get_sensor_name(cl_data->sensor_idx[i]),
243+
cl_data->sensor_sts[i]);
224244
goto cleanup;
225245
}
226246
}
227-
dev_dbg(dev, "sid 0x%x status 0x%x\n",
228-
cl_data->sensor_idx[i], cl_data->sensor_sts[i]);
247+
dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
248+
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
249+
cl_data->sensor_sts[i]);
229250
}
230251
if (privdata->mp2_ops->discovery_status &&
231252
privdata->mp2_ops->discovery_status(privdata) == 0) {
@@ -268,8 +289,9 @@ int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata)
268289
(privdata, cl_data->sensor_idx[i], SENSOR_DISABLED);
269290
if (status != SENSOR_ENABLED)
270291
cl_data->sensor_sts[i] = SENSOR_DISABLED;
271-
dev_dbg(&privdata->pdev->dev, "stopping sid 0x%x status 0x%x\n",
272-
cl_data->sensor_idx[i], cl_data->sensor_sts[i]);
292+
dev_dbg(&privdata->pdev->dev, "stopping sid 0x%x (%s) status 0x%x\n",
293+
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
294+
cl_data->sensor_sts[i]);
273295
}
274296
}
275297

drivers/hid/amd-sfh-hid/amd_sfh_pcie.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,9 @@ static int __maybe_unused amd_mp2_pci_resume(struct device *dev)
353353
(mp2, cl_data->sensor_idx[i], SENSOR_ENABLED);
354354
if (status == SENSOR_ENABLED)
355355
cl_data->sensor_sts[i] = SENSOR_ENABLED;
356-
dev_dbg(dev, "resume sid 0x%x status 0x%x\n",
357-
cl_data->sensor_idx[i], cl_data->sensor_sts[i]);
356+
dev_dbg(dev, "suspend sid 0x%x (%s) status 0x%x\n",
357+
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
358+
cl_data->sensor_sts[i]);
358359
}
359360
}
360361

@@ -378,8 +379,9 @@ static int __maybe_unused amd_mp2_pci_suspend(struct device *dev)
378379
(mp2, cl_data->sensor_idx[i], SENSOR_DISABLED);
379380
if (status != SENSOR_ENABLED)
380381
cl_data->sensor_sts[i] = SENSOR_DISABLED;
381-
dev_dbg(dev, "suspend sid 0x%x status 0x%x\n",
382-
cl_data->sensor_idx[i], cl_data->sensor_sts[i]);
382+
dev_dbg(dev, "suspend sid 0x%x (%s) status 0x%x\n",
383+
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
384+
cl_data->sensor_sts[i]);
383385
}
384386
}
385387

drivers/hid/amd-sfh-hid/amd_sfh_pcie.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata);
138138
u32 amd_sfh_wait_for_response(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts);
139139
void amd_mp2_suspend(struct amd_mp2_dev *mp2);
140140
void amd_mp2_resume(struct amd_mp2_dev *mp2);
141+
const char *get_sensor_name(int idx);
141142

142143
struct amd_mp2_ops {
143144
void (*start)(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info);

0 commit comments

Comments
 (0)