Received: by 10.223.148.5 with SMTP id 5csp7559075wrq; Thu, 18 Jan 2018 06:53:07 -0800 (PST) X-Google-Smtp-Source: ACJfBouw8EJ5WI3HA3Xf9ulbUi+UNCpBdOMHRWsZF6OBbmLpIii6TFoOzqtWyX2yj/CAxFms+JIE X-Received: by 10.98.16.79 with SMTP id y76mr27487636pfi.111.1516287187098; Thu, 18 Jan 2018 06:53:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516287187; cv=none; d=google.com; s=arc-20160816; b=qPusobJAKwEPmrw6LWTSBsd+KSLyPC8/Hs2p3t3QexNrlBcS3wgaYOM2zC+oCXDPuh 7cYKPYQZpgVb8GLS4FT360G+pVjIkwwxKEQjj7cxBrZ+QZxQt5EqC+Rj7FhhFCvGG4e5 wYJopUHPbfgQzgP9Q9YlShQYrVRcfPAp6EOcdSmzJnnY57a1xM5/5qago2DsyQw2ahfw qNIFyVL1LfYXqYZogEPq1BasjorJ6yitxkg5XFwuMNltzGEdA7tIrK2oVzEBzx9AjIhZ nEsWMOUcU0mg4dMS4ZRnnF3dT63VnnIm3OI+IWb2dKJCSyhJPAz0wVA9/8+TVQuU0/8j wa2A== 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:in-reply-to :mime-version:user-agent:date:message-id:from:references:to:subject :arc-authentication-results; bh=Vc72YCxhdPTMA/QgZP+XXI8GKqmFTtu7KQ6XT16QAV8=; b=n55eZ3bz/uWJQ4IUmOtZIziLDN2U9Fa5+pkSxCivNkrQlsfC6V9bqprSueP6RE5e6t PuFFy1jRUkoLZtgxuSrosbuGIFlpyFZR5MPrhK+AVFTdgx4jFijNvzY/w0D8YxZkRy9n ZsEPciEtE0+wcpGlIrpu5UbtRekzWi3IP2RCb0yaECPUSaEwuvhIx5lmhiD77f+42jqG kIdWq75vVk4Bdjxa+EWU09ZsQ2msaLHWsMHcWVs8V2wB7IIb33i4J2zms6yaCuUTuLtE 4NRv+/Nw3NzCy9FmH9VUTRGwHg9xeVAOm84+28z16+6UcrIG47yVtjAKkR0MhJcR48DO w1DA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k12si371763pgo.806.2018.01.18.06.52.52; Thu, 18 Jan 2018 06:53:07 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932536AbeAROvl (ORCPT + 99 others); Thu, 18 Jan 2018 09:51:41 -0500 Received: from smtp.domeneshop.no ([194.63.252.55]:44984 "EHLO smtp.domeneshop.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932466AbeAROvZ (ORCPT ); Thu, 18 Jan 2018 09:51:25 -0500 Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:62178 helo=[192.168.10.157]) by smtp.domeneshop.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1ecBXH-0002q0-2o; Thu, 18 Jan 2018 15:51:23 +0100 Subject: Re: [PATCH v16 09/10] drm/panel: Use of_find_backlight helper To: Meghana Madhyastha , Lee Jones , Daniel Thompson , Jingoo Han , Thierry Reding , Tomi Valkeinen , Daniel Vetter , Sean Paul , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20180118120732.GC4864@meghana-HP-Pavilion-Notebook> From: =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= Message-ID: <938045f6-e404-b26e-138b-7eb5ef456975@tronnes.org> Date: Thu, 18 Jan 2018 15:51:12 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180118120732.GC4864@meghana-HP-Pavilion-Notebook> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Den 18.01.2018 13.07, skrev Meghana Madhyastha: > On Tue, Jan 16, 2018 at 06:08:53PM +0100, Noralf Trønnes wrote: >> Den 16.01.2018 11.36, skrev Meghana Madhyastha: >>> 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 >>> --- >>> drivers/gpu/drm/panel/panel-innolux-p079zca.c | 10 +++------- >>> drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c | 10 +++------- >>> drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c | 10 +++------- >>> 3 files changed, 9 insertions(+), 21 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/panel/panel-innolux-p079zca.c b/drivers/gpu/drm/panel/panel-innolux-p079zca.c >>> index 4c1b29eec..a69b0530f 100644 >>> --- a/drivers/gpu/drm/panel/panel-innolux-p079zca.c >>> +++ b/drivers/gpu/drm/panel/panel-innolux-p079zca.c >>> @@ -230,14 +230,10 @@ 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(np); >> This driver isn't broken like tinydrm was, so it does put the backlight >> device on cleanup like it should. So when you're using the devm_ version, >> the result is a double put. Just remove the put_device() in >> innolux_panel_add/del() and you're good. > I have a quick question here. So devm_of_find_backlight automatically > does a put_device on detachment of the driver. However in this case, > put_device is called when panel_add is not successful (i.e when it > returns a negative value here). So is devm's release mechanism still > invoked here ? As long as the error is propagated back up the chain, which it is in this case, devres_release_all() is called and the resources are released. Driver callchain passing up the error: innolux_panel_driver.probe = innolux_panel_probe <- innolux_panel_add <- devm_of_find_backlight This is mipi_dsi setting up the probe hook and calling into it's own version: drivers/gpu/drm/drm_mipi_dsi.c: int mipi_dsi_driver_register_full(struct mipi_dsi_driver *drv,                   struct module *owner) { ...     if (drv->probe)         drv->driver.probe = mipi_dsi_drv_probe; ... } static int mipi_dsi_drv_probe(struct device *dev) {     struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver);     struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);     return drv->probe(dsi); } This is the device-driver core that initiates the probing: drivers/base/dd.c static int really_probe(struct device *dev, struct device_driver *drv) { ...     } else if (drv->probe) {         ret = drv->probe(dev);         if (ret)             goto probe_failed;     } ... probe_failed: ...     devres_release_all(dev); ... } > err = drm_panel_add(&innolux->base); > if (err < 0) > goto put_backlight; > > return 0; > > put_backlight: > put_device(&innolux->backlight->dev); > return err; > > If so then I should change this to > err = drm_panel_add(&innolux->base) > return err; Yes, and you can drop the variable:         return drm_panel_add(&innolux->base); Noralf. > > Thanks and regards, > Meghana > >> I haven't checked the other drivers. >> >> Noralf. >> >> PS: >> Give people a few days (one week?) to respond before respinning a new >> version, so we avoid a fragmented discussion. >> >>> - 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; >>> diff --git a/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c b/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c >>> index 1512ec4f3..d5450c9d9 100644 >>> --- a/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c >>> +++ b/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c >>> @@ -329,14 +329,10 @@ 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(np); >>> - 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; >>> diff --git a/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c b/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c >>> index a6af3257f..db31d8268 100644 >>> --- a/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c >>> +++ b/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c >>> @@ -273,14 +273,10 @@ 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(np); >>> - 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;