[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210301150840.mqngl7og46o3nxjb@pengutronix.de>
Date: Mon, 1 Mar 2021 16:08:40 +0100
From: Marc Kleine-Budde <mkl@...gutronix.de>
To: Tong Zhang <ztong0001@...il.com>
Cc: Wolfgang Grandegger <wg@...ndegger.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Vincent Mailhol <mailhol.vincent@...adoo.fr>,
Oliver Hartkopp <socketcan@...tkopp.net>,
YueHaibing <yuehaibing@...wei.com>,
Zhang Qilong <zhangqilong3@...wei.com>,
linux-can@...r.kernel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] can: c_can: move runtime PM enable/disable to
c_can_platform
On 28.02.2021 23:15:48, Tong Zhang wrote:
> Currently doing modprobe c_can_pci will make kernel complain
> "Unbalanced pm_runtime_enable!", this is caused by pm_runtime_enable()
> called before pm is initialized in register_candev() and doing so will
I don't see where register_candev() is doing any pm related
initialization.
> also cause it to enable twice.
> This fix is similar to 227619c3ff7c, move those pm_enable/disable code to
> c_can_platform.
As I understand 227619c3ff7c ("can: m_can: move runtime PM
enable/disable to m_can_platform"), PCI devices automatically enable PM,
when the "PCI device is added".
Please clarify the above point, otherwise the code looks OK, small
nitpick inline:
> Signed-off-by: Tong Zhang <ztong0001@...il.com>
> ---
> drivers/net/can/c_can/c_can.c | 26 ++------------------------
> drivers/net/can/c_can/c_can_platform.c | 6 +++++-
> 2 files changed, 7 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
> index ef474bae47a1..04f783b3d9d3 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
> - devm_can_led_init(dev);
> -
> + if (!err)
> + devm_can_led_init(dev);
Please indent with two tabs here.
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists