[Xenomai] [PATCH 3/3] kernel: rtdm: gpio: Add support for GPIO_RTIOC_IRQAFF.

Christoph Muellner christoph.muellner at theobroma-systems.com
Mon Oct 23 16:59:44 CEST 2017


To set a GPIO interrupt's CPU affinity, we simply call
rtdm_irq_affinity() with a proper bitmask.

Signed-off-by: Christoph Muellner <christoph.muellner at theobroma-systems.com>
---
 kernel/drivers/gpio/gpio-core.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index 55594f6ae..84153a937 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -118,6 +118,23 @@ static void release_gpio_irq(unsigned int gpio, struct rtdm_gpio_pin *pin,
 	chan->requested = false;
 }
 
+static int set_gpio_irq_affinity(struct rtdm_gpio_pin *pin, int val)
+{
+	cpumask_t tgt;
+	unsigned int i = 0;
+
+	cpumask_clear(&tgt);
+
+	while (val) {
+		if (val & (1 << i))
+			cpumask_set_cpu(i, &tgt);
+		val &= ~(1 << i);
+		i++;
+	}
+
+	return rtdm_irq_affinity(&pin->irqh, tgt);
+}
+
 static int gpio_pin_ioctl_nrt(struct rtdm_fd *fd,
 			      unsigned int request, void *arg)
 {
@@ -158,6 +175,14 @@ static int gpio_pin_ioctl_nrt(struct rtdm_fd *fd,
 		release_gpio_irq(gpio, pin, chan);
 		chan->requested = false;
 		break;
+	case GPIO_RTIOC_IRQAFF:
+		if (!chan->requested)
+			return -EINVAL;
+		ret = rtdm_safe_copy_from_user(fd, &val, arg, sizeof(val));
+		if (ret)
+			return ret;
+		ret = set_gpio_irq_affinity(pin, val);
+		break;
 	default:
 		return -EINVAL;
 	}
-- 
2.11.0




More information about the Xenomai mailing list