Received: by 10.223.148.5 with SMTP id 5csp6086594wrq; Wed, 17 Jan 2018 09:10:42 -0800 (PST) X-Google-Smtp-Source: ACJfBouO5cFSFzew0CL0Ox+2JdSUC2NkeUUGKBf7rxdO0enptCZ0wlSDLvTIM2PYYLSVkGLJ/oQz X-Received: by 10.101.81.7 with SMTP id f7mr34167800pgq.433.1516209042340; Wed, 17 Jan 2018 09:10:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516209042; cv=none; d=google.com; s=arc-20160816; b=t1lzbBPj1p/cszm+PEtUIHrEzZeHyZmKX1du4CQHcjHdqX8EZFnH72OsNn44UdsW2Z +Oq4esTYf56DD3Jr01jQvBIPmGSlCrpoOSGCpjw/P6UvPsvypcVCGgM3E8SqLHk85Bc2 kFHnu3fjEkv5IaKDGJOch0tJlPPJcfk/1UJxVLreJyaGbo/t2xJveaxRI6kE5MW0ecTq jV7mRefzHUJj/MGY50e7zw+7k5DdBRIzGjdY18v0PsczHurgze2YDR3awClTUGDEHNsy JVJNqkERIThbeDJSfk9C2QQYGIgXseWSt1rYBRUS6CzZf0cMJsY9XkmzDzOzDGbrg9gT GeRw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature :arc-authentication-results; bh=fmSNfUBxMUr9iJbtJ6zR26mngIXXpAXuAR9Nr8fCU0s=; b=Vn4JDByMJjuyKzXyamjTARdK3j4QJFZ8QlbEukyuze1iJHXsHt7lcH3BGAD2fdWyST l+KZfgMZZvkH58yys+m7S72WH/hlTrJryy74Jir1Ke44VfN17S1LMwTfaEcF/lzr/0pc VMSLARl+SUIf9rd1NbtbMa0rm92/Shs4gWwPMhIIE7EyVdkt214GjAtaQLdp81GLyO/c DB+QOmXH3qwbpNy+RUIHxbX1Sg+3/6UE/081qwzJqubxs5o/Kn6AAzzCqFGxjunkCk40 wxaXTBm46FImoJVR6HzKTw5InIoqcYdBzPey/oYvJWMB6YlS+L2ul9U/+V9ZA53Z9mRw Qqqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kV6bnvVz; 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 68si4771617pla.612.2018.01.17.09.10.28; Wed, 17 Jan 2018 09:10:42 -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=kV6bnvVz; 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 S1753351AbeAQRKD (ORCPT + 99 others); Wed, 17 Jan 2018 12:10:03 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:37888 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752250AbeAQRKC (ORCPT ); Wed, 17 Jan 2018 12:10:02 -0500 Received: by mail-wm0-f66.google.com with SMTP id 141so17131707wme.3 for ; Wed, 17 Jan 2018 09:10:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=fmSNfUBxMUr9iJbtJ6zR26mngIXXpAXuAR9Nr8fCU0s=; b=kV6bnvVzM5j8TMPl/g3fNYEDed8Ox+8LsuUkuZ+OkYsDktw9qiA5yvylHkX9e+HsAr 80QY9PdChB2BafArR5oLHR4cqWtvdD2Q0D6TL2F4YgqY5QEA+txbBexro82S+pZakEZy kfEscNz3vfeMAECAkMDNM157A0ARJSz+WAMrw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=fmSNfUBxMUr9iJbtJ6zR26mngIXXpAXuAR9Nr8fCU0s=; b=o/zBBfkOp8K8xIqZUpjaB123kTTopxWjSevfSeock111VIP4xADwzNnWqpdpWImkI9 pjjezdCXONarXFmN5wi5eQY6qDA58ipymvyIT5k/1/Ik9wdaVhkDnAOGFUxOZ9xaLSzH Y62YsYNbclyzuQD8fSDtht2+m8b2apzq94d/jml4RIOUGJFTlCyx+EbQcZGZHjgzKyMK Yqcn08ncZLlHnUXqv+AH/B247DvPuH/QjF8cuBZ9ExFrJ/atQrds9AJ8hLV0YPErVSoa Rmgm6M8MGNHmoPpYznoduN4p/WtH1KthdQ8fQ+qYq3O/Qu4yEDkkVFiCXYun6PPt0qbX P3wA== X-Gm-Message-State: AKwxytdmB9xYvv8wvzqLqoQ0Wv81v1o3YpeDc6z4aUQ4T6U7sCcjEYfX 8/3jeFhS6JXZPBBjZFSEeE7GjAIzpvo= X-Received: by 10.28.120.15 with SMTP id t15mr2733703wmc.34.1516209000751; Wed, 17 Jan 2018 09:10:00 -0800 (PST) Received: from [192.168.1.24] (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id z5sm3742666wre.94.2018.01.17.09.09.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jan 2018 09:09:59 -0800 (PST) Subject: Re: [PATCH v16 05/10] video: backlight: Add devres versions of of_find_backlight To: Meghana Madhyastha , Lee Jones , Jingoo Han , Thierry Reding , =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= , Tomi Valkeinen , Daniel Vetter , Sean Paul , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <87984b3cb205b19d50f3093e34c6dc8d8179b768.1516098341.git.meghana.madhyastha@gmail.com> From: Daniel Thompson Message-ID: <8e3ad1f2-b4df-10a4-844c-8bbc8801aaf5@linaro.org> Date: Wed, 17 Jan 2018 17:09:57 +0000 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <87984b3cb205b19d50f3093e34c6dc8d8179b768.1516098341.git.meghana.madhyastha@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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()? > +} > + > +/** > + * 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 >