From patchwork Mon Mar 16 16:39:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 11443043 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2189214B4 for ; Tue, 17 Mar 2020 14:18:29 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 09DB62051A for ; Tue, 17 Mar 2020 14:18:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 09DB62051A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2AA9A6E1C4; Tue, 17 Mar 2020 14:18:28 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from pokefinder.org (sauhun.de [88.99.104.3]) by gabe.freedesktop.org (Postfix) with ESMTP id 01D4489E05 for ; Mon, 16 Mar 2020 16:44:22 +0000 (UTC) Received: from localhost (p54B334BA.dip0.t-ipconnect.de [84.179.52.186]) by pokefinder.org (Postfix) with ESMTPSA id D625D2C1EFA; Mon, 16 Mar 2020 17:39:11 +0100 (CET) From: Wolfram Sang To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] drm: encoder_slave: fix refcouting error for modules Date: Mon, 16 Mar 2020 17:39:06 +0100 Message-Id: <20200316163907.13709-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316163907.13709-1-wsa+renesas@sang-engineering.com> References: <20200316163907.13709-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 17 Mar 2020 14:16:40 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Wolfram Sang , Thomas Zimmermann , Dave Airlie Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" module_put() balances try_module_get(), not request_module(). Fix the error path to match that. Fixes: 2066facca4c7 ("drm/kms: slave encoder interface.") Signed-off-by: Wolfram Sang --- drivers/gpu/drm/drm_encoder_slave.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_encoder_slave.c b/drivers/gpu/drm/drm_encoder_slave.c index cf804389f5ec..d50a7884e69e 100644 --- a/drivers/gpu/drm/drm_encoder_slave.c +++ b/drivers/gpu/drm/drm_encoder_slave.c @@ -84,7 +84,7 @@ int drm_i2c_encoder_init(struct drm_device *dev, err = encoder_drv->encoder_init(client, dev, encoder); if (err) - goto fail_unregister; + goto fail_module_put; if (info->platform_data) encoder->slave_funcs->set_config(&encoder->base, @@ -92,9 +92,10 @@ int drm_i2c_encoder_init(struct drm_device *dev, return 0; +fail_module_put: + module_put(module); fail_unregister: i2c_unregister_device(client); - module_put(module); fail: return err; } From patchwork Mon Mar 16 16:39:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 11443009 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A98ED14B4 for ; Tue, 17 Mar 2020 14:17:14 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 921D12051A for ; Tue, 17 Mar 2020 14:17:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 921D12051A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 764FF6E184; Tue, 17 Mar 2020 14:16:43 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from pokefinder.org (sauhun.de [88.99.104.3]) by gabe.freedesktop.org (Postfix) with ESMTP id 05C0989E14 for ; Mon, 16 Mar 2020 16:44:23 +0000 (UTC) Received: from localhost (p54B334BA.dip0.t-ipconnect.de [84.179.52.186]) by pokefinder.org (Postfix) with ESMTPSA id 7F4EC2C1F53; Mon, 16 Mar 2020 17:39:12 +0100 (CET) From: Wolfram Sang To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm: encoder_slave: use new I2C API Date: Mon, 16 Mar 2020 17:39:07 +0100 Message-Id: <20200316163907.13709-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316163907.13709-1-wsa+renesas@sang-engineering.com> References: <20200316163907.13709-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 17 Mar 2020 14:16:40 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Wolfram Sang , Thomas Zimmermann Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" i2c_new_client() is deprecated, use the replacement i2c_new_client_device(). Also, we have a helper to check if a driver is bound. Use it to simplify the code. Note that this changes the errno for a failed device creation from ENOMEM to ENODEV. No callers currently interpret this errno, though, so we use this condensed error check. Signed-off-by: Wolfram Sang --- drivers/gpu/drm/drm_encoder_slave.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/drm_encoder_slave.c b/drivers/gpu/drm/drm_encoder_slave.c index d50a7884e69e..e464429d32df 100644 --- a/drivers/gpu/drm/drm_encoder_slave.c +++ b/drivers/gpu/drm/drm_encoder_slave.c @@ -61,13 +61,8 @@ int drm_i2c_encoder_init(struct drm_device *dev, request_module("%s%s", I2C_MODULE_PREFIX, info->type); - client = i2c_new_device(adap, info); - if (!client) { - err = -ENOMEM; - goto fail; - } - - if (!client->dev.driver) { + client = i2c_new_client_device(adap, info); + if (!i2c_client_has_driver(client)) { err = -ENODEV; goto fail_unregister; } @@ -96,7 +91,6 @@ int drm_i2c_encoder_init(struct drm_device *dev, module_put(module); fail_unregister: i2c_unregister_device(client); -fail: return err; } EXPORT_SYMBOL(drm_i2c_encoder_init);