diff mbox series

[net-next,v2,3/3] net: emaclite: Adopt clock support

Message ID 1728313563-722267-4-git-send-email-radhey.shyam.pandey@amd.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: xilinx: emaclite: Adopt clock support | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 6 this patch: 6
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 6 this patch: 6
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 26 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-10-08--00-00 (tests: 773)

Commit Message

Pandey, Radhey Shyam Oct. 7, 2024, 3:06 p.m. UTC
From: Abin Joseph <abin.joseph@amd.com>

Adapt to use the clock framework. Add s_axi_aclk clock from the processor
bus clock domain and make clk optional to keep DTB backward compatibility.

Signed-off-by: Abin Joseph <abin.joseph@amd.com>
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
---
changes for v2:
- None.
---
 drivers/net/ethernet/xilinx/xilinx_emaclite.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Kalesh Anakkur Purayil Oct. 8, 2024, 3:42 a.m. UTC | #1
On Mon, Oct 7, 2024 at 8:39 PM Radhey Shyam Pandey
<radhey.shyam.pandey@amd.com> wrote:
>
> From: Abin Joseph <abin.joseph@amd.com>
>
> Adapt to use the clock framework. Add s_axi_aclk clock from the processor
> bus clock domain and make clk optional to keep DTB backward compatibility.
>
> Signed-off-by: Abin Joseph <abin.joseph@amd.com>
> Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
> ---
> changes for v2:
> - None.
> ---
>  drivers/net/ethernet/xilinx/xilinx_emaclite.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
> index 418587942527..fe901af5ddfa 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
> +++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
> @@ -7,6 +7,7 @@
>   * Copyright (c) 2007 - 2013 Xilinx, Inc.
>   */
>
> +#include <linux/clk.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/uaccess.h>
> @@ -1091,6 +1092,7 @@ static int xemaclite_of_probe(struct platform_device *ofdev)
>         struct net_device *ndev = NULL;
>         struct net_local *lp = NULL;
>         struct device *dev = &ofdev->dev;
> +       struct clk *clkin;
>
>         int rc = 0;
>
> @@ -1127,6 +1129,12 @@ static int xemaclite_of_probe(struct platform_device *ofdev)
>         lp->tx_ping_pong = get_bool(ofdev, "xlnx,tx-ping-pong");
>         lp->rx_ping_pong = get_bool(ofdev, "xlnx,rx-ping-pong");
>
> +       clkin = devm_clk_get_optional_enabled(&ofdev->dev, NULL);
> +       if (IS_ERR(clkin)) {
> +               return dev_err_probe(&ofdev->dev, PTR_ERR(clkin),
> +                               "Failed to get and enable clock from Device Tree\n");
> +       }
[Kalesh] Braces are not needed here for a single statement block.

