From patchwork Wed Feb 15 09:52:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 57459 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp100431wrn; Wed, 15 Feb 2023 01:58:09 -0800 (PST) X-Google-Smtp-Source: AK7set+Le7cMwxsQ8+XCXuAI15I/cKKX3EWfAof7QNi2sVrzZT/dWGaC/sEG6qLDFQeH8gaO99TS X-Received: by 2002:a05:6a20:3ca6:b0:bc:50a6:5944 with SMTP id b38-20020a056a203ca600b000bc50a65944mr1644984pzj.38.1676455089610; Wed, 15 Feb 2023 01:58:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676455089; cv=none; d=google.com; s=arc-20160816; b=hI9jcmjztAWXfX05ke9hNlELc4iGSZB6n1j5O7DcxqFEsP8pH6hPw19o/jLLAS/oSb QRG8vaOoM70wL82DkE6uWl82hA787jxIJwC9iqbvkmCsMd0lewuYVrWherBaE01QIf8M TbqBeafr0ls2H4YiUhoMXp5w6bjEFBLjSaEtajyxt6wzSlUmDha9lUr9T4k3bk/MVtnX PJreY+3aQ1F+HEsb/p/nkrdo6QxC446NvKa5VH2VG1idT55cm57mibZKQbjFsK0/LhGY ObCNUHDPPUIV0CKCXD5KYDIEdKn9jivamOhEewFkn7H1nxJCdyD+nUepRF/aZsw+KNzH 3Xcw== 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 :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=917TbSorXv9GVu/+ZW9arvslQQDDR7WNCOVqfSHfEUE=; b=ONDQ3206pfU9TKiHYs4OHrxekITLcnkq8/O73sp5L92nxEvVMFc61p/paMDcrM+uta O0X+PDUm26PCCGZzwJbwSm4ZdCDUoPKPdzAczxqNCZDhz/M8zl+2zi1KFzoD9VH9nSje mgnVM0smtd1kp5tUVBlu9KsMlar52oPg82Jyfbcwk0AUVElbM87rLqcYZk+MPDCrZfpQ urN2Clxnt6r15WaWNLkV2SaBLWTikbOxxIEm3QmI/HcmkXfM/jFobBIOAHqVTyAqf8em tzYErolxTZs+SjgBXaCD1LU9XFR5Xski1nDO1Sfdn6nGy8+37WB5ZmjRuGHQYhlBY2sh kw+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tq-group.com header.s=key1 header.b=LMC1JY4W; dkim=pass header.i=@tq-group.com header.s=key1 header.b=IZ5Z6z9G; 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=NONE dis=NONE) header.from=tq-group.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bu19-20020a632953000000b004fb98290dbdsi6023741pgb.50.2023.02.15.01.57.56; Wed, 15 Feb 2023 01:58:09 -0800 (PST) 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=@tq-group.com header.s=key1 header.b=LMC1JY4W; dkim=pass header.i=@tq-group.com header.s=key1 header.b=IZ5Z6z9G; 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=NONE dis=NONE) header.from=tq-group.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234072AbjBOJxA (ORCPT + 99 others); Wed, 15 Feb 2023 04:53:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231750AbjBOJw7 (ORCPT ); Wed, 15 Feb 2023 04:52:59 -0500 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3EEEA5D6; Wed, 15 Feb 2023 01:52:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1676454777; x=1707990777; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=917TbSorXv9GVu/+ZW9arvslQQDDR7WNCOVqfSHfEUE=; b=LMC1JY4WA1O+Ti0Xy/11HbtABRUOaB3ei2QIbAxH14XOQmwfhir8OSw0 JGqQ7cJM708ALPId3WKKNJpd/+zozmXd4y/zv9sKf2A/axIKfibJml9pJ hh5oLsim7yzat6Z51uY859R3rjhn4j0rpPTkaBWu6rMGKVy3y4ep/vIMU UEBGVYRtyCim7EpWLmMGvM5a9mOmSwESV2ee9ihvuNGYUiwdTr0LGX4gC f4eNAfmTXwlD+mhei688aMXevCbe/KfqlN2AJ4HdQapufSoPxDsyUpSTz lW9LNGP/FfKUd/p9vZ5IXrWOGl14CmfPrOrD5XbXu9K3RAPA0OEAkQg8r Q==; X-IronPort-AV: E=Sophos;i="5.97,299,1669071600"; d="scan'208";a="29095925" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 15 Feb 2023 10:52:55 +0100 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Wed, 15 Feb 2023 10:52:55 +0100 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Wed, 15 Feb 2023 10:52:55 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1676454775; x=1707990775; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=917TbSorXv9GVu/+ZW9arvslQQDDR7WNCOVqfSHfEUE=; b=IZ5Z6z9GzIoEGqIkqkYOIwzfxLkJfFQ7s7j0GMTZazX7eY9pPbQQMbxe NemGbr5Q1pjFQTnX+4ws5ABzKi+Ard5dq19ZGkjtvMM38ZQ0ih1ZmEaYI xNYVvq23onRRun/rFL02cVrOBYkr2Ze1GGEP0VylXWDgNwNsv+2tWG9VX iWpHLB+FtrkJAveT1sf5a8fffugFNzKQFYn0gckZSPwtyl+JKNSl/+6LL OBO6Wzyf4oUobL/6AU6IMrZ6GVlanzHDgn49/mpPK2O0zaebJC31fUqA5 Ju7H15gIKpm3MOE3nT+WpqX9P/pQai8ehBaSt2/yW69ty7hGE/y1+rG+z A==; X-IronPort-AV: E=Sophos;i="5.97,299,1669071600"; d="scan'208";a="29095924" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 15 Feb 2023 10:52:55 +0100 Received: from steina-w.tq-net.de (unknown [10.123.53.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by vtuxmail01.tq-net.de (Postfix) with ESMTPSA id 1AC11280056; Wed, 15 Feb 2023 10:52:55 +0100 (CET) From: Alexander Stein To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, andy.shevchenko@gmail.com Cc: Alexander Stein Subject: [PATCH v3 1/1] gpio: vf610: make irq_chip immutable Date: Wed, 15 Feb 2023 10:52:49 +0100 Message-Id: <20230215095249.246911-1-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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?1757890571974636158?= X-GMAIL-MSGID: =?utf-8?q?1757890571974636158?= Since recently, the kernel is nagging about mutable irq_chips: "not an immutable chip, please consider fixing it!" Drop the unneeded copy, flag it as IRQCHIP_IMMUTABLE, add the new helper functions and call the appropriate gpiolib functions. Signed-off-by: Alexander Stein Reviewed-by: Andy Shevchenko Reviewed-by: Linus Walleij --- Changes in v3: * Use calculated gpio_num instead of accessing struct member drivers/gpio/gpio-vf610.c | 41 ++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c index a429176673e7..d3f3a69d4907 100644 --- a/drivers/gpio/gpio-vf610.c +++ b/drivers/gpio/gpio-vf610.c @@ -30,7 +30,6 @@ struct fsl_gpio_soc_data { struct vf610_gpio_port { struct gpio_chip gc; - struct irq_chip ic; void __iomem *base; void __iomem *gpio_base; const struct fsl_gpio_soc_data *sdata; @@ -207,20 +206,24 @@ static int vf610_gpio_irq_set_type(struct irq_data *d, u32 type) static void vf610_gpio_irq_mask(struct irq_data *d) { - struct vf610_gpio_port *port = - gpiochip_get_data(irq_data_get_irq_chip_data(d)); - void __iomem *pcr_base = port->base + PORT_PCR(d->hwirq); + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct vf610_gpio_port *port = gpiochip_get_data(gc); + irq_hw_number_t gpio_num = irqd_to_hwirq(d); + void __iomem *pcr_base = port->base + PORT_PCR(gpio_num); vf610_gpio_writel(0, pcr_base); + gpiochip_disable_irq(gc, gpio_num); } static void vf610_gpio_irq_unmask(struct irq_data *d) { - struct vf610_gpio_port *port = - gpiochip_get_data(irq_data_get_irq_chip_data(d)); - void __iomem *pcr_base = port->base + PORT_PCR(d->hwirq); + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct vf610_gpio_port *port = gpiochip_get_data(gc); + irq_hw_number_t gpio_num = irqd_to_hwirq(d); + void __iomem *pcr_base = port->base + PORT_PCR(gpio_num); - vf610_gpio_writel(port->irqc[d->hwirq] << PORT_PCR_IRQC_OFFSET, + gpiochip_enable_irq(gc, gpio_num); + vf610_gpio_writel(port->irqc[gpio_num] << PORT_PCR_IRQC_OFFSET, pcr_base); } @@ -237,6 +240,17 @@ static int vf610_gpio_irq_set_wake(struct irq_data *d, u32 enable) return 0; } +static const struct irq_chip vf610_irqchip = { + .name = "gpio-vf610", + .irq_ack = vf610_gpio_irq_ack, + .irq_mask = vf610_gpio_irq_mask, + .irq_unmask = vf610_gpio_irq_unmask, + .irq_set_type = vf610_gpio_irq_set_type, + .irq_set_wake = vf610_gpio_irq_set_wake, + .flags = IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + static void vf610_gpio_disable_clk(void *data) { clk_disable_unprepare(data); @@ -249,7 +263,6 @@ static int vf610_gpio_probe(struct platform_device *pdev) struct vf610_gpio_port *port; struct gpio_chip *gc; struct gpio_irq_chip *girq; - struct irq_chip *ic; int i; int ret; @@ -315,14 +328,6 @@ static int vf610_gpio_probe(struct platform_device *pdev) gc->direction_output = vf610_gpio_direction_output; gc->set = vf610_gpio_set; - ic = &port->ic; - ic->name = "gpio-vf610"; - ic->irq_ack = vf610_gpio_irq_ack; - ic->irq_mask = vf610_gpio_irq_mask; - ic->irq_unmask = vf610_gpio_irq_unmask; - ic->irq_set_type = vf610_gpio_irq_set_type; - ic->irq_set_wake = vf610_gpio_irq_set_wake; - /* Mask all GPIO interrupts */ for (i = 0; i < gc->ngpio; i++) vf610_gpio_writel(0, port->base + PORT_PCR(i)); @@ -331,7 +336,7 @@ static int vf610_gpio_probe(struct platform_device *pdev) vf610_gpio_writel(~0, port->base + PORT_ISFR); girq = &gc->irq; - girq->chip = ic; + gpio_irq_chip_set_chip(girq, &vf610_irqchip); girq->parent_handler = vf610_gpio_irq_handler; girq->num_parents = 1; girq->parents = devm_kcalloc(&pdev->dev, 1,