Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1176609pxb; Fri, 6 Nov 2020 03:04:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJy5cl+Ui5tDsvw3yf4YJu3WS/bI6Jyp7WhVwQKPLcUe+Nb0gWItExYB3tH44LgMhEueGlJM X-Received: by 2002:a17:907:9d0:: with SMTP id bx16mr1493187ejc.426.1604660660070; Fri, 06 Nov 2020 03:04:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604660660; cv=none; d=google.com; s=arc-20160816; b=Zkp7jnMSHpHajkU3dZ7igzklDRq7Th5YNsaSh6R7J9ISlAAFoZC96TXVOyyM6hQKff ulPYgNqfrOy/d/c2ReQofEKsaPreZgcHqfZwGL5+BKsYrOq0+sDFWNnlKCz2gv54KPKe dWJxUdetstxATv7yI4kXcznNr7mf6XaTpg5FCPK6l/d+ucq1/DuFfWwxNnAUGbxLtbKI rPnIb2qS3PUkjUFz/XfLHme1phS/nCojm9hbHBcoeY4BU2YC8s0HPS4CDDC1hYEu47Sc 6Xbowbj41UFblx1QKxyeCFB3fNDg5kK+Njop2xoFjUtkHfTZl5ub6BZq9T9pBxPXMH4s YX2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=5scwP+FH/3TvdU9cRBPIGfL9OLQBWnAyRxebsQvYQJw=; b=XW9sl8N/lqD0TBlx+43wb2AkP6Mk75+iJmPd7wSp2dcoZVZb51egM2pXu3V2qZQ4zg bXEiBarIBiByHTLP2mljOecjR3dWTtPFadomR93H8f94trNmxaWGGpYgoR5nm9McVRO5 elA8DYECZOsgIVfAwhSFrLO/MzHmZUqejq7R2mpTaf9WzpuNQa2rUpMXeRxo6g2xWtMc zkOg+NCc/4J+FEyTjGg2B3CCVkHFZo70+4vaRQhBTAV1J1HrrZqJG2irjrGbLQCLd5QF 1CB3eIOoEn7alR7ce6BrccomX4GF/JBnfLBq/5PTMs7oAPo8ndEg37oSeC+0zCubUKiK YRAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=K3GEevu5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w15si575922ejk.62.2020.11.06.03.03.53; Fri, 06 Nov 2020 03:04:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@sifive.com header.s=google header.b=K3GEevu5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726942AbgKFLAN (ORCPT + 99 others); Fri, 6 Nov 2020 06:00:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726317AbgKFLAM (ORCPT ); Fri, 6 Nov 2020 06:00:12 -0500 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 877CFC0613CF for ; Fri, 6 Nov 2020 03:00:12 -0800 (PST) Received: by mail-qk1-x741.google.com with SMTP id z6so648943qkz.4 for ; Fri, 06 Nov 2020 03:00:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=5scwP+FH/3TvdU9cRBPIGfL9OLQBWnAyRxebsQvYQJw=; b=K3GEevu5XTiJFobdS3WdtKWhU/wb279WC0tnyvUS0zrqS+1hRZU39kLzr6Rs2Rs4Ct RnA0QI/duInuNOTC8svzJEUEgB+Zy/BsCor7akvZoBtUE5sACyi9u5NFoHdi30UnIM7q zaZ0izVo/c09fKHF4D/7D6TWLdSZ3YT99RFC5TF0OVrbzY8mNmAYKhmnbDOc9Wm+JITd TKUC8zR9IakSoFyRx8uXTFhEOT4hyPv7p7IbpwDVvLZ0O31a4BDmyGxXLApCEI0fA4Tc cRkT8DhvvKS6XCVkl15e2vE37m6na9YhMXtGgvYchipGxSTryUijvuK32I7bIg1y26g5 EUIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=5scwP+FH/3TvdU9cRBPIGfL9OLQBWnAyRxebsQvYQJw=; b=fgs+E4ch13USGLIB74g/dVICNUlOFB4X8kGR1OZWfLKa6QjUl1wWUe1cYMLiN+c6yw hp66nlgKL/bS3LXNSOaMIYxtLyP5WK/BQzyyDv6Z1lfmoA/peewHC2/vZrUG2e6nxYw7 UKk10t1PMI7A4x7Takd/vjCbDXIztYem5uDKy9X+vCV4Qclk3GUnP1s76i2suH8KvWmv mWNDoJ173iA5f1yH4U2L2JP6Af3uhgY8m/IT41tujlJ1h18aRKpcAbYgnY9+3qbt4wey stglPd+Y+kj066x7f6TClqpCVYOcyo/i/68apb2pPrGsnDhq5dy4adJpgoFIVeRdm94g swLw== X-Gm-Message-State: AOAM531cAg8farHBSFXsZy/QrkfF/h/6ZwzRtMm4XuC9cQYtS4+O0ewo AyYaEgCD0F9CjIb4R7z4xxSsW/3Kz+jTaIHxHJBZyA== X-Received: by 2002:a05:620a:697:: with SMTP id f23mr831545qkh.374.1604660411776; Fri, 06 Nov 2020 03:00:11 -0800 (PST) MIME-Version: 1.0 References: <802c8865b70c3bdf70e44d37f14e7767b6495e88.1604631371.git.greentime.hu@sifive.com> In-Reply-To: From: Greentime Hu Date: Fri, 6 Nov 2020 19:00:00 +0800 Message-ID: Subject: Re: [RFC PATCH 1/1] gpio: sifive: To get gpio irq offset from device tree data To: Andy Shevchenko Cc: Linux Kernel Mailing List , Linus Walleij , Bartosz Golaszewski , "open list:GPIO SUBSYSTEM" , linux-riscv , Palmer Dabbelt , Paul Walmsley , Yash Shah Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Andy Shevchenko =E6=96=BC 2020=E5=B9=B411=E6=9C= =886=E6=97=A5 =E9=80=B1=E4=BA=94 =E4=B8=8B=E5=8D=885:25=E5=AF=AB=E9=81=93= =EF=BC=9A > > On Fri, Nov 6, 2020 at 4:59 AM Greentime Hu wro= te: > > > > We can get hwirq number of the gpio by its irq_data->hwirq so that we d= on't > > need to add more macros for different platforms. This patch is tested i= n > > SiFive Unleashed board and SiFive Unmatched board. > > ... > > > + struct sifive_gpio *chip =3D gpiochip_get_data(gc); > > + struct irq_data *d =3D irq_get_irq_data(chip->irq_number[child]= ); > > > + *parent =3D d->hwirq; > > There is an API to get hwirq. > > ... > > > + for (i =3D 0; i < ngpio; i++) > > + chip->irq_number[i] =3D irq_of_parse_and_map(node, i); > > Can't you use platform_get_irq_optional()? > Thank you for reviewing. I would change it like this. diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c index e8cd8741dbae..bfb915bf5d78 100644 --- a/drivers/gpio/gpio-sifive.c +++ b/drivers/gpio/gpio-sifive.c @@ -145,7 +145,7 @@ static int sifive_gpio_child_to_parent_hwirq(struct gpio_chip *gc, { struct sifive_gpio *chip =3D gpiochip_get_data(gc); struct irq_data *d =3D irq_get_irq_data(chip->irq_number[child]); - *parent =3D d->hwirq; + *parent =3D irqd_to_hwirq(d); *parent_type =3D IRQ_TYPE_NONE; return 0; } @@ -202,7 +202,7 @@ static int sifive_gpio_probe(struct platform_device *pd= ev) } for (i =3D 0; i < ngpio; i++) - chip->irq_number[i] =3D irq_of_parse_and_map(node, i); + chip->irq_number[i] =3D platform_get_irq(pdev, i); ret =3D bgpio_init(&chip->gc, dev, 4, chip->base + SIFIVE_GPIO_INPUT_VAL,