From patchwork Wed Jul 22 10:48:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 246988 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp418254ilg; Wed, 22 Jul 2020 03:50:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1L9UfxrNZH4gDEVfamvty7G4VnDxyCP9uLSSdYscKgzpn2b585mCPS7xoCVEqmpuMKcjM X-Received: by 2002:a50:cd53:: with SMTP id d19mr30730883edj.300.1595415025909; Wed, 22 Jul 2020 03:50:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595415025; cv=none; d=google.com; s=arc-20160816; b=kaRUkTsIa/fyDpuWXoW5tuBrXILPSCUbQkH9obkGygcu6cZttwsbnwOqkIAA9wV8By 3rTgWZ0A1+ADGurD0viIa4xugRaE9JHQVOT4EMrCWqJo+8fNpRAPpoRgdJ/W+YyxMzpG vGBWFHKKyr79hEtXhFLrHlKufy2JRRQNJTXC90UTVrQ6JmTLSZ2GRxvT7nNmEHOCd1P7 mNcVutnChlLnJo9B5JurwZKiHvZot//2TcFz3U2Z14Zsj10rlui0hB4gW6vu3Jz4uB3K 5CFF6Y24YjW6gW1ZE/pKua9sUdqpKUrsMQXaCi++G2tsgL1oS8qbm5dpeAA55+MC2B17 XZZw== 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=BlKFCV+w8C/Efkq0KGerH9f4JXaF8cEGwSDRVd0xhz4=; b=C8YF/H8PX2pnV2ao2QJseZCLll/RPz2NVZaARLx/n0rTyyNuVlsZmU2MJUJoXIFiXT BOAcpJC9CHWiWC0tbl47NzoYopB8/Rfh6Uix+GwAgxZl1wmgmPcLFK8Ime5mPN8wANgH fUVHk4qKqG9+CxgIbQ/8lELe6rR+x2zLbGMTMP3/lSGHwfLBWNScGlsgrphiiutBWoTz GJkUgT0CHqOYqESYoEfE1XIt7oDNbd5b7QzgI/sHnrqrJB4J/ARUtbMK8P3+CLffKsnQ j7MoOGePOXlKySi5S8/WxpiJWWDdD2aaAzHJ7+n0Jl0Hr0/pTEOeKBkEutm6e1st/5si CanQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=keIn5TiC; spf=pass (google.com: domain of linux-gpio-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id jz6si14152348ejb.508.2020.07.22.03.50.25; Wed, 22 Jul 2020 03:50:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-gpio-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=keIn5TiC; spf=pass (google.com: domain of linux-gpio-owner@vger.kernel.org designates 23.128.96.18 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 S1726153AbgGVKuZ (ORCPT + 5 others); Wed, 22 Jul 2020 06:50:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726028AbgGVKuY (ORCPT ); Wed, 22 Jul 2020 06:50:24 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72037C0619DC for ; Wed, 22 Jul 2020 03:50:24 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id h22so1960269lji.9 for ; Wed, 22 Jul 2020 03:50:24 -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=BlKFCV+w8C/Efkq0KGerH9f4JXaF8cEGwSDRVd0xhz4=; b=keIn5TiCZovCECf6CNWZWVyZNCUJcxyiaudz0i9yiG4zNV5gA+O1KjwAXUK2+xGZlY zYdtWtPAvCYh0WuJo97sHbTYJ9bmP2HxJL386CwZwSACRZfBdk6tuC6MPA4si4e5Hwzh TWNEIYEcpyMsZkXPNbXTxhq9e0MOI4vgUdMG/DutUxEykhZYNIH0GVHbXQfNBQI8hHoi ZvCSUgSgp4CHTQXLTL7f3rAbe90KKCFMAo3XpHbeLsXEdIF4Htti8g7V4njBP8AwwqoM aaJXaDnPcIP0SUOdRobmCZm2A0baO+n5Wrj9rH5TYAmKLVNAgFhY/KiV4UEhb9opItOJ L28A== 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=BlKFCV+w8C/Efkq0KGerH9f4JXaF8cEGwSDRVd0xhz4=; b=Wmxfjn0744+PFgM645DRn5JenDQSTgRPwUCSNBeFKKRXSl0RJ6TjjUeoTid8e5Z+Eh m7FW1QjrNay+UU/+js0NDAhH9YmJGqxlKDs9vwlTS2fBvBAo2ucxrMymJC24RkzrlQBe iEvttElx6VfJt3mX9zA4rTGC3XHOERvQCHsjvhIHESkBuPREsh7F8VQsUoou6CFPS2FY Nv7XlhtO5zoZoCDSoWHja3rAAMkLQxxGEf7XDBUgNhtKdp8a8R7xklnDPBxHX+oVuiyq gTc83mIoce7iqRNO4xTU399dbf3xGoLiHsAoFXSA9l5fXXuAYdbPzg25NWzawWG5QfJj V2Bw== X-Gm-Message-State: AOAM531n7uvcmXXW7nwtsfwPv9sKsXNRsZ/ADpp6T20gFJ3hTyJacYsl W7scWKiwwzNtCz9GzPwafWyxrP8kudqwyA== X-Received: by 2002:a2e:9b0f:: with SMTP id u15mr15788554lji.180.1595415022686; Wed, 22 Jul 2020 03:50:22 -0700 (PDT) Received: from localhost.localdomain (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id x30sm7747405lfn.3.2020.07.22.03.50.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 03:50:22 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org Cc: Bartosz Golaszewski , Linus Walleij , William Breathitt Gray Subject: [PATCH] gpio: 104-idi-48: Use irqchip template Date: Wed, 22 Jul 2020 12:48:20 +0200 Message-Id: <20200722104820.174654-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This makes the driver use the irqchip template to assign properties to the gpio_irq_chip instead of using the explicit call to gpiochip_irqchip_add(). The irqchip is instead added while adding the gpiochip. Also move the IRQ initialization to the special .init_hw() callback. Cc: William Breathitt Gray Signed-off-by: Linus Walleij --- drivers/gpio/gpio-104-idi-48.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) -- 2.26.2 Acked-by: William Breathitt Gray diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c index d350ac0de06b..94c3a9bc4e75 100644 --- a/drivers/gpio/gpio-104-idi-48.c +++ b/drivers/gpio/gpio-104-idi-48.c @@ -247,10 +247,22 @@ static const char *idi48_names[IDI48_NGPIO] = { "Bit 18 B", "Bit 19 B", "Bit 20 B", "Bit 21 B", "Bit 22 B", "Bit 23 B" }; +static int idi_48_irq_init_hw(struct gpio_chip *gc) +{ + struct idi_48_gpio *const idi48gpio = gpiochip_get_data(gc); + + /* Disable IRQ by default */ + outb(0, idi48gpio->base + 7); + inb(idi48gpio->base + 7); + + return 0; +} + static int idi_48_probe(struct device *dev, unsigned int id) { struct idi_48_gpio *idi48gpio; const char *const name = dev_name(dev); + struct gpio_irq_chip *girq; int err; idi48gpio = devm_kzalloc(dev, sizeof(*idi48gpio), GFP_KERNEL); @@ -275,6 +287,16 @@ static int idi_48_probe(struct device *dev, unsigned int id) idi48gpio->chip.get_multiple = idi_48_gpio_get_multiple; idi48gpio->base = base[id]; + girq = &idi48gpio->chip.irq; + girq->chip = &idi_48_irqchip; + /* This will let us handle the parent IRQ in the driver */ + girq->parent_handler = NULL; + girq->num_parents = 0; + girq->parents = NULL; + girq->default_type = IRQ_TYPE_NONE; + girq->handler = handle_edge_irq; + girq->init_hw = idi_48_irq_init_hw; + raw_spin_lock_init(&idi48gpio->lock); spin_lock_init(&idi48gpio->ack_lock); @@ -284,17 +306,6 @@ static int idi_48_probe(struct device *dev, unsigned int id) return err; } - /* Disable IRQ by default */ - outb(0, base[id] + 7); - inb(base[id] + 7); - - err = gpiochip_irqchip_add(&idi48gpio->chip, &idi_48_irqchip, 0, - handle_edge_irq, IRQ_TYPE_NONE); - if (err) { - dev_err(dev, "Could not add irqchip (%d)\n", err); - return err; - } - err = devm_request_irq(dev, irq[id], idi_48_irq_handler, IRQF_SHARED, name, idi48gpio); if (err) {