Received: by 10.223.176.46 with SMTP id f43csp972585wra; Wed, 24 Jan 2018 08:39:23 -0800 (PST) X-Google-Smtp-Source: AH8x224nXQReYMWJTaN2vwXlK9CmBWYgYh6KO3KluIQWFnORSJnXexz9v6WRKCTAnBWkGrpnBvT1 X-Received: by 10.99.147.70 with SMTP id w6mr11780980pgm.410.1516811962775; Wed, 24 Jan 2018 08:39:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516811962; cv=none; d=google.com; s=arc-20160816; b=SkxPoRL7LtprUEGZ2osTgKGpbx5ZKQrDikCj/Ma3KvkaxhBUkLvl43B8JnWVgEToEo /MRMMt8u4q63k83nLnhKb5JcxGMn2cFP+5JooxkOC2+AD6TS1IpIA2J7Op/1wkeEwUZ3 E/z5Rsk+obupnzoHw36GxPpjvXOneUSAcIYD9jo5U479oNtuWlgGXRHGgn0bkO3G0Yqe HmPQMo7+ao4Og/EXKx+dg5A20xb6wAdePpaVtArzPqxVj17XQLtkXSwd76JHo+LaWEwD 38cGq2DhF/m4SyVg/vknxxwZG7qSzDZvi8wAUz35HLwH74marDJ69R4L3lZCytuPfBrz VbJw== 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=o6MURGlkDXQRNjhmnlYstaNNtyf7y1tuDaEMR/POz8U=; b=w2msOeWuwv8RDUWWmiFLxml2B21y1buvcaJ7NY4AUTHJ1BURk2s1XCuFk9aN4UgH5S NKI/1fA710KS5bN7Xwf0dUNzqZQ9TtMto/uSODEdnXBJzGw5hCkNs1zGIcfP5LHhxUb9 5a7cnHh3r77rjwsmqSVeWvyPxOSOmksk4WFsvdhzhjE8fksz/NqR8kJq/Okok3Gzyz4R V/Ps/jZWk525PTEt25Uhs9j9pvFrM75X7PK2JvfQl9H0TaB424MhlGZ0HWfqiJ8u3bF3 q2+AdGuwmPY/iv6pDFEJ5H3qaatu6yzSrsvMiUpzqPblQinNJV3Lcy6JsAiKpz1Ojj2C kJHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XNYjjvv2; 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 z8-v6si425284plo.762.2018.01.24.08.39.08; Wed, 24 Jan 2018 08:39:22 -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=XNYjjvv2; 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 S964941AbeAXQhf (ORCPT + 99 others); Wed, 24 Jan 2018 11:37:35 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:39134 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934286AbeAXQha (ORCPT ); Wed, 24 Jan 2018 11:37:30 -0500 Received: by mail-pf0-f194.google.com with SMTP id e11so3483008pff.6 for ; Wed, 24 Jan 2018 08:37:30 -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=o6MURGlkDXQRNjhmnlYstaNNtyf7y1tuDaEMR/POz8U=; b=XNYjjvv2ewPI9hcn61SwapYSuyeTiGuXMQKATJqx8Pvb26BuR3psKYV+B14EYvm6gm c7PfxWvPAZ1p1URNCLnMuGc2CvO4AZVxa6xgeIfFHo2hbZDFN+uJorid+W3B55KzdgfS 43lLhmbDxNbvlrRDIpNKJr5E5G8yb9sAd/yUJvhsVjE5o5AT3YogRoVfEJO+IKygg3hY jgAtwNGhDtX/FFHZv1lD1durNaKhpCiuzJVSPWI1pdV0sL6zBJ3hU33EY+1V+pW5iY3W l/rsXwvcGbIzDn7GEyVQXOgrH/Z3ZRWdge1qgEzZsRNMR2PIfyd1H2bwK4KYw+Q9RDc1 2lWQ== 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=o6MURGlkDXQRNjhmnlYstaNNtyf7y1tuDaEMR/POz8U=; b=DbHonlfKfhhERwf3qYglXhWSecqGNiHAQ80uVYqtNdM5lCpMEeIMsUyqyifPtQs8Nf ZWi9JGzjk1z7IYVJF256U6epk8jaJnvrcL9d3d+Ph3Y8SWwjABPdQCKkU4PpjJq9VaJi VMt1gefJcyWMF1Wu9lTKv6KNf8JQh9YRrL5PMr3QxiWc1KdAT+9FeyXH1ceWL2AcNdRZ wsWOyMTdz5FHi4kDAX4pTfBRpMXU9DNF/2BKCvbP1Z2/mxv1wN+/CwDBUrPxDRM4Onmc ToFQ1o5tKTA94Qu199go86BknfJSQOVP3sD0XA6IU4wWAl6gKYEydfEFypEqdyOl2cAA wmYA== X-Gm-Message-State: AKwxytciGB9hXvMOceVrpJ6sAAtkT4XOMVKvgI+rTl/zk8uWNO8gfI7U KBcpqjl61y+o+ZyaTnsI5qg= X-Received: by 2002:a17:902:b68b:: with SMTP id c11-v6mr8559814pls.95.1516811849558; Wed, 24 Jan 2018 08:37:29 -0800 (PST) Received: from raspberrypi ([122.172.61.122]) by smtp.gmail.com with ESMTPSA id b69sm14550879pfk.128.2018.01.24.08.37.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Jan 2018 08:37:28 -0800 (PST) Date: Wed, 24 Jan 2018 16:37:23 +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 v19 05/10] video: backlight: Add devres versions of of_find_backlight Message-ID: <021f8fecfa3f374dc5dcb70fb07a6f6b019bea7b.1516810725.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. Acked-by: Daniel Thompson Reviewed-by: Noralf Tr?nnes Reviewed-by: Sean Paul Signed-off-by: Meghana Madhyastha --- 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