From patchwork Fri Jun 14 08:14:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 166795 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1743491ilk; Fri, 14 Jun 2019 01:15:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4ipohQ7BvQzeCoRWlF7lItZqD6f9PiD6i6Y5rlSH10brF2R6qfJR4AhA4J3i0stIPE0YN X-Received: by 2002:a63:6cc9:: with SMTP id h192mr11974489pgc.339.1560500102241; Fri, 14 Jun 2019 01:15:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560500102; cv=none; d=google.com; s=arc-20160816; b=TVFbyFMDDm9Ay5nTEH0RWiffbJTRR7EEsCAWpOVmTNyK9SQI91+bZc/D8MZUTjAt7m 2mg6gXXUdC/5aZ3XLkzlob5IhrTSS5RDL1sWMdInS8dBrEBbjaMbw80spU2A/TLO3Ul9 Tf+ood/Zk4Ty1C3JdN2RTmZQJ91vOlGltjrmbnCfCUtI5OmFMXtpzMsZOQLlW+rJ3FMI 5kdYSmuIyXxjgZwBGHBAKtmSOKo+zOejCumWoesiZk53qJXrQCxgtbUmXI80hhdX45Bj ZP57zguJmvuI9u1+iRHYU9nkX52lyJQ/GQxXwWbCKGa0RXyp8cwcGRsMNyfI9WPcVeRM NTzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=lFbiqfQknF0eJ3MG2qJQektDrQrX7sZNjc7Bl0wDXo4=; b=p2GCm8fZIRg7qHmxhk50ooNJ4dw90M/OiGqcfYz1B36OuGp7n6zQBuQEn30wZsrWDj 5FoPIyAGWTrsUmKHTqHalzzy/knf0hq27+FH45e7BAzu5bF513ThEwTNMCBow+Vvr5sG SBYlKY8ZAoGa+OPI4MGtkIQ5jXiJpWederk2iJZI2SuNnnp6K5x0izB/+6OVsJ82ISUT fT4ebkY6rYs1O6/L6UypW0BkB3tghcDk3RaCwY8TkA6iA4dXM5MZ+Su3azjKH2kLHtt5 Wc3srfMl/16C32/vuR1kEfaCm7gO3dMX/Wtmb+7Z/Nrdv38G9eeyDh3C7QFxBw4AmHa1 cb+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rmfxbW+b; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id go22si1673219plb.150.2019.06.14.01.15.01; Fri, 14 Jun 2019 01:15:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rmfxbW+b; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726353AbfFNIPB (ORCPT + 5 others); Fri, 14 Jun 2019 04:15:01 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:44957 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725973AbfFNIPB (ORCPT ); Fri, 14 Jun 2019 04:15:01 -0400 Received: by mail-lj1-f195.google.com with SMTP id k18so1422984ljc.11 for ; Fri, 14 Jun 2019 01:15:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lFbiqfQknF0eJ3MG2qJQektDrQrX7sZNjc7Bl0wDXo4=; b=rmfxbW+bdZywUhzkSxFlVgEiuaJonr1HaYuEj5RRrsCQp0SZu5+miXijjoXoZ3ICru gRc4um4ggmMQPwX8rtFYPLEYU47RF3/g0c6eHzyz0EVHEscuRBiE0m51vGU3FcN2fMs/ Kqv6h115yy8/RxnO+N+IVyw4MBREcQyFu3mnapdkTi1gkihZ6/ioS8JUIvL4we9a5I8g nS9Xm2XgaB8d6AJrpF7lTNQf70uEe+ayA6TlByiRjFUzGnY3WhouCB0ZCkkY2ZCVPphx pm0HftCMkz8hbUWM2XLHvihUyWRTuR/1Iqoldxirmckf9mn82ZOJSXWUyphgSTmuTYce MWVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lFbiqfQknF0eJ3MG2qJQektDrQrX7sZNjc7Bl0wDXo4=; b=DILA7WRnBNqmQmiEXeNq6O69VqeDdWGIoQ7AwWg+Q5J3xkeJgmU7V/0TVl0lXfbsYt CLMiLTulpCbvRQNMawEpsGpGNlZeprQhoMAVYg71pyeGWJV7tj4GYgbRY5ZHWsDmAwYB JC4vk9LDugGslsWCIL3YXS63jtDAsiYZRcXQHSEXvcjFN8jOXgsRpfvpEaAhTnQWHPNn Zr1owLnZ3U7BaVqSMTR2R3zKvtpXRXelszx+O1eRCmQRrRbyCWgzhoDSv5qJV7czARnL ShsJSYZP4BCpbSaL1Qn/xCnkKIC7Yyx1yIexNjZR0DjDzlBiRHBKcHWG/nOM7jPYxxNL KOGw== X-Gm-Message-State: APjAAAXPldJyEpVhGDv4QWb/kg1WSsayaryJ/AtwpjMPsiwtIrDHTQq7 lKu8qk85v6q1ruYCd8ZUj5IWewY9Fvo= X-Received: by 2002:a2e:8195:: with SMTP id e21mr28280664ljg.62.1560500099328; Fri, 14 Jun 2019 01:14:59 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id b62sm439891ljb.71.2019.06.14.01.14.58 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 01:14:58 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org Cc: Bartosz Golaszewski , Linus Walleij Subject: [PATCH] gpio: Drop the parent_irq from gpio_irq_chip Date: Fri, 14 Jun 2019 10:14:56 +0200 Message-Id: <20190614081456.530-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org We already have an array named "parents" so instead of letting one point to the other, simply allocate a dynamic array to hold the parents, just one if desired and drop the number of members in gpio_irq_chip by 1. Rename gpiochip to gc in the process. Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 30 +++++++++++++++++++----------- include/linux/gpio/driver.h | 7 ------- 2 files changed, 19 insertions(+), 18 deletions(-) -- 2.20.1 diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 4561cb39bdb4..71cd685ed6c4 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1644,39 +1644,47 @@ EXPORT_SYMBOL_GPL(gpiochip_irqchip_irq_valid); /** * gpiochip_set_cascaded_irqchip() - connects a cascaded irqchip to a gpiochip - * @gpiochip: the gpiochip to set the irqchip chain to + * @gc: the gpiochip to set the irqchip chain to * @parent_irq: the irq number corresponding to the parent IRQ for this * chained irqchip * @parent_handler: the parent interrupt handler for the accumulated IRQ * coming out of the gpiochip. If the interrupt is nested rather than * cascaded, pass NULL in this handler argument */ -static void gpiochip_set_cascaded_irqchip(struct gpio_chip *gpiochip, +static void gpiochip_set_cascaded_irqchip(struct gpio_chip *gc, unsigned int parent_irq, irq_flow_handler_t parent_handler) { - if (!gpiochip->irq.domain) { - chip_err(gpiochip, "called %s before setting up irqchip\n", + struct gpio_irq_chip *girq = &gc->irq; + struct device *dev = &gc->gpiodev->dev; + + if (!girq->domain) { + chip_err(gc, "called %s before setting up irqchip\n", __func__); return; } if (parent_handler) { - if (gpiochip->can_sleep) { - chip_err(gpiochip, + if (gc->can_sleep) { + chip_err(gc, "you cannot have chained interrupts on a chip that may sleep\n"); return; } + girq->parents = devm_kcalloc(dev, 1, + sizeof(*girq->parents), + GFP_KERNEL); + if (!girq->parents) { + chip_err(gc, "out of memory allocating parent IRQ\n"); + return; + } + girq->parents[0] = parent_irq; + girq->num_parents = 1; /* * The parent irqchip is already using the chip_data for this * irqchip, so our callbacks simply use the handler_data. */ irq_set_chained_handler_and_data(parent_irq, parent_handler, - gpiochip); - - gpiochip->irq.parent_irq = parent_irq; - gpiochip->irq.parents = &gpiochip->irq.parent_irq; - gpiochip->irq.num_parents = 1; + gc); } } diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 937c40fb61f7..02698c0f34ea 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -102,13 +102,6 @@ struct gpio_irq_chip { */ unsigned int num_parents; - /** - * @parent_irq: - * - * For use by gpiochip_set_cascaded_irqchip() - */ - unsigned int parent_irq; - /** * @parents: *