forked from mirrors/linux
		
	spmi: pmic-arb: validate type when mapping IRQ
qpnpint_irq_domain_map did not validate the IRQ type and this can cause IRQs to not work as expected if an unsupported type (such as IRQ_TYPE_NONE) is passed in. Now that spmi-gpio is a hierarchical IRQ controller, and all device tree bindings have been updated, add additional validation to the type field. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
		
							parent
							
								
									f14a5e6da4
								
							
						
					
					
						commit
						135ef21ab0
					
				
					 1 changed files with 14 additions and 7 deletions
				
			
		| 
						 | 
					@ -740,9 +740,9 @@ static int qpnpint_irq_domain_translate(struct irq_domain *d,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void qpnpint_irq_domain_map(struct spmi_pmic_arb *pmic_arb,
 | 
					static int qpnpint_irq_domain_map(struct spmi_pmic_arb *pmic_arb,
 | 
				
			||||||
				   struct irq_domain *domain, unsigned int virq,
 | 
									  struct irq_domain *domain, unsigned int virq,
 | 
				
			||||||
				   irq_hw_number_t hwirq, unsigned int type)
 | 
									  irq_hw_number_t hwirq, unsigned int type)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	irq_flow_handler_t handler;
 | 
						irq_flow_handler_t handler;
 | 
				
			||||||
	unsigned int old_virq;
 | 
						unsigned int old_virq;
 | 
				
			||||||
| 
						 | 
					@ -756,11 +756,15 @@ static void qpnpint_irq_domain_map(struct spmi_pmic_arb *pmic_arb,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (type & IRQ_TYPE_EDGE_BOTH)
 | 
						if (type & IRQ_TYPE_EDGE_BOTH)
 | 
				
			||||||
		handler = handle_edge_irq;
 | 
							handler = handle_edge_irq;
 | 
				
			||||||
	else
 | 
						else if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH))
 | 
				
			||||||
		handler = handle_level_irq;
 | 
							handler = handle_level_irq;
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	irq_domain_set_info(domain, virq, hwirq, &pmic_arb_irqchip, pmic_arb,
 | 
						irq_domain_set_info(domain, virq, hwirq, &pmic_arb_irqchip, pmic_arb,
 | 
				
			||||||
			    handler, NULL, NULL);
 | 
								    handler, NULL, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int qpnpint_irq_domain_alloc(struct irq_domain *domain,
 | 
					static int qpnpint_irq_domain_alloc(struct irq_domain *domain,
 | 
				
			||||||
| 
						 | 
					@ -777,9 +781,12 @@ static int qpnpint_irq_domain_alloc(struct irq_domain *domain,
 | 
				
			||||||
	if (ret)
 | 
						if (ret)
 | 
				
			||||||
		return ret;
 | 
							return ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; i < nr_irqs; i++)
 | 
						for (i = 0; i < nr_irqs; i++) {
 | 
				
			||||||
		qpnpint_irq_domain_map(pmic_arb, domain, virq + i, hwirq + i,
 | 
							ret = qpnpint_irq_domain_map(pmic_arb, domain, virq + i,
 | 
				
			||||||
				       type);
 | 
										     hwirq + i, type);
 | 
				
			||||||
 | 
							if (ret)
 | 
				
			||||||
 | 
								return ret;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue