HID: amd_sfh: Track MP2 version explicitly

The MP2 version is currently known only implicitly, from whether an ops
pointer was stored in the PCI driver_data. Subsequent changes need to
act on the MP2 version directly, for example to read the operating-mode
register only on confirmed MP2 v2.

Track the MP2 version explicitly so that version-specific behaviour can
be gated on it, and leave it unset for generations that do not require
such handling.

Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
This commit is contained in:
Basavaraj Natikar 2026-08-03 23:22:26 +05:30 committed by Jiri Kosina
parent 336af689d5
commit 1a73a4e767
2 changed files with 11 additions and 4 deletions

View File

@ -35,6 +35,11 @@ enum cmd_id {
STOP_ALL_SENSORS = 8,
};
enum amd_mp2_version {
MP2_VER_V2 = 1,
MP2_VER_1_1 = 2,
};
struct amd_mp2_sensor_info {
u8 sensor_idx;
u32 period;
@ -64,6 +69,7 @@ struct amd_mp2_dev {
struct mutex lock;
u8 init_done;
u8 rver;
u8 mp2_ver;
};
struct amd_mp2_ops {

View File

@ -285,6 +285,7 @@ static void mp2_select_ops(struct amd_mp2_dev *privdata)
switch (acs) {
case V2_STATUS:
privdata->mp2_ops = &amd_sfh_ops_v2;
privdata->mp2_ver = MP2_VER_V2;
break;
default:
privdata->mp2_ops = &amd_sfh_ops;
@ -471,8 +472,9 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
if (rc)
return rc;
privdata->sfh1_1_ops = (const struct amd_sfh1_1_ops *)id->driver_data;
if (privdata->sfh1_1_ops) {
privdata->mp2_ver = (enum amd_mp2_version)id->driver_data;
if (privdata->mp2_ver >= MP2_VER_1_1) {
privdata->sfh1_1_ops = &sfh1_1_ops;
if (boot_cpu_data.x86 >= 0x1A)
privdata->rver = 1;
@ -540,8 +542,7 @@ static SIMPLE_DEV_PM_OPS(amd_mp2_pm_ops, amd_mp2_pci_suspend,
static const struct pci_device_id amd_mp2_pci_tbl[] = {
{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_MP2) },
{ PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_MP2_1_1),
.driver_data = (kernel_ulong_t)&sfh1_1_ops },
{ PCI_DEVICE_DATA(AMD, MP2_1_1, MP2_VER_1_1) },
{ }
};
MODULE_DEVICE_TABLE(pci, amd_mp2_pci_tbl);