Skip to content

Commit 1b788c4

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. Remove device tree matching functions from SBRMI drivers that are no longer needed after migrating Alert_L driver to use the global device registry from apml_common framework. The legacy Alert_L module used *_match_i2c/*_match_i3c functions to retrieve device node information from device tree nodes. With the new design, Alert_L module devices are now registered during each module's probe function, making the old matching functions obsolete. 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 d628617 commit 1b788c4

3 files changed

Lines changed: 25 additions & 26 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-common.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,4 @@ int rmi_cpuid_read(struct apml_sbrmi_device *rmi_dev,
3535
struct apml_message *msg);
3636
int rmi_mailbox_xfer(struct apml_sbrmi_device *rmi_dev,
3737
struct apml_message *msg);
38-
int sbrmi_match_i3c(struct device *dev, const void *data);
39-
int sbrmi_match_i2c(struct device *dev, const void *data);
4038
#endif /*_AMD_APML_SBRMI_H_*/

drivers/misc/amd-apml/sbrmi.c

Lines changed: 24 additions & 24 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;
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
@@ -845,26 +865,6 @@ static struct i3c_driver sbrmi_i3c_driver = {
845865

846866
module_i3c_i2c_driver(sbrmi_i3c_driver, &sbrmi_driver)
847867

848-
int sbrmi_match_i3c(struct device *dev, const void *data)
849-
{
850-
const struct device_node *node = (const struct device_node *)data;
851-
852-
if (dev->of_node == node && dev->driver == &sbrmi_i3c_driver.driver)
853-
return 1;
854-
return 0;
855-
}
856-
EXPORT_SYMBOL_GPL(sbrmi_match_i3c);
857-
858-
int sbrmi_match_i2c(struct device *dev, const void *data)
859-
{
860-
const struct device_node *node = (const struct device_node *)data;
861-
862-
if (dev->of_node == node && dev->driver == &sbrmi_driver.driver)
863-
return 1;
864-
return 0;
865-
}
866-
EXPORT_SYMBOL_GPL(sbrmi_match_i2c);
867-
868868
MODULE_AUTHOR("Akshay Gupta <akshay.gupta@amd.com>");
869869
MODULE_AUTHOR("Naveenkrishna Chatradhi <naveenkrishna.chatradhi@amd.com>");
870870
MODULE_DESCRIPTION("Hwmon driver for AMD SB-RMI emulated sensor");

0 commit comments

Comments
 (0)