Skip to content

Commit 8d4c998

Browse files
author
Marc Zyngier
committed
irqchip/qcom-pdc: Kill PDC_NO_PARENT_IRQ
PDC_NO_PARENT_IRQ is pretty pointless, as all it indicates is that the PDC terminates the interrupt hierarchy. Which is exactly the same as not having a mapping in the GIC space. This is also bad practice to treat the absence of a hwirq as a hwirq itself. Just explicitly use the region mapping pointer, and drop the definition. Signed-off-by: Marc Zyngier <maz@kernel.org> Reviewed-by: Maulik Shah <quic_mkshah@quicinc.com> Link: https://lore.kernel.org/r/20220224101226.88373-2-maz@kernel.org
1 parent dfd42fa commit 8d4c998

1 file changed

Lines changed: 17 additions & 17 deletions

File tree

drivers/irqchip/qcom-pdc.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
#define IRQ_ENABLE_BANK 0x10
3131
#define IRQ_i_CFG 0x110
3232

33-
#define PDC_NO_PARENT_IRQ ~0UL
34-
3533
struct pdc_pin_region {
3634
u32 pin_base;
3735
u32 parent_base;
3836
u32 cnt;
3937
};
4038

39+
#define pin_to_hwirq(r, p) ((r)->parent_base + (p) - (r)->pin_base)
40+
4141
static DEFINE_RAW_SPINLOCK(pdc_lock);
4242
static void __iomem *pdc_base;
4343
static struct pdc_pin_region *pdc_region;
@@ -186,19 +186,17 @@ static struct irq_chip qcom_pdc_gic_chip = {
186186
.irq_set_affinity = irq_chip_set_affinity_parent,
187187
};
188188

189-
static irq_hw_number_t get_parent_hwirq(int pin)
189+
static struct pdc_pin_region *get_pin_region(int pin)
190190
{
191191
int i;
192-
struct pdc_pin_region *region;
193192

194193
for (i = 0; i < pdc_region_cnt; i++) {
195-
region = &pdc_region[i];
196-
if (pin >= region->pin_base &&
197-
pin < region->pin_base + region->cnt)
198-
return (region->parent_base + pin - region->pin_base);
194+
if (pin >= pdc_region[i].pin_base &&
195+
pin < pdc_region[i].pin_base + pdc_region[i].cnt)
196+
return &pdc_region[i];
199197
}
200198

201-
return PDC_NO_PARENT_IRQ;
199+
return NULL;
202200
}
203201

204202
static int qcom_pdc_translate(struct irq_domain *d, struct irq_fwspec *fwspec,
@@ -221,7 +219,8 @@ static int qcom_pdc_alloc(struct irq_domain *domain, unsigned int virq,
221219
{
222220
struct irq_fwspec *fwspec = data;
223221
struct irq_fwspec parent_fwspec;
224-
irq_hw_number_t hwirq, parent_hwirq;
222+
struct pdc_pin_region *region;
223+
irq_hw_number_t hwirq;
225224
unsigned int type;
226225
int ret;
227226

@@ -234,8 +233,8 @@ static int qcom_pdc_alloc(struct irq_domain *domain, unsigned int virq,
234233
if (ret)
235234
return ret;
236235

237-
parent_hwirq = get_parent_hwirq(hwirq);
238-
if (parent_hwirq == PDC_NO_PARENT_IRQ)
236+
region = get_pin_region(hwirq);
237+
if (!region)
239238
return irq_domain_disconnect_hierarchy(domain->parent, virq);
240239

241240
if (type & IRQ_TYPE_EDGE_BOTH)
@@ -247,7 +246,7 @@ static int qcom_pdc_alloc(struct irq_domain *domain, unsigned int virq,
247246
parent_fwspec.fwnode = domain->parent->fwnode;
248247
parent_fwspec.param_count = 3;
249248
parent_fwspec.param[0] = 0;
250-
parent_fwspec.param[1] = parent_hwirq;
249+
parent_fwspec.param[1] = pin_to_hwirq(region, hwirq);
251250
parent_fwspec.param[2] = type;
252251

253252
return irq_domain_alloc_irqs_parent(domain, virq, nr_irqs,
@@ -265,7 +264,8 @@ static int qcom_pdc_gpio_alloc(struct irq_domain *domain, unsigned int virq,
265264
{
266265
struct irq_fwspec *fwspec = data;
267266
struct irq_fwspec parent_fwspec;
268-
irq_hw_number_t hwirq, parent_hwirq;
267+
struct pdc_pin_region *region;
268+
irq_hw_number_t hwirq;
269269
unsigned int type;
270270
int ret;
271271

@@ -281,8 +281,8 @@ static int qcom_pdc_gpio_alloc(struct irq_domain *domain, unsigned int virq,
281281
if (ret)
282282
return ret;
283283

284-
parent_hwirq = get_parent_hwirq(hwirq);
285-
if (parent_hwirq == PDC_NO_PARENT_IRQ)
284+
region = get_pin_region(hwirq);
285+
if (!region)
286286
return irq_domain_disconnect_hierarchy(domain->parent, virq);
287287

288288
if (type & IRQ_TYPE_EDGE_BOTH)
@@ -294,7 +294,7 @@ static int qcom_pdc_gpio_alloc(struct irq_domain *domain, unsigned int virq,
294294
parent_fwspec.fwnode = domain->parent->fwnode;
295295
parent_fwspec.param_count = 3;
296296
parent_fwspec.param[0] = 0;
297-
parent_fwspec.param[1] = parent_hwirq;
297+
parent_fwspec.param[1] = pin_to_hwirq(region, hwirq);
298298
parent_fwspec.param[2] = type;
299299

300300
return irq_domain_alloc_irqs_parent(domain, virq, nr_irqs,

0 commit comments

Comments
 (0)