Skip to content

Commit 5edd96b

Browse files
committed
misc: amd-apml: Integrate SBRMI with common device registration framework
Add device registration/unregistration calls to SBRMI drivers. This enables Alert_L driver to discover and safely access registered RMI devices for processing RAS event. Reviewed-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com> Signed-off-by: sathya priya kumar <SathyaPriya.K@amd.com> Signed-off-by: Akshay Gupta <akshay.gupta@amd.com>
1 parent 05e6627 commit 5edd96b

2 files changed

Lines changed: 29 additions & 4 deletions

File tree

drivers/misc/amd-apml/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ config APML_COMMON
1818
config APML_SBRMI
1919
tristate "Emulated SB-RMI interface driver over i3c bus"
2020
depends on I3C && !SENSORS_SBRMI
21+
depends on APML_COMMON
2122
select REGMAP_I3C if I3C
2223
help
2324
If you say yes here you get support for emulated RMI

drivers/misc/amd-apml/sbrmi.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/version.h>
2323

2424
#include "sbrmi-common.h"
25+
#include "apml_common.h"
2526

2627
/* Do not allow setting negative power limit */
2728
#define SBRMI_PWR_MIN 0
@@ -491,6 +492,7 @@ static int sbrmi_i2c_probe(struct i2c_client *client)
491492
struct device *hwmon_dev;
492493
struct apml_sbrmi_device *rmi_dev;
493494
const char *hwmon_dev_name;
495+
int ret = 0;
494496

495497
rmi_dev = devm_kzalloc(dev, sizeof(struct apml_sbrmi_device), GFP_KERNEL);
496498
if (!rmi_dev)
@@ -517,7 +519,17 @@ static int sbrmi_i2c_probe(struct i2c_client *client)
517519
return PTR_ERR_OR_ZERO(hwmon_dev);
518520

519521
init_completion(&rmi_dev->misc_fops_done);
520-
return create_misc_rmi_device(rmi_dev, dev);
522+
ret = create_misc_rmi_device(rmi_dev, dev);
523+
if (ret)
524+
return ret;
525+
/* Register with ALERT_L common system */
526+
ret = apml_register_sbrmi_device(rmi_dev);
527+
if (ret) {
528+
dev_warn(dev, "Failed to register with ALERT_L common system: %d\n", ret);
529+
misc_deregister(&rmi_dev->sbrmi_misc_dev);
530+
return -ENODEV;
531+
}
532+
return ret;
521533
}
522534

523535
static int sbrmi_i3c_reg_read(struct i3c_device *i3cdev, int reg_size, u32 *val)
@@ -713,7 +725,17 @@ static int sbrmi_i3c_probe(struct i3c_device *i3cdev)
713725
}
714726

715727
init_completion(&rmi_dev->misc_fops_done);
716-
return create_misc_rmi_device(rmi_dev, dev);
728+
ret = create_misc_rmi_device(rmi_dev, dev);
729+
if (ret)
730+
return ret;
731+
/* Register with ALERT_L common system */
732+
ret = apml_register_sbrmi_device(rmi_dev);
733+
if (ret) {
734+
dev_warn(dev, "Failed to register with ALERT_L common system: %d\n", ret);
735+
misc_deregister(&rmi_dev->sbrmi_misc_dev);
736+
return -ENODEV;
737+
}
738+
return ret;
717739
}
718740

719741
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)
@@ -730,7 +752,8 @@ static void sbrmi_i2c_remove(struct i2c_client *client)
730752
#else
731753
return;
732754
#endif
733-
755+
/* Unregister from APML common system */
756+
apml_unregister_sbrmi_device(rmi_dev);
734757
/*
735758
* Set the no_new_trans so no new transaction can
736759
* occur in sbrmi_ioctl
@@ -770,7 +793,8 @@ static void sbrmi_i3c_remove(struct i3c_device *i3cdev)
770793
#else
771794
return;
772795
#endif
773-
796+
/* Unregister from APML common system */
797+
apml_unregister_sbrmi_device(rmi_dev);
774798
/*
775799
* Set the no_new_trans so no new transaction can
776800
* occur in sbrmi_ioctl

0 commit comments

Comments
 (0)