linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2] can: ti_hecc: convert to devm_platform_ioremap_resource_byname()
@ 2020-04-20 13:22 Dejin Zheng
  2020-04-20 14:00 ` [net-next " Markus Elfring
  0 siblings, 1 reply; 6+ messages in thread
From: Dejin Zheng @ 2020-04-20 13:22 UTC (permalink / raw)
  To: wg, mkl, davem, Markus.Elfring, linux-can, netdev
  Cc: linux-kernel, Dejin Zheng

Use the function devm_platform_ioremap_resource_byname() to simplify
source code which calls the functions platform_get_resource_byname()
and devm_ioremap_resource(). Remove also a few error messages which
became unnecessary with this software refactoring.

Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
---
v1 -> v2:
	- modify the commit comments by Markus's suggestion.

 drivers/net/can/ti_hecc.c | 27 +++++----------------------
 1 file changed, 5 insertions(+), 22 deletions(-)

diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index 94b1491b569f..5f39a4c668b5 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -857,7 +857,7 @@ static int ti_hecc_probe(struct platform_device *pdev)
 	struct net_device *ndev = (struct net_device *)0;
 	struct ti_hecc_priv *priv;
 	struct device_node *np = pdev->dev.of_node;
-	struct resource *res, *irq;
+	struct resource *irq;
 	struct regulator *reg_xceiver;
 	int err = -ENODEV;
 
@@ -878,39 +878,22 @@ static int ti_hecc_probe(struct platform_device *pdev)
 	priv = netdev_priv(ndev);
 
 	/* handle hecc memory */
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hecc");
-	if (!res) {
-		dev_err(&pdev->dev, "can't get IORESOURCE_MEM hecc\n");
-		return -EINVAL;
-	}
-
-	priv->base = devm_ioremap_resource(&pdev->dev, res);
+	priv->base = devm_platform_ioremap_resource_byname(pdev, "hecc");
 	if (IS_ERR(priv->base)) {
 		dev_err(&pdev->dev, "hecc ioremap failed\n");
 		return PTR_ERR(priv->base);
 	}
 
 	/* handle hecc-ram memory */
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hecc-ram");
-	if (!res) {
-		dev_err(&pdev->dev, "can't get IORESOURCE_MEM hecc-ram\n");
-		return -EINVAL;
-	}
-
-	priv->hecc_ram = devm_ioremap_resource(&pdev->dev, res);
+	priv->hecc_ram = devm_platform_ioremap_resource_byname(pdev,
+							       "hecc-ram");
 	if (IS_ERR(priv->hecc_ram)) {
 		dev_err(&pdev->dev, "hecc-ram ioremap failed\n");
 		return PTR_ERR(priv->hecc_ram);
 	}
 
 	/* handle mbx memory */
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mbx");
-	if (!res) {
-		dev_err(&pdev->dev, "can't get IORESOURCE_MEM mbx\n");
-		return -EINVAL;
-	}
-
-	priv->mbx = devm_ioremap_resource(&pdev->dev, res);
+	priv->mbx = devm_platform_ioremap_resource_byname(pdev, "mbx");
 	if (IS_ERR(priv->mbx)) {
 		dev_err(&pdev->dev, "mbx ioremap failed\n");
 		return PTR_ERR(priv->mbx);
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [net-next v2] can: ti_hecc: convert to devm_platform_ioremap_resource_byname()
  2020-04-20 13:22 [PATCH net-next v2] can: ti_hecc: convert to devm_platform_ioremap_resource_byname() Dejin Zheng
@ 2020-04-20 14:00 ` Markus Elfring
  2020-04-20 14:19   ` Dejin Zheng
  0 siblings, 1 reply; 6+ messages in thread
From: Markus Elfring @ 2020-04-20 14:00 UTC (permalink / raw)
  To: Dejin Zheng, netdev
  Cc: linux-can, linux-kernel, David S. Miller, Marc Kleine-Budde,
	Wolfgang Grandegger

> v1 -> v2:
> 	- modify the commit comments by Markus's suggestion.

Thanks for another wording fine-tuning.

Would you like to extend your adjustment interests to similar update candidates?

Example:
bgmac_probe()
https://elixir.bootlin.com/linux/v5.7-rc2/source/drivers/net/ethernet/broadcom/bgmac-platform.c#L201
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/broadcom/bgmac-platform.c?id=ae83d0b416db002fe95601e7f97f64b59514d936#n201

Regards,
Markus

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [net-next v2] can: ti_hecc: convert to devm_platform_ioremap_resource_byname()
  2020-04-20 14:00 ` [net-next " Markus Elfring
@ 2020-04-20 14:19   ` Dejin Zheng
  2020-04-20 14:54     ` Markus Elfring
  0 siblings, 1 reply; 6+ messages in thread
From: Dejin Zheng @ 2020-04-20 14:19 UTC (permalink / raw)
  To: Markus Elfring
  Cc: netdev, linux-can, linux-kernel, David S. Miller,
	Marc Kleine-Budde, Wolfgang Grandegger

On Mon, Apr 20, 2020 at 04:00:54PM +0200, Markus Elfring wrote:
> > v1 -> v2:
> > 	- modify the commit comments by Markus's suggestion.
> 
> Thanks for another wording fine-tuning.
> 
> Would you like to extend your adjustment interests to similar update candidates?
> 
> Example:
> bgmac_probe()
> https://elixir.bootlin.com/linux/v5.7-rc2/source/drivers/net/ethernet/broadcom/bgmac-platform.c#L201
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/broadcom/bgmac-platform.c?id=ae83d0b416db002fe95601e7f97f64b59514d936#n201
>
Markus, Thanks very much for your info, I will do it. Thanks again.

BR,
Dejin

> Regards,
> Markus

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [net-next v2] can: ti_hecc: convert to devm_platform_ioremap_resource_byname()
  2020-04-20 14:19   ` Dejin Zheng
@ 2020-04-20 14:54     ` Markus Elfring
  2020-04-20 15:19       ` Dejin Zheng
  0 siblings, 1 reply; 6+ messages in thread
From: Markus Elfring @ 2020-04-20 14:54 UTC (permalink / raw)
  To: Dejin Zheng, netdev
  Cc: linux-can, linux-kernel, David S. Miller, Marc Kleine-Budde,
	Wolfgang Grandegger

>> Example:
>> bgmac_probe()
>> https://elixir.bootlin.com/linux/v5.7-rc2/source/drivers/net/ethernet/broadcom/bgmac-platform.c#L201
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/broadcom/bgmac-platform.c?id=ae83d0b416db002fe95601e7f97f64b59514d936#n201
>>
> Markus, Thanks very much for your info, I will do it. Thanks again.

If you would use another script (like for the semantic patch language),
you could find remaining update candidates in a convenient way,
couldn't you?

Regards,
Markus

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [net-next v2] can: ti_hecc: convert to devm_platform_ioremap_resource_byname()
  2020-04-20 14:54     ` Markus Elfring
@ 2020-04-20 15:19       ` Dejin Zheng
  2020-04-20 15:42         ` Markus Elfring
  0 siblings, 1 reply; 6+ messages in thread
From: Dejin Zheng @ 2020-04-20 15:19 UTC (permalink / raw)
  To: Markus Elfring
  Cc: netdev, linux-can, linux-kernel, David S. Miller,
	Marc Kleine-Budde, Wolfgang Grandegger

On Mon, Apr 20, 2020 at 04:54:22PM +0200, Markus Elfring wrote:
> >> Example:
> >> bgmac_probe()
> >> https://elixir.bootlin.com/linux/v5.7-rc2/source/drivers/net/ethernet/broadcom/bgmac-platform.c#L201
> >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/broadcom/bgmac-platform.c?id=ae83d0b416db002fe95601e7f97f64b59514d936#n201
> >>
> > Markus, Thanks very much for your info, I will do it. Thanks again.
> 
> If you would use another script (like for the semantic patch language),
> you could find remaining update candidates in a convenient way,
> couldn't you?
>
Markus, could you share the script? Thanks very much!

BR,
Dejin

> Regards,
> Markus

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [net-next v2] can: ti_hecc: convert to devm_platform_ioremap_resource_byname()
  2020-04-20 15:19       ` Dejin Zheng
@ 2020-04-20 15:42         ` Markus Elfring
  0 siblings, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2020-04-20 15:42 UTC (permalink / raw)
  To: Dejin Zheng, netdev
  Cc: linux-can, linux-kernel, David S. Miller, Marc Kleine-Budde,
	Wolfgang Grandegger

>> If you would use another script (like for the semantic patch language),
>> you could find remaining update candidates in a convenient way,
>> couldn't you?
>>
> Markus, could you share the script?

Theoretically, yes.

Practically, I would prefer additional development options.

* I am trying for a while to improve some components also by advanced
  applications of the Coccinelle software.
  I hope to increase incentives for involved contributors.

* I imagine that a known directory would be a nice place for
  further reuse of such SmPL scripts.
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/coccinelle?id=ae83d0b416db002fe95601e7f97f64b59514d936

* How will your motivation evolve?
  + Pick more updates for your own contribution statistics.
  And / Or
  + Tell more interested parties about change possibilities.

Regards,
Markus

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-04-20 15:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-20 13:22 [PATCH net-next v2] can: ti_hecc: convert to devm_platform_ioremap_resource_byname() Dejin Zheng
2020-04-20 14:00 ` [net-next " Markus Elfring
2020-04-20 14:19   ` Dejin Zheng
2020-04-20 14:54     ` Markus Elfring
2020-04-20 15:19       ` Dejin Zheng
2020-04-20 15:42         ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).