* [PATCH net-next] net: stmmac: platform: use optional clk/reset get APIs
@ 2020-11-09 8:09 ` Jisheng Zhang
0 siblings, 0 replies; 8+ messages in thread
From: Jisheng Zhang @ 2020-11-09 8:09 UTC (permalink / raw)
To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
David S. Miller, Jakub Kicinski, Maxime Coquelin, Philipp Zabel
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel
Use the devm_reset_control_get_optional() and devm_clk_get_optional()
rather than open coding them.
Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
---
.../ethernet/stmicro/stmmac/stmmac_platform.c | 21 +++++++------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index af34a4cadbb0..f1d5b2ce1039 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -399,6 +399,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
struct device_node *np = pdev->dev.of_node;
struct plat_stmmacenet_data *plat;
struct stmmac_dma_cfg *dma_cfg;
+ void *ret;
int rc;
plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
@@ -576,12 +577,10 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
clk_prepare_enable(plat->stmmac_clk);
}
- plat->pclk = devm_clk_get(&pdev->dev, "pclk");
+ plat->pclk = devm_clk_get_optional(&pdev->dev, "pclk");
if (IS_ERR(plat->pclk)) {
- if (PTR_ERR(plat->pclk) == -EPROBE_DEFER)
- goto error_pclk_get;
-
- plat->pclk = NULL;
+ ret = plat->pclk;
+ goto error_pclk_get;
}
clk_prepare_enable(plat->pclk);
@@ -596,14 +595,10 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
dev_dbg(&pdev->dev, "PTP rate %d\n", plat->clk_ptp_rate);
}
- plat->stmmac_rst = devm_reset_control_get(&pdev->dev,
- STMMAC_RESOURCE_NAME);
+ plat->stmmac_rst = devm_reset_control_get_optional(&pdev->dev, STMMAC_RESOURCE_NAME);
if (IS_ERR(plat->stmmac_rst)) {
- if (PTR_ERR(plat->stmmac_rst) == -EPROBE_DEFER)
- goto error_hw_init;
-
- dev_info(&pdev->dev, "no reset control found\n");
- plat->stmmac_rst = NULL;
+ ret = plat->stmmac_rst;
+ goto error_hw_init;
}
return plat;
@@ -613,7 +608,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
error_pclk_get:
clk_disable_unprepare(plat->stmmac_clk);
- return ERR_PTR(-EPROBE_DEFER);
+ return ret;
}
/**
--
2.29.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next] net: stmmac: platform: use optional clk/reset get APIs
@ 2020-11-09 8:09 ` Jisheng Zhang
0 siblings, 0 replies; 8+ messages in thread
From: Jisheng Zhang @ 2020-11-09 8:09 UTC (permalink / raw)
To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
David S. Miller, Jakub Kicinski, Maxime Coquelin, Philipp Zabel
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel
Use the devm_reset_control_get_optional() and devm_clk_get_optional()
rather than open coding them.
Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
---
.../ethernet/stmicro/stmmac/stmmac_platform.c | 21 +++++++------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index af34a4cadbb0..f1d5b2ce1039 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -399,6 +399,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
struct device_node *np = pdev->dev.of_node;
struct plat_stmmacenet_data *plat;
struct stmmac_dma_cfg *dma_cfg;
+ void *ret;
int rc;
plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
@@ -576,12 +577,10 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
clk_prepare_enable(plat->stmmac_clk);
}
- plat->pclk = devm_clk_get(&pdev->dev, "pclk");
+ plat->pclk = devm_clk_get_optional(&pdev->dev, "pclk");
if (IS_ERR(plat->pclk)) {
- if (PTR_ERR(plat->pclk) == -EPROBE_DEFER)
- goto error_pclk_get;
-
- plat->pclk = NULL;
+ ret = plat->pclk;
+ goto error_pclk_get;
}
clk_prepare_enable(plat->pclk);
@@ -596,14 +595,10 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
dev_dbg(&pdev->dev, "PTP rate %d\n", plat->clk_ptp_rate);
}
- plat->stmmac_rst = devm_reset_control_get(&pdev->dev,
- STMMAC_RESOURCE_NAME);
+ plat->stmmac_rst = devm_reset_control_get_optional(&pdev->dev, STMMAC_RESOURCE_NAME);
if (IS_ERR(plat->stmmac_rst)) {
- if (PTR_ERR(plat->stmmac_rst) == -EPROBE_DEFER)
- goto error_hw_init;
-
- dev_info(&pdev->dev, "no reset control found\n");
- plat->stmmac_rst = NULL;
+ ret = plat->stmmac_rst;
+ goto error_hw_init;
}
return plat;
@@ -613,7 +608,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
error_pclk_get:
clk_disable_unprepare(plat->stmmac_clk);
- return ERR_PTR(-EPROBE_DEFER);
+ return ret;
}
/**
--
2.29.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next] net: stmmac: platform: use optional clk/reset get APIs
2020-11-09 8:09 ` Jisheng Zhang
@ 2020-11-09 19:57 ` Jakub Kicinski
-1 siblings, 0 replies; 8+ messages in thread
From: Jakub Kicinski @ 2020-11-09 19:57 UTC (permalink / raw)
To: Jisheng Zhang
Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
David S. Miller, Maxime Coquelin, Philipp Zabel, netdev,
linux-stm32, linux-arm-kernel, linux-kernel
On Mon, 9 Nov 2020 16:09:10 +0800 Jisheng Zhang wrote:
> @@ -596,14 +595,10 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
> dev_dbg(&pdev->dev, "PTP rate %d\n", plat->clk_ptp_rate);
> }
>
> - plat->stmmac_rst = devm_reset_control_get(&pdev->dev,
> - STMMAC_RESOURCE_NAME);
> + plat->stmmac_rst = devm_reset_control_get_optional(&pdev->dev, STMMAC_RESOURCE_NAME);
This code was wrapped at 80 chars, please keep it wrapped.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next] net: stmmac: platform: use optional clk/reset get APIs
@ 2020-11-09 19:57 ` Jakub Kicinski
0 siblings, 0 replies; 8+ messages in thread
From: Jakub Kicinski @ 2020-11-09 19:57 UTC (permalink / raw)
To: Jisheng Zhang
Cc: Maxime Coquelin, Alexandre Torgue, netdev, linux-kernel,
linux-stm32, Jose Abreu, Philipp Zabel, Giuseppe Cavallaro,
David S. Miller, linux-arm-kernel
On Mon, 9 Nov 2020 16:09:10 +0800 Jisheng Zhang wrote:
> @@ -596,14 +595,10 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
> dev_dbg(&pdev->dev, "PTP rate %d\n", plat->clk_ptp_rate);
> }
>
> - plat->stmmac_rst = devm_reset_control_get(&pdev->dev,
> - STMMAC_RESOURCE_NAME);
> + plat->stmmac_rst = devm_reset_control_get_optional(&pdev->dev, STMMAC_RESOURCE_NAME);
This code was wrapped at 80 chars, please keep it wrapped.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next] net: stmmac: platform: use optional clk/reset get APIs
2020-11-09 19:57 ` Jakub Kicinski
@ 2020-11-11 2:10 ` Jisheng Zhang
-1 siblings, 0 replies; 8+ messages in thread
From: Jisheng Zhang @ 2020-11-11 2:10 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
David S. Miller, Maxime Coquelin, Philipp Zabel, netdev,
linux-stm32, linux-arm-kernel, linux-kernel
On Mon, 9 Nov 2020 11:57:13 -0800 Jakub Kicinski wrote:
>
>
> On Mon, 9 Nov 2020 16:09:10 +0800 Jisheng Zhang wrote:
> > @@ -596,14 +595,10 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
> > dev_dbg(&pdev->dev, "PTP rate %d\n", plat->clk_ptp_rate);
> > }
> >
> > - plat->stmmac_rst = devm_reset_control_get(&pdev->dev,
> > - STMMAC_RESOURCE_NAME);
> > + plat->stmmac_rst = devm_reset_control_get_optional(&pdev->dev, STMMAC_RESOURCE_NAME);
>
> This code was wrapped at 80 chars, please keep it wrapped.
>
I tried to keep wrapped, since s/devm_reset_control_get/devm_reset_control_get_optional,
to match alignment at open parenthesis on the second line, the
"STMMAC_RESOURCE_NAME" will exceed 80 chars. How to handle this situation?
Thanks in advance
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next] net: stmmac: platform: use optional clk/reset get APIs
@ 2020-11-11 2:10 ` Jisheng Zhang
0 siblings, 0 replies; 8+ messages in thread
From: Jisheng Zhang @ 2020-11-11 2:10 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Maxime Coquelin, Alexandre Torgue, netdev, linux-kernel,
linux-stm32, Jose Abreu, Philipp Zabel, Giuseppe Cavallaro,
David S. Miller, linux-arm-kernel
On Mon, 9 Nov 2020 11:57:13 -0800 Jakub Kicinski wrote:
>
>
> On Mon, 9 Nov 2020 16:09:10 +0800 Jisheng Zhang wrote:
> > @@ -596,14 +595,10 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
> > dev_dbg(&pdev->dev, "PTP rate %d\n", plat->clk_ptp_rate);
> > }
> >
> > - plat->stmmac_rst = devm_reset_control_get(&pdev->dev,
> > - STMMAC_RESOURCE_NAME);
> > + plat->stmmac_rst = devm_reset_control_get_optional(&pdev->dev, STMMAC_RESOURCE_NAME);
>
> This code was wrapped at 80 chars, please keep it wrapped.
>
I tried to keep wrapped, since s/devm_reset_control_get/devm_reset_control_get_optional,
to match alignment at open parenthesis on the second line, the
"STMMAC_RESOURCE_NAME" will exceed 80 chars. How to handle this situation?
Thanks in advance
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next] net: stmmac: platform: use optional clk/reset get APIs
2020-11-11 2:10 ` Jisheng Zhang
@ 2020-11-11 16:22 ` Jakub Kicinski
-1 siblings, 0 replies; 8+ messages in thread
From: Jakub Kicinski @ 2020-11-11 16:22 UTC (permalink / raw)
To: Jisheng Zhang
Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
David S. Miller, Maxime Coquelin, Philipp Zabel, netdev,
linux-stm32, linux-arm-kernel, linux-kernel
On Wed, 11 Nov 2020 10:10:33 +0800 Jisheng Zhang wrote:
> On Mon, 9 Nov 2020 11:57:13 -0800 Jakub Kicinski wrote:
> > On Mon, 9 Nov 2020 16:09:10 +0800 Jisheng Zhang wrote:
> > > @@ -596,14 +595,10 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
> > > dev_dbg(&pdev->dev, "PTP rate %d\n", plat->clk_ptp_rate);
> > > }
> > >
> > > - plat->stmmac_rst = devm_reset_control_get(&pdev->dev,
> > > - STMMAC_RESOURCE_NAME);
> > > + plat->stmmac_rst = devm_reset_control_get_optional(&pdev->dev, STMMAC_RESOURCE_NAME);
> >
> > This code was wrapped at 80 chars, please keep it wrapped.
> >
>
> I tried to keep wrapped, since s/devm_reset_control_get/devm_reset_control_get_optional,
> to match alignment at open parenthesis on the second line, the
> "STMMAC_RESOURCE_NAME" will exceed 80 chars. How to handle this situation?
Indeed, it's 81 chars. Still one character over 80 is easier to read
than when STMMAC_RESOURCE_NAME is wrapped half way through the name.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next] net: stmmac: platform: use optional clk/reset get APIs
@ 2020-11-11 16:22 ` Jakub Kicinski
0 siblings, 0 replies; 8+ messages in thread
From: Jakub Kicinski @ 2020-11-11 16:22 UTC (permalink / raw)
To: Jisheng Zhang
Cc: Maxime Coquelin, Alexandre Torgue, netdev, linux-kernel,
linux-stm32, Jose Abreu, Philipp Zabel, Giuseppe Cavallaro,
David S. Miller, linux-arm-kernel
On Wed, 11 Nov 2020 10:10:33 +0800 Jisheng Zhang wrote:
> On Mon, 9 Nov 2020 11:57:13 -0800 Jakub Kicinski wrote:
> > On Mon, 9 Nov 2020 16:09:10 +0800 Jisheng Zhang wrote:
> > > @@ -596,14 +595,10 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
> > > dev_dbg(&pdev->dev, "PTP rate %d\n", plat->clk_ptp_rate);
> > > }
> > >
> > > - plat->stmmac_rst = devm_reset_control_get(&pdev->dev,
> > > - STMMAC_RESOURCE_NAME);
> > > + plat->stmmac_rst = devm_reset_control_get_optional(&pdev->dev, STMMAC_RESOURCE_NAME);
> >
> > This code was wrapped at 80 chars, please keep it wrapped.
> >
>
> I tried to keep wrapped, since s/devm_reset_control_get/devm_reset_control_get_optional,
> to match alignment at open parenthesis on the second line, the
> "STMMAC_RESOURCE_NAME" will exceed 80 chars. How to handle this situation?
Indeed, it's 81 chars. Still one character over 80 is easier to read
than when STMMAC_RESOURCE_NAME is wrapped half way through the name.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-11-11 16:23 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-09 8:09 [PATCH net-next] net: stmmac: platform: use optional clk/reset get APIs Jisheng Zhang
2020-11-09 8:09 ` Jisheng Zhang
2020-11-09 19:57 ` Jakub Kicinski
2020-11-09 19:57 ` Jakub Kicinski
2020-11-11 2:10 ` Jisheng Zhang
2020-11-11 2:10 ` Jisheng Zhang
2020-11-11 16:22 ` Jakub Kicinski
2020-11-11 16:22 ` Jakub Kicinski
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.