/* Attach a free interrupt line to a GPIO.  */
static int pintsel_attach(const struct gpio_lpc11u6x_shared *shared, uint8_t intpin)
/* Attach a free interrupt line to a GPIO.  */
static int pintsel_attach(const struct gpio_lpc11u6x_shared *shared, uint8_t intpin)
{
	uint8_t irq;
	int ret = -EBUSY;
	uint32_t *pintsel_reg =
		(uint32_t *) (shared->syscon_base + LPC11U6X_PINTSEL_REGS);
	for (irq = 0; irq < shared->nirqs; irq++) {
		if ((pintsel_reg[irq] & BIT_MASK(5)) == intpin) {
			return irq;
		}
		if (ret < 0 && (pintsel_reg[irq] & BIT_MASK(5)) == 0) {
			ret = irq;
		}
	}
	if (ret >= 0) {
		pintsel_reg[ret] = intpin;
	}
	return ret;
}