Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3423532pxf; Mon, 29 Mar 2021 01:39:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeGfOtrFMEdO1WSwQaotEkZgEVV/GQLckKcHWb1kRVAwjeshR3pDgLsIKjUCOo6RXhfsMd X-Received: by 2002:a05:6402:354d:: with SMTP id f13mr27700724edd.228.1617007149539; Mon, 29 Mar 2021 01:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617007149; cv=none; d=google.com; s=arc-20160816; b=XqLf5MzWvsK3TvBIG18Qk1uxzrqpahB7z6uep3nzPQKWLQR8zNRhpiXouGFLk3phX/ N0kdbE4oh8X67+Py+0hsf1DnGJt4x1g/9kSfCHWoqpED3N2EnJ730o8OnxVqADOrn9Zb l7MAa8tjTkOJ4tV3G7dp7yt5HS78Twrx2CVhzTLpz9gC0LQq35Qta3r9F3O41OPZsWey R4vSYzWptFuYw/h5WVnJnY0Ps9JjAoJF/Lm9aNP8uP7Dbj1V9i0+XOBzs8jcDidAm6qo x/zzBqejs5i3Y+zzccds5+2zz2uu0Deo0BROA0SUCVdK4Iv6Xm5W3Xc+D9tuPcN0011x NELw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=arVLkHZIQCu5ILqkcToRzn4tIBHHceNz8GQ3EzhRym4=; b=l8CAgV3anJbH7f9RrE1O0DCfiwzzzTOmYbyYRGsMLEVzRQm0x3a1e2zK15VBn81A7U 7M3dMKm8iGX2IUh8DA3y4Lnu1DnSCHoZHKnWnQXXisaeCOqSnA4EzwiOro8cAQIjX2aC tNFzO+ftLTKcJEG/JN54LNabeS4l+egZkW8RU6TUKsrd6xrGdjnEBgO7eb5o/ppL/JWg 7qxufyvUuWk200Fw40g8YpM9vyM3fNsI1bEsdC9JH8HsYmF8B3yJ3Q7vEe3VVebzoeOX SmGu7ePrI89iXn222S0a4zLaqjrsZESnPkColgHxKZLezMZfks0DlzQte0WvLoHItM+M DhEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k4bzq5Wz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h6si11895634ejt.184.2021.03.29.01.38.47; Mon, 29 Mar 2021 01:39:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k4bzq5Wz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234074AbhC2Ige (ORCPT + 99 others); Mon, 29 Mar 2021 04:36:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:39204 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233740AbhC2IWR (ORCPT ); Mon, 29 Mar 2021 04:22:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5AD3B61554; Mon, 29 Mar 2021 08:22:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006136; bh=BO6EC8n6FKfkAkutF6c1uPEG/Ap31tEs+1mSfH/vrfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k4bzq5Wz8vB1yIN0sh6hUctZa29NB3iuEzrTNtKlcLGe9XC4VCPArnh+6MhI0me2v V1Sg3lt8dPoEqMnH78xz8tdWkj9joJ1SibdurO3VKcxm2km5TF5ce/94wyJQtGnfXt koe1f3+KD0fUMBdEeYSZcl/C2+Hv0U7VtM82lU0s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tong Zhang , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 5.10 130/221] can: c_can: move runtime PM enable/disable to c_can_platform Date: Mon, 29 Mar 2021 09:57:41 +0200 Message-Id: <20210329075633.531826117@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tong Zhang [ Upstream commit 6e2fe01dd6f98da6cae8b07cd5cfa67abc70d97d ] Currently doing modprobe c_can_pci will make the kernel complain: Unbalanced pm_runtime_enable! this is caused by pm_runtime_enable() called before pm is initialized. This fix is similar to 227619c3ff7c, move those pm_enable/disable code to c_can_platform. Fixes: 4cdd34b26826 ("can: c_can: Add runtime PM support to Bosch C_CAN/D_CAN controller") Link: http://lore.kernel.org/r/20210302025542.987600-1-ztong0001@gmail.com Signed-off-by: Tong Zhang Tested-by: Uwe Kleine-König Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin --- drivers/net/can/c_can/c_can.c | 24 +----------------------- drivers/net/can/c_can/c_can_platform.c | 6 +++++- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c index 1a9e9b9a4bf6..6c75e5897620 100644 --- a/drivers/net/can/c_can/c_can.c +++ b/drivers/net/can/c_can/c_can.c @@ -212,18 +212,6 @@ static const struct can_bittiming_const c_can_bittiming_const = { .brp_inc = 1, }; -static inline void c_can_pm_runtime_enable(const struct c_can_priv *priv) -{ - if (priv->device) - pm_runtime_enable(priv->device); -} - -static inline void c_can_pm_runtime_disable(const struct c_can_priv *priv) -{ - if (priv->device) - pm_runtime_disable(priv->device); -} - static inline void c_can_pm_runtime_get_sync(const struct c_can_priv *priv) { if (priv->device) @@ -1335,7 +1323,6 @@ static const struct net_device_ops c_can_netdev_ops = { int register_c_can_dev(struct net_device *dev) { - struct c_can_priv *priv = netdev_priv(dev); int err; /* Deactivate pins to prevent DRA7 DCAN IP from being @@ -1345,28 +1332,19 @@ int register_c_can_dev(struct net_device *dev) */ pinctrl_pm_select_sleep_state(dev->dev.parent); - c_can_pm_runtime_enable(priv); - dev->flags |= IFF_ECHO; /* we support local echo */ dev->netdev_ops = &c_can_netdev_ops; err = register_candev(dev); - if (err) - c_can_pm_runtime_disable(priv); - else + if (!err) devm_can_led_init(dev); - return err; } EXPORT_SYMBOL_GPL(register_c_can_dev); void unregister_c_can_dev(struct net_device *dev) { - struct c_can_priv *priv = netdev_priv(dev); - unregister_candev(dev); - - c_can_pm_runtime_disable(priv); } EXPORT_SYMBOL_GPL(unregister_c_can_dev); diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c index 05f425ceb53a..47b251b1607c 100644 --- a/drivers/net/can/c_can/c_can_platform.c +++ b/drivers/net/can/c_can/c_can_platform.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -386,6 +387,7 @@ static int c_can_plat_probe(struct platform_device *pdev) platform_set_drvdata(pdev, dev); SET_NETDEV_DEV(dev, &pdev->dev); + pm_runtime_enable(priv->device); ret = register_c_can_dev(dev); if (ret) { dev_err(&pdev->dev, "registering %s failed (err=%d)\n", @@ -398,6 +400,7 @@ static int c_can_plat_probe(struct platform_device *pdev) return 0; exit_free_device: + pm_runtime_disable(priv->device); free_c_can_dev(dev); exit: dev_err(&pdev->dev, "probe failed\n"); @@ -408,9 +411,10 @@ exit: static int c_can_plat_remove(struct platform_device *pdev) { struct net_device *dev = platform_get_drvdata(pdev); + struct c_can_priv *priv = netdev_priv(dev); unregister_c_can_dev(dev); - + pm_runtime_disable(priv->device); free_c_can_dev(dev); return 0; -- 2.30.1