Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5181348ybv; Mon, 17 Feb 2020 14:11:21 -0800 (PST) X-Google-Smtp-Source: APXvYqzT5VbSEUV1Zbqr/6m+2d89FyqBhqzniPc0SBKTKvUsAmqfmqnANxOv9mr1CkulS9GQJz1c X-Received: by 2002:a9d:7617:: with SMTP id k23mr12868078otl.329.1581977481389; Mon, 17 Feb 2020 14:11:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581977481; cv=none; d=google.com; s=arc-20160816; b=tzTmnSWHAN8jUToxWgW/iih0HysdnpceLv5QoygP78PCKbfq/ga3KIZ+T+y27UXiWz KAfdXQ9OJpwXDJT1SeOkFuEsVL9Sm86mb5nFWmDiXQVqWeiiAPAZCiHBuz7eH/cVrU4F DJEdn0pEefAMuNXheNcqbi2b4oYl/PlqbiZmzvWmmnmpMZbjkfgXaStYW///58fDl9qV O1v0DRvgy/snVpE1np3A1u7eVtszEsTXg2fLUjyblRrWhQkPrXoHmBkVbqqp7+Kbg+Ne rklB32nx82CMdW//ZFpmW41aOF0PakpwddXGGz9GoGcQnooBsueZjV9tAwlA81J52PQY 46Qw== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Omu0NuzaolVnSx+lzNIehq/LH4WJjwka83BM14aUe54=; b=nhxsOFDolxpKdbefXcYDD2s3ACay7/I4xDSs+Pn3mt358UnRHBjS2iSBNQCl2ulOp9 WaFFvpT1mOFD6HIO1K8c1y0WV8aJWpwrn9vDb1/9O4WOCqwZ/Kr8SOuKs0cGAGAgcIw7 GEitDhVV+rstN5nKRYggA/k7sl5ziX0K6dPhukI3Qtxf6yw/hB7aCU0ELDLBijhxG5Io sSxAWuQltTAvdwE3MnAXxmP5Y4QQsoa/UqWbEVaeLnO0kzGfiWr2X5d25lWGEy2ZcfgN SrwFm0rEbSpZzyGFWozMVYFGdPlc8ggj3/DyNiIL5xAFZNMjij3FDX5q2RYRmCAU+YkH 3RcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=iCVpOe7W; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10si1093288ots.106.2020.02.17.14.11.09; Mon, 17 Feb 2020 14:11:21 -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=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=iCVpOe7W; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726155AbgBQWJq (ORCPT + 99 others); Mon, 17 Feb 2020 17:09:46 -0500 Received: from mail-io1-f68.google.com ([209.85.166.68]:40524 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726054AbgBQWJp (ORCPT ); Mon, 17 Feb 2020 17:09:45 -0500 Received: by mail-io1-f68.google.com with SMTP id x1so8635166iop.7 for ; Mon, 17 Feb 2020 14:09:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Omu0NuzaolVnSx+lzNIehq/LH4WJjwka83BM14aUe54=; b=iCVpOe7WsfoX/5+MZ7nl4keAYitzKy0yV7RlA0i4AO/J36knvEx8lMaYo/OXa8Rvjs xkuw887fAWD1+yXzmaB4+sdQS6RL5fCV/Ou+94O3RQyXjLfs+VHut1Tmwtdrl39nxck/ gQbVWU5sKU+7RAc5i2by5TEL+kqzqnotCEm6f9XxghErud7lXxBHwxLsv1/v0DV6dfl3 4RXZ4GCoQu/LBntfMP9WI6Eidd7SrBpppEcRp+Rl4AuU11PpY6aj94+NvMP/JTIkfA7H hJdefnIk7nGEo6HsNJdHMM7WK5nFz04oSHgqmCjfuHzop0id+dend0MtGyHtyAaLdYZy d9mQ== 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=Omu0NuzaolVnSx+lzNIehq/LH4WJjwka83BM14aUe54=; b=gMoAsKHoHCH2lQ+85mQG3aXPRGgDTY7xvXd5ysveA0lRA9d7WOSrPnpts3NMVUduzb 9nvZJEJOoWLTzr6C98Yx91cQM7JiuY156mHT3vLLaz1BD21CT22tpw8Nmgukm6RKAozB uqaTWPC0qwzfibK2rZHyWc1BYFk4SmgaEbSGa11iSCzrPHYKk0SrCltyFiVSMyVDNZPF VyvsxcLRAjreitgzidAaptzaoq16gJcDGVL4b/dtvZdkaVFfMI7rQDRsG1K+klKYYf/r mr8QDPr57cy6dkuQYcsQePAlh6dbJltmHi6x7gbCn2q+fp3LDgcOy9qXZaxMV7qvR1k+ DdBQ== X-Gm-Message-State: APjAAAVUMdv+o/fVEQXc+Ns2nf9rzdqaWqsvztv3EClpOlyaeU9PDhsS LUaRvLKFsfdg6Iky3TudZd/3YYjUt+Iw8XUiaykfYQ== X-Received: by 2002:a5d:8952:: with SMTP id b18mr13653283iot.40.1581977383891; Mon, 17 Feb 2020 14:09:43 -0800 (PST) MIME-Version: 1.0 References: <20200217195435.9309-1-brgl@bgdev.pl> <20200217195435.9309-7-brgl@bgdev.pl> In-Reply-To: From: Bartosz Golaszewski Date: Mon, 17 Feb 2020 23:09:33 +0100 Message-ID: Subject: Re: [PATCH 6/6] nvmem: increase the reference count of a gpio passed over config To: Geert Uytterhoeven Cc: Linus Walleij , Srinivas Kandagatla , Khouloud Touil , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List , Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pon., 17 lut 2020 o 22:13 Geert Uytterhoeven napisa= =C5=82(a): > > Hi Bartosz, > > On Mon, Feb 17, 2020 at 8:56 PM Bartosz Golaszewski wrote= : > > From: Bartosz Golaszewski > > > > We can obtain the write-protect GPIO in nvmem_register() by requesting > > it ourselves or by storing the gpio_desc passed in nvmem_config. In the > > latter case we need to increase the reference count so that it gets > > freed correctly. > > > > Signed-off-by: Bartosz Golaszewski > > Thanks for your patch! > > > --- a/drivers/nvmem/core.c > > +++ b/drivers/nvmem/core.c > > @@ -349,11 +349,13 @@ struct nvmem_device *nvmem_register(const struct = nvmem_config *config) > > return ERR_PTR(rval); > > } > > > > - if (config->wp_gpio) > > + if (config->wp_gpio) { > > nvmem->wp_gpio =3D config->wp_gpio; > > - else > > + gpiod_ref(config->wp_gpio); > > If gpiod_ref() would return the passed GPIO, or an error code, you could = write > > nvmem->wp_gpio =3D gpiod_ref(config->wp_gpio); > Yes, makes perfect sense - v2 coming up tomorrow. Bart