HID: amd_sfh: Add sensor name by index for debug info
authorBasavaraj Natikar <Basavaraj.Natikar@amd.com>
Mon, 9 May 2022 13:20:21 +0000 (18:50 +0530)
committerJiri Kosina <jkosina@suse.cz>
Wed, 11 May 2022 12:16:26 +0000 (14:16 +0200)
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>
drivers/hid/amd-sfh-hid/amd_sfh_client.c
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
drivers/hid/amd-sfh-hid/amd_sfh_pcie.h

index 444acd9..0f770a2 100644 (file)
@@ -141,6 +141,24 @@ u32 amd_sfh_wait_for_response(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts)
        return sensor_sts;
 }
 
+const char *get_sensor_name(int idx)
+{
+       switch (idx) {
+       case accel_idx:
+               return "accelerometer";
+       case gyro_idx:
+               return "gyroscope";
+       case mag_idx:
+               return "magnetometer";
+       case als_idx:
+               return "ALS";
+       case HPD_IDX:
+               return "HPD";
+       default:
+               return "unknown sensor type";
+       }
+}
+
 int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
 {
        struct amd_input_data *in_data = &privdata->in_data;
@@ -219,13 +237,16 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
                                        (privdata, cl_data->sensor_idx[i], SENSOR_DISABLED);
                                if (status != SENSOR_ENABLED)
                                        cl_data->sensor_sts[i] = SENSOR_DISABLED;
-                               dev_dbg(dev, "sid 0x%x status 0x%x\n",
-                                       cl_data->sensor_idx[i], cl_data->sensor_sts[i]);
+                               dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
+                                       cl_data->sensor_idx[i],
+                                       get_sensor_name(cl_data->sensor_idx[i]),
+                                       cl_data->sensor_sts[i]);
                                goto cleanup;
                        }
                }
-               dev_dbg(dev, "sid 0x%x status 0x%x\n",
-                       cl_data->sensor_idx[i], cl_data->sensor_sts[i]);
+               dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n",
+                       cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
+                       cl_data->sensor_sts[i]);
        }
        if (privdata->mp2_ops->discovery_status &&
            privdata->mp2_ops->discovery_status(privdata) == 0) {
@@ -268,8 +289,9 @@ int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata)
                                        (privdata, cl_data->sensor_idx[i], SENSOR_DISABLED);
                        if (status != SENSOR_ENABLED)
                                cl_data->sensor_sts[i] = SENSOR_DISABLED;
-                       dev_dbg(&privdata->pdev->dev, "stopping sid 0x%x status 0x%x\n",
-                               cl_data->sensor_idx[i], cl_data->sensor_sts[i]);
+                       dev_dbg(&privdata->pdev->dev, "stopping sid 0x%x (%s) status 0x%x\n",
+                               cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
+                               cl_data->sensor_sts[i]);
                }
        }
 
index e18a4ef..dadc491 100644 (file)
@@ -353,8 +353,9 @@ static int __maybe_unused amd_mp2_pci_resume(struct device *dev)
                                        (mp2, cl_data->sensor_idx[i], SENSOR_ENABLED);
                        if (status == SENSOR_ENABLED)
                                cl_data->sensor_sts[i] = SENSOR_ENABLED;
-                       dev_dbg(dev, "resume sid 0x%x status 0x%x\n",
-                               cl_data->sensor_idx[i], cl_data->sensor_sts[i]);
+                       dev_dbg(dev, "suspend sid 0x%x (%s) status 0x%x\n",
+                               cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
+                               cl_data->sensor_sts[i]);
                }
        }
 
@@ -378,8 +379,9 @@ static int __maybe_unused amd_mp2_pci_suspend(struct device *dev)
                                        (mp2, cl_data->sensor_idx[i], SENSOR_DISABLED);
                        if (status != SENSOR_ENABLED)
                                cl_data->sensor_sts[i] = SENSOR_DISABLED;
-                       dev_dbg(dev, "suspend sid 0x%x status 0x%x\n",
-                               cl_data->sensor_idx[i], cl_data->sensor_sts[i]);
+                       dev_dbg(dev, "suspend sid 0x%x (%s) status 0x%x\n",
+                               cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
+                               cl_data->sensor_sts[i]);
                }
        }
 
index 9aa88a9..8c76052 100644 (file)
@@ -138,6 +138,7 @@ int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata);
 u32 amd_sfh_wait_for_response(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts);
 void amd_mp2_suspend(struct amd_mp2_dev *mp2);
 void amd_mp2_resume(struct amd_mp2_dev *mp2);
+const char *get_sensor_name(int idx);
 
 struct amd_mp2_ops {
         void (*start)(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info);