From patchwork Fri Apr 7 11:47:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 672184 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32150C76196 for ; Fri, 7 Apr 2023 11:50:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240293AbjDGLuW (ORCPT ); Fri, 7 Apr 2023 07:50:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240120AbjDGLuR (ORCPT ); Fri, 7 Apr 2023 07:50:17 -0400 Received: from mail-yw1-x112a.google.com (mail-yw1-x112a.google.com [IPv6:2607:f8b0:4864:20::112a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6B057AB9 for ; Fri, 7 Apr 2023 04:50:14 -0700 (PDT) Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-5491fa028adso295276457b3.10 for ; Fri, 07 Apr 2023 04:50:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680868212; x=1683460212; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pn9VGQBxO0VW8CThpup8iOfOpiJuYyrE48H21arWabA=; b=PS+WYQIP26GBXUU1txWOSQkhyjA9mC1r0ZTdmHThdqM/kQIewGs/FAORfQfDR+/TJv UMiYAT0pgGZygzlN8Rv35b5zCeqrviHL6roT+jLupnMglDSzianQEiYAR305Ow5T7WeM IdpncrB6X2tJZ9ToBalbemJX45r8MikYkg7yPYR8oxoMdJpQne+hagG0xlrQoZKy5Wkf osk52yvoEfRDUSF0urzVAVEnWd9R6zq5x0/88fwz0I4NVmxeFkKYrvTXCwQ/sjA2DtRT gk/rbdKupKBo5msA9IIFMDqpp7/KeYFo343Pf3MLNVXqaZoK+F1POxOlvyn22fybOryi Ei7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680868212; x=1683460212; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pn9VGQBxO0VW8CThpup8iOfOpiJuYyrE48H21arWabA=; b=ZFrtC8qyIM7QIzGy4oflDGXhVB6x8P0A1ZT9fINT/ira3SJmQLb1n6UR6EFmVK6Tyi AzloNCVjPREfpNa+d2DoA7+Oap8t+a73PXgKFnwZmKQjq15E9NtoTcrWiNdi/5PXr5XH f3yhCWRnb5DBZqQKykq9J5Uze8aGa1yThOzGr4yY4Hq3l5DwM8iocrlCe1xy6Lx4y1OK Ma9ujv6/2Od5wnixxfZzKGHU/+KvyD47FCPN8hsW7jFIrE/FzAJmx+42I0z13mMgT8U6 tzey3ULHj0vz9cdc5iKpfVPQoOXP02xrAkeFDOtSh2FrpZXVadNKCsLupAMcs1auzfec Rt2g== X-Gm-Message-State: AAQBX9eG46PKu37zUQcbnRKeG5xxDPiQ8SycnyQLxOW3zEbZ5X1Lykva 48xQ2mQfQnKgKLDSu3xixq8UdA== X-Google-Smtp-Source: AKy350b6xNq5sP6ICoP8hRVz+gsVa9gv2d6v37wE9aqmG2X+HKX2QngMg9E+B+fShVBqT67umlkgjw== X-Received: by 2002:a81:d02:0:b0:54c:289b:6983 with SMTP id 2-20020a810d02000000b0054c289b6983mr1706558ywn.14.1680868212364; Fri, 07 Apr 2023 04:50:12 -0700 (PDT) Received: from fedora.attlocal.net (69-109-179-158.lightspeed.dybhfl.sbcglobal.net. [69.109.179.158]) by smtp.gmail.com with ESMTPSA id bw28-20020a05690c079c00b00545a08184bfsm955644ywb.79.2023.04.07.04.50.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 04:50:12 -0700 (PDT) From: William Breathitt Gray To: Mark Brown , Linus Walleij , Bartosz Golaszewski Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Andy Shevchenko , William Breathitt Gray Subject: [RESEND PATCH v3 1/2] gpio: 104-dio-48e: Implement struct dio48e_gpio Date: Fri, 7 Apr 2023 07:47:32 -0400 Message-ID: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Message-ID: <20230407114732.6VOJdxNSnnN8bnM3YczwirgbXvf_77gUslGlX4QkE-Q@z> A private data structure struct dio48e_gpio is introduced to facilitate passage of the regmap and IRQ mask state for the device to the callback dio48e_handle_mask_sync(). This is in preparation for the removal of the handle_mask_sync() map parameter in a subsequent patch. Signed-off-by: William Breathitt Gray Reviewed-by: Linus Walleij --- Changes in v3: - Inline dio48gpio->map usage in dio48e_handle_mask_sync() to avoid redefining map parameter drivers/gpio/gpio-104-dio-48e.c | 35 ++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c index 74e2721f2613..3516321c92b0 100644 --- a/drivers/gpio/gpio-104-dio-48e.c +++ b/drivers/gpio/gpio-104-dio-48e.c @@ -99,13 +99,23 @@ static const struct regmap_irq dio48e_regmap_irqs[] = { DIO48E_REGMAP_IRQ(0), DIO48E_REGMAP_IRQ(1), }; +/** + * struct dio48e_gpio - GPIO device private data structure + * @map: Regmap for the device + * @irq_mask: Current IRQ mask state on the device + */ +struct dio48e_gpio { + struct regmap *map; + unsigned int irq_mask; +}; + static int dio48e_handle_mask_sync(struct regmap *const map, const int index, const unsigned int mask_buf_def, const unsigned int mask_buf, void *const irq_drv_data) { - unsigned int *const irq_mask = irq_drv_data; - const unsigned int prev_mask = *irq_mask; + struct dio48e_gpio *const dio48egpio = irq_drv_data; + const unsigned int prev_mask = dio48egpio->irq_mask; int err; unsigned int val; @@ -114,19 +124,19 @@ static int dio48e_handle_mask_sync(struct regmap *const map, const int index, return 0; /* remember the current mask for the next mask sync */ - *irq_mask = mask_buf; + dio48egpio->irq_mask = mask_buf; /* if all previously masked, enable interrupts when unmasking */ if (prev_mask == mask_buf_def) { - err = regmap_write(map, DIO48E_CLEAR_INTERRUPT, 0x00); + err = regmap_write(dio48egpio->map, DIO48E_CLEAR_INTERRUPT, 0x00); if (err) return err; - return regmap_write(map, DIO48E_ENABLE_INTERRUPT, 0x00); + return regmap_write(dio48egpio->map, DIO48E_ENABLE_INTERRUPT, 0x00); } /* if all are currently masked, disable interrupts */ if (mask_buf == mask_buf_def) - return regmap_read(map, DIO48E_DISABLE_INTERRUPT, &val); + return regmap_read(dio48egpio->map, DIO48E_DISABLE_INTERRUPT, &val); return 0; } @@ -167,7 +177,7 @@ static int dio48e_probe(struct device *dev, unsigned int id) struct regmap *map; int err; struct regmap_irq_chip *chip; - unsigned int irq_mask; + struct dio48e_gpio *dio48egpio; struct regmap_irq_chip_data *chip_data; if (!devm_request_region(dev, base[id], DIO48E_EXTENT, name)) { @@ -185,12 +195,14 @@ static int dio48e_probe(struct device *dev, unsigned int id) return dev_err_probe(dev, PTR_ERR(map), "Unable to initialize register map\n"); - chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); - if (!chip) + dio48egpio = devm_kzalloc(dev, sizeof(*dio48egpio), GFP_KERNEL); + if (!dio48egpio) return -ENOMEM; - chip->irq_drv_data = devm_kzalloc(dev, sizeof(irq_mask), GFP_KERNEL); - if (!chip->irq_drv_data) + dio48egpio->map = map; + + chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); + if (!chip) return -ENOMEM; chip->name = name; @@ -205,6 +217,7 @@ static int dio48e_probe(struct device *dev, unsigned int id) chip->irqs = dio48e_regmap_irqs; chip->num_irqs = ARRAY_SIZE(dio48e_regmap_irqs); chip->handle_mask_sync = dio48e_handle_mask_sync; + chip->irq_drv_data = dio48egpio; /* Initialize to prevent spurious interrupts before we're ready */ err = dio48e_irq_init_hw(map); From patchwork Mon Mar 20 14:50:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 665414 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F165DC76195 for ; Mon, 20 Mar 2023 14:52:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232073AbjCTOwh (ORCPT ); Mon, 20 Mar 2023 10:52:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231989AbjCTOwQ (ORCPT ); Mon, 20 Mar 2023 10:52:16 -0400 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1089F2BF2B for ; Mon, 20 Mar 2023 07:50:32 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id n2so13351042qtp.0 for ; Mon, 20 Mar 2023 07:50:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679323828; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2ubabgTfuQRUHcQ6nKf64nxm8BOFtXJ8YmpeRNoMRoE=; b=VgzMDQtzc2uS93M5NqYUM9GW1/DSCkXn5WixLv5WihMtmetUYprltbDnXBQm4g76vJ JJw6O8YxEABBK0ksy6TriZYj+5onqsoNZYlcXamfnOf2nzh6GG8zMvj0SkxFt243/QkN m5YqZDjgG1kqvCZPpQbhgzpGX32BfqKuUAZnWF2Degt46aFo45W8FZFOuf/IED7HG1FG 4iY1kCEh8pc+cT3SbHT74+rmOOuyJtjJxtSU1fCP98zFpbr6ZheUp2rtVPvQot7SFFpZ VN2ArSINAz+oF5RqsIGJiOXnsNcfpTrDp8uHeWJHvq4z1/c86rl+MQZc2DxuDBnjFXI1 NvdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679323828; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2ubabgTfuQRUHcQ6nKf64nxm8BOFtXJ8YmpeRNoMRoE=; b=6KmFlS5/S6b6Hw2T5RAhY8JyyeXUZ/JSr/boZH8BI3agsF7mlejgSCS9YekxAhtc3U wXHWZr0qPzZ3pXheGbcgQQRg4cIa3PL2+ITqHm3iOEWioZi+HjMFlFIkUOv/4ZX6Mact loeUmJrgHxA2vBWHsSfkQz4xnA9wjo9DcXnamcJ08QvHp/JEmoUjbs00xevw+aab8VI7 tJZDQL/l3depa6ehrqPenP9VX63za3viGUfYQOkNGF/EO6ADG9yfaWullrccTW//tonD vZbjfULfeCoxs62m0bZSpE5cVgDpHoZA02Xr6MWVXHBnUM7urALQ7gmgQ4v5ukXyqUGg lFbA== X-Gm-Message-State: AO0yUKUUybq/PG26dQaCZUfwx/kidcqIL3vYxiu5DtcolsYl+3WH5/nG T04wpWbzkYApQeqCLyEGH3qq/w== X-Google-Smtp-Source: AK7set+D0Rm41SOApjBFCQ5yh30ru/0ykF0WLXGC9d6vTpRvFPoE1Xf2cQLng+XR7vx5OJx3VBc/5g== X-Received: by 2002:ac8:5f86:0:b0:3d2:a927:21bc with SMTP id j6-20020ac85f86000000b003d2a92721bcmr25454885qta.18.1679323827850; Mon, 20 Mar 2023 07:50:27 -0700 (PDT) Received: from fedora.attlocal.net (69-109-179-158.lightspeed.dybhfl.sbcglobal.net. [69.109.179.158]) by smtp.gmail.com with ESMTPSA id o14-20020ac872ce000000b003e03178112dsm2661003qtp.13.2023.03.20.07.50.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 07:50:27 -0700 (PDT) From: William Breathitt Gray To: Mark Brown , Linus Walleij , Bartosz Golaszewski Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Andy Shevchenko , William Breathitt Gray Subject: [PATCH v3 2/2] regmap-irq: Drop map from handle_mask_sync() parameters Date: Mon, 20 Mar 2023 10:50:16 -0400 Message-Id: <1f44fb0fbcd3dccea3371215b00f1b9a956c1a12.1679323449.git.william.gray@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Remove the map parameter from the struct regmap_irq_chip callback handle_mask_sync() because it can be passed via the irq_drv_data parameter instead. The gpio-104-dio-48e driver is the only consumer of this callback and is thus updated accordingly. Reviewed-by: Linus Walleij Signed-off-by: William Breathitt Gray --- drivers/base/regmap/regmap-irq.c | 5 ++--- drivers/gpio/gpio-104-dio-48e.c | 2 +- include/linux/regmap.h | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c index 8c903b8c9714..a9337192ddd3 100644 --- a/drivers/base/regmap/regmap-irq.c +++ b/drivers/base/regmap/regmap-irq.c @@ -116,8 +116,7 @@ static void regmap_irq_sync_unlock(struct irq_data *data) for (i = 0; i < d->chip->num_regs; i++) { if (d->mask_base) { if (d->chip->handle_mask_sync) - d->chip->handle_mask_sync(d->map, i, - d->mask_buf_def[i], + d->chip->handle_mask_sync(i, d->mask_buf_def[i], d->mask_buf[i], d->chip->irq_drv_data); else { @@ -915,7 +914,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, if (d->mask_base) { if (chip->handle_mask_sync) { - ret = chip->handle_mask_sync(d->map, i, + ret = chip->handle_mask_sync(i, d->mask_buf_def[i], d->mask_buf[i], chip->irq_drv_data); diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c index 3516321c92b0..509864d36940 100644 --- a/drivers/gpio/gpio-104-dio-48e.c +++ b/drivers/gpio/gpio-104-dio-48e.c @@ -109,7 +109,7 @@ struct dio48e_gpio { unsigned int irq_mask; }; -static int dio48e_handle_mask_sync(struct regmap *const map, const int index, +static int dio48e_handle_mask_sync(const int index, const unsigned int mask_buf_def, const unsigned int mask_buf, void *const irq_drv_data) diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 4d10790adeb0..6e18d8b405b1 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -1644,8 +1644,7 @@ struct regmap_irq_chip { int (*handle_pre_irq)(void *irq_drv_data); int (*handle_post_irq)(void *irq_drv_data); - int (*handle_mask_sync)(struct regmap *map, int index, - unsigned int mask_buf_def, + int (*handle_mask_sync)(int index, unsigned int mask_buf_def, unsigned int mask_buf, void *irq_drv_data); int (*set_type_virt)(unsigned int **buf, unsigned int type, unsigned long hwirq, int reg);