Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2238792ybv; Mon, 24 Feb 2020 01:43:32 -0800 (PST) X-Google-Smtp-Source: APXvYqzETxInfEwFTKjXq0mUHJnZ04McKPAPT0tnVnRmqMdVb7VFJ/fy3/TI74tW5Arb/iQgn6+Y X-Received: by 2002:a9d:7498:: with SMTP id t24mr40367083otk.290.1582537412304; Mon, 24 Feb 2020 01:43:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582537412; cv=none; d=google.com; s=arc-20160816; b=zGOxeeI8DCOKUg/GeLnr0lTlN9H6XYqepTe8a6cvJqcCrKuWdLx2rbJil+Hk0wlU2k DmF+0I2raBrNfYF1gOiqBNypB5mVwU8xk+TjfiUVpDeMQixP+4A20nLI5Ms2mneKC501 ob9fQlXFHhGy+w5rChZIe3gpaxRszdUEGuSO4HIqRQKeOWHJKqo/b0zlrYWqWV7gL9sF 0joROErsP0uWigPGhiF3IS71x5jE0X8fVcdyeU0yuaXo/KvhIhSrUMCRjVgK82l/E4tp CxN4Za5VdJPgPcvKBC48KkI6qj8sF6B/NsBfX0FUTcq2wO8j7bHnxz6KsxWLRdhul6w8 wRmQ== 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; bh=se6uVwZcUyEVQTI7VQ6AKAp5xkuS44LPDYDciQyl3tk=; b=XnQaxMAESL7+9oej4zK9Var19Nds2lDt/0ZcBxJRtRF5XSSLeruNPUnzVlUds6q3SQ yLOeJ9d7kJCFKr3QHphw7DriU/rQypJ50UOM4ORKzX7/1GXppJM+ccwW7WPr9QFbgyNO aY2zNkI2nkZJHR6C7+fnWsu8Kku9ORAubW3pxuWbmO6muxE3qEI5Vlb/A+61Dzx9MKcZ eirOJG3Bo01CIX7HRn0wYUhrwJ/fMnhejz7QXt4aXNvsSPskaI7oGlWFnSYWKjV5kzMW +yes+s88USusU/7Km5vkgnWoNuVkzV8RttgIqOVx3SrlA9rMUV1HVtIaPgq0MWloOW5D PXww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=O82vNF3Q; 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 e15si6085439otq.237.2020.02.24.01.43.20; Mon, 24 Feb 2020 01:43:32 -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=O82vNF3Q; 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 S1727405AbgBXJmL (ORCPT + 99 others); Mon, 24 Feb 2020 04:42:11 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33252 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727351AbgBXJmI (ORCPT ); Mon, 24 Feb 2020 04:42:08 -0500 Received: by mail-wr1-f68.google.com with SMTP id u6so9558255wrt.0 for ; Mon, 24 Feb 2020 01:42:06 -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=se6uVwZcUyEVQTI7VQ6AKAp5xkuS44LPDYDciQyl3tk=; b=O82vNF3QqwU7p+lGPjsqdpw1i7j+XuJ8MZsNiIkmrG7MVC9u6AwMxE0cqfHxeJ+rdd tcWC1wkiKWJDfAZqgk95DzKAyoIFgwr1kzHjr5u8RkqPtvy1IyocArEV2vnsJV4U7w5m re/Aa8x8RbQ8VT+DL0O1KiEIlSQLSOY3CIr96Uj60GbBhlW6HdQd0iIPTu/927HieDNZ 6B5Q3wdHpuHQfUgj3/wC2Oo/VMoNscNTnnCMDC3pWRrgHlnNfLhGe9SHbUY1KlxpSUUH QnRiMS2pdZps8WBFT+lVDK51CFuUpxlMnGoS12C6Svk9gHhTlSlTKlxpIEoWPSBFJkoq giQA== 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=se6uVwZcUyEVQTI7VQ6AKAp5xkuS44LPDYDciQyl3tk=; b=h8yRSgv7lrqIPRYoEEYs+FnlJqNXFqeRKT8oieSrm+MWfjOenjgiMi5N7ojAGXrtuk Dvbvm80hJPf7YXQbYTIK4Q/edPjVWN5Fy56+k+pDsNxhnHRCLFp6Rp98J/RJMXNxaM7p P49Z0hOz38pkH2Vbt1kLAsH+ca8uUfVk53+trohs2ym1Dxiu9azWS1ubitmnYU2lVTkg D8ayvO7L01Mdac6vZr+LnrZIj1X9CWqP3rZklJ16cwymXkjwjG3ZYJA3eAHordbAsrE4 ZctrbwNTz/L6SAZAVKZlvuH1p6AKtcVFMLWM3+/CVSIiKq1XqJvvRwojpVaI3Zw+7EVm 2BpA== X-Gm-Message-State: APjAAAU+OfJzsg/JH0Iq2KJNbMO+AHWHUcIcDTezkfjhjy78fTzZATLs Uydph2x3tLqIGOEBwFBqxzgMLA== X-Received: by 2002:adf:e683:: with SMTP id r3mr69472357wrm.38.1582537325948; Mon, 24 Feb 2020 01:42:05 -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 t10sm16920730wmi.40.2020.02.24.01.42.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 01:42:05 -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 3/3] nvmem: increase the reference count of a gpio passed over config Date: Mon, 24 Feb 2020 10:41:58 +0100 Message-Id: <20200224094158.28761-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224094158.28761-1-brgl@bgdev.pl> References: <20200224094158.28761-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/nvmem/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index c05c4f4a7b9e..790ec9b5552e 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -350,7 +350,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) } if (config->wp_gpio) - nvmem->wp_gpio = config->wp_gpio; + nvmem->wp_gpio = gpiod_ref(config->wp_gpio); else nvmem->wp_gpio = gpiod_get_optional(config->dev, "wp", GPIOD_OUT_HIGH); -- 2.25.0