From patchwork Thu May 11 09:13:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 92444 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4230586vqo; Thu, 11 May 2023 02:25:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ48j+yHCOxm1E92Htl4eoaJnoqQiV8PZkv06OpICTGnXeqACnb3pnUnvNq/+vAEV66RazTP X-Received: by 2002:a05:6a20:7d8d:b0:103:ee82:dcb0 with SMTP id v13-20020a056a207d8d00b00103ee82dcb0mr1582859pzj.13.1683797122172; Thu, 11 May 2023 02:25:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683797122; cv=none; d=google.com; s=arc-20160816; b=TeU5NFvXDC2DPo77tJQtHt/DcSUSyFaCtYkVZcZob4u3l0vAL+MLJlxkkLKXDlxTMC s38HtDhaCXxtjyXYRLfW/xbjEkO3arWLFd4l56XL8o7ub7ge3qIzwi7hAo2c3oLHOHdb Gk4E+lZRasXW9RJRkmcXKAtpPQpK3G0A7bUrf6hCD7oqjAxVLUSp1DdE7l5T8elH1uhR qgE1CwQGoVxZOqyuZsaRc13LuFPiugdsNCcGTtakz5a7j23k4n4JmCDIF4uEE6+cLXF0 rOtfQxw7R9FDJ5zOCzc8tTtKi7hGkXp1yLIIZlcFnH6Cq3PtSKE6vCVepUmoBQTReKD9 FcYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xn6oPNO0+H8urawE2tn6HpuoupILu8RQiDcmPsO/63U=; b=JmYnuHKkYjE+FljDPQWZklB+gWlXocoCP7ICI+3R08GHDYxVjVynXe8qKAV1J2jhtY cQsTji4JOv4WMnHNGyL0GVkt42n6IEtmUkvgoKAezzSokjZjwmVu3y1XIp5XMGrwH7VL +e1uLYInt6csl9R5ZbvgPm8ehVlAmfBGymfF9xPhcZwVk02Jtu820W8Al3TMEi5SKzVb q4QG5sZlq8hc5u4KUDlJt5jTxKVvj0ra8fshcffS/YTuCBMDLCVhmsbNKoMzio58UuEE 1k9yjhkeYh+C9gY51orYIdYIvMYTI0zrHRlex9y+WhABDQC6U3xqf85OrxkrgwM2PXLT 3nYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=XL8QGnZa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q11-20020aa7960b000000b0062804ba6fb4si7318185pfg.58.2023.05.11.02.25.03; Thu, 11 May 2023 02:25:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=XL8QGnZa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236759AbjEKJOC (ORCPT + 99 others); Thu, 11 May 2023 05:14:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237273AbjEKJN6 (ORCPT ); Thu, 11 May 2023 05:13:58 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28E757D84 for ; Thu, 11 May 2023 02:13:57 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3078aa0b152so3867202f8f.3 for ; Thu, 11 May 2023 02:13:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683796435; x=1686388435; 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=xn6oPNO0+H8urawE2tn6HpuoupILu8RQiDcmPsO/63U=; b=XL8QGnZaZhkXvBwsKRHtFtHThuYQXI7kuR/G7+tqJxyxJu5rpSa11g5fLpSU8AfGYz dXkwox43sU3k3upv5P4Ku1Di+8Z4DflbV89K6FOumV6eNV5c76/YwKJgC8utZ/uGQy3Y z7cFM4QastKWeFaw6XxX+kWFzXkqanvOkwdfhO/DGqjDvu8IvPNPCgK50AteygSntUKy Bzjs7CeXGHrwm2U01RKIQvx/hEzfNfKLq8dBxhMw7/7ScrGZimuiEA+wJsT82nEKQjmp IUjp48NakuUTZJCPke+hFZwHZ01+1joETklMA5eROvoPA3pKSCAIMS05lN1sOBvgMJdQ ezjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683796435; x=1686388435; 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=xn6oPNO0+H8urawE2tn6HpuoupILu8RQiDcmPsO/63U=; b=K92heaxs0OS60/IsQo/fRfxvul7J6cI/7/mU3CGJW21roP5fK6St2D4FAxQnxIXPme BwLUIcEn0OJFNQwGCmvUsIF2OB9PlZ+BcgrFFNrGCQ4kUQH6WKXu7qIBTr0v5dK6fo95 OuNnGqyG+9Bs6wF3Xjr7QdBCE8oBtAGLUYu0UicgLwaZ6cmCTh+GzqrY6GYdiEO6P+1+ jG2XfHey1wkbWXmk2wuhkmf3skgC+GQPD+s5YjTbQU5qCO4znXdZM60q1C+wAhfeY/cT TXTJ9BUS7pvdwuoVkW8tAFRaw1LSuiaCz8cZVj24k6FULuWOCNmHGWLWtB5Z2teQI47H czsQ== X-Gm-Message-State: AC+VfDza0eXluAMLUlTt9tfA3G+jyDPm6QUpn9AeXBgVpXiLnUEHgtjJ CvvQvh7mYJ+i8n1n+0fb70A= X-Received: by 2002:adf:fac1:0:b0:2d8:47c7:7b52 with SMTP id a1-20020adffac1000000b002d847c77b52mr14441353wrs.9.1683796435402; Thu, 11 May 2023 02:13:55 -0700 (PDT) Received: from localhost ([167.98.27.226]) by smtp.gmail.com with ESMTPSA id p6-20020adfe606000000b002e5f6f8fc4fsm19882730wrm.100.2023.05.11.02.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 May 2023 02:13:55 -0700 (PDT) From: Aidan MacDonald To: broonie@kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/4] regmap-irq: Remove type registers Date: Thu, 11 May 2023 10:13:39 +0100 Message-Id: <20230511091342.26604-2-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20230511091342.26604-1-aidanmacdonald.0x0@gmail.com> References: <20230511091342.26604-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765589251384612507?= X-GMAIL-MSGID: =?utf-8?q?1765589251384612507?= No remaining users, these have been replaced by config registers. Signed-off-by: Aidan MacDonald --- drivers/base/regmap/regmap-irq.c | 82 ++++---------------------------- include/linux/regmap.h | 7 --- 2 files changed, 8 insertions(+), 81 deletions(-) diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c index 48bff842cc31..c11295e3fe5e 100644 --- a/drivers/base/regmap/regmap-irq.c +++ b/drivers/base/regmap/regmap-irq.c @@ -181,20 +181,6 @@ static void regmap_irq_sync_unlock(struct irq_data *data) } } - /* Don't update the type bits if we're using mask bits for irq type. */ - if (!d->chip->type_in_mask) { - for (i = 0; i < d->chip->num_type_reg; i++) { - if (!d->type_buf_def[i]) - continue; - reg = d->get_irq_reg(d, d->chip->type_base, i); - ret = regmap_update_bits(d->map, reg, - d->type_buf_def[i], d->type_buf[i]); - if (ret != 0) - dev_err(d->map->dev, "Failed to sync type in %x\n", - reg); - } - } - for (i = 0; i < d->chip->num_config_bases; i++) { for (j = 0; j < d->chip->num_config_regs; j++) { reg = d->get_irq_reg(d, d->chip->config_base[i], j); @@ -273,36 +259,11 @@ static int regmap_irq_set_type(struct irq_data *data, unsigned int type) reg = t->type_reg_offset / map->reg_stride; - if (t->type_reg_mask) - d->type_buf[reg] &= ~t->type_reg_mask; - else - d->type_buf[reg] &= ~(t->type_falling_val | - t->type_rising_val | - t->type_level_low_val | - t->type_level_high_val); - switch (type) { - case IRQ_TYPE_EDGE_FALLING: - d->type_buf[reg] |= t->type_falling_val; - break; - - case IRQ_TYPE_EDGE_RISING: - d->type_buf[reg] |= t->type_rising_val; - break; - - case IRQ_TYPE_EDGE_BOTH: - d->type_buf[reg] |= (t->type_falling_val | - t->type_rising_val); - break; - - case IRQ_TYPE_LEVEL_HIGH: - d->type_buf[reg] |= t->type_level_high_val; - break; - - case IRQ_TYPE_LEVEL_LOW: - d->type_buf[reg] |= t->type_level_low_val; - break; - default: - return -EINVAL; + if (d->chip->type_in_mask) { + ret = regmap_irq_set_type_config_simple(&d->type_buf, type, + irq_data, reg, d->chip->irq_drv_data); + if (ret) + return ret; } if (d->chip->set_type_config) { @@ -707,8 +668,6 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, struct regmap_irq_chip_data *d; int i; int ret = -ENOMEM; - int num_type_reg; - int num_regs; u32 reg; if (chip->num_regs <= 0) @@ -733,9 +692,6 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, return -EINVAL; } - if (chip->num_type_reg) - dev_warn(map->dev, "type registers are deprecated; use config registers instead"); - if (irq_base) { irq_base = irq_alloc_descs(irq_base, 0, chip->num_irqs, 0); if (irq_base < 0) { @@ -780,21 +736,13 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, goto err_alloc; } - /* - * Use num_config_regs if defined, otherwise fall back to num_type_reg - * to maintain backward compatibility. - */ - num_type_reg = chip->num_config_regs ? chip->num_config_regs - : chip->num_type_reg; - num_regs = chip->type_in_mask ? chip->num_regs : num_type_reg; - if (num_regs) { - d->type_buf_def = kcalloc(num_regs, + if (chip->type_in_mask) { + d->type_buf_def = kcalloc(chip->num_regs, sizeof(*d->type_buf_def), GFP_KERNEL); if (!d->type_buf_def) goto err_alloc; - d->type_buf = kcalloc(num_regs, sizeof(*d->type_buf), - GFP_KERNEL); + d->type_buf = kcalloc(chip->num_regs, sizeof(*d->type_buf), GFP_KERNEL); if (!d->type_buf) goto err_alloc; } @@ -970,20 +918,6 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, } } - if (chip->num_type_reg && !chip->type_in_mask) { - for (i = 0; i < chip->num_type_reg; ++i) { - reg = d->get_irq_reg(d, d->chip->type_base, i); - - ret = regmap_read(map, reg, &d->type_buf_def[i]); - - if (ret) { - dev_err(map->dev, "Failed to get type defaults at 0x%x: %d\n", - reg, ret); - goto err_alloc; - } - } - } - if (irq_base) d->domain = irq_domain_create_legacy(fwnode, chip->num_irqs, irq_base, 0, diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 2ad0e3d77b95..0b4b9eca480d 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -1542,8 +1542,6 @@ struct regmap_irq_chip_data; * @ack_base: Base ack address. If zero then the chip is clear on read. * Using zero value is possible with @use_ack bit. * @wake_base: Base address for wake enables. If zero unsupported. - * @type_base: Base address for irq type. If zero unsupported. Deprecated, - * use @config_base instead. * @config_base: Base address for IRQ type config regs. If null unsupported. * @irq_reg_stride: Stride to use for chips where registers are not contiguous. * @init_ack_masked: Ack all masked interrupts once during initalization. @@ -1581,9 +1579,6 @@ struct regmap_irq_chip_data; * @irqs: Descriptors for individual IRQs. Interrupt numbers are * assigned based on the index in the array of the interrupt. * @num_irqs: Number of descriptors. - * - * @num_type_reg: Number of type registers. Deprecated, use config registers - * instead. * @num_config_bases: Number of config base registers. * @num_config_regs: Number of config registers for each config base register. * @@ -1621,7 +1616,6 @@ struct regmap_irq_chip { unsigned int unmask_base; unsigned int ack_base; unsigned int wake_base; - unsigned int type_base; const unsigned int *config_base; unsigned int irq_reg_stride; unsigned int init_ack_masked:1; @@ -1642,7 +1636,6 @@ struct regmap_irq_chip { const struct regmap_irq *irqs; int num_irqs; - int num_type_reg; int num_config_bases; int num_config_regs; From patchwork Thu May 11 09:13:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 92442 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4230558vqo; Thu, 11 May 2023 02:25:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4/A4PGb5xA6y+/ncs7A0gtmaYlWRGkX33T6xqLIR2iEpcRaQ2zwJhDiZFepBHIQyVkw0hR X-Received: by 2002:a05:6a20:244d:b0:101:7761:ad2a with SMTP id t13-20020a056a20244d00b001017761ad2amr9019904pzc.5.1683797117396; Thu, 11 May 2023 02:25:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683797117; cv=none; d=google.com; s=arc-20160816; b=p3UyXNiYZ4sP4aGYWqu7QMVglmg6Sgg/3/HsuBpAQbV0Hf0YZIAPOiBGWN2yGQLh1H 50PJPhy1H3VIvSGA4n2fF0EMXwR0rPOgqFbzTjXekwvyPcUsqkZ+1l15lXDwM82LRCj3 CoihXcXPg4rI7wvSBQUyQS4+ex/AQ0B8US64gAUHuWpur8ljYNE3Vfh534AkB0Hf1sL8 VJSZp1QaJ1pbF/Pi/svTukZI4hwXv/DadNJvH6HBnXh2aBiS2Fj+OgiCkcgOrZT5L5f8 0tlML0zgLjyXPyPQl9iij0cGeoQ1biuYM4vDO8CotmVH7gox7yC5jiK9g9ceLxF2FFLv rzBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WEHyHwezs0VBg1/gOR5LcksWON8haOfKNBrPIcoTjRs=; b=plVBcN5CMycHb2XYC/ffZwqs+hIaIqqE6/oHcVWOK7+9OQ0x/PYAN9U//ZvFDs737Q Eo4vq5E/uTW+E9q72WqofYU6sZ263b2rUUSIk/VQ5zPoqj5uN1h1JaAdYlknYxeD9uQx nUqYDBqGchsMJkEfzubsW+/O8eMPThS+eh9vlielZwY7ep3qMONRfEtfTpwyYOVQr+uS S35HD2bsNtlsk2k0KEz+LeREKzSeb6EYlnZsVTtPbwSqT8OwPHarOuLgSR/R9abiyb+n 28RlnM+B/NYCIHFdOwFiK4OuNVUMV//55oi/d3q02aM7/iv1bRk55qonwOtshXD2s0tQ DGew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=MVwkqN5r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bu17-20020a632951000000b005303d78c47asi5883570pgb.726.2023.05.11.02.24.50; Thu, 11 May 2023 02:25:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=MVwkqN5r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237332AbjEKJOG (ORCPT + 99 others); Thu, 11 May 2023 05:14:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237288AbjEKJOA (ORCPT ); Thu, 11 May 2023 05:14:00 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 182F526A2 for ; Thu, 11 May 2023 02:13:58 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-30789a4c537so3855990f8f.0 for ; Thu, 11 May 2023 02:13:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683796436; x=1686388436; 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=WEHyHwezs0VBg1/gOR5LcksWON8haOfKNBrPIcoTjRs=; b=MVwkqN5rTvWEnYOqX6VAcY6Sc+22mTmiMXYS6O05/T2rlI9T1hmz8chDxZYoKZwU30 uZEDFORU4tBo89Qvrihy0lILEWp8ShF7aeKQP+vP2VGWug89krsNh34Kznj/iW1r5j6Q gCBGFdNDxdgvlvVxSKkBwmmTZD0sD0an1qtAL98ANKERNciGDiqwHwOPvFBsdp1WrZIx nTcjicmrO8VxaEsZso42lVZA9OAC/Tecr0mEZ2gWb5Q+okDyEavUvH3M3aybO/8vnWHA DtOf+Q4T/JKbTb6Br1/1o/kRnWaJMPFM8ddE87Ygebdc6U5gxIwIw/JwsJs2EUz+94Mf vzNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683796436; x=1686388436; 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=WEHyHwezs0VBg1/gOR5LcksWON8haOfKNBrPIcoTjRs=; b=Wq8sO6kwBpCx5E6wg3qQDbaUHh0pNlQNxvY2A4NGaeQCl2h02k7rnVruJGBmCKj10H hoYU9KM0kkzNaBcgnGyPZRRMO3zcS52kzz4OeKv2d73HUSXw18Y8uln1zZ9r74Br/3ge S36EwrrG5bd5Y5XbV+IxELrfTauUzdNH/iQ0Q05t1YUwu0i07rm4wLib+GeM936oPwsQ IrEUm/Hb2OtXb+2uneaMx0bQtnjOhRi2e8FbKLG7u98WDBN+UdaUXQQCDEkGIMoIidyA Z/xrQs5otfdbpLvQjYDEDQxXtMEWBzWncTapND6T/YHFKlTUhYM1ZsBxkASPZL75UR7L p1tg== X-Gm-Message-State: AC+VfDzHBSPz0uT705bycpQdYmB0V6S3eNRqeptsjDJYeUA31NZ6cd6h pwxWaSKsmJQ9i+TMFS8uiY4= X-Received: by 2002:a5d:5221:0:b0:2fb:703d:1915 with SMTP id i1-20020a5d5221000000b002fb703d1915mr13463224wra.43.1683796436440; Thu, 11 May 2023 02:13:56 -0700 (PDT) Received: from localhost ([167.98.27.226]) by smtp.gmail.com with ESMTPSA id o1-20020a5d58c1000000b00306c5900c10sm19627786wrf.9.2023.05.11.02.13.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 May 2023 02:13:56 -0700 (PDT) From: Aidan MacDonald To: broonie@kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] regmap-irq: Remove support for not_fixed_stride Date: Thu, 11 May 2023 10:13:40 +0100 Message-Id: <20230511091342.26604-3-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20230511091342.26604-1-aidanmacdonald.0x0@gmail.com> References: <20230511091342.26604-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765589245877577510?= X-GMAIL-MSGID: =?utf-8?q?1765589245877577510?= No remaining users, use a custom .get_irq_reg() callback instead. Signed-off-by: Aidan MacDonald --- drivers/base/regmap/regmap-irq.c | 43 +++----------------------------- include/linux/regmap.h | 9 ------- 2 files changed, 3 insertions(+), 49 deletions(-) diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c index c11295e3fe5e..7cb457af2332 100644 --- a/drivers/base/regmap/regmap-irq.c +++ b/drivers/base/regmap/regmap-irq.c @@ -328,15 +328,8 @@ static inline int read_sub_irq_data(struct regmap_irq_chip_data *data, unsigned int offset = subreg->offset[i]; unsigned int index = offset / map->reg_stride; - if (chip->not_fixed_stride) - ret = regmap_read(map, - chip->status_base + offset, - &data->status_buf[b]); - else - ret = regmap_read(map, - chip->status_base + offset, - &data->status_buf[index]); - + ret = regmap_read(map, chip->status_base + offset, + &data->status_buf[index]); if (ret) break; } @@ -391,17 +384,7 @@ static irqreturn_t regmap_irq_thread(int irq, void *d) * sake of simplicity. and add bulk reads only if needed */ for (i = 0; i < chip->num_main_regs; i++) { - /* - * For not_fixed_stride, don't use ->get_irq_reg(). - * It would produce an incorrect result. - */ - if (data->chip->not_fixed_stride) - reg = chip->main_status + - i * map->reg_stride * data->irq_reg_stride; - else - reg = data->get_irq_reg(data, - chip->main_status, i); - + reg = data->get_irq_reg(data, chip->main_status, i); ret = regmap_read(map, reg, &data->main_status_buf[i]); if (ret) { dev_err(map->dev, @@ -567,20 +550,8 @@ static const struct irq_domain_ops regmap_domain_ops = { unsigned int regmap_irq_get_irq_reg_linear(struct regmap_irq_chip_data *data, unsigned int base, int index) { - const struct regmap_irq_chip *chip = data->chip; struct regmap *map = data->map; - /* - * FIXME: This is for backward compatibility and should be removed - * when not_fixed_stride is dropped (it's only used by qcom-pm8008). - */ - if (chip->not_fixed_stride && chip->sub_reg_offsets) { - struct regmap_irq_sub_irq_map *subreg; - - subreg = &chip->sub_reg_offsets[0]; - return base + subreg->offset[0]; - } - return base + index * map->reg_stride * data->irq_reg_stride; } EXPORT_SYMBOL_GPL(regmap_irq_get_irq_reg_linear); @@ -684,14 +655,6 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, return -EINVAL; } - if (chip->not_fixed_stride) { - dev_warn(map->dev, "not_fixed_stride is deprecated; use ->get_irq_reg() instead"); - - for (i = 0; i < chip->num_regs; i++) - if (chip->sub_reg_offsets[i].num_regs != 1) - return -EINVAL; - } - if (irq_base) { irq_base = irq_alloc_descs(irq_base, 0, chip->num_irqs, 0); if (irq_base < 0) { diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 0b4b9eca480d..8fc0b3ebce44 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -1528,9 +1528,6 @@ struct regmap_irq_chip_data; * status_base. Should contain num_regs arrays. * Can be provided for chips with more complex mapping than * 1.st bit to 1.st sub-reg, 2.nd bit to 2.nd sub-reg, ... - * When used with not_fixed_stride, each one-element array - * member contains offset calculated as address from each - * peripheral to first peripheral. * @num_main_regs: Number of 'main status' irq registers for chips which have * main_status set. * @@ -1567,11 +1564,6 @@ struct regmap_irq_chip_data; * registers before unmasking interrupts to clear any bits * set when they were masked. * @runtime_pm: Hold a runtime PM lock on the device when accessing it. - * @not_fixed_stride: Used when chip peripherals are not laid out with fixed - * stride. Must be used with sub_reg_offsets containing the - * offsets to each peripheral. Deprecated; the same thing - * can be accomplished with a @get_irq_reg callback, without - * the need for a @sub_reg_offsets table. * @no_status: No status register: all interrupts assumed generated by device. * * @num_regs: Number of registers in each control bank. @@ -1628,7 +1620,6 @@ struct regmap_irq_chip { unsigned int type_in_mask:1; unsigned int clear_on_unmask:1; unsigned int runtime_pm:1; - unsigned int not_fixed_stride:1; unsigned int no_status:1; int num_regs; From patchwork Thu May 11 09:13:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 92440 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4230508vqo; Thu, 11 May 2023 02:25:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5I5bojpLj+yLn8ouHV39GtlJ+JlUDSkb3guIrfYXB0IrP1PtUzavE7AEdagMQA28OdCuWF X-Received: by 2002:a05:6a20:258d:b0:ee:e0d8:515d with SMTP id k13-20020a056a20258d00b000eee0d8515dmr28170520pzd.46.1683797110982; Thu, 11 May 2023 02:25:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683797110; cv=none; d=google.com; s=arc-20160816; b=IcndXkidyNXE2R+YdgOU6ec/G9BE9mHL7ejtcMWMjThu2AwIwxxFxWm1pdz43xMhsB 6OMu0Uto5XtKlxQs4d2yp7kH8ZA0ZbkhOaVkXHtuVRTClDSCaoHBwipbeq6MJ/guEUma Q2bo4EwkOJdtlZ7EpPxw/4PYJftcUlqQ7/ADe23bRc3qiMvBi/nnVgIyMeyn1foV4HfA jobsJcOQWv3qvYSzyxmCQ2R2HAKgRmSrrzmfMycmiLxq6Aan5wfcO8IekZ0UuYaVVrwL 5ExVEWTk5K9qAsjr8eul7wXu2bxjaBnjGIz4ubY5BTI/yzgFMRxHgsjjVLEFw+yxL7AO eLVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=58FKT6mBLi9/p/z/H4le9F9arcqBmz3tNrQ4oPYMtxs=; b=FSGtSq1ANTyTaDQ3CyxwXRl4D/+n08ROlte+lvKWkmtYhiJ1TeNjqB2VKYjn2bqK+U Iz/It4TnNhLLyBrj768/Zgedl8JP1O3M3DvJpld4jxr+ngyQFaymcSbcNip5VqwcD3UI etVp0KvgoSgXWLkimL+F26+NF47Nuf/NfoZTvl/F/e9wFTGNHHn0KRHt3L2yV+8JFU5f g3XQtGKOrGjlNsMz8fIcd/QDmK3d16xQ+39RMJjEJNyfi39WrmTqo83tP3mHp8KvKw3E zTXwgsqSaJK4SNz9/KyeDnEwAwmzspRO9hB3t2WJsYilFcfXFlA7o1KLe9/gwfiqgqdb NToA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=RMfwftQ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c6-20020a6566c6000000b005303bf3e14bsi6371178pgw.412.2023.05.11.02.24.31; Thu, 11 May 2023 02:25:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=RMfwftQ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237364AbjEKJOK (ORCPT + 99 others); Thu, 11 May 2023 05:14:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237296AbjEKJOA (ORCPT ); Thu, 11 May 2023 05:14:00 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA6CAAF for ; Thu, 11 May 2023 02:13:58 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3f42c86543bso20532515e9.3 for ; Thu, 11 May 2023 02:13:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683796437; x=1686388437; 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=58FKT6mBLi9/p/z/H4le9F9arcqBmz3tNrQ4oPYMtxs=; b=RMfwftQ4O9nVrknSfSxB5Y6EQfvzZDAFihS192nR/sT2BqRlJC/sVyDzKx38lNiXrN IDOrH4j4oCyH6j8Jn/2QFB3uetyQueGmz0aymEHqU43+AicQk7p0L1CwcrvpvhhcwBlg /mYiM01PpSe//t8i3ptdhGFlc5adL50UUObpn7ypufRIOnfX2z6iY2q+aCvyDc1qYvuf pgjjZWvMEaqc8mNGI4Pio71bFsfSWjEKzTtgkNnHTjSkvFC6ZEe9eWdgt4LurRU/G3aS 57HVJMcgLAF+wfCMU6na0yi0J4Hmg24VZa0rhbM6UISYLRNrYr97u7j10nn7eKLOhUaJ MyoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683796437; x=1686388437; 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=58FKT6mBLi9/p/z/H4le9F9arcqBmz3tNrQ4oPYMtxs=; b=fJrLVDRymAfXZuGO0wNB+2Z1rT1pu9RPZvpph2wl91rHmXH7DxmJ1l9l7T/nraZuFS V4xCy+yHTymAbEDeSVvlqaseDFeBy00qM+SQX+fN8lFFHGa4nCsoczVia16ik77X8J9+ 8IfQ/KHpjiJ6X+TO414YzRUOyckPmmzhGFPAFErpgZXVc6th1bQkP0aLU/9Qk+sr1rIU p3+PlR9Lir//NO5wF4q0XXRGdYH4So1bwzrXcfR5Jn/njsa6C7VOCkNEH4h1z46kVnU5 X3H6NhTJJqLe7AIQFw0rD2K5vSOxRIKMuyoq6HvR3sQKzdXVIEHVkfGTUqYY/x13F/Sw PchQ== X-Gm-Message-State: AC+VfDx5UhmGlGHnmLuG/ivFBPG6q3ZfnuV+lOgHwgrTybMZSTF3sAjO L61086fgDMls55BsmoaED5xoCpirh88= X-Received: by 2002:a1c:f615:0:b0:3f1:952c:3c70 with SMTP id w21-20020a1cf615000000b003f1952c3c70mr12815163wmc.40.1683796437347; Thu, 11 May 2023 02:13:57 -0700 (PDT) Received: from localhost ([167.98.27.226]) by smtp.gmail.com with ESMTPSA id x18-20020a5d6b52000000b002ff2c39d072sm19889177wrw.104.2023.05.11.02.13.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 May 2023 02:13:57 -0700 (PDT) From: Aidan MacDonald To: broonie@kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/4] regmap-irq: Minor adjustments to .handle_mask_sync() Date: Thu, 11 May 2023 10:13:41 +0100 Message-Id: <20230511091342.26604-4-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20230511091342.26604-1-aidanmacdonald.0x0@gmail.com> References: <20230511091342.26604-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765589239424942982?= X-GMAIL-MSGID: =?utf-8?q?1765589239424942982?= If a .handle_mask_sync() callback is provided it supersedes all inbuilt handling of mask registers, and judging by the commit 69af4bcaa08d ("regmap-irq: Add handle_mask_sync() callback") it is intended to completely replace all default IRQ masking logic. The implementation has two minor inconsistencies, which can be fixed without breaking compatibility: (1) mask_base must be set to enable .handle_mask_sync(), even though mask_base is otherwise unused. This is easily fixed because mask_base is already optional. (2) Unmask registers aren't accounted for -- they are part of the default IRQ masking logic and are just a bit-inverted version of mask registers. It would be a bad idea to allow them to be used at the same time as .handle_mask_sync(), as the result would be confusing and unmaintainable, so make sure this can't happen. Signed-off-by: Aidan MacDonald --- drivers/base/regmap/regmap-irq.c | 65 +++++++++++++++----------------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c index 7cb457af2332..95bf457204bf 100644 --- a/drivers/base/regmap/regmap-irq.c +++ b/drivers/base/regmap/regmap-irq.c @@ -113,23 +113,21 @@ static void regmap_irq_sync_unlock(struct irq_data *data) * suppress pointless writes. */ for (i = 0; i < d->chip->num_regs; i++) { - if (d->mask_base) { - if (d->chip->handle_mask_sync) - d->chip->handle_mask_sync(i, d->mask_buf_def[i], - d->mask_buf[i], - d->chip->irq_drv_data); - else { - reg = d->get_irq_reg(d, d->mask_base, i); - ret = regmap_update_bits(d->map, reg, - d->mask_buf_def[i], - d->mask_buf[i]); - if (ret) - dev_err(d->map->dev, "Failed to sync masks in %x\n", - reg); - } + if (d->chip->handle_mask_sync) + d->chip->handle_mask_sync(i, d->mask_buf_def[i], + d->mask_buf[i], + d->chip->irq_drv_data); + + if (d->mask_base && !d->chip->handle_mask_sync) { + reg = d->get_irq_reg(d, d->mask_base, i); + ret = regmap_update_bits(d->map, reg, + d->mask_buf_def[i], + d->mask_buf[i]); + if (ret) + dev_err(d->map->dev, "Failed to sync masks in %x\n", reg); } - if (d->unmask_base) { + if (d->unmask_base && !d->chip->handle_mask_sync) { reg = d->get_irq_reg(d, d->unmask_base, i); ret = regmap_update_bits(d->map, reg, d->mask_buf_def[i], ~d->mask_buf[i]); @@ -785,28 +783,27 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, for (i = 0; i < chip->num_regs; i++) { d->mask_buf[i] = d->mask_buf_def[i]; - if (d->mask_base) { - if (chip->handle_mask_sync) { - ret = chip->handle_mask_sync(i, - d->mask_buf_def[i], - d->mask_buf[i], - chip->irq_drv_data); - if (ret) - goto err_alloc; - } else { - reg = d->get_irq_reg(d, d->mask_base, i); - ret = regmap_update_bits(d->map, reg, - d->mask_buf_def[i], - d->mask_buf[i]); - if (ret) { - dev_err(map->dev, "Failed to set masks in 0x%x: %d\n", - reg, ret); - goto err_alloc; - } + if (chip->handle_mask_sync) { + ret = chip->handle_mask_sync(i, d->mask_buf_def[i], + d->mask_buf[i], + chip->irq_drv_data); + if (ret) + goto err_alloc; + } + + if (d->mask_base && !chip->handle_mask_sync) { + reg = d->get_irq_reg(d, d->mask_base, i); + ret = regmap_update_bits(d->map, reg, + d->mask_buf_def[i], + d->mask_buf[i]); + if (ret) { + dev_err(map->dev, "Failed to set masks in 0x%x: %d\n", + reg, ret); + goto err_alloc; } } - if (d->unmask_base) { + if (d->unmask_base && !chip->handle_mask_sync) { reg = d->get_irq_reg(d, d->unmask_base, i); ret = regmap_update_bits(d->map, reg, d->mask_buf_def[i], ~d->mask_buf[i]); From patchwork Thu May 11 09:13:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 92446 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4230648vqo; Thu, 11 May 2023 02:25:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ45M2uJ2tYPd3yeLTDfg9K4yG40FiE5OPtYbJ98sASwjeh8wwHq+UuKot/wqpUqf9H1tujq X-Received: by 2002:a17:90a:6ac4:b0:24e:1ae5:1bed with SMTP id b4-20020a17090a6ac400b0024e1ae51bedmr20324785pjm.16.1683797131603; Thu, 11 May 2023 02:25:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683797131; cv=none; d=google.com; s=arc-20160816; b=ZzVLl69F9mSuCck+3KWFJWt8JQ+SsZn32X8SD40lOsLaJK8R7lge7XPeUJA5gbu84q UdVwF2nFRqxoFu3+g5vthbYVX673LFfpYgixbOa/FBPTQMgzFvsZklDdmShAM1uRKLUu jqVIq/a4f9Ljq3hDwZAFjwpHb2yfzSNnrXoDjetDknb+XgxGzRcG16K8mQ44DqdHsXcF cxIlw5fEoIRpH6YqyUXfp49a4e7xAvwvOdTXJ7ll5ZKoQ7G7ifs/5FtyNf7sAmo32Xj6 MUeXtHSFWB/5niWazDxlKU//lpbcAwopS2IkstM02Znz/dUGk37w9o0l9YvoX88BOapo JvPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vtZdgeg9ddbhPRh6PC9cZ0EnGp++W69JKMYWDuC5ZjM=; b=i+HzGbWf55RmkvBBN+9r1RzXY3QOcaLDtrifBwfR3i6nlZS5BvGX05rKUI1juWON4H C89DDJVjywqhJxTtM967E3Caqr1j2yM9++kObWzDtfn1C0TPh3FY9upAlZsbK1MxGmYb Kln2VtW45tCjQGOFxIb/OMCzPqEocZ3kuFCs5DFQJis4oY6l5CfWezlkd/KKKHs4+ivq xOcquupdyii/B5xp5auTTVZD/Kiz+ox0m3Dlw+a2nDVgxhFCjANWt5rt5Tm3VCfigURV YGfY4aYdeT6lW7rdhe0kZAg6K0lHSk0tPBQT0FDb8B5UOgkcBWq0lz811MQoIxXieL3h h2BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=AhK75zZb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t5-20020a17090aba8500b0024681cc291csi8955431pjr.88.2023.05.11.02.25.13; Thu, 11 May 2023 02:25:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=AhK75zZb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237375AbjEKJOQ (ORCPT + 99 others); Thu, 11 May 2023 05:14:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229538AbjEKJOB (ORCPT ); Thu, 11 May 2023 05:14:01 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F195B2126 for ; Thu, 11 May 2023 02:13:59 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3f475366514so13403995e9.2 for ; Thu, 11 May 2023 02:13:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683796438; x=1686388438; 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=vtZdgeg9ddbhPRh6PC9cZ0EnGp++W69JKMYWDuC5ZjM=; b=AhK75zZbjGAdW/dYUEU3Goj+tB4VJJrBzSM4Vdb5pqMRkj37o9FXlra9lcfJzDc5Mp qXuPVOYPMBVor3UCpiGhOq6iwERosDJUgBqbZrlh+0v/8GuyaS0fdaQPDmoQiqQGeK1e YsEIZfLMLe5xTzDFLMZmB4PCC5wBL3W7DfqiV3GSGZYl64Z0uRAV+8c41cdvxiCvL3y5 McbkBJJmu55RhEkqK2puHTfnpUtkQM/nuBwRXqrz4z/I7lVXt3DPNXafgg0GY9mhhJGQ V8H7Cdo2Pn6CncoUF6VHxgo5WjtBgRrSh6fFTiihH2hVRWfmPL0rKy52/nUdOHbHXzrd GtKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683796438; x=1686388438; 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=vtZdgeg9ddbhPRh6PC9cZ0EnGp++W69JKMYWDuC5ZjM=; b=jA7B+A09QGjoFTSpP4vetR7z33OKcB/Sc6qoMphxvAlY3C/nCWoWmzuPXsR03YKtDp qrLcQgZ86T6iCOI7w2OWwbaRMGGyc69qWS3hvtBIjDxgqnSuOEbN8bVP5L9cIBc6WoII 9od/DUicu6ljZf3yZ6zmYVCL7+t3epq7S/pqK6lvCFvqW2sT+K7aiCG6rMHomlQ7Ma5g tN4JjLfwcqcNm82xkIrX5tA4SNbRLeE+mEKn1Kzy9ddqBheq5QV2I3NmDJ232aZZmBEC 0uA3SD7oDlYF/ii1LeefNYGSRzMoMYNO0UGnOGUOhel+Bqz/4tfa8RIqKc0VGs62NyVj jeaQ== X-Gm-Message-State: AC+VfDxUfRGDNhGXlba/Aev4w4mrwUr2Hdrads7uzhp0Qv9miuYqBW19 dEr69W9KfWgaohEHV74MzZ8= X-Received: by 2002:a05:600c:24ce:b0:3f2:5641:3d4 with SMTP id 14-20020a05600c24ce00b003f2564103d4mr14102169wmu.33.1683796438339; Thu, 11 May 2023 02:13:58 -0700 (PDT) Received: from localhost ([167.98.27.226]) by smtp.gmail.com with ESMTPSA id e1-20020adfdbc1000000b0030795249ffasm12304958wrj.92.2023.05.11.02.13.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 May 2023 02:13:57 -0700 (PDT) From: Aidan MacDonald To: broonie@kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/4] regmap-irq: Drop backward compatibility for inverted mask/unmask Date: Thu, 11 May 2023 10:13:42 +0100 Message-Id: <20230511091342.26604-5-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20230511091342.26604-1-aidanmacdonald.0x0@gmail.com> References: <20230511091342.26604-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765589260811912150?= X-GMAIL-MSGID: =?utf-8?q?1765589260811912150?= All users must now specify .mask_unmask_non_inverted = true to ensure they are using the expected semantics: 1s disable IRQs in the mask registers, and enable IRQs in the unmask registers. Signed-off-by: Aidan MacDonald --- drivers/base/regmap/regmap-irq.c | 44 ++++++++------------------------ 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c index 95bf457204bf..330da5d6c8c3 100644 --- a/drivers/base/regmap/regmap-irq.c +++ b/drivers/base/regmap/regmap-irq.c @@ -30,9 +30,6 @@ struct regmap_irq_chip_data { int irq; int wake_count; - unsigned int mask_base; - unsigned int unmask_base; - void *status_reg_buf; unsigned int *main_status_buf; unsigned int *status_buf; @@ -118,8 +115,8 @@ static void regmap_irq_sync_unlock(struct irq_data *data) d->mask_buf[i], d->chip->irq_drv_data); - if (d->mask_base && !d->chip->handle_mask_sync) { - reg = d->get_irq_reg(d, d->mask_base, i); + if (d->chip->mask_base && !d->chip->handle_mask_sync) { + reg = d->get_irq_reg(d, d->chip->mask_base, i); ret = regmap_update_bits(d->map, reg, d->mask_buf_def[i], d->mask_buf[i]); @@ -127,8 +124,8 @@ static void regmap_irq_sync_unlock(struct irq_data *data) dev_err(d->map->dev, "Failed to sync masks in %x\n", reg); } - if (d->unmask_base && !d->chip->handle_mask_sync) { - reg = d->get_irq_reg(d, d->unmask_base, i); + if (d->chip->unmask_base && !d->chip->handle_mask_sync) { + reg = d->get_irq_reg(d, d->chip->unmask_base, i); ret = regmap_update_bits(d->map, reg, d->mask_buf_def[i], ~d->mask_buf[i]); if (ret) @@ -645,6 +642,9 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, if (chip->clear_on_unmask && (chip->ack_base || chip->use_ack)) return -EINVAL; + if (chip->mask_base && chip->unmask_base && !chip->mask_unmask_non_inverted) + return -EINVAL; + for (i = 0; i < chip->num_irqs; i++) { if (chip->irqs[i].reg_offset % map->reg_stride) return -EINVAL; @@ -733,28 +733,6 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, d->chip = chip; d->irq_base = irq_base; - if (chip->mask_base && chip->unmask_base && - !chip->mask_unmask_non_inverted) { - /* - * Chips that specify both mask_base and unmask_base used to - * get inverted mask behavior by default, with no way to ask - * for the normal, non-inverted behavior. This "inverted by - * default" behavior is deprecated, but we have to support it - * until existing drivers have been fixed. - * - * Existing drivers should be updated by swapping mask_base - * and unmask_base and setting mask_unmask_non_inverted=true. - * New drivers should always set the flag. - */ - dev_warn(map->dev, "mask_base and unmask_base are inverted, please fix it"); - - d->mask_base = chip->unmask_base; - d->unmask_base = chip->mask_base; - } else { - d->mask_base = chip->mask_base; - d->unmask_base = chip->unmask_base; - } - if (chip->irq_reg_stride) d->irq_reg_stride = chip->irq_reg_stride; else @@ -791,8 +769,8 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, goto err_alloc; } - if (d->mask_base && !chip->handle_mask_sync) { - reg = d->get_irq_reg(d, d->mask_base, i); + if (chip->mask_base && !chip->handle_mask_sync) { + reg = d->get_irq_reg(d, chip->mask_base, i); ret = regmap_update_bits(d->map, reg, d->mask_buf_def[i], d->mask_buf[i]); @@ -803,8 +781,8 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, } } - if (d->unmask_base && !chip->handle_mask_sync) { - reg = d->get_irq_reg(d, d->unmask_base, i); + if (chip->unmask_base && !chip->handle_mask_sync) { + reg = d->get_irq_reg(d, chip->unmask_base, i); ret = regmap_update_bits(d->map, reg, d->mask_buf_def[i], ~d->mask_buf[i]); if (ret) {