[PATCH] HID: amd_sfh: Ignore uninitialized device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Lenovo ThinkPad C13 Yoga has AMD Sensor Fusion Hub, but it is not used
because Chrome OS EC Sensor Hub is used instead. The system therefore
never loads the firmware for MP2 and MP2 does not work. It results in
AMD_P2C_MSG3 register to have -1 as its value.

Without this change, the driver interprets the value as it supports all
sensor types and exposes them, which confuses a userspace program,
iio-sensor-proxy, and makes it to use the non-functioning sensors
instead of functioning sensors exposed via Chrome OS EC Sensor Hub.

Check the version bits included in AMD_P2C_MSG3 register and ignore the
device if all of the bits are set.

Signed-off-by: Akihiko Odaki <akihiko.odaki@xxxxxxxxx>
---
 drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
index dadc491bbf6b..4137e5da77ad 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
@@ -271,6 +271,8 @@ static void mp2_select_ops(struct amd_mp2_dev *privdata)
 	case V2_STATUS:
 		privdata->mp2_ops = &amd_sfh_ops_v2;
 		break;
+	case 15:
+		break;
 	default:
 		privdata->mp2_ops = &amd_sfh_ops;
 		break;
@@ -317,6 +319,8 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 		return -ENOMEM;
 
 	mp2_select_ops(privdata);
+	if (!privdata->mp2_ops)
+		return -ENODEV;
 
 	rc = amd_sfh_irq_init(privdata);
 	if (rc) {
-- 
2.36.1




[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux