Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp2283561pxv; Sat, 24 Jul 2021 10:58:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhJI4qVnNl1/Xp7Ci9f+3UWewVU079OZlx2vceCuE036lTex4Dgfg3Mra9WzOwQb7PJFZR X-Received: by 2002:a05:6e02:1a46:: with SMTP id u6mr7306101ilv.135.1627149529121; Sat, 24 Jul 2021 10:58:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627149529; cv=none; d=google.com; s=arc-20160816; b=IbsNFhIgb9Wr80/dWs8KSiETVpy5g50/xPk+Dw+vuPPISJak/LhspHyqVbm8iEygXU JGgCHtuV20DAvA1mLY/ny7FyYfcQ0wHu6KcfIRSC31GTRQovaW4IgJP1jCdWNqaAAXXp Fk+Pac03WfImvYIiyPurvFJT1pdnOjnVs6AZ3Vwg1DlIoRnYPJIwZsl3KalHeT+bGcj6 ocnMg91CQU0cGcw500V7beLJbrtZN1dY9EHcoyGBjZhA4EVtxzAnI1rRYPmBGM+1f0Bs Udsd5QH7vaZlygYYvHXdUeWuQlFhSAHr7zvD0vzYNd7G7OMgZqH+m3VEWI+eCYdhwi7i EbaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=BsTTE5js17lRfuMd3lQRzaExF46VkuFsWAonbcaCCbQ=; b=NJ+bxGePP3yH2Lnx+45AfLcyl3BeZFwQvoZjP9u/x5LP9EywOqqanrwOVripoThS1K DCw7IXZviw50GfwUNvqHjZLwCRHWZSt8E3qQc5gPNmo7pQRpbjod4Xk0sQ4iIERn5jMI OGUgGfoUGvxUE+hcsvnVhOlNLDMYrf5PjEQDG5YjJ/YNpV6cDBHTWaiBbkGDkTbTb6pe pmGghoN9mAskDktYv5m5BH5c1tr3Olw+g3MWPd7aHmXYfNsUj6LWAO2e0cX7mpEWHONh WXk0vQ9dLXfE9kxT4o7ZXMH61CtnXQRucUcpkS3HLmHpKwJOorPmZ1/OHrF2LJl+29Lq RmGQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x5si17612898ilq.85.2021.07.24.10.58.23; Sat, 24 Jul 2021 10:58:49 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229912AbhGXRQZ (ORCPT + 99 others); Sat, 24 Jul 2021 13:16:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbhGXRQY (ORCPT ); Sat, 24 Jul 2021 13:16:24 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26DC6C061575 for ; Sat, 24 Jul 2021 10:56:56 -0700 (PDT) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=bjornoya.blackshift.org) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m7LtC-0006BX-5X; Sat, 24 Jul 2021 19:56:42 +0200 Received: from pengutronix.de (unknown [IPv6:2a03:f580:87bc:d400:41cc:c65c:f580:3bde]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: mkl-all@blackshift.org) by smtp.blackshift.org (Postfix) with ESMTPSA id 1B18D657090; Sat, 24 Jul 2021 17:56:39 +0000 (UTC) Date: Sat, 24 Jul 2021 19:56:37 +0200 From: Marc Kleine-Budde To: Aswath Govindraju Cc: Chandrasekar Ramakrishnan , Wolfgang Grandegger , "David S . Miller" , Jakub Kicinski , Rob Herring , linux-can@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Vignesh Raghavendra , Lokesh Vutla , Kishon Vijay Abraham I Subject: Re: [PATCH v4 2/2] can: m_can: Add support for transceiver as phy Message-ID: <20210724175637.vcslc2iewcdqnvev@pengutronix.de> References: <20210510052541.14168-1-a-govindraju@ti.com> <20210510052541.14168-3-a-govindraju@ti.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="aozsztylvh5w2ifj" Content-Disposition: inline In-Reply-To: <20210510052541.14168-3-a-govindraju@ti.com> X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --aozsztylvh5w2ifj Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 10.05.2021 10:55:41, Aswath Govindraju wrote: > From: Faiz Abbas >=20 > Add support for implementing transceiver node as phy. The max_bitrate is > obtained by getting a phy attribute. >=20 > Signed-off-by: Faiz Abbas > Signed-off-by: Aswath Govindraju > --- > drivers/net/can/m_can/m_can.c | 11 +++++++++++ > drivers/net/can/m_can/m_can.h | 2 ++ > drivers/net/can/m_can/m_can_platform.c | 13 +++++++++++++ > 3 files changed, 26 insertions(+) >=20 > diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c > index 3cf6de21d19c..afbecc35d3b6 100644 > --- a/drivers/net/can/m_can/m_can.c > +++ b/drivers/net/can/m_can/m_can.c > @@ -21,6 +21,7 @@ > #include > #include > #include > +#include > =20 > #include "m_can.h" > =20 > @@ -1514,6 +1515,7 @@ static void m_can_stop(struct net_device *dev) > static int m_can_close(struct net_device *dev) > { > struct m_can_classdev *cdev =3D netdev_priv(dev); > + int err; > =20 > netif_stop_queue(dev); > =20 > @@ -1536,6 +1538,10 @@ static int m_can_close(struct net_device *dev) > close_candev(dev); > can_led_event(dev, CAN_LED_EVENT_STOP); > =20 > + err =3D phy_power_off(cdev->transceiver); > + if (err) > + return err; No need to propagate errors in the close(). > + > return 0; > } > =20 > @@ -1721,6 +1727,10 @@ static int m_can_open(struct net_device *dev) > struct m_can_classdev *cdev =3D netdev_priv(dev); > int err; > =20 > + err =3D phy_power_on(cdev->transceiver); > + if (err) > + return err; > + > err =3D m_can_clk_start(cdev); > if (err) > return err; Here, don't handle the error properly. > @@ -1781,6 +1791,7 @@ static int m_can_open(struct net_device *dev) > close_candev(dev); > exit_disable_clks: > m_can_clk_stop(cdev); > + phy_power_off(cdev->transceiver); > return err; > } > =20 > diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h > index ace071c3e58c..38cad068abad 100644 > --- a/drivers/net/can/m_can/m_can.h > +++ b/drivers/net/can/m_can/m_can.h > @@ -28,6 +28,7 @@ > #include > #include > #include > +#include > =20 > /* m_can lec values */ > enum m_can_lec_type { > @@ -82,6 +83,7 @@ struct m_can_classdev { > struct workqueue_struct *tx_wq; > struct work_struct tx_work; > struct sk_buff *tx_skb; > + struct phy *transceiver; > =20 > struct can_bittiming_const *bit_timing; > struct can_bittiming_const *data_timing; > diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_c= an/m_can_platform.c > index 599de0e08cd7..f102d532b7f0 100644 > --- a/drivers/net/can/m_can/m_can_platform.c > +++ b/drivers/net/can/m_can/m_can_platform.c > @@ -6,6 +6,7 @@ > // Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.= com/ > =20 > #include > +#include > =20 > #include "m_can.h" > =20 > @@ -67,6 +68,7 @@ static int m_can_plat_probe(struct platform_device *pde= v) > struct resource *res; > void __iomem *addr; > void __iomem *mram_addr; > + struct phy *transceiver; > int irq, ret =3D 0; > =20 > mcan_class =3D m_can_class_allocate_dev(&pdev->dev, > @@ -101,6 +103,16 @@ static int m_can_plat_probe(struct platform_device *= pdev) > goto probe_fail; > } > =20 > + transceiver =3D devm_phy_optional_get(&pdev->dev, NULL); > + if (IS_ERR(transceiver)) { > + ret =3D PTR_ERR(transceiver); > + dev_err_probe(&pdev->dev, ret, "failed to get phy\n"); > + return ret; Here you leak the memory allocated by m_can_class_allocate_dev(). > + } > + > + if (transceiver) > + mcan_class->can.bitrate_max =3D transceiver->attrs.max_link_rate; > + > priv->base =3D addr; > priv->mram_base =3D mram_addr; > =20 > @@ -108,6 +120,7 @@ static int m_can_plat_probe(struct platform_device *p= dev) > mcan_class->pm_clock_support =3D 1; > mcan_class->can.clock.freq =3D clk_get_rate(mcan_class->cclk); > mcan_class->dev =3D &pdev->dev; > + mcan_class->transceiver =3D transceiver; > =20 > mcan_class->ops =3D &m_can_plat_ops; > =20 > --=20 > 2.17.1 >=20 > I've send a v5 fixing these problems. regards, Marc --=20 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 | --aozsztylvh5w2ifj Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEK3kIWJt9yTYMP3ehqclaivrt76kFAmD8VFMACgkQqclaivrt 76lU3Af6A5JrBDeFGF/y9LtAa9s/HuuJtW5am23+tonZTKV2LwpFZlxSR18/e9of ZpdHaLJf+XBo33FxQKc32zvHg+4u+d2qgfkrAJrqaSadRx0V3nwm08Ab/QBc4LPM gO99CqSvRUGZkmhiFMQ51u5WQHQ1VDS4UszqAcyuyZ7JIlwUE2/tzDU0/Ovmu6kO yuRIOHZuhEO8bHP26u1/4iZOpOhRfC9xg70/HeXZvwGQmLXLLZzXQJVY1+mPEjkn us6tglOHQO/SWugT8xwSxGydys3NN92aB+xxsmsd97det544z0wEjjS4d6gJYSaN /psJgaQEDFCttcrHRUMT4XfxylnhxA== =uHbx -----END PGP SIGNATURE----- --aozsztylvh5w2ifj--