summaryrefslogtreecommitdiff
path: root/drivers/net/ipa/ipa_interrupt.c
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2024-03-01 11:02:37 -0600
committerDavid S. Miller <davem@davemloft.net>2024-03-04 11:44:40 +0000
commitad1be80d75827aad9582541ecc9d7953d354634f (patch)
tree09cb17c85304fef9930fc1925426939d3f409e03 /drivers/net/ipa/ipa_interrupt.c
parente87e4371edfc369dcc6abbabc3f276d4e0260513 (diff)
net: ipa: introduce ipa_interrupt_init()
Create a new function ipa_interrupt_init() that is called at probe time to allocate and initialize the IPA interrupt data structure. Create ipa_interrupt_exit() as its inverse. This follows the normal IPA driver pattern of *_init() functions doing things that can be done before access to hardware is required. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ipa/ipa_interrupt.c')
-rw-r--r--drivers/net/ipa/ipa_interrupt.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/drivers/net/ipa/ipa_interrupt.c b/drivers/net/ipa/ipa_interrupt.c
index e23c9a5942ed..7399724160a8 100644
--- a/drivers/net/ipa/ipa_interrupt.c
+++ b/drivers/net/ipa/ipa_interrupt.c
@@ -19,6 +19,7 @@
* time only these three are supported.
*/
+#include <linux/platform_device.h>
#include <linux/types.h>
#include <linux/interrupt.h>
#include <linux/pm_runtime.h>
@@ -238,26 +239,15 @@ void ipa_interrupt_simulate_suspend(struct ipa_interrupt *interrupt)
/* Configure the IPA interrupt framework */
int ipa_interrupt_config(struct ipa *ipa)
{
+ struct ipa_interrupt *interrupt = ipa->interrupt;
struct device *dev = &ipa->pdev->dev;
- struct ipa_interrupt *interrupt;
+ unsigned int irq = interrupt->irq;
const struct reg *reg;
- unsigned int irq;
int ret;
- ret = platform_get_irq_byname(ipa->pdev, "ipa");
- if (ret <= 0) {
- dev_err(dev, "DT error %d getting \"ipa\" IRQ property\n", ret);
- return ret ? : -EINVAL;
- }
- irq = ret;
-
- interrupt = kzalloc(sizeof(*interrupt), GFP_KERNEL);
- if (!interrupt)
- return -ENOMEM;
interrupt->ipa = ipa;
- interrupt->irq = irq;
- /* Start with all IPA interrupts disabled */
+ /* Disable all IPA interrupt types */
reg = ipa_reg(ipa, IPA_IRQ_EN);
iowrite32(0, ipa->reg_virt + reg_offset(reg));
@@ -297,5 +287,32 @@ void ipa_interrupt_deconfig(struct ipa *ipa)
dev_pm_clear_wake_irq(dev);
free_irq(interrupt->irq, interrupt);
+}
+
+/* Initialize the IPA interrupt structure */
+struct ipa_interrupt *ipa_interrupt_init(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct ipa_interrupt *interrupt;
+ int irq;
+
+ irq = platform_get_irq_byname(pdev, "ipa");
+ if (irq <= 0) {
+ dev_err(dev, "DT error %d getting \"ipa\" IRQ property\n", irq);
+
+ return ERR_PTR(irq ? : -EINVAL);
+ }
+
+ interrupt = kzalloc(sizeof(*interrupt), GFP_KERNEL);
+ if (!interrupt)
+ return ERR_PTR(-ENOMEM);
+ interrupt->irq = irq;
+
+ return interrupt;
+}
+
+/* Inverse of ipa_interrupt_init() */
+void ipa_interrupt_exit(struct ipa_interrupt *interrupt)
+{
kfree(interrupt);
}