Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp628117ybc; Tue, 19 Nov 2019 06:48:36 -0800 (PST) X-Google-Smtp-Source: APXvYqyqRni3Sjz9xG1akZ8uTp+jmKnFdSlNNbuqwNE9aydFujSAnd3RET48Afx/SpQ2T4NF38sU X-Received: by 2002:a17:906:5211:: with SMTP id g17mr36103951ejm.60.1574174916045; Tue, 19 Nov 2019 06:48:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574174916; cv=none; d=google.com; s=arc-20160816; b=Brn6dmbGuS1Z2M7+B1rRi/x1wU1J3Uk5y+fF+pnl+wkYPEDJGF7WVEDA5YEDHWPyWG g3HtmQ/WfOPLN5Gx/0+AOzuKhY6WP8YQufC1Qde30NKkHue9/WxnyJJ+RuoSbycnp20v C8kNlFHbkxl4qgaVnV8MVmFJ1PtCeCuS09XBDgA5WZdWb28FxydzroDXo4atCimRiW71 AFGYNlr8LNfHUWceXO4gC8MrQ1RamIiQXpO2UijjppGcDXp3mBmXy9UmpL4b6XXTdL2M 0vtDxFncyCvtWcyZQR77SBPbuPssOoLu09YtfTNpkwbX37R1vpxqpmM/lZXL5/yqPqKc o8Qg== 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=3HGForXYrnzKKwFOiKAr5qSOuuqdU2k4wA1CfbalcbQ=; b=Yy5kw9d+oHdDNiEsN0ee6tGzkhp53Vx0iYLlx0ut/ceU8Wj7gVbJ0mDgpEIg8xScvh 6SED42SO7ulFJmLJHrK1Up6Z0n2PHMz6fNXkIOs8uD2qxAauaVekBJb483clTE/FLl9Q UpxC0Z/uOa42bMsp2895gDtS5ch0vUD6NeQr9/WbvYY2BCA/HGyUNz0U8w6vQZmJrQm0 6/VzTnidXlf7Hjh2CCoYBB7KXdqqtZh0sTW0X482vyyHE+D+TgbX667ST/1yFdaIbkKA qhb6sI1wfhy3VSPhOVNghN7d8lw1jzEJo1+SVbPVx5eCEdplYmgnzT6Rdo8hLkITx1qu 3OSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="o8/7NQNC"; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gu7si14144120ejb.405.2019.11.19.06.48.10; Tue, 19 Nov 2019 06:48:36 -0800 (PST) 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=@linaro.org header.s=google header.b="o8/7NQNC"; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728323AbfKSOoD (ORCPT + 99 others); Tue, 19 Nov 2019 09:44:03 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:37001 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728313AbfKSOoC (ORCPT ); Tue, 19 Nov 2019 09:44:02 -0500 Received: by mail-lf1-f66.google.com with SMTP id b20so17294259lfp.4 for ; Tue, 19 Nov 2019 06:44:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3HGForXYrnzKKwFOiKAr5qSOuuqdU2k4wA1CfbalcbQ=; b=o8/7NQNCdscgcAzoUXE+jNTk/DJagMvuw5Z5JaWY30/Z/muA51WNthzWcG+/MtHPBP ny6dVonMKRnen+it9ngeeXt1nR2rMvm4MxOKRsW5mUt9arjSEhZM4tMEKXJRcjqQx8t8 UwAYBSUYodJCrJjJxwSpcnYicu7wJuE+0By/ddHV3P+BQR3Lp7t+G1kjRHchnAx24qMJ SA9vVP9M+gd+aI6o0RnPHJ0b1q0yRooX6UUA86zcAYvWai/ge//6X1NsbP93Bwm+VLIX BqN6l+PH8M5Cw6YFIvmW/Ygb/vNNIT3uU4vu68nKXH9wt785xkMpxaAXLMSC4C3ZTGrO vEUw== 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=3HGForXYrnzKKwFOiKAr5qSOuuqdU2k4wA1CfbalcbQ=; b=saekyfG2gv23MXI1A9UN1tuxzeRygEmp1NDrugZQzPDLOAak1gRB7d7JiADdH/R3W8 P52VEqM/PYShG19TwJFPo7HpbGzMMK6Yjs0U42oX8FWn4Y9rLQcYNbMCnZ7iLi79R8nG Cnfqsc2nNgoEW14sOp0JcI8sD+ajoVBRsNSfdHFKQcxSIysaEKwwz45LqQ2/q1mZ9YrP /DIprE/PnkN4yPagaJyNznbfR6p1wCoWqOLUyneRlijMnV81DyRzDdxrWrABSxdM+tJQ DL2JGeXyZ8OQTxNOrRi9XXzras41+GQewK1QGCbjPBQSrbXz6Ot5Hirj1sw7fIJQscpu EF3w== X-Gm-Message-State: APjAAAWXTDInRF7SqTNd1ccqjjWLkKuysjbAIZ6I4sitzBlHbjep3gOv WyXr2lfNmbjBv4p5V7CPFKRlPC2GfC1f4VhTihh8eA== X-Received: by 2002:a19:651b:: with SMTP id z27mr4166813lfb.117.1574174639988; Tue, 19 Nov 2019 06:43:59 -0800 (PST) MIME-Version: 1.0 References: <8dd9dad2765d47fd6c6fec20566326d00e48a696.1574059625.git.matti.vaittinen@fi.rohmeurope.com> In-Reply-To: <8dd9dad2765d47fd6c6fec20566326d00e48a696.1574059625.git.matti.vaittinen@fi.rohmeurope.com> From: Linus Walleij Date: Tue, 19 Nov 2019 15:43:47 +0100 Message-ID: Subject: Re: [PATCH v5 10/16] gpio: devres: Add devm_gpiod_get_parent_array To: Matti Vaittinen Cc: Matti Vaittinen , Lee Jones , Jacek Anaszewski , Pavel Machek , Dan Murphy , Rob Herring , Mark Rutland , Liam Girdwood , Mark Brown , Jonathan Corbet , Michael Turquette , Stephen Boyd , Bartosz Golaszewski , Alessandro Zummo , Alexandre Belloni , Mauro Carvalho Chehab , Jeff Kirsher , Wolfram Sang , Marek Szyprowski , Heiner Kallweit , Nicholas Mc Guire , Phil Edworthy , Linux LED Subsystem , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "linux-kernel@vger.kernel.org" , Linux Doc Mailing List , linux-clk , "open list:GPIO SUBSYSTEM" , linux-rtc@vger.kernel.org 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 On Mon, Nov 18, 2019 at 7:58 AM Matti Vaittinen wrote: > Bunch of MFD sub-devices which are instantiated by MFD do not have > own device-tree nodes but have (for example) the GPIO consumer > information in parent device's DT node. Add resource managed > devm_gpiod_get_array() for such devices so that they can get the > consumer information from parent DT while still binding the GPIO > reservation life-time to this sub-device life time. > > If devm_gpiod_get_array is used as such - then unloading and then > re-loading the child device fails as the GPIOs reserved during first > load are not freed when driver for sub-device is unload (if parent > stays there). > > Signed-off-by: Matti Vaittinen (...) > +static struct gpio_descs *__must_check > +__devm_gpiod_get_array(struct device *gpiodev, > + struct device *managed, > + const char *con_id, > + enum gpiod_flags flags) I'm opposed to functions named __underscore_something() so find a proper name for this function. devm_gpiod_get_array_common() works if nothing else. > @@ -292,19 +284,62 @@ struct gpio_descs *__must_check devm_gpiod_get_array(struct device *dev, > if (!dr) > return ERR_PTR(-ENOMEM); > > - descs = gpiod_get_array(dev, con_id, flags); > + descs = gpiod_get_array(gpiodev, con_id, flags); > if (IS_ERR(descs)) { > devres_free(dr); > return descs; > } > > *dr = descs; > - devres_add(dev, dr); > + if (managed) > + devres_add(managed, dr); > + else > + devres_add(gpiodev, dr); So we only get managed resources if the "managed" device is passed in. > +/** > + * devm_gpiod_get_array - Resource-managed gpiod_get_array() And this function is supposed to be resource managed for sure. > + * @dev: GPIO consumer > + * @con_id: function within the GPIO consumer > + * @flags: optional GPIO initialization flags > + * > + * Managed gpiod_get_array(). GPIO descriptors returned from this function are > + * automatically disposed on driver detach. See gpiod_get_array() for detailed > + * information about behavior and return values. > + */ > +struct gpio_descs *__must_check devm_gpiod_get_array(struct device *dev, > + const char *con_id, > + enum gpiod_flags flags) > +{ > + return __devm_gpiod_get_array(dev, NULL, con_id, flags); So what is this? NULL? Doesn't that mean you just removed all resource management for this call? Or am I reading it wrong? Yours, Linus Walleij