diff mbox series

[net-next,7/9] net: lantiq_etop: remove struct resource

Message ID 20240930202434.296960-8-rosenp@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: lantiq_etop: some cleanups | 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: 9 this patch: 9
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 9 this patch: 9
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 fail Errors and warnings before: 12 this patch: 12
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 45 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

Commit Message

Rosen Penev Sept. 30, 2024, 8:24 p.m. UTC
All of this can be simplified with devm_platformn_ioremap_resource. No
need for extra code.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/net/ethernet/lantiq_etop.c | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)

Comments

Simon Horman Oct. 1, 2024, 3:33 p.m. UTC | #1
On Mon, Sep 30, 2024 at 01:24:32PM -0700, Rosen Penev wrote:
> All of this can be simplified with devm_platformn_ioremap_resource. No
> need for extra code.
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  drivers/net/ethernet/lantiq_etop.c | 23 +++--------------------
>  1 file changed, 3 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
> index bc97b189785e..0cb5d536f351 100644
> --- a/drivers/net/ethernet/lantiq_etop.c
> +++ b/drivers/net/ethernet/lantiq_etop.c
> @@ -90,7 +90,6 @@ struct ltq_etop_priv {
>  	struct net_device *netdev;
>  	struct platform_device *pdev;
>  	struct ltq_eth_data *pldata;
> -	struct resource *res;
>  
>  	struct mii_bus *mii_bus;
>  
> @@ -620,28 +619,13 @@ ltq_etop_probe(struct platform_device *pdev)
>  {
>  	struct net_device *dev;
>  	struct ltq_etop_priv *priv;
> -	struct resource *res;
>  	int err;
>  	int i;
>  
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res) {
> -		dev_err(&pdev->dev, "failed to get etop resource");
> -		return -ENOENT;
> -	}
> -
> -	res = devm_request_mem_region(&pdev->dev, res->start,
> -				      resource_size(res), dev_name(&pdev->dev));
> -	if (!res) {
> -		dev_err(&pdev->dev, "failed to request etop resource");
> -		return -EBUSY;
> -	}
> -
> -	ltq_etop_membase = devm_ioremap(&pdev->dev, res->start,
> -					resource_size(res));
> -	if (!ltq_etop_membase) {
> +	ltq_etop_membase = devm_platformn_ioremap_resource(pdev, 0);

Hi Rosen,

I believe this should be devm_platform_ioremap_resource()

> +	if (IS_ERR(ltq_etop_membase)) {
>  		dev_err(&pdev->dev, "failed to remap etop engine %d", pdev->id);
> -		return -ENOMEM;
> +		return PTR_ERR(ltq_etop_membase);
>  	}
>  
>  	dev = devm_alloc_etherdev_mqs(&pdev->dev, sizeof(struct ltq_etop_priv),
> @@ -651,7 +635,6 @@ ltq_etop_probe(struct platform_device *pdev)
>  	dev->netdev_ops = &ltq_eth_netdev_ops;
>  	dev->ethtool_ops = &ltq_etop_ethtool_ops;
>  	priv = netdev_priv(dev);
> -	priv->res = res;
>  	priv->pdev = pdev;
>  	priv->pldata = dev_get_platdata(&pdev->dev);
>  	priv->netdev = dev;
diff mbox series

Patch

diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
index bc97b189785e..0cb5d536f351 100644
--- a/drivers/net/ethernet/lantiq_etop.c
+++ b/drivers/net/ethernet/lantiq_etop.c
@@ -90,7 +90,6 @@  struct ltq_etop_priv {
 	struct net_device *netdev;
 	struct platform_device *pdev;
 	struct ltq_eth_data *pldata;
-	struct resource *res;
 
 	struct mii_bus *mii_bus;
 
@@ -620,28 +619,13 @@  ltq_etop_probe(struct platform_device *pdev)
 {
 	struct net_device *dev;
 	struct ltq_etop_priv *priv;
-	struct resource *res;
 	int err;
 	int i;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "failed to get etop resource");
-		return -ENOENT;
-	}
-
-	res = devm_request_mem_region(&pdev->dev, res->start,
-				      resource_size(res), dev_name(&pdev->dev));
-	if (!res) {
-		dev_err(&pdev->dev, "failed to request etop resource");
-		return -EBUSY;
-	}
-
-	ltq_etop_membase = devm_ioremap(&pdev->dev, res->start,
-					resource_size(res));
-	if (!ltq_etop_membase) {
+	ltq_etop_membase = devm_platformn_ioremap_resource(pdev, 0);
+	if (IS_ERR(ltq_etop_membase)) {
 		dev_err(&pdev->dev, "failed to remap etop engine %d", pdev->id);
-		return -ENOMEM;
+		return PTR_ERR(ltq_etop_membase);
 	}
 
 	dev = devm_alloc_etherdev_mqs(&pdev->dev, sizeof(struct ltq_etop_priv),
@@ -651,7 +635,6 @@  ltq_etop_probe(struct platform_device *pdev)
 	dev->netdev_ops = &ltq_eth_netdev_ops;
 	dev->ethtool_ops = &ltq_etop_ethtool_ops;
 	priv = netdev_priv(dev);
-	priv->res = res;
 	priv->pdev = pdev;
 	priv->pldata = dev_get_platdata(&pdev->dev);
 	priv->netdev = dev;