Received: by 10.223.148.5 with SMTP id 5csp7353747wrq; Thu, 18 Jan 2018 04:33:55 -0800 (PST) X-Google-Smtp-Source: ACJfBounzkdvlQ+15ig+9hJUiEKOH4d+B7xeXAV6i1DLlgWqJ2TUs9lIH2WGBxjUOCEggIXJRAwm X-Received: by 10.99.114.27 with SMTP id n27mr31190191pgc.424.1516278834928; Thu, 18 Jan 2018 04:33:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516278834; cv=none; d=google.com; s=arc-20160816; b=oZwcW7uHPkIyBhA4ERNQMyaJgcdJl8prHJxrs4Ntm5pPOebziCCUjP0PWpRNHoWTqV tWVH0KWHMbMW+ZX80wFxilhGUBh2kL5mhOTV5JJOhylXJzIYYoq9ZnUq/ojzzPLlxBrD zLBZUw4JoS5fuGJl7eq6wNbWG/XpEBDNyIIRMAQLXs674m04k7FCrSEdxEPb+U286nBX QPqFTbiGdG964ADV0jpDyR8LIwq8n8KiMcWAEKyt7ai3J8jN2ySvKgpk/4k4Nkmj2Fxr NMBg940KmO78B1Qx1YFII9EdeCslpKmKrUG6ByjhQT4b13V0uypP6kyUQO5tbCqDUJl3 wLRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=OBa0oGdcTE6NSbkZD28Z08ccj/ZqCK9eGiRgKRgWg9Y=; b=lc+53Ku8VnYj4hmtHmeTW9sDZGvUcpBs5dwGH0/REAxX1jp+TBbSd5dtS1+OGBk1yd cxjOP2vmw4L52ZP04BahZJ9AfJKLSiplM43gS48Sl8s6eOON4YkM7I4PkfPoxiEHUOer 109Ucf+dRYh8Ursvgc+QLZurZrEWvbIK7LJ4Ox8XEMe7JdcSQwffOFpt3qtdv2lhewXD iWexHCALzurnKgNZfV0bc8qxZolWbK4x1S7QyFD7kZ5l9B+Z9how+yPkxmcpiUlcfbbS avN8rg4gPUEue521bPDPUZ6+jWsJBCZJk0/EP/ViUvC/fNKRGa+8JNla5MSmJ2S/VA+l M9zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MKwizTY+; 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 o30si5884089pgn.548.2018.01.18.04.33.40; Thu, 18 Jan 2018 04:33:54 -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=MKwizTY+; 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 S1755758AbeARLuH (ORCPT + 99 others); Thu, 18 Jan 2018 06:50:07 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:43777 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755407AbeARLuG (ORCPT ); Thu, 18 Jan 2018 06:50:06 -0500 Received: by mail-wm0-f68.google.com with SMTP id g1so21340021wmg.2 for ; Thu, 18 Jan 2018 03:50:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=OBa0oGdcTE6NSbkZD28Z08ccj/ZqCK9eGiRgKRgWg9Y=; b=MKwizTY+MGHqLyxXAtd0vyew0eSespCOdkvCW1lSUCdX/UFXmXxDEjBCrh1dpP4rOx DGNmpFl+Oe8t8sgVmhRfsKDz7J0BhZTDhGjhUW78FuKzfxjD3z7YZk9kmveKk2v+WPmH UkTDwG89PcJPxyRLlXJubfIBiqWVfrvztp5zo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=OBa0oGdcTE6NSbkZD28Z08ccj/ZqCK9eGiRgKRgWg9Y=; b=IWEmnq0PLEICEMErYUaZ3nxWUeTLzWoZFg1VzxDtn7iyznaHr4sSGwVbQYhTjJSQ3l Tr/2pY0PNukhDjqpBuWJ4eL0KqS4g+m0nVVLGcKiM13EvgDKpRlROBtPzTPyUF6SEUK5 +N896OgoKyMZI7mX+pjXl3gz+xhEcciry5cw3zuB3MEc8kR5vp3gGUTpqWm7wbe2+68M sjV2uP4VBnnT94SQGP6Ksfzn/+MYAAdMndxTymGj1x/1KhMqluO5IXX1aRAIqHH7Exhs 9KLIN7JZJtLHXtI1HjrUrO2a51XbUobJopFdrRruM/fWzgJR8JtSk72A71nAlKLg6fWQ PoxA== X-Gm-Message-State: AKwxytfre1yOg3seBSwJIKrScIZx39aTnEDSMkUmWR9tzG+BlP/W+qEH 9PStDapdTvIFa8jx+3agGgXeLQ== X-Received: by 10.28.152.74 with SMTP id a71mr5238806wme.76.1516276205317; Thu, 18 Jan 2018 03:50:05 -0800 (PST) Received: from oak.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id y62sm5039326wrb.48.2018.01.18.03.50.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jan 2018 03:50:03 -0800 (PST) Date: Thu, 18 Jan 2018 11:50:01 +0000 From: Daniel Thompson To: Meghana Madhyastha Cc: Lee Jones , Jingoo Han , Thierry Reding , Noralf =?iso-8859-1?Q?Tr=F8nnes?= , Tomi Valkeinen , Daniel Vetter , Sean Paul , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v16 05/10] video: backlight: Add devres versions of of_find_backlight Message-ID: <20180118115001.zp2oypbsemwdpoqb@oak.lan> References: <87984b3cb205b19d50f3093e34c6dc8d8179b768.1516098341.git.meghana.madhyastha@gmail.com> <8e3ad1f2-b4df-10a4-844c-8bbc8801aaf5@linaro.org> <20180118110226.GB4864@meghana-HP-Pavilion-Notebook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180118110226.GB4864@meghana-HP-Pavilion-Notebook> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 18, 2018 at 04:32:26PM +0530, Meghana Madhyastha wrote: > On Wed, Jan 17, 2018 at 05:09:57PM +0000, Daniel Thompson wrote: > > On 16/01/18 10:34, Meghana Madhyastha wrote: > > >Add devm_of_find_backlight and the corresponding release > > >function because some drivers use devres versions of functions > > >for acquiring device resources. > > > > > >Signed-off-by: Meghana Madhyastha > > >--- > > > drivers/video/backlight/backlight.c | 29 +++++++++++++++++++++++++++++ > > > include/linux/backlight.h | 7 +++++++ > > > 2 files changed, 36 insertions(+) > > > > > >diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c > > >index 7e4a5d77d..b3f76945f 100644 > > >--- a/drivers/video/backlight/backlight.c > > >+++ b/drivers/video/backlight/backlight.c > > >@@ -620,6 +620,35 @@ struct backlight_device *of_find_backlight(struct device *dev) > > > } > > > EXPORT_SYMBOL(of_find_backlight); > > >+static void devm_backlight_put(void *data) > > >+{ > > >+ backlight_put(data); > > > > Shouldn't this be using devres_release()? > > backlight_put calls put_device which essentially does a release right? > And looking at the code in other driver, looks like most of them use > put_device (to the best of my knowledge, correct me if I'm mistaken). Sorry, the name confused me. I mistakenly though this was API code like devm_gpiod_put and devm_clk_put, rather than a static method. Whilst its my fault for overlooking the "static" please could rename this to devm_backlight_release(). I don't want to keep being confused every time I re-read it! Daniel. > > Thanks and regards, > Meghana > > > > > >+} > > >+ > > >+/** > > >+ * devm_of_find_backlight - Resource-managed of_find_backlight() > > >+ * @dev: Device > > >+ * > > >+ * Device managed version of of_find_backlight(). The reference on the backlight > > >+ * device is automatically dropped on driver detach. > > >+ */ > > >+struct backlight_device *devm_of_find_backlight(struct device *dev) > > >+{ > > >+ struct backlight_device *bd; > > >+ int ret; > > >+ > > >+ bd = of_find_backlight(dev); > > >+ if (IS_ERR_OR_NULL(bd)) > > >+ return bd; > > >+ ret = devm_add_action(dev, devm_backlight_put, bd); > > >+ if (ret) { > > >+ backlight_put(bd); > > >+ return ERR_PTR(ret); > > >+ } > > >+ return bd; > > >+} > > >+EXPORT_SYMBOL(devm_of_find_backlight); > > >+ > > > static void __exit backlight_class_exit(void) > > > { > > > class_destroy(backlight_class); > > >diff --git a/include/linux/backlight.h b/include/linux/backlight.h > > >index 32ea510da..1d373f5a6 100644 > > >--- a/include/linux/backlight.h > > >+++ b/include/linux/backlight.h > > >@@ -215,11 +215,18 @@ of_find_backlight_by_node(struct device_node *node) > > > #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE) > > > struct backlight_device *of_find_backlight(struct device *dev); > > >+struct backlight_device *devm_of_find_backlight(struct device *dev); > > > #else > > > static inline struct backlight_device *of_find_backlight(struct device *dev) > > > { > > > return NULL; > > > } > > >+ > > >+static inline struct backlight_device * > > >+devm_of_find_backlight(struct device *dev) > > >+{ > > >+ return NULL; > > >+} > > > #endif > > > #endif > > >