Received: by 10.223.176.46 with SMTP id f43csp2999994wra; Mon, 22 Jan 2018 06:56:11 -0800 (PST) X-Google-Smtp-Source: AH8x225H0iFZgcRIuoipVtMnZTok4nW5Ci8iiK0ulZRK7AnCqsWXfP6HlL+fYciD3tTUDH7DCbLn X-Received: by 10.107.48.68 with SMTP id w65mr8478951iow.84.1516632971752; Mon, 22 Jan 2018 06:56:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516632971; cv=none; d=google.com; s=arc-20160816; b=x/Iv0hLF/r9ovvaUjBA8S/VyBVFMu0ew1GNW6MQcPwFTbojVRES+4nkXNDefRVFjDO cSr8A+QAhLALVX25PhTZGvjmG7hc0ePuVGQrmY8fzLfMY42hYUESnsaSfyy1KdQkl1Q+ 1UuYSRBLQFZ7WUuSMdX7x6yu7o1o09y01aobm+lQopztamvTV4DbW9fvQE5D4Q3Gc/Mp trvefbTyF2HA6AGtx3Fi7nVAhbBEBWGHDkX4mEwh/p6QK1gVzYjk0lAG1ZxfSiLy4kBa oTyvTw6pN/jMsbGzzSSeUAWFkdeQxc9pcQbQuZoNC7Bk1f3tFi/A44VQV3NJ2OiyIMzM nRAg== 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:to :from:date:dkim-signature:arc-authentication-results; bh=DX4DO9cL5tfzAxV4zv3jcdfnCh8aErJ2DJoTu6BZ8rY=; b=imzLcTWBRoPzYQ9pIFwVuOeXBtqP4k5FAOWLiz+4ohBNFMWJTgPyndhmcWQNeVrjkt OsLJER99twr99aTbESmpq8Xz3Dc0XyhZTq3GGFNc+QAXYfSOwM1Nxo3AsYHjy2FR1GT5 zvHGvp6YjGroKDPxMgPQX43V29r+G7tP/Kp/OcA3F0mlbeDVuIUZoGvI3xw5u8CKb24k FMYaKBGu+wEis+ZoJI1nzQ5v6JxsT546AwTViJSl2j6aoZtvO21ItlyrD3uN9UoWpI0R nJ+OZeKGgO8fE0ms5NrrLnJamueakD1MX4J9OcczJCIzDYRw/Nptze/WTeDLc+pNYch+ j/3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=L1mQQU/d; 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 m137si5889755itg.159.2018.01.22.06.55.59; Mon, 22 Jan 2018 06:56:11 -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=L1mQQU/d; 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 S1751239AbeAVOz2 (ORCPT + 99 others); Mon, 22 Jan 2018 09:55:28 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:44043 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750848AbeAVOz1 (ORCPT ); Mon, 22 Jan 2018 09:55:27 -0500 Received: by mail-pg0-f66.google.com with SMTP id m20so7264551pgc.11 for ; Mon, 22 Jan 2018 06:55:27 -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:in-reply-to:user-agent; bh=DX4DO9cL5tfzAxV4zv3jcdfnCh8aErJ2DJoTu6BZ8rY=; b=L1mQQU/dS3iyHltb8p0uEJN7YM6YvC1WnhD30gwBSBaXZM3RYHvAK8Huw3vUBu3sgE 6loMpJBwfdReYXYyyhISuUb152LJeSYPbsBkSLeqx3Gvo2GlDEtVqtlp4VSkqNyfnhgx 5HaK2zTNB1uXNPSdQeW1Tp/omNv3oJAZi+KurrRnOW885ILytqx6ImZb9HzKaBmkXuJ8 ASJulyMc3ByCjlyGcOrET8AsJnuiu5cKgwkkqVEZxs3I00JZ3XM+M69IqiIrfK2OILlK TNWVxEWLa4logDvqsgmeHSQhZpDcKxNBwyV08q2aD397zC3Eub8shXOra23yrm4xX5gj GWYA== 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:in-reply-to:user-agent; bh=DX4DO9cL5tfzAxV4zv3jcdfnCh8aErJ2DJoTu6BZ8rY=; b=r8KXKmLUcmbjYNxeSl/eYd+fLhwAY/CtVbrhTz66QrSpRoFSfpEu9kk2ZFkLKLVAYk lcf2DOkyVf0JlkF91vZEQFaa1LvAXzcnbKI+aAdUkFgC1vihaA7MWx7ajdGyEGhNBoXF gKimMzl6G4SnBqg538eB1YK1o0RcLQMu2HyqNCWNCNO7lQb6mdmIG7dnvqX5w6gBX9yE PJTF3sKjDPF4LDyMRohFYzZkYu6ZKRx0eN0237TAsU5oxkgkBzvxlRO5UzMLMnP4fmAt rkd3ooh0KFkqSc5q9JlFju4kZt1PfgrcwFm3uxgP5WItoVn1GBRq1OKodHUGC1UB29go 7n0w== X-Gm-Message-State: AKwxytdZXTPQJa436cAFEudxpV6/b4AUKGW6CPUgrzEB05+6wJGVeHHr 3WYAGfESC8MXSmmIhy7ahCOlZGhR X-Received: by 2002:a17:902:380c:: with SMTP id l12-v6mr3440642plc.8.1516632926786; Mon, 22 Jan 2018 06:55:26 -0800 (PST) Received: from raspberrypi ([122.171.92.137]) by smtp.gmail.com with ESMTPSA id 62sm914698pfw.129.2018.01.22.06.55.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jan 2018 06:55:25 -0800 (PST) Date: Mon, 22 Jan 2018 14:55:20 +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 09/10] drm/panel: Use of_find_backlight helper Message-ID: <140d01afb138d687680b2d1776a4c101c9fa9a0a.1516632388.git.meghana.madhyastha@gmail.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 Replace of_find_backlight_by_node and of the code around it with of_find_backlight helper to avoid repetition of code. Signed-off-by: Meghana Madhyastha --- Changes in v18: -Fixed warnings resulting from passing device_node* to of_find_backlight. Fixed it by passing struct device* to of_find_backlight drivers/gpu/drm/panel/panel-innolux-p079zca.c | 24 ++++----------------- drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c | 28 +++++-------------------- drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c | 27 ++++-------------------- 3 files changed, 13 insertions(+), 66 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-innolux-p079zca.c b/drivers/gpu/drm/panel/panel-innolux-p079zca.c index 4c1b29eec..57df39b5c 100644 --- a/drivers/gpu/drm/panel/panel-innolux-p079zca.c +++ b/drivers/gpu/drm/panel/panel-innolux-p079zca.c @@ -215,7 +215,6 @@ MODULE_DEVICE_TABLE(of, innolux_of_match); static int innolux_panel_add(struct innolux_panel *innolux) { struct device *dev = &innolux->link->dev; - struct device_node *np; int err; innolux->supply = devm_regulator_get(dev, "power"); @@ -230,37 +229,22 @@ static int innolux_panel_add(struct innolux_panel *innolux) innolux->enable_gpio = NULL; } - np = of_parse_phandle(dev->of_node, "backlight", 0); - if (np) { - innolux->backlight = of_find_backlight_by_node(np); - of_node_put(np); + innolux->backlight = devm_of_find_backlight(dev); - if (!innolux->backlight) - return -EPROBE_DEFER; - } + if (IS_ERR(innolux->backlight)) + return PTR_ERR(innolux->backlight); drm_panel_init(&innolux->base); innolux->base.funcs = &innolux_panel_funcs; innolux->base.dev = &innolux->link->dev; - err = drm_panel_add(&innolux->base); - if (err < 0) - goto put_backlight; - - return 0; - -put_backlight: - put_device(&innolux->backlight->dev); - - return err; + return drm_panel_add(&innolux->base); } static void innolux_panel_del(struct innolux_panel *innolux) { if (innolux->base.dev) drm_panel_remove(&innolux->base); - - put_device(&innolux->backlight->dev); } static int innolux_panel_probe(struct mipi_dsi_device *dsi) diff --git a/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c b/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c index 072c0fc79..6bf8730f1 100644 --- a/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c +++ b/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c @@ -318,8 +318,7 @@ MODULE_DEVICE_TABLE(of, sharp_of_match); static int sharp_panel_add(struct sharp_panel *sharp) { - struct device_node *np; - int err; + struct device *dev = &sharp->link1->dev; sharp->mode = &default_mode; @@ -327,30 +326,16 @@ static int sharp_panel_add(struct sharp_panel *sharp) if (IS_ERR(sharp->supply)) return PTR_ERR(sharp->supply); - np = of_parse_phandle(sharp->link1->dev.of_node, "backlight", 0); - if (np) { - sharp->backlight = of_find_backlight_by_node(np); - of_node_put(np); + sharp->backlight = devm_of_find_backlight(dev); - if (!sharp->backlight) - return -EPROBE_DEFER; - } + if (IS_ERR(sharp->backlight)) + return PTR_ERR(sharp->backlight); drm_panel_init(&sharp->base); sharp->base.funcs = &sharp_panel_funcs; sharp->base.dev = &sharp->link1->dev; - err = drm_panel_add(&sharp->base); - if (err < 0) - goto put_backlight; - - return 0; - -put_backlight: - if (sharp->backlight) - put_device(&sharp->backlight->dev); - - return err; + return drm_panel_add(&sharp->base); } static void sharp_panel_del(struct sharp_panel *sharp) @@ -358,9 +343,6 @@ static void sharp_panel_del(struct sharp_panel *sharp) if (sharp->base.dev) drm_panel_remove(&sharp->base); - if (sharp->backlight) - put_device(&sharp->backlight->dev); - if (sharp->link2) put_device(&sharp->link2->dev); } diff --git a/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c b/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c index 8a5137963..494aa9b16 100644 --- a/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c +++ b/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c @@ -253,8 +253,6 @@ static const struct drm_panel_funcs sharp_nt_panel_funcs = { static int sharp_nt_panel_add(struct sharp_nt_panel *sharp_nt) { struct device *dev = &sharp_nt->dsi->dev; - struct device_node *np; - int ret; sharp_nt->mode = &default_mode; @@ -271,39 +269,22 @@ static int sharp_nt_panel_add(struct sharp_nt_panel *sharp_nt) gpiod_set_value(sharp_nt->reset_gpio, 0); } - np = of_parse_phandle(dev->of_node, "backlight", 0); - if (np) { - sharp_nt->backlight = of_find_backlight_by_node(np); - of_node_put(np); + sharp_nt->backlight = devm_of_find_backlight(dev); - if (!sharp_nt->backlight) - return -EPROBE_DEFER; - } + if (IS_ERR(sharp_nt->backlight)) + return PTR_ERR(sharp_nt->backlight); drm_panel_init(&sharp_nt->base); sharp_nt->base.funcs = &sharp_nt_panel_funcs; sharp_nt->base.dev = &sharp_nt->dsi->dev; - ret = drm_panel_add(&sharp_nt->base); - if (ret < 0) - goto put_backlight; - - return 0; - -put_backlight: - if (sharp_nt->backlight) - put_device(&sharp_nt->backlight->dev); - - return ret; + return drm_panel_add(&sharp_nt->base); } static void sharp_nt_panel_del(struct sharp_nt_panel *sharp_nt) { if (sharp_nt->base.dev) drm_panel_remove(&sharp_nt->base); - - if (sharp_nt->backlight) - put_device(&sharp_nt->backlight->dev); } static int sharp_nt_panel_probe(struct mipi_dsi_device *dsi) -- 2.11.0