From patchwork Thu Dec 7 21:27:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Khoroshilov X-Patchwork-Id: 845851 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yt7rK59fsz9s81 for ; Fri, 8 Dec 2017 08:28:17 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752565AbdLGV2Q (ORCPT ); Thu, 7 Dec 2017 16:28:16 -0500 Received: from mail.ispras.ru ([83.149.199.45]:33670 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752379AbdLGV2P (ORCPT ); Thu, 7 Dec 2017 16:28:15 -0500 Received: from hednb3.t-mobile.de (unknown [88.128.82.163]) by mail.ispras.ru (Postfix) with ESMTPSA id 092D854006C; Fri, 8 Dec 2017 00:28:12 +0300 (MSK) From: Alexey Khoroshilov To: Wolfram Sang Cc: Alexey Khoroshilov , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] i2c: hix5hd2: Make sure clk is disabled in remove Date: Thu, 7 Dec 2017 22:27:55 +0100 Message-Id: <1512682075-29755-1-git-send-email-khoroshilov@ispras.ru> X-Mailer: git-send-email 2.7.4 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org pm_runtime_set_suspended() does not lead to call of suspend callback, so clk may be left undisabled in hix5hd2_i2c_remove(). By the way, the patch adds error handling for clk_prepare_enable(). Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov --- drivers/i2c/busses/i2c-hix5hd2.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-hix5hd2.c b/drivers/i2c/busses/i2c-hix5hd2.c index bb68957d3da5..8a921b5135ad 100644 --- a/drivers/i2c/busses/i2c-hix5hd2.c +++ b/drivers/i2c/busses/i2c-hix5hd2.c @@ -446,7 +446,11 @@ static int hix5hd2_i2c_probe(struct platform_device *pdev) dev_err(&pdev->dev, "cannot get clock\n"); return PTR_ERR(priv->clk); } - clk_prepare_enable(priv->clk); + ret = clk_prepare_enable(priv->clk); + if (ret) { + dev_err(&pdev->dev, "cannot enable clock\n"); + return ret; + } strlcpy(priv->adap.name, "hix5hd2-i2c", sizeof(priv->adap.name)); priv->dev = &pdev->dev; @@ -496,8 +500,9 @@ static int hix5hd2_i2c_remove(struct platform_device *pdev) struct hix5hd2_i2c_priv *priv = platform_get_drvdata(pdev); i2c_del_adapter(&priv->adap); - pm_runtime_disable(priv->dev); - pm_runtime_set_suspended(priv->dev); + + /* Make sure priv->clk is disabled */ + pm_runtime_force_suspend(priv->dev); return 0; }