From patchwork Wed Feb 19 09:22:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 207274 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD8BEC34047 for ; Wed, 19 Feb 2020 09:22:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A6BBF24672 for ; Wed, 19 Feb 2020 09:22:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="1QPvypsL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726671AbgBSJW0 (ORCPT ); Wed, 19 Feb 2020 04:22:26 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:39631 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726582AbgBSJWZ (ORCPT ); Wed, 19 Feb 2020 04:22:25 -0500 Received: by mail-wm1-f68.google.com with SMTP id c84so5898204wme.4 for ; Wed, 19 Feb 2020 01:22:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VfILqk1K8yoP2xSE2um+i6NreaS03PgUUyWkRYE/P00=; b=1QPvypsLACAl0jKeCmtjEj3e2Ud60KrFKki2VdyRd9aKZR++Bapjb+krH1SDvqTx54 5+on0pPv6zN5z8LaCwouBhQGhcAjzenmy1vl+fr8txp2xR7h7Vuj3Mcfj1s8b0Mlzh3J /ClvcTFpd8Kj4jOfdzYUcNWSvADx+P5ah+s1D6fjMcu0e/s8aQjjL6VmVJ6NVxVvyxPd qz8mM8ubNRsok4mHN1a9DGr6852IkOgKSKU0LPBgm5cqkD77GWrOBLGzL7pPryBcJGdO xa0ldiLA8uMlR40F+mrK4ezl3fwKMM3weI/PV+a25ciVh7vcRIdjvHq8T+6H/Hq/vVzm 507Q== 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=VfILqk1K8yoP2xSE2um+i6NreaS03PgUUyWkRYE/P00=; b=AUC8N8TLlyBhJaykis7mw00M461j3KymIDkDS8j9Nrfpe2DZXDRGNTehYCqcyaJfKp k7zB0sGU7RWWcaP5yxOLMY9R4IaIDyupPJlaoJxGgXxAreSNfqN0OQ/fkBVkwRmZOkMN Uo+nEcSFK/8kvy2uCbM+Ba1Chqdp3VZoSu9aomWTmHUJHwZx/iBjFQi7DE0azqZqeRzt wwSSB595TDi1QUp1LcMrYyxpkjyopFQB0ZYI/ndkt2N6fYdnkr5zAprOGOdxrkMr1PYh tZRCrqgTE3ToAuitQxuFiqx12LzFx2uvVaD3mWZ5CNmOlXAfwSkQ74onqUDJkyfJ7VR8 +CnQ== X-Gm-Message-State: APjAAAX3fh4k1x6BVuPHH0efxAl9jMLJ/dm8o03N9EjVK9tzLyTohKKz e/1sBBT+AZxTygDu3gK1dvhASA== X-Google-Smtp-Source: APXvYqzGDi13DVhhCKSM4kQot9bTETdx4VEMmzdXo6DxTwM9QgizGw1gIkl9DpZI9RbueNtqQPnbsw== X-Received: by 2002:a7b:c318:: with SMTP id k24mr9260090wmj.54.1582104142489; Wed, 19 Feb 2020 01:22:22 -0800 (PST) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id s65sm2172296wmf.48.2020.02.19.01.22.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 01:22:21 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Srinivas Kandagatla , Khouloud Touil , Geert Uytterhoeven Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 1/7] nvmem: fix memory leak in error path Date: Wed, 19 Feb 2020 10:22:12 +0100 Message-Id: <20200219092218.18143-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200219092218.18143-1-brgl@bgdev.pl> References: <20200219092218.18143-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski We need to free the ida mapping and nvmem struct if the write-protect GPIO lookup fails. Fixes: 2a127da461a9 ("nvmem: add support for the write-protect pin") Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index ef326f243f36..89974e40d250 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -352,8 +352,11 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) else nvmem->wp_gpio = gpiod_get_optional(config->dev, "wp", GPIOD_OUT_HIGH); - if (IS_ERR(nvmem->wp_gpio)) - return ERR_CAST(nvmem->wp_gpio); + if (IS_ERR(nvmem->wp_gpio)) { + ida_simple_remove(&nvmem_ida, nvmem->id); + kfree(nvmem); + return ERR_PTR(rval); + } kref_init(&nvmem->refcnt); From patchwork Wed Feb 19 09:22:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 207271 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70AB2C34051 for ; Wed, 19 Feb 2020 09:22:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 490DF24658 for ; Wed, 19 Feb 2020 09:22:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="PvkqZ1DD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726681AbgBSJW0 (ORCPT ); Wed, 19 Feb 2020 04:22:26 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:56213 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbgBSJW0 (ORCPT ); Wed, 19 Feb 2020 04:22:26 -0500 Received: by mail-wm1-f65.google.com with SMTP id q9so5622535wmj.5 for ; Wed, 19 Feb 2020 01:22:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8EYskHCO+Ze6d2P/0tNY66T5czh8vXZPUNBi7vs1Mng=; b=PvkqZ1DD7PX52G/eA7u72zEvePAPG0FfjU3TFvvxfsXMcp/FUpJdyrVLko9XMABHRX DmQkxjo4jFqZ131bGV2WCRbfRq4uGQ79OnrWkruOdGsC96qk5etFiZAUj+TXZTgTyDxA QG18MWfjDvTSBLMCbZp2WqCkzrhbHJ0+UotspPWhTeQkE6kDWhJsGnGIxQFfTCVZ5DGe R31RAeRZ2NuZagH4Y5u3vt5kWPU4nrUT6Y1lB728Zlwu7zFsXAiQLHfo1/psAvlZUfq0 jLvJ8fVhHXcct8dNOxAFzWkuIEoG1qQGC9Li+13xHaxZUHOq9kyfmbFnBhab5VdV1k1n TXAA== 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=8EYskHCO+Ze6d2P/0tNY66T5czh8vXZPUNBi7vs1Mng=; b=bxspuk/CXwdKX5DnbNeLji/e3JsMJljZm8Fa2B/s8+/qHRCp3N5HJwpGBuulAgxEbW iI1p4ueYWnv16AKPS1Cvwg8E19goR+qC18xN0CkePvEHr1P4pod5aoXr5bUsZ3JLiGq9 sOidMR0FI+E409xGX8H201Np42C9Q6OuRLNC/BsNv0+l1wyIiw08jOh2BeXe0lazeJhY BYkzQGjyxWh32WZkUGimnGRAyctBqhPUapD2B/duEH4uRrntaZKv3QNdBoa5xTvaL4cZ CQoU23LBc1S1B0ySW9SXmV9qQuJT6KdTIv201bcAeXmxl4hGXGJ0u9loVHvYytN9NMXq xE8A== X-Gm-Message-State: APjAAAVXFix3ng/BjRtPr8Cxd6/3d+Wo9A7snoy6GiwyjKvQS3DzxeaR Uza5r3QBo7ZMVbKwHuCcO43jnQ== X-Google-Smtp-Source: APXvYqw9jrMzpPpWL+KcxGAO03nrW+jmOV33681F53QYsl6rCf0Ztjz9bWUOTa5o0Qzr9w2eeDOyLw== X-Received: by 2002:a1c:688a:: with SMTP id d132mr9314062wmc.189.1582104143536; Wed, 19 Feb 2020 01:22:23 -0800 (PST) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id s65sm2172296wmf.48.2020.02.19.01.22.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 01:22:23 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Srinivas Kandagatla , Khouloud Touil , Geert Uytterhoeven Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 2/7] gpiolib: use kref in gpio_desc Date: Wed, 19 Feb 2020 10:22:13 +0100 Message-Id: <20200219092218.18143-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200219092218.18143-1-brgl@bgdev.pl> References: <20200219092218.18143-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski GPIO descriptors are freed by consumers using gpiod_put(). The name of this function suggests some reference counting is going on but it's not true. Use kref to actually introduce reference counting for gpio_desc objects. Add a corresponding gpiod_get() helper for increasing the reference count. This doesn't change anything for already existing (correct) drivers but allows us to keep track of GPIO descs used by multiple users. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpiolib.c | 36 ++++++++++++++++++++++++++++++++--- drivers/gpio/gpiolib.h | 1 + include/linux/gpio/consumer.h | 1 + 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 4d0106ceeba7..78220e86b2bd 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2798,6 +2798,8 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label) goto done; } + kref_init(&desc->ref); + if (chip->request) { /* chip->request may sleep */ spin_unlock_irqrestore(&gpio_lock, flags); @@ -2933,6 +2935,13 @@ void gpiod_free(struct gpio_desc *desc) } } +static void gpiod_free_kref(struct kref *ref) +{ + struct gpio_desc *desc = container_of(ref, struct gpio_desc, ref); + + gpiod_free(desc); +} + /** * gpiochip_is_requested - return string iff signal was requested * @chip: controller managing the signal @@ -5067,18 +5076,39 @@ struct gpio_descs *__must_check gpiod_get_array_optional(struct device *dev, EXPORT_SYMBOL_GPL(gpiod_get_array_optional); /** - * gpiod_put - dispose of a GPIO descriptor - * @desc: GPIO descriptor to dispose of + * gpiod_put - decrease the reference count of a GPIO descriptor + * @desc: GPIO descriptor to unref * * No descriptor can be used after gpiod_put() has been called on it. */ void gpiod_put(struct gpio_desc *desc) { if (desc) - gpiod_free(desc); + kref_put(&desc->ref, gpiod_free_kref); } EXPORT_SYMBOL_GPL(gpiod_put); +/** + * gpiod_ref - increase the reference count of a GPIO descriptor + * @desc: GPIO descriptor to reference + * + * Returns the same gpio_desc after increasing the reference count. + */ +struct gpio_desc *gpiod_ref(struct gpio_desc *desc) +{ + if (!desc) + return NULL; + + if (!test_bit(FLAG_REQUESTED, &desc->flags)) { + pr_warn("gpiolib: unable to increase the reference count of unrequested GPIO descriptor\n"); + return desc; + } + + kref_get(&desc->ref); + return desc; +} +EXPORT_SYMBOL_GPL(gpiod_ref); + /** * gpiod_put_array - dispose of multiple GPIO descriptors * @descs: struct gpio_descs containing an array of descriptors diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 3e0aab2945d8..51a92c43dd55 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -119,6 +119,7 @@ struct gpio_desc { const char *label; /* Name of the GPIO */ const char *name; + struct kref ref; }; int gpiod_request(struct gpio_desc *desc, const char *label); diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index bf2d017dd7b7..c7b5fb3d9d64 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -81,6 +81,7 @@ struct gpio_descs *__must_check gpiod_get_array(struct device *dev, struct gpio_descs *__must_check gpiod_get_array_optional(struct device *dev, const char *con_id, enum gpiod_flags flags); +struct gpio_desc *gpiod_ref(struct gpio_desc *desc); void gpiod_put(struct gpio_desc *desc); void gpiod_put_array(struct gpio_descs *descs); From patchwork Wed Feb 19 09:22:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 207272 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 438C4C34047 for ; Wed, 19 Feb 2020 09:22:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1B99A24658 for ; Wed, 19 Feb 2020 09:22:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="iCGQ3bYj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726530AbgBSJWr (ORCPT ); Wed, 19 Feb 2020 04:22:47 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:43173 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726668AbgBSJW2 (ORCPT ); Wed, 19 Feb 2020 04:22:28 -0500 Received: by mail-wr1-f65.google.com with SMTP id r11so27252796wrq.10 for ; Wed, 19 Feb 2020 01:22:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oxGRWgQyZaN66YaIn8IJWZO9FxN0tzHUnwFNQKByXPI=; b=iCGQ3bYjmnOtKoJ8pKeMvNLxscxSAGuVvttFcWq2ERZDxpGRRgO4kidvI0KcWv8nXA fx57kM/cJliaS+twGxTaw3zKJDBsfoYHa7l9U6aenq93u+5ev0oIhZNTK9Wbteug9wnL IjSYJt9mFbu6taLp+WVqE1ruW4cCVjEGbVkU2ZzMb2Fs/mQjVEEDydcRcdx/s5k7pRq5 o27YxsJuK63V3PaWEeM0uy/k5V317m6z82zIwMC4P31TLDp5LbZ9idSRt334Ki2gNc7n fEq0R0ybgBcLWz1Z9CyQutYbY6F9wgeqlqqCZZpAmJOW99FDkgxWO4KK4pRuqmRm4Pzx gABQ== 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=oxGRWgQyZaN66YaIn8IJWZO9FxN0tzHUnwFNQKByXPI=; b=ihHhV1+xXX3Ja6JueWcask1NJ8nEhIXQNt/S0PTbalNfp+aMXgGfSkrCgaAQOf2uUQ 7a0RI/QPsJs6O6OSjfbjtaK5KWKO/xQ10DXZjO/WoT8etTNNGRoMg7JNgfDq5IQcZNoq u7U4P6qyWr3sZYIjrVQsEMTPtwwaDBT4w6b74E7BoS0CaZ7Z+WF8/9CNl0ktXDYBtRE5 l0CsFnZsZiU9t7FbRpU8RBTqC79W2NRZ3CphrYWhQaODCJJ4+F4ejN7CzgYXkNEge/Lk 6WVxY7mr12KFbaKBJ/lrJj+ENSsyY6ZMnoOZq4bpCrtEus+pdidSulNprfSXT2mrjV7b oj2w== X-Gm-Message-State: APjAAAXoK6saZ9f3F/mQW5hQvU4LhUX8dZbWF5mBzuK3RL0tjDWxtFNU coTe+RlkAb87fYR/iBmV0CECs/xDhV8= X-Google-Smtp-Source: APXvYqx1Po0CNLWh6Y6FSu7EmSWTjdBDdibTgs3GlSbpu8zQIsgCN4AFKouhXosuNsOi9axD96FpVg== X-Received: by 2002:adf:f406:: with SMTP id g6mr35205849wro.189.1582104145872; Wed, 19 Feb 2020 01:22:25 -0800 (PST) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id s65sm2172296wmf.48.2020.02.19.01.22.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 01:22:25 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Srinivas Kandagatla , Khouloud Touil , Geert Uytterhoeven Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 4/7] nvmem: release the write-protect pin Date: Wed, 19 Feb 2020 10:22:15 +0100 Message-Id: <20200219092218.18143-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200219092218.18143-1-brgl@bgdev.pl> References: <20200219092218.18143-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Khouloud Touil Put the write-protect GPIO descriptor in nvmem_release() so that it can be automatically released when the associated device's reference count drops to 0. Fixes: 2a127da461a9 ("nvmem: add support for the write-protect pin") Reported-by: Geert Uytterhoeven Signed-off-by: Khouloud Touil [Bartosz: tweak the commit message] Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 4e6daaa2b0f6..c718ed7859e8 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -72,6 +72,7 @@ static void nvmem_release(struct device *dev) struct nvmem_device *nvmem = to_nvmem_device(dev); ida_simple_remove(&nvmem_ida, nvmem->id); + gpiod_put(nvmem->wp_gpio); kfree(nvmem); } From patchwork Wed Feb 19 09:22:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 207273 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7969C34051 for ; Wed, 19 Feb 2020 09:22:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A050E24658 for ; Wed, 19 Feb 2020 09:22:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="HCU0L7yA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726722AbgBSJWc (ORCPT ); Wed, 19 Feb 2020 04:22:32 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35039 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726750AbgBSJWb (ORCPT ); Wed, 19 Feb 2020 04:22:31 -0500 Received: by mail-wr1-f66.google.com with SMTP id w12so27298840wrt.2 for ; Wed, 19 Feb 2020 01:22:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kseu72RlmoHjw0Ds52fvPmAht9fKcAm4Amcp4sUWzMQ=; b=HCU0L7yAvvvBNWJayyd7FYZeBYqdwM7Zf8WQ+NXdSnzvuO3j2rUxNdyyGCJkLFwhJN RJzLgIxfUeYzq8PjE1mPp1736eObAvyPM/SV9+m4UPeqCwIEJf7wuxFKmVNwXDY8QIn+ rDuhD57rBSGAKQ2uF15NB9PmtVX/OYx+7SBrW4R1w8OtazouaNhGJhvWm34dhfei863G R49ia2NwPlIEzy5zwUSwPhHGkYWvvBsBCBH3kezDI0b2JdJ/UJz7yGvljfyUXKsoHX6C JNwRSpFQW2+0sFK67QK9EMSpMG2ius3kd2co7FlYju8N2KNbqjRNW7QzsMTJK69Dkqhk YI3Q== 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=Kseu72RlmoHjw0Ds52fvPmAht9fKcAm4Amcp4sUWzMQ=; b=VTXEL3lIyAOcxZC6Lc3hMofXUKvdstJYgoeuswiT8+xqf1M1d6lLh1FVL09o0NzRXS WzdBPSJJT36giYJ+Y8v/jYaMxBYu/qc1Bw9REn627ovXcxPOhOBRdhKCO+6gHV6gPZZf t1SHBwW/96uRMd9yumTa1oh+OujDp82b3oVn4Gq1TOEYpDOtlxpgrzVLpuCz4QLkamou eBnDkMKSPKXHATqhRwSAm2jjrr8UaGpIIL/+lNKSLuOoF89oGlskiPuNePH+3ThryTfg vdXH3fvOE+qJyLISYkTJGmhHd/jBrlJQyany1XXXZ33BXSScsMz8CWsvuTFLTYFUNYKR rKDg== X-Gm-Message-State: APjAAAUnt2ZvjV5UTyYkEOzMUes47HH8opd5zNKJv9kZtb/vmTidtC37 9D19/pTVxkMMPlDsoLvlcHrk67iITmc= X-Google-Smtp-Source: APXvYqz956puqcBVPbs9NYq+NZ78vLaaJccYXy+tQ4MMwlUCIqIZuO5pVR5NZzAU8Vap8m9jpsxeDA== X-Received: by 2002:adf:f504:: with SMTP id q4mr33087616wro.28.1582104148131; Wed, 19 Feb 2020 01:22:28 -0800 (PST) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id s65sm2172296wmf.48.2020.02.19.01.22.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 01:22:27 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Srinivas Kandagatla , Khouloud Touil , Geert Uytterhoeven Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 6/7] nvmem: add a newline for readability Date: Wed, 19 Feb 2020 10:22:17 +0100 Message-Id: <20200219092218.18143-7-brgl@bgdev.pl> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200219092218.18143-1-brgl@bgdev.pl> References: <20200219092218.18143-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski Visibly separate the GPIO request from the previous operation in the code with a newline. Signed-off-by: Bartosz Golaszewski --- drivers/nvmem/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index bbdf2fe076b9..40fe5913c264 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -348,6 +348,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) kfree(nvmem); return ERR_PTR(rval); } + if (config->wp_gpio) nvmem->wp_gpio = gpiod_ref(config->wp_gpio); else