Received: by 10.223.176.46 with SMTP id f43csp2997449wra; Mon, 22 Jan 2018 06:53:49 -0800 (PST) X-Google-Smtp-Source: AH8x225LleLij9rLf3v7zPUA86Ubr1v+qsWIxGyUrGqBJXDsPKMGDvyPy5CfTfMGDLFUNVM9avJ0 X-Received: by 2002:a17:902:2845:: with SMTP id e63-v6mr3477983plb.438.1516632829553; Mon, 22 Jan 2018 06:53:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516632829; cv=none; d=google.com; s=arc-20160816; b=EDPHO+ZRtIcr1JXuC6O55pRkF/1hSyufXOfRzPx/+cVrJJiFwEayoAIDbpR0MgdRNH PqsDD4ofs8aqbUuj4jrj4B+fxqTc8C9UaU+zqj5oUpYSnhiWgoeQl4pFdG9xNIcszWjK g4EvkEzyt84QbDprRF1dbuvXnpmQ9HXMJoc1gK+ud00jwr5J/3geu2o2awkhQLdjD0yz Ja7oJpgebwgMBC7WBmS3v660wxO1UENOsO1i7H3P+w54mI6MTmjZnG8sfVMd2W1O45rN L/6HSrQ7UBkxZYQYgCV+65ZD3s4q9UpDFrKOJ0S75sq7pG93kp6HWPJgv+hYN2z+XY+2 6/0Q== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:to:from:date:dkim-signature :arc-authentication-results; bh=FwY0Mx90uqpZAPwM7ucka/WuOWl5LCArPJD8Yt++I2Y=; b=hxqjiE/3falnc8446AV8J4Hiu4zGSZ8nIA0HC425HMMnyEmmregRhwqbIBq2e7Vt3s mSYvIJvUWVhNm3pVAkrs59n2jMUR/ENzSUjvQhA6ZptkVXYygXnEHRGFDoTJSAvnTZX5 Irjh8a6JCye+o2t+bscWx9EkhuKZjNeSea12Iv7Lm9hyu3YQsvLnY3FHfHdSmij+r/M/ YR75REIIVKJFZyueMmtV3gntKp6c6D6o6/oOPH0yyUaF9kdGcOmNxT62Rynx7OHFZA0C 8RKJyaDLGPXFQSydrP8uLdpwqP5sfv74yL9GAUBczraxGCcNrVTb7ih0MxeTR3BaU7wB 0djQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=onJGSxw/; 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=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a16si288758pfl.77.2018.01.22.06.53.34; Mon, 22 Jan 2018 06:53:49 -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=@gmail.com header.s=20161025 header.b=onJGSxw/; 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=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751216AbeAVOww (ORCPT + 99 others); Mon, 22 Jan 2018 09:52:52 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:38506 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750848AbeAVOwv (ORCPT ); Mon, 22 Jan 2018 09:52:51 -0500 Received: by mail-pg0-f67.google.com with SMTP id y27so7267407pgc.5 for ; Mon, 22 Jan 2018 06:52:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=FwY0Mx90uqpZAPwM7ucka/WuOWl5LCArPJD8Yt++I2Y=; b=onJGSxw/t/LMKUxcY5QQm9Q/rPNVaS0nlwFfzirZ/X6VpK2OBSWi4IWVRUrECB15gR r/rtLA7sbYgPEUYE/Nd7X7B/RPXnN/SjDY7pWA1QT/7/9ivuuiHJyNs58wV9zMsii5Bb zqkLOguRhuF4l5Dv9V9Vd2gK0qd+IAAweZjq5DnwMa6voAGn8ZC2dkoWNuRgLIlJecSb ZXgSCJn8VwIYCrf3kgQTzfBrz86A3Iat4kQ5cWqeo9Vv/QRDJeRg4mpF8wFyhPeRQh69 rhV9go3ZBJzwWraspi8s701xC9hiH2oBLtznz5xh5JExtvDbltcRXta/YWa5J5Zzu72I CQ6w== 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:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=FwY0Mx90uqpZAPwM7ucka/WuOWl5LCArPJD8Yt++I2Y=; b=S2wD5IB9lM25USQ9Hxn8sYtHqYOfR8Khb9feF1fTCAM4gV62KyLaVKVtP29l34bK/c w+JjT5wSSqlhUjZQSTrTJ15ygycFL/MiQ37UZGSbuWO2qwsBO3kxte1avVungCwYI4oo X+J3wmZK0ZdSzKMxAy54lqfqFQOJYIxTDQ7LAELao3hhbdp9S3RhyzxRyJTsEnAjnv+a ngNgMHKDeV0oNkqgwFhZf4rmo/myF6a5WoanZ9uckYP3sgKA+eYJ1qxCFaAjNCZxO2YV DGaqSJzVb1AE05tE5sHOYNNo5nYI/anxU8nRD/8bBaBhZkHYeq4sHEL2fj8n6jMyIgFR Tv3A== X-Gm-Message-State: AKwxytepTgDhnB0b0s5zJYNEiwJSsfRORVSoTD3GV4aze5GKRkWFi5K9 MLqiOeQw741QZ+28nG7oYwU= X-Received: by 10.99.163.2 with SMTP id s2mr7544974pge.264.1516632771002; Mon, 22 Jan 2018 06:52:51 -0800 (PST) Received: from raspberrypi ([122.171.92.137]) by smtp.gmail.com with ESMTPSA id p75sm1254119pfi.148.2018.01.22.06.52.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jan 2018 06:52:50 -0800 (PST) Date: Mon, 22 Jan 2018 14:52:44 +0000 From: Meghana Madhyastha To: Lee Jones , Daniel Thompson , 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: [PATCH v18 05/10] video: backlight: Add devres versions of of_find_backlight Message-ID: <021f8fecfa3f374dc5dcb70fb07a6f6b019bea7b.1516632388.git.meghana.madhyastha@gmail.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 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 --- Acked-by: Daniel Thompson Reviewed-by: Noralf Tr?nnes Reviewed-by: Sean Paul drivers/video/backlight/backlight.c | 30 ++++++++++++++++++++++++++++++ include/linux/backlight.h | 7 +++++++ 2 files changed, 37 insertions(+) diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 553bf5c48..deb824bef 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c @@ -623,6 +623,36 @@ struct backlight_device *of_find_backlight(struct device *dev) } EXPORT_SYMBOL(of_find_backlight); +static void devm_backlight_release(void *data) +{ + backlight_put(data); +} + +/** + * 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_release, 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 ddc9bade4..2baab6f38 100644 --- a/include/linux/backlight.h +++ b/include/linux/backlight.h @@ -217,11 +217,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 -- 2.11.0