877cd94e0d895a45336180af339ad0e0ce4b5a6c
[openwrt/openwrt.git] /
1 From 25694a71e1958a4d72891b99b6a2805b7a7bffff Mon Sep 17 00:00:00 2001
2 From: Zhao Qiang <qiang.zhao@nxp.com>
3 Date: Tue, 14 Mar 2017 10:40:38 +0800
4 Subject: [PATCH] irqchip/qeic: merge qeic_of_init into qe_ic_init
5
6 qeic_of_init just get device_node of qeic from dtb and call qe_ic_init,
7 pass the device_node to qe_ic_init.
8 So merge qeic_of_init into qe_ic_init to get the qeic node in
9 qe_ic_init.
10
11 Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
12 ---
13 drivers/irqchip/irq-qeic.c | 89 ++++++++++++++++++++--------------------------
14 include/soc/fsl/qe/qe_ic.h | 7 ----
15 2 files changed, 39 insertions(+), 57 deletions(-)
16
17 --- a/drivers/irqchip/irq-qeic.c
18 +++ b/drivers/irqchip/irq-qeic.c
19 @@ -402,27 +402,33 @@ unsigned int qe_ic_get_high_irq(struct q
20 return irq_linear_revmap(qe_ic->irqhost, irq);
21 }
22
23 -void __init qe_ic_init(struct device_node *node, unsigned int flags,
24 - void (*low_handler)(struct irq_desc *desc),
25 - void (*high_handler)(struct irq_desc *desc))
26 +static int __init qe_ic_init(struct device_node *node, unsigned int flags)
27 {
28 struct qe_ic *qe_ic;
29 struct resource res;
30 - u32 temp = 0, ret, high_active = 0;
31 + u32 temp = 0, high_active = 0;
32 + int ret = 0;
33 +
34 + if (!node)
35 + return -ENODEV;
36
37 ret = of_address_to_resource(node, 0, &res);
38 - if (ret)
39 - return;
40 + if (ret) {
41 + ret = -ENODEV;
42 + goto err_put_node;
43 + }
44
45 qe_ic = kzalloc(sizeof(*qe_ic), GFP_KERNEL);
46 - if (qe_ic == NULL)
47 - return;
48 + if (qe_ic == NULL) {
49 + ret = -ENOMEM;
50 + goto err_put_node;
51 + }
52
53 qe_ic->irqhost = irq_domain_add_linear(node, NR_QE_IC_INTS,
54 &qe_ic_host_ops, qe_ic);
55 if (qe_ic->irqhost == NULL) {
56 - kfree(qe_ic);
57 - return;
58 + ret = -ENOMEM;
59 + goto err_free_qe_ic;
60 }
61
62 qe_ic->regs = ioremap(res.start, resource_size(&res));
63 @@ -433,9 +439,9 @@ void __init qe_ic_init(struct device_nod
64 qe_ic->virq_low = irq_of_parse_and_map(node, 1);
65
66 if (qe_ic->virq_low == NO_IRQ) {
67 - printk(KERN_ERR "Failed to map QE_IC low IRQ\n");
68 - kfree(qe_ic);
69 - return;
70 + pr_err("Failed to map QE_IC low IRQ\n");
71 + ret = -ENOMEM;
72 + goto err_domain_remove;
73 }
74
75 /* default priority scheme is grouped. If spread mode is */
76 @@ -462,13 +468,24 @@ void __init qe_ic_init(struct device_nod
77 qe_ic_write(qe_ic->regs, QEIC_CICR, temp);
78
79 irq_set_handler_data(qe_ic->virq_low, qe_ic);
80 - irq_set_chained_handler(qe_ic->virq_low, low_handler);
81 + irq_set_chained_handler(qe_ic->virq_low, qe_ic_cascade_low_mpic);
82
83 if (qe_ic->virq_high != NO_IRQ &&
84 qe_ic->virq_high != qe_ic->virq_low) {
85 irq_set_handler_data(qe_ic->virq_high, qe_ic);
86 - irq_set_chained_handler(qe_ic->virq_high, high_handler);
87 + irq_set_chained_handler(qe_ic->virq_high,
88 + qe_ic_cascade_high_mpic);
89 }
90 + of_node_put(node);
91 + return 0;
92 +
93 +err_domain_remove:
94 + irq_domain_remove(qe_ic->irqhost);
95 +err_free_qe_ic:
96 + kfree(qe_ic);
97 +err_put_node:
98 + of_node_put(node);
99 + return ret;
100 }
101
102 void qe_ic_set_highest_priority(unsigned int virq, int high)
103 @@ -565,44 +582,16 @@ int qe_ic_set_high_priority(unsigned int
104 return 0;
105 }
106
107 -static struct bus_type qe_ic_subsys = {
108 - .name = "qe_ic",
109 - .dev_name = "qe_ic",
110 -};
111 -
112 -static struct device device_qe_ic = {
113 - .id = 0,
114 - .bus = &qe_ic_subsys,
115 -};
116 -
117 -static int __init init_qe_ic_sysfs(void)
118 +static int __init init_qe_ic(struct device_node *node,
119 + struct device_node *parent)
120 {
121 - int rc;
122 + int ret;
123
124 - printk(KERN_DEBUG "Registering qe_ic with sysfs...\n");
125 + ret = qe_ic_init(node, 0);
126 + if (ret)
127 + return ret;
128
129 - rc = subsys_system_register(&qe_ic_subsys, NULL);
130 - if (rc) {
131 - printk(KERN_ERR "Failed registering qe_ic sys class\n");
132 - return -ENODEV;
133 - }
134 - rc = device_register(&device_qe_ic);
135 - if (rc) {
136 - printk(KERN_ERR "Failed registering qe_ic sys device\n");
137 - return -ENODEV;
138 - }
139 return 0;
140 }
141
142 -static int __init qeic_of_init(struct device_node *node,
143 - struct device_node *parent)
144 -{
145 - if (!node)
146 - return;
147 - qe_ic_init(node, 0, qe_ic_cascade_low_mpic,
148 - qe_ic_cascade_high_mpic);
149 - of_node_put(node);
150 -}
151 -
152 -IRQCHIP_DECLARE(qeic, "fsl,qe-ic", qeic_of_init);
153 -subsys_initcall(init_qe_ic_sysfs);
154 +IRQCHIP_DECLARE(qeic, "fsl,qe-ic", init_qe_ic);
155 --- a/include/soc/fsl/qe/qe_ic.h
156 +++ b/include/soc/fsl/qe/qe_ic.h
157 @@ -54,16 +54,9 @@ enum qe_ic_grp_id {
158 };
159
160 #ifdef CONFIG_QUICC_ENGINE
161 -void qe_ic_init(struct device_node *node, unsigned int flags,
162 - void (*low_handler)(struct irq_desc *desc),
163 - void (*high_handler)(struct irq_desc *desc));
164 unsigned int qe_ic_get_low_irq(struct qe_ic *qe_ic);
165 unsigned int qe_ic_get_high_irq(struct qe_ic *qe_ic);
166 #else
167 -static inline void qe_ic_init(struct device_node *node, unsigned int flags,
168 - void (*low_handler)(struct irq_desc *desc),
169 - void (*high_handler)(struct irq_desc *desc))
170 -{}
171 static inline unsigned int qe_ic_get_low_irq(struct qe_ic *qe_ic)
172 { return 0; }
173 static inline unsigned int qe_ic_get_high_irq(struct qe_ic *qe_ic)