mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	coresight: Add helpers registering/removing both AMBA and platform drivers
This adds two different helpers i.e coresight_init_driver()/remove_driver() enabling coresight devices to register or remove AMBA and platform drivers. This changes replicator and funnel devices to use above new helpers. Cc: Suzuki K Poulose <suzuki.poulose@arm.com> Cc: Mike Leach <mike.leach@linaro.org> Cc: James Clark <james.clark@arm.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Cc: coresight@lists.linaro.org Reviewed-by: James Clark <james.clark@arm.com> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20240314055843.2625883-5-anshuman.khandual@arm.com
This commit is contained in:
		
							parent
							
								
									3ab210297c
								
							
						
					
					
						commit
						075b7cd7ad
					
				
					 4 changed files with 41 additions and 34 deletions
				
			
		| 
						 | 
					@ -1398,6 +1398,35 @@ static void __exit coresight_exit(void)
 | 
				
			||||||
module_init(coresight_init);
 | 
					module_init(coresight_init);
 | 
				
			||||||
module_exit(coresight_exit);
 | 
					module_exit(coresight_exit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int coresight_init_driver(const char *drv, struct amba_driver *amba_drv,
 | 
				
			||||||
 | 
								  struct platform_driver *pdev_drv)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ret = amba_driver_register(amba_drv);
 | 
				
			||||||
 | 
						if (ret) {
 | 
				
			||||||
 | 
							pr_err("%s: error registering AMBA driver\n", drv);
 | 
				
			||||||
 | 
							return ret;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ret = platform_driver_register(pdev_drv);
 | 
				
			||||||
 | 
						if (!ret)
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						pr_err("%s: error registering platform driver\n", drv);
 | 
				
			||||||
 | 
						amba_driver_unregister(amba_drv);
 | 
				
			||||||
 | 
						return ret;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					EXPORT_SYMBOL_GPL(coresight_init_driver);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void coresight_remove_driver(struct amba_driver *amba_drv,
 | 
				
			||||||
 | 
								     struct platform_driver *pdev_drv)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						amba_driver_unregister(amba_drv);
 | 
				
			||||||
 | 
						platform_driver_unregister(pdev_drv);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					EXPORT_SYMBOL_GPL(coresight_remove_driver);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MODULE_LICENSE("GPL v2");
 | 
					MODULE_LICENSE("GPL v2");
 | 
				
			||||||
MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
 | 
					MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
 | 
				
			||||||
MODULE_AUTHOR("Mathieu Poirier <mathieu.poirier@linaro.org>");
 | 
					MODULE_AUTHOR("Mathieu Poirier <mathieu.poirier@linaro.org>");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -410,27 +410,12 @@ static struct amba_driver dynamic_funnel_driver = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int __init funnel_init(void)
 | 
					static int __init funnel_init(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						return coresight_init_driver("funnel", &dynamic_funnel_driver, &static_funnel_driver);
 | 
				
			||||||
 | 
					 | 
				
			||||||
	ret = platform_driver_register(&static_funnel_driver);
 | 
					 | 
				
			||||||
	if (ret) {
 | 
					 | 
				
			||||||
		pr_info("Error registering platform driver\n");
 | 
					 | 
				
			||||||
		return ret;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ret = amba_driver_register(&dynamic_funnel_driver);
 | 
					 | 
				
			||||||
	if (ret) {
 | 
					 | 
				
			||||||
		pr_info("Error registering amba driver\n");
 | 
					 | 
				
			||||||
		platform_driver_unregister(&static_funnel_driver);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void __exit funnel_exit(void)
 | 
					static void __exit funnel_exit(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	platform_driver_unregister(&static_funnel_driver);
 | 
						coresight_remove_driver(&dynamic_funnel_driver, &static_funnel_driver);
 | 
				
			||||||
	amba_driver_unregister(&dynamic_funnel_driver);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module_init(funnel_init);
 | 
					module_init(funnel_init);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -416,27 +416,13 @@ static struct amba_driver dynamic_replicator_driver = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int __init replicator_init(void)
 | 
					static int __init replicator_init(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						return coresight_init_driver("replicator", &dynamic_replicator_driver,
 | 
				
			||||||
 | 
									     &static_replicator_driver);
 | 
				
			||||||
	ret = platform_driver_register(&static_replicator_driver);
 | 
					 | 
				
			||||||
	if (ret) {
 | 
					 | 
				
			||||||
		pr_info("Error registering platform driver\n");
 | 
					 | 
				
			||||||
		return ret;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ret = amba_driver_register(&dynamic_replicator_driver);
 | 
					 | 
				
			||||||
	if (ret) {
 | 
					 | 
				
			||||||
		pr_info("Error registering amba driver\n");
 | 
					 | 
				
			||||||
		platform_driver_unregister(&static_replicator_driver);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void __exit replicator_exit(void)
 | 
					static void __exit replicator_exit(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	platform_driver_unregister(&static_replicator_driver);
 | 
						coresight_remove_driver(&dynamic_replicator_driver, &static_replicator_driver);
 | 
				
			||||||
	amba_driver_unregister(&dynamic_replicator_driver);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module_init(replicator_init);
 | 
					module_init(replicator_init);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,6 +12,8 @@
 | 
				
			||||||
#include <linux/io.h>
 | 
					#include <linux/io.h>
 | 
				
			||||||
#include <linux/perf_event.h>
 | 
					#include <linux/perf_event.h>
 | 
				
			||||||
#include <linux/sched.h>
 | 
					#include <linux/sched.h>
 | 
				
			||||||
 | 
					#include <linux/amba/bus.h>
 | 
				
			||||||
 | 
					#include <linux/platform_device.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Peripheral id registers (0xFD0-0xFEC) */
 | 
					/* Peripheral id registers (0xFD0-0xFEC) */
 | 
				
			||||||
#define CORESIGHT_PERIPHIDR4	0xfd0
 | 
					#define CORESIGHT_PERIPHIDR4	0xfd0
 | 
				
			||||||
| 
						 | 
					@ -658,4 +660,9 @@ coresight_find_output_type(struct coresight_platform_data *pdata,
 | 
				
			||||||
			   enum coresight_dev_type type,
 | 
								   enum coresight_dev_type type,
 | 
				
			||||||
			   union coresight_dev_subtype subtype);
 | 
								   union coresight_dev_subtype subtype);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int coresight_init_driver(const char *drv, struct amba_driver *amba_drv,
 | 
				
			||||||
 | 
								  struct platform_driver *pdev_drv);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void coresight_remove_driver(struct amba_driver *amba_drv,
 | 
				
			||||||
 | 
								     struct platform_driver *pdev_drv);
 | 
				
			||||||
#endif		/* _LINUX_COREISGHT_H */
 | 
					#endif		/* _LINUX_COREISGHT_H */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue