Skip to content

Commit 3694db8

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 1f222e5 commit 3694db8

2 files changed

Lines changed: 25 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: 24 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,15 @@ 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+
530+
return ret;
521531
}
522532

523533
static int sbrmi_i3c_reg_read(struct i3c_device *i3cdev, int reg_size, u32 *val)
@@ -713,7 +723,15 @@ static int sbrmi_i3c_probe(struct i3c_device *i3cdev)
713723
}
714724

715725
init_completion(&rmi_dev->misc_fops_done);
716-
return create_misc_rmi_device(rmi_dev, dev);
726+
ret = create_misc_rmi_device(rmi_dev, dev);
727+
if (ret)
728+
return ret;
729+
/* Register with ALERT_L common system */
730+
ret = apml_register_sbrmi_device(rmi_dev);
731+
if (ret)
732+
dev_warn(dev, "Failed to register with ALERT_L common system: %d\n", ret);
733+
734+
return ret;
717735
}
718736

719737
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)
@@ -730,7 +748,8 @@ static void sbrmi_i2c_remove(struct i2c_client *client)
730748
#else
731749
return;
732750
#endif
733-
751+
/* Unregister from APML common system */
752+
apml_unregister_sbrmi_device(rmi_dev);
734753
/*
735754
* Set the no_new_trans so no new transaction can
736755
* occur in sbrmi_ioctl
@@ -770,7 +789,8 @@ static void sbrmi_i3c_remove(struct i3c_device *i3cdev)
770789
#else
771790
return;
772791
#endif
773-
792+
/* Unregister from APML common system */
793+
apml_unregister_sbrmi_device(rmi_dev);
774794
/*
775795
* Set the no_new_trans so no new transaction can
776796
* occur in sbrmi_ioctl

0 commit comments

Comments
 (0)