From patchwork Tue Aug 16 20:26:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 9284719 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1919960839 for ; Tue, 16 Aug 2016 21:01:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0745C287FA for ; Tue, 16 Aug 2016 21:01:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED9142881C; Tue, 16 Aug 2016 21:01:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D5CC3287FA for ; Tue, 16 Aug 2016 21:01:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7BDF98929B; Tue, 16 Aug 2016 21:01:02 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from relay1.mentorg.com (relay1.mentorg.com [192.94.38.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 174EA8929B for ; Tue, 16 Aug 2016 21:01:01 +0000 (UTC) Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1bZkwn-0004g9-2O from Vladimir_Zapolskiy@mentor.com ; Tue, 16 Aug 2016 13:26:53 -0700 Received: from eyas.local (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server (TLS) id 14.3.224.2; Tue, 16 Aug 2016 21:26:51 +0100 From: Vladimir Zapolskiy To: Daniel Vetter , Dave Airlie Subject: [RESEND PATCH v2 3/3] drm: tegra: use of_get_i2c_adapter_by_node interface Date: Tue, 16 Aug 2016 23:26:45 +0300 Message-ID: <1471379205-32304-3-git-send-email-vladimir_zapolskiy@mentor.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1471379184-32252-1-git-send-email-vladimir_zapolskiy@mentor.com> References: <1471379184-32252-1-git-send-email-vladimir_zapolskiy@mentor.com> MIME-Version: 1.0 X-Originating-IP: [137.202.0.76] Cc: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This change is needed to properly lock I2C bus driver, which serves DDC, otherwise there is an error in I2C bus driver user counting. Note, that prior to the change put_device() coupled with of_find_i2c_adapter_by_node() was missing on error path of tegra_output_probe(). Signed-off-by: Vladimir Zapolskiy Cc: Thierry Reding --- drivers/gpu/drm/tegra/output.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c index 595d1ec3e02e..1edfde77bb6d 100644 --- a/drivers/gpu/drm/tegra/output.c +++ b/drivers/gpu/drm/tegra/output.c @@ -113,14 +113,12 @@ int tegra_output_probe(struct tegra_output *output) ddc = of_parse_phandle(output->of_node, "nvidia,ddc-i2c-bus", 0); if (ddc) { - output->ddc = of_find_i2c_adapter_by_node(ddc); + output->ddc = of_get_i2c_adapter_by_node(ddc); + of_node_put(ddc); if (!output->ddc) { err = -EPROBE_DEFER; - of_node_put(ddc); return err; } - - of_node_put(ddc); } output->hpd_gpio = of_get_named_gpio_flags(output->of_node, @@ -133,14 +131,13 @@ int tegra_output_probe(struct tegra_output *output) "HDMI hotplug detect"); if (err < 0) { dev_err(output->dev, "gpio_request_one(): %d\n", err); - return err; + goto i2c_release; } err = gpio_to_irq(output->hpd_gpio); if (err < 0) { dev_err(output->dev, "gpio_to_irq(): %d\n", err); - gpio_free(output->hpd_gpio); - return err; + goto gpio_release; } output->hpd_irq = err; @@ -153,8 +150,7 @@ int tegra_output_probe(struct tegra_output *output) if (err < 0) { dev_err(output->dev, "failed to request IRQ#%u: %d\n", output->hpd_irq, err); - gpio_free(output->hpd_gpio); - return err; + goto gpio_release; } output->connector.polled = DRM_CONNECTOR_POLL_HPD; @@ -168,6 +164,14 @@ int tegra_output_probe(struct tegra_output *output) } return 0; + +gpio_release: + gpio_free(output->hpd_gpio); + +i2c_release: + i2c_put_adapter(output->ddc); + + return err; } void tegra_output_remove(struct tegra_output *output) @@ -177,8 +181,7 @@ void tegra_output_remove(struct tegra_output *output) gpio_free(output->hpd_gpio); } - if (output->ddc) - put_device(&output->ddc->dev); + i2c_put_adapter(output->ddc); } int tegra_output_init(struct drm_device *drm, struct tegra_output *output)