Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp164345imm; Mon, 4 Jun 2018 15:05:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJeXm2fjeP1e5zJQ1H6IWqILo/KMXhyb4PnDwWeBj1ngNsXNG84tROSZtO2eWhAbuHlW0QZ X-Received: by 2002:a17:902:24e:: with SMTP id 72-v6mr23110181plc.87.1528149922438; Mon, 04 Jun 2018 15:05:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528149922; cv=none; d=google.com; s=arc-20160816; b=VWzLxQdu4GfXSAmb8czvqTNykj5OuaCUR5t77K9GEsluNI4UaBRDD5bC9eSfr34/Bq fKxLErA2PuCFWgBYpMOoFeyCIVnr9TGi3v2snHYMFPDv7TMSCu7EixRkpVk/+PHb6/NC D/tlxr58l6mzK8NBPfp8b1rPElLDJtfkioQBDNIPMnvuhiySkE34nUJJcetmZodUj+eH UhLRDACxve9fL9ultZ8y1+5GlIiK6AbtI2UKRIU9H98cMxRdpq74MRHrTBssIZdM1v/t 8r1H3iZcWXzc82NVB2AQ9rmboSEOm47lMe+qQ2+oqt4pADqVaTiKNjgSFmUMTGK0ycLw QPfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=oZDQYdW+UDUpR7SicI2Uoq34VKbESGXcgAM2SWlAPjQ=; b=laPUVtrP8cZiQBEDrlDbb+gdMXGPE9jger0WLD4gom6YF0T0cDiL4eswges7xRngMt MaOzJsVnTXvkcle18POO05WPGTwlByZigtqfFKVi3ZpM8nRnyXQZNDvEpUi9uOjRdeK4 shEanJvYWd2HPfjDPxKsfC+Zaj40gBKowewZdb0YUm+sTpyX8WBzpuxHra0zr/ekmYYB +/Cmf2bZD8R0SRMnJ/p+QDQRi1dxqMHLu84dZKG11DMdzXJvWOElJZTQdlPtYUNDLsau DCMiSIDjj9KTov6PIR7tHP9g60vz8KheBoDSXmgXLLcZ3ARZPRJI6zSgenf/f/NSzwA1 whyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gN2nuiqX; 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 189-v6si22291852pfy.293.2018.06.04.15.05.07; Mon, 04 Jun 2018 15:05:22 -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=gN2nuiqX; 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 S1751802AbeFDWEP (ORCPT + 99 others); Mon, 4 Jun 2018 18:04:15 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:39266 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751764AbeFDWEN (ORCPT ); Mon, 4 Jun 2018 18:04:13 -0400 Received: by mail-lf0-f65.google.com with SMTP id t134-v6so329681lff.6 for ; Mon, 04 Jun 2018 15:04:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oZDQYdW+UDUpR7SicI2Uoq34VKbESGXcgAM2SWlAPjQ=; b=gN2nuiqXOPAXk3YXs9+w+00vvKX1NO5IOP0UGohxx+nMIdv7VP8tnqdZgVFJGyDF2N N5T9rD/RU6TdNO2CBaeaHBf4BDDcqiuRVksfZhZ+tN+03IsyKwsu3F+mWpRAgOci90J/ mO8z3Jn5pHnk4FzwvyLvngvA0e7BDN/KdOSztlwpNZeOD+p/QjFfurbKXa9SUnGe9N1l sNYlifVtNODM5DzJAAjjFJ+8bByyn0pWBm6z539emz8GlyY4rm4p4jtl7Axe2b9bRjDx +OtRHrnIuJHMzzLv8maMPRJPwZ2rrqdombUsV+GGC5XlDP6mukTb55e8fp2eEFM37mnC qiWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oZDQYdW+UDUpR7SicI2Uoq34VKbESGXcgAM2SWlAPjQ=; b=VDkS8fw6ZzEca5Z6mj5kRSHRjUBrf6n6chHyYRR0wgwMc9aLRb8DlxS2HJMxC4jV+L RgCEi8G12ri1gobhitSWHLKzQHv1bc6YqiQ4si4IVfcn06Q8nMP8mDXdUmFkjmKd8THg nubp8iNgX8LZNLm0Qk7jid5mv9xrEC3BpPsDEdCq0wTLM1BMRUNn4FmdHKqfXI1iSywz 4DfBSUiKon3wjPlzmtJkHlsx3JwNJWSnITA1eBr568gbl1h/SUNMQktqxF/LnFjw8QjE nVO1wGWoo15f6HmIB40zy94kh4qNmyzkbShix9K44JzTutOeazekchwRCglOTb9e6//1 Ue/w== X-Gm-Message-State: APt69E0YNePbmVWs3OMo20lPaDLJgfTY+IvCX9THyai1yZGwkeX1vOjm AXEK4oXulejM+gkupycZIXs= X-Received: by 2002:a2e:43db:: with SMTP id z88-v6mr12546819lje.24.1528149851523; Mon, 04 Jun 2018 15:04:11 -0700 (PDT) Received: from z50.localnet (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id p18-v6sm10377353lfd.91.2018.06.04.15.04.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 15:04:10 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon Cc: Richard Weinberger , H Hartley Sweeten , Tony Lindgren , linux-kernel@vger.kernel.org, Marek Vasut , Krzysztof Halasa , Shreeya Patel , Arvind Yadav , Brian Norris , David Woodhouse , linux-mtd@lists.infradead.org Subject: Re: [PATCH 5/6 v2] mtd: rawnand: ams-delta: use GPIO lookup table Date: Mon, 04 Jun 2018 18:48:08 +0200 Message-ID: <1716431.jBl9UCSIdH@z50> In-Reply-To: <20180604115543.3be75717@bbrezillon> References: <1582841.uoaVdad1fL@z50> <20180604115543.3be75717@bbrezillon> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, June 4, 2018 11:55:43 AM CEST Boris Brezillon wrote: > On Wed, 30 May 2018 22:39:03 +0200 > > Janusz Krzysztofik wrote: > > On Wednesday, May 30, 2018 7:52:20 PM CEST Boris Brezillon wrote: > > > On Wed, 30 May 2018 19:43:09 +0200 > > > > > > Janusz Krzysztofik wrote: > > > > On Wednesday, May 30, 2018 11:05:00 AM CEST Boris Brezillon wrote: > > > > > Hi Janusz, > > > > > > > > Hi Boris, > > > > > > > > > On Sat, 26 May 2018 00:20:45 +0200 > > > > > > > > > > Janusz Krzysztofik wrote: > > > > > > ... > > > > > > Changes since v1: > > > > > > - fix handling of devm_gpiod_get_optional() return values - thanks > > > > > > to > > > > > > > > > > > > Andy Shevchenko. > > > > > > > > > > Can you put the changelog after the "---" separator so that it does > > > > > not > > > > > appear in the final commit message? > > > > > > > > Yes, sure, sorry for that. > > > > > > > > > > +err_gpiod: > > > > > > + if (err == -ENODEV || err == -ENOENT) > > > > > > + err = -EPROBE_DEFER; > > > > > > > > > > Hm, isn't it better to make gpiod_find() return > > > > > ERR_PTR(-EPROBE_DEFER) > > > > > here [1]? At least, ENOENT should not be turned into EPROBE_DEFER, > > > > > because it's returned when there's no entry matching the requested > > > > > gpio > > > > > in the lookup table, and deferring the probe won't solve this > > > > > problem. > > > > > > > > ENOENT is also returned when no matching lookup table is found. That > > > > may > > > > happen if consumer dev_name stored in the table differs from dev_name > > > > assigned to the consumer by its bus, the platform bus in this case. > > > > For > > > > that reason I think the consumer dev_name should be initialized in the > > > > table after the device is registered, when its actual dev_name can be > > > > obtained. If that device registration happens after the driver is > > > > already > > > > registered, e.g., at late_initcall, the device is probed before its > > > > lookup table is ready. For that reason returning EPROBE_DEFER seems > > > > better to me even in the ENOENT case. > > > > > > Sorry, I don't get it. Aren't GPIO lookup tables supposed to be declared > > > in board files, especially if the GPIO is used by a platform device? > > > When would you have a lookup table registered later in the init/boot > > > process? > > > > When e.g. I'd like to register my GPIO consumer platform device at > > late_initcall for some reason, and I'm not sure what exact dev_name my > > consomer will be registered with by the platform bus. > > You should know the name before the device is registered. What if I use PLATFORM_DEVID_AUTO? For other cases, if bus specific names of devices were supposed to be known before registration, bus drivers should export functions returning those names from initialized bus specific device structures or their components while they don't. Under such circumstances, we end up hardcoding device names based on our knowledge of bus internals if we need to specify them in advance, and those internals are not guaranteed to never change. > > In that case I think I > > should assign dev_name to the lookup table after the consumer device is > > registered and its exact dev_name can be obtained, then register the > > table, > > I'm pretty sure it's not supposed to work like that. Resources attached > to a device should be defined before the device is registered, not > after, What do you mean by resources attached to a device? I don't think we should consider GPIO lookup tables as consumer device resources. Those tables are registered separately from consumer device registration and I know of no requirement for registering them in advance. Maybe I'm missing something. Let's have a look at regulators. There are no separately registered regulator lookup tables, instead regulator consumer supply tables are attached to bus specific device structures of regulator devices, not their consumers, hence registered together with providers, not consumers. Will you still call those tables 'resources attached to' consumers? As far as I can see, regulator_get() never returns -EINVAL, only -ENODEV or - EPROBE_DEFER. However, gpiod_get() can also return -EINVAL. Maybe it shouldn't, but it does, and I'm just trying to adopt to that in order to not break a driver I'm trying to update. > simply because when you call platform_device_register(), the > device might be directly bind to the driver before the > platform_device_register() calls return, and the driver will fail to > probe the device if it doesn't find the GPIO it needs. That's exactly the case I'm talking about, but my conclusion is different: the driver should fail softly so the device is probed again later, as long as I'm not wrong the no requirement exists for registering GPIO lookup tables before related consumers are registered. If I' missing something or you are still not convinced, I'll try to resolve issues with the device I see in a different way and submit a new patch that hopefully matches your requirements. Thanks, Janusz