lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 16 Apr 2021 08:57:52 +0200
From:   Marc Kleine-Budde <mkl@...gutronix.de>
To:     Aswath Govindraju <a-govindraju@...com>
Cc:     linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
        linux-can@...r.kernel.org, netdev@...r.kernel.org,
        Wolfgang Grandegger <wg@...ndegger.com>,
        Rob Herring <robh+dt@...nel.org>,
        "David S . Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Chandrasekar Ramakrishnan <rcsekar@...sung.com>,
        Kishon Vijay Abraham I <kishon@...com>,
        Lokesh Vutla <lokeshvutla@...com>,
        Vignesh Raghavendra <vigneshr@...com>,
        Grygorii Strashko <grygorii.strashko@...com>,
        Faiz Abbas <faiz_abbas@...com>
Subject: Re: [PATCH v2 2/2] can: m_can: Add support for transceiver as phy

On 4/15/21 5:46 PM, Aswath Govindraju wrote:
> From: Faiz Abbas <faiz_abbas@...com>
> 
> Add support for implementing transceiver node as phy. The max_bitrate is
> obtained by getting a phy attribute.
> 
> Signed-off-by: Faiz Abbas <faiz_abbas@...com>
> Signed-off-by: Aswath Govindraju <a-govindraju@...com>
> ---
>  drivers/net/can/m_can/m_can.c          | 10 ++++++++++
>  drivers/net/can/m_can/m_can.h          |  2 ++
>  drivers/net/can/m_can/m_can_platform.c | 13 +++++++++++++
>  3 files changed, 25 insertions(+)
> 
> diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
> index 34073cd077e4..7d31250446c2 100644
> --- a/drivers/net/can/m_can/m_can.c
> +++ b/drivers/net/can/m_can/m_can.c
> @@ -21,6 +21,7 @@
>  #include <linux/iopoll.h>
>  #include <linux/can/dev.h>
>  #include <linux/pinctrl/consumer.h>
> +#include <linux/phy/phy.h>
>  
>  #include "m_can.h"
>  
> @@ -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 = netdev_priv(dev);
> +	int err;
>  
>  	netif_stop_queue(dev);
>  
> @@ -1536,6 +1538,10 @@ static int m_can_close(struct net_device *dev)
>  	close_candev(dev);
>  	can_led_event(dev, CAN_LED_EVENT_STOP);
>  
> +	err = phy_power_off(cdev->transceiver);
> +	if (err)
> +		return err;
> +
>  	return 0;
>  }
>  
> @@ -1720,6 +1726,10 @@ static int m_can_open(struct net_device *dev)
>  	struct m_can_classdev *cdev = netdev_priv(dev);
>  	int err;
>  
> +	err = phy_power_on(cdev->transceiver);
> +	if (err)
> +		return err;
> +
>  	err = m_can_clk_start(cdev);
>  	if (err)
>  		return err;
> 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 <linux/iopoll.h>
>  #include <linux/can/dev.h>
>  #include <linux/pinctrl/consumer.h>
> +#include <linux/phy/phy.h>
>  
>  /* 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;
>  
>  	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_can/m_can_platform.c
> index 599de0e08cd7..82d4f1a15dd7 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/
>  
>  #include <linux/platform_device.h>
> +#include <linux/phy/phy.h>
>  
>  #include "m_can.h"
>  
> @@ -67,6 +68,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
>  	struct resource *res;
>  	void __iomem *addr;
>  	void __iomem *mram_addr;
> +	struct phy *transceiver;
>  	int irq, ret = 0;
>  
>  	mcan_class = m_can_class_allocate_dev(&pdev->dev,
> @@ -101,6 +103,16 @@ static int m_can_plat_probe(struct platform_device *pdev)
>  		goto probe_fail;
>  	}
>  
> +	transceiver = devm_phy_optional_get(&pdev->dev, NULL);
> +	if (IS_ERR(transceiver)) {
> +		ret = PTR_ERR(transceiver);
> +		dev_err(&pdev->dev, "error while getting phy, err=%d\n", ret);

please use dev_err_probe(), as the probing might be deferred and this is not an
error.

> +		return ret;
> +	}
> +
> +	if (transceiver)
> +		priv->cdev.can.bitrate_max = transceiver->attrs.max_link_rate;
> +
>  	priv->base = addr;
>  	priv->mram_base = mram_addr;
>  
> @@ -108,6 +120,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
>  	mcan_class->pm_clock_support = 1;
>  	mcan_class->can.clock.freq = clk_get_rate(mcan_class->cclk);
>  	mcan_class->dev = &pdev->dev;
> +	mcan_class->transceiver = transceiver;
>  
>  	mcan_class->ops = &m_can_plat_ops;
>  
> 

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

Powered by Openwall GNU/*/Linux Powered by OpenVZ