Also, I do not see where you use this "clkin" in this driver. I may be
missing something as I am not an expert in this area.
> +
>         rc = of_get_ethdev_address(ofdev->dev.of_node, ndev);
>         if (rc) {
>                 dev_warn(dev, "No MAC address found, using random\n");
> --
> 2.34.1
>
>
Pandey, Radhey Shyam Oct. 8, 2024, 2:08 p.m. UTC | #2
> -----Original Message-----
> From: Kalesh Anakkur Purayil <kalesh-anakkur.purayil@broadcom.com>
> Sent: Tuesday, October 8, 2024 9:12 AM
> To: Pandey, Radhey Shyam <radhey.shyam.pandey@amd.com>
> Cc: davem@davemloft.net; edumazet@google.com; kuba@kernel.org;
> pabeni@redhat.com; robh@kernel.org; krzk+dt@kernel.org; conor+dt@kernel.org;
> Simek, Michal <michal.simek@amd.com>; Katakam, Harini
> <harini.katakam@amd.com>; netdev@vger.kernel.org; devicetree@vger.kernel.org;
> linux-kernel@vger.kernel.org; linux-arm-kernel@lists.infradead.org; git (AMD-Xilinx)
> <git@amd.com>; Joseph, Abin <Abin.Joseph@amd.com>
> Subject: Re: [PATCH net-next v2 3/3] net: emaclite: Adopt clock support
> 
> On Mon, Oct 7, 2024 at 8:39 PM Radhey Shyam Pandey
> <radhey.shyam.pandey@amd.com> wrote:
> >
> > From: Abin Joseph <abin.joseph@amd.com>
> >
> > Adapt to use the clock framework. Add s_axi_aclk clock from the processor
> > bus clock domain and make clk optional to keep DTB backward compatibility.
> >
> > Signed-off-by: Abin Joseph <abin.joseph@amd.com>
> > Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
> > ---
> > changes for v2:
> > - None.
> > ---
> >  drivers/net/ethernet/xilinx/xilinx_emaclite.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
> b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
> > index 418587942527..fe901af5ddfa 100644
> > --- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
> > +++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
> > @@ -7,6 +7,7 @@
> >   * Copyright (c) 2007 - 2013 Xilinx, Inc.
> >   */
> >
> > +#include <linux/clk.h>
> >  #include <linux/module.h>
> >  #include <linux/platform_device.h>
> >  #include <linux/uaccess.h>
> > @@ -1091,6 +1092,7 @@ static int xemaclite_of_probe(struct platform_device
> *ofdev)
> >         struct net_device *ndev = NULL;
> >         struct net_local *lp = NULL;
> >         struct device *dev = &ofdev->dev;
> > +       struct clk *clkin;
> >
> >         int rc = 0;
> >
> > @@ -1127,6 +1129,12 @@ static int xemaclite_of_probe(struct platform_device
> *ofdev)
> >         lp->tx_ping_pong = get_bool(ofdev, "xlnx,tx-ping-pong");
> >         lp->rx_ping_pong = get_bool(ofdev, "xlnx,rx-ping-pong");
> >
> > +       clkin = devm_clk_get_optional_enabled(&ofdev->dev, NULL);
> > +       if (IS_ERR(clkin)) {
> > +               return dev_err_probe(&ofdev->dev, PTR_ERR(clkin),
> > +                               "Failed to get and enable clock from Device Tree\n");
> > +       }
> [Kalesh] Braces are not needed here for a single statement block.

Yes, braces not required. Will fix that in next version.

> 
> Also, I do not see where you use this "clkin" in this driver. I may be
> missing something as I am not an expert in this area.

devm_clk_get_optional_enabled() -> returned clk (if valid) is prepared 
and enabled. 

When the device is unbound from the bus the clock will 
automatically be disabled, unprepared and freed.

So clkin is not used later on.

> > +
> >         rc = of_get_ethdev_address(ofdev->dev.of_node, ndev);
> >         if (rc) {
> >                 dev_warn(dev, "No MAC address found, using random\n");
> > --
> > 2.34.1
> >
> >
> 
> 
> --
> Regards,
> Kalesh A P
diff mbox series

Patch

diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 418587942527..fe901af5ddfa 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -7,6 +7,7 @@ 
  * Copyright (c) 2007 - 2013 Xilinx, Inc.
  */
 
+#include <linux/clk.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/uaccess.h>
@@ -1091,6 +1092,7 @@  static int xemaclite_of_probe(struct platform_device *ofdev)
 	struct net_device *ndev = NULL;
 	struct net_local *lp = NULL;
 	struct device *dev = &ofdev->dev;
+	struct clk *clkin;
 
 	int rc = 0;
 
@@ -1127,6 +1129,12 @@  static int xemaclite_of_probe(struct platform_device *ofdev)
 	lp->tx_ping_pong = get_bool(ofdev, "xlnx,tx-ping-pong");
 	lp->rx_ping_pong = get_bool(ofdev, "xlnx,rx-ping-pong");
 
+	clkin = devm_clk_get_optional_enabled(&ofdev->dev, NULL);
+	if (IS_ERR(clkin)) {
+		return dev_err_probe(&ofdev->dev, PTR_ERR(clkin),
+				"Failed to get and enable clock from Device Tree\n");
+	}
+
 	rc = of_get_ethdev_address(ofdev->dev.of_node, ndev);
 	if (rc) {
 		dev_warn(dev, "No MAC address found, using random\n");