Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2771337imm; Wed, 3 Oct 2018 08:56:58 -0700 (PDT) X-Google-Smtp-Source: ACcGV62j2rFti1EnC5i+mUDJkZzY49oNZ+p3WMTaruMHJGXiDfqJkyNq/C7+qpop+kb0A0PcCpHo X-Received: by 2002:a17:902:a985:: with SMTP id bh5-v6mr2302692plb.193.1538582218832; Wed, 03 Oct 2018 08:56:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538582218; cv=none; d=google.com; s=arc-20160816; b=DAQs1Yg+XNHcY9EbAxtKB76fB2ocMVzWqDOAlDxqQw5wYbpX+2e1hbEvqw9Y3WJ+dB 8dmApFyS5cfi2qbSwc+O3TdCMIsfWO+wnJ8LtqCd2LdNQf+kYSTyTwtLeX9NVY73zYNP LgAr7gX43YQf2mXKF3QwA1K9pQqnk4rQbXDfSxbgm1pZ9Kx149wqsvveMXI/4wIygTiG Si0TG0AlMzqCSrRG/RoOZMcp8K16lRr7P1wMgJuhg2RqpUaNZZmkAHzdzv2muoNyFljy Cu1+MdJOEHn0rvgjmXPzpo5naNd7UpBMoy029vh+vyPBovqA+uDA443oxgNgBBFosBBm LLJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=N/3MzC4UtSDm27UecYvCUrDDNblZ9QnRKZvGaUz8yCA=; b=w0RYYGG7s4bO4NXLqlM++LRmOsT3f7c2CpmCQvvSSlp7sefuK/IkmfwRG2co147t5l BwcCzHupY529sDENHA2I0XmXP/XqYaedD/42Jz49X9Gcr2t8nmNdcONZUZ8Lkld2Kgrs p64B2VqeRUu8VCxaF3igM0thseDnGphMET/VcSfesM3GB1SyUb8h941xnpIvGvj1p1dd MSTpWjeuiPHgRN1/d66Re9HqA818P9xS6TdADCqNcAJw5grzVzNSULcpHG/0z0yE322u HX655+sMTMDVVSyIrRD7q6NrCkXbfA4NKdQKgYHMrOBxNmtOvuGbssqaK3g7xagYZCHY UzMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Av52P7Hj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h22-v6si1548804pgi.368.2018.10.03.08.56.43; Wed, 03 Oct 2018 08:56:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Av52P7Hj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727417AbeJCWpV (ORCPT + 99 others); Wed, 3 Oct 2018 18:45:21 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:38939 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726833AbeJCWpV (ORCPT ); Wed, 3 Oct 2018 18:45:21 -0400 Received: by mail-lf1-f65.google.com with SMTP id w21-v6so4528819lff.6 for ; Wed, 03 Oct 2018 08:56:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=N/3MzC4UtSDm27UecYvCUrDDNblZ9QnRKZvGaUz8yCA=; b=Av52P7HjWbPXAHJUnghTUj6qLx4UVGQbvxSfRdOlyodm07BBCHehusPGIdljKY+cF4 g7fJjdWXbvr4b4B7vKYYgNXGtAcF4LUKrPVR5wbbiGY3a5+Dyzat8Qa5WbPMclGTEx1V uRVg+gPhGVJElNaLCRjLpDxiPvyvq7tx4hVZ7hUlbnfHm7jexeRGtUNPjGRb0LBJdWcn PMXI+D19l0v0WTQ+JXM1wYG/blUMnRkdClD0Qgvdvohmo4yphnbFBmTBYO9XcuXtfGt3 2CHnocbjY1PrhuxTlCmxleuK2nnM2X88tC1dLoOf31KmnZAE4FvYor+t1IUvvIdcb4Uk fvCQ== 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; bh=N/3MzC4UtSDm27UecYvCUrDDNblZ9QnRKZvGaUz8yCA=; b=YGGFZ84QUy5YOLxd47N8KOk/ae5s7IHjAehKcUQfbF7L5zRl21dTFihP2XoEAmupeh oklLrLporQ17t7xHhH1jNr2jQy2kBjcA/9uaBy4CHaJqYvRrUJriJM6GvdFuBvkg4Cw8 SBkQNWq/ZgSpPM3vU+m53q/XZeujRxO3BhNFRRrpuHHH2F1zMXx2E72EUkd9dqoMrju2 ben7XhYdmBPHV3wywM/nPpHEECOWgBPHO3UTT6yWjN9npb4SSEaoCI6W9QUjGYOTp5RJ 1KY8G4TDlvzrzFUzmjXn4WLrAzrJGnvRhVP9Ha9JLOIoQCgn7VHxV9eNLbrpCvGEsVpE Z9Ig== X-Gm-Message-State: ABuFfojLdTiUaMFDziKRuRmraxrRZ0DnO7r8BJowOd5hqWHCprMt3fpw NSxB00Rw6Ae8nhRQtZlZh8ACTO0HjtfhCuAXlag= X-Received: by 2002:a19:169d:: with SMTP id 29-v6mr1386503lfw.151.1538582180551; Wed, 03 Oct 2018 08:56:20 -0700 (PDT) MIME-Version: 1.0 References: <20181001124351.31615-1-ricardo.ribalda@gmail.com> <20181001124351.31615-6-ricardo.ribalda@gmail.com> <20181003171114.51ab47b8@bbrezillon> <20181003171727.145e7e41@bbrezillon> In-Reply-To: <20181003171727.145e7e41@bbrezillon> From: Ricardo Ribalda Delgado Date: Wed, 3 Oct 2018 17:56:03 +0200 Message-ID: Subject: Re: [PATCH v4 6/8] mtd: maps: gpio-addr-flash: Convert to gpiod To: Boris Brezillon Cc: Zhouyang Jia , LKML , Marek Vasut , linux-mtd@lists.infradead.org, Richard Weinberger , Brian Norris , David Woodhouse Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Boris On Wed, Oct 3, 2018 at 5:17 PM Boris Brezillon wrote: > > On Wed, 3 Oct 2018 17:11:14 +0200 > Boris Brezillon wrote: > > > Hi Ricardo, > > > > On Mon, 1 Oct 2018 14:43:49 +0200 > > Ricardo Ribalda Delgado wrote: > > > > > @@ -248,14 +252,19 @@ static int gpio_flash_probe(struct platform_device *pdev) > > > > > > i = 0; > > > do { > > > - if (devm_gpio_request(&pdev->dev, state->gpio_addrs[i], > > > - DRIVER_NAME)) { > > > + unsigned int *gpio_id = (unsigned int *)gpios->start; > > > + > > > + if (devm_gpio_request_one(&pdev->dev, gpio_id[i], GPIOD_OUT_LOW, > > > + DRIVER_NAME)) { > > > dev_err(&pdev->dev, "failed to request gpio %d\n", > > > - state->gpio_addrs[i]); > > > + gpio_id[i]); > > > return -EBUSY; > > > } > > > - gpio_direction_output(state->gpio_addrs[i], 0); > > > - } while (++i < state->gpio_count); > > > + > > > + state->gpios->desc[i] = gpio_to_desc(gpio_id[i]); > > > + if (!state->gpios->desc[i]) > > > + return -EINVAL; > > > + } while (++i < state->gpios->ndescs); > > > > Actually, I was thinking about using devm_gpiod_get_array() here and > > defining a gpio lookup table in the board file registering the device. > > This way, adding support for DT based parsing is transparent. > > It's actually easier than I thought since no one is registering such a > device, so all you have to do is call devm_gpiod_get_array() and have a > struct gpio_descs pointer in struct async_state. That is what I do in patch 8/8 for DT based parsing. I am am doing the gpio_to_desc and other to maintain compatibility with old platform board files (in and out tree). I think is important to maintain that compatibility, but you decide ;) Cheers -- Ricardo Ribalda