Re: [PATCH 2/4] gpiolib: add bitmask for valid GPIO lines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/31/2017 04:12 AM, Andy Shevchenko wrote:
Instead of mangling this function wouldn't be better to introduce a
separate one for line and perhaps a third one which calls them both?

The diff is convoluted, but the end result is clean:

static int gpiochip_irqchip_init_valid_mask(struct gpio_chip *gpiochip)
{
	if (gpiochip->irq_need_valid_mask) {
		gpiochip->irq_valid_mask =
			kcalloc(BITS_TO_LONGS(gpiochip->ngpio),
				sizeof(long), GFP_KERNEL);
		if (!gpiochip->irq_valid_mask)
			return -ENOMEM;

		/* Assume by default all GPIOs are valid */
		bitmap_fill(gpiochip->irq_valid_mask, gpiochip->ngpio);
	}

	if (gpiochip->line_need_valid_mask) {
		gpiochip->line_valid_mask =
			kcalloc(BITS_TO_LONGS(gpiochip->ngpio),
				sizeof(long), GFP_KERNEL);
		if (!gpiochip->line_valid_mask)
			return -ENOMEM;

		/* Assume by default all GPIOs are valid */
		bitmap_fill(gpiochip->line_valid_mask, gpiochip->ngpio);
	}

	return 0;
}

Is this acceptable?

--
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux