[PATCH 2/5] irqchip/gic: allow gic-pm driver to be used as module

From: Sameer Pujar
Date: Wed Mar 13 2019 - 07:02:56 EST


In order to use irq-gic-pm driver as module following changes are made.

1. config ARM_GIC_PM is changed to tristate to allow it to be built as
module.

2. following functions are exported from irq-gic driver.
* gic_of_init_child()
* gic_cpu_save()
* gic_dist_save()
* gic_cpu_restore()
* gic_dist_restore()

3. MODULE_LICENSE is added to make sure driver load is successful, else
it fails to resolve required symbols. The 'builtin_platform_driver' is
replaced with 'module_platform_driver' to allow driver removal, else it
complains that device or resource is busy.

Signed-off-by: Sameer Pujar <spujar@xxxxxxxxxx>
---
drivers/irqchip/Kconfig | 2 +-
drivers/irqchip/irq-gic-pm.c | 3 ++-
drivers/irqchip/irq-gic.c | 6 ++++++
3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 5438abb..8b5ce12 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -12,7 +12,7 @@ config ARM_GIC
select GENERIC_IRQ_EFFECTIVE_AFF_MASK

config ARM_GIC_PM
- bool
+ tristate "ARM GIC with PM support"
depends on PM
select ARM_GIC
select PM_CLK
diff --git a/drivers/irqchip/irq-gic-pm.c b/drivers/irqchip/irq-gic-pm.c
index 56a785f..cde9714 100644
--- a/drivers/irqchip/irq-gic-pm.c
+++ b/drivers/irqchip/irq-gic-pm.c
@@ -195,4 +195,5 @@ static struct platform_driver gic_driver = {
}
};

-builtin_platform_driver(gic_driver);
+module_platform_driver(gic_driver);
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index f88018b..b3ad7ed 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -600,6 +600,7 @@ void gic_dist_save(struct gic_chip_data *gic)
gic->saved_spi_active[i] =
readl_relaxed(dist_base + GIC_DIST_ACTIVE_SET + i * 4);
}
+EXPORT_SYMBOL_GPL(gic_dist_save);

/*
* Restores the GIC distributor registers during resume or when coming out of
@@ -653,6 +654,7 @@ void gic_dist_restore(struct gic_chip_data *gic)

writel_relaxed(GICD_ENABLE, dist_base + GIC_DIST_CTRL);
}
+EXPORT_SYMBOL_GPL(gic_dist_restore);

void gic_cpu_save(struct gic_chip_data *gic)
{
@@ -683,6 +685,7 @@ void gic_cpu_save(struct gic_chip_data *gic)
ptr[i] = readl_relaxed(dist_base + GIC_DIST_CONFIG + i * 4);

}
+EXPORT_SYMBOL_GPL(gic_cpu_save);

void gic_cpu_restore(struct gic_chip_data *gic)
{
@@ -725,6 +728,7 @@ void gic_cpu_restore(struct gic_chip_data *gic)
writel_relaxed(GICC_INT_PRI_THRESHOLD, cpu_base + GIC_CPU_PRIMASK);
gic_cpu_if_up(gic);
}
+EXPORT_SYMBOL_GPL(gic_cpu_restore);

static int gic_notifier(struct notifier_block *self, unsigned long cmd, void *v)
{
@@ -1410,6 +1414,7 @@ int gic_of_init_child(struct device *dev, struct gic_chip_data **gic, int irq)

return 0;
}
+EXPORT_SYMBOL_GPL(gic_of_init_child);

static void __init gic_of_setup_kvm_info(struct device_node *node)
{
@@ -1496,6 +1501,7 @@ int gic_of_init_child(struct device *dev, struct gic_chip_data **gic, int irq)
{
return -ENOTSUPP;
}
+EXPORT_SYMBOL_GPL(gic_of_init_child);
#endif

#ifdef CONFIG_ACPI
--
2.7.4