net: bcmgenet: Clean up after ACPI enablement
Subsystems (3)
PATCH v2 2/5 net: bcmgenet: Drop useless OF code
In reply to Andy ShevchenkoThere is nothing which needs a set of OF headers, followed by redundant OF node ID check. Drop them for good.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 13 ------------- 1 file changed, 13 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +0 -13
@@ -23,11 +23,6 @@#include <linux/dma-mapping.h> #include <linux/pm.h> #include <linux/clk.h> -#include <linux/of.h> -#include <linux/of_address.h> -#include <linux/of_irq.h> -#include <linux/of_net.h> -#include <linux/of_platform.h> #include <net/arp.h> #include <linux/mii.h>
@@ -3417,8 +3412,6 @@ MODULE_DEVICE_TABLE(of, bcmgenet_match);static int bcmgenet_probe (struct platform_device *pdev) {struct bcmgenet_platform_data *pd = pdev->dev.platform_data; -struct device_node *dn = pdev->dev.of_node; -const struct of_device_id *of_id =NULL ;const struct bcmgenet_plat_data *pdata;struct bcmgenet_priv *priv;struct net_device *dev;
@@ -3433,12 +3426,6 @@ static int bcmgenet_probe(struct platform_device *pdev)return -ENOMEM ; } -if (dn) { - of_id =of_match_node (bcmgenet_match, dn); -if (!of_id) -return -EINVAL ; - } - priv =netdev_priv (dev); priv->irq0 =platform_get_irq (pdev,0 );if (priv->irq0 <0 ) {
Signature · 1 line
2.26.1
PATCH v2 3/5 net: bcmgenet: Use devm_clk_get_optional() to get the clocks
In reply to Andy ShevchenkoConversion to devm_clk_get_optional() makes it explicit that clocks are optional. This change allows to handle deferred probe in case clocks are defined, but not yet probed. Due to above changes bail out in error case.
While here, check potential error when enable main clock.
--- .../net/ethernet/broadcom/genet/bcmgenet.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +12 -7
@@ -3487,13 +3487,16 @@ static int bcmgenet_probe(struct platform_device *pdev) priv->dma_max_burst_length =DMA_MAX_BURST_LENGTH ; } - priv->clk =devm_clk_get (&priv->pdev->dev,"enet" ); + priv->clk =devm_clk_get_optional (&priv->pdev->dev,"enet" );if (IS_ERR (priv->clk)) {dev_dbg (&priv->pdev->dev,"failed to get enet clock\n" ); - priv->clk =NULL ; + err =PTR_ERR (priv->clk); + goto err; } -clk_prepare_enable (priv->clk); + err =clk_prepare_enable (priv->clk); +if (err) + goto err;bcmgenet_set_hw_params (priv);
@@ -3511,16 +3514,18 @@ static int bcmgenet_probe(struct platform_device *pdev) priv->rx_buf_len =RX_BUF_LENGTH ;INIT_WORK (&priv->bcmgenet_irq_work, bcmgenet_irq_task); - priv->clk_wol =devm_clk_get (&priv->pdev->dev,"enet-wol" ); + priv->clk_wol =devm_clk_get_optional (&priv->pdev->dev,"enet-wol" );if (IS_ERR (priv->clk_wol)) {dev_dbg (&priv->pdev->dev,"failed to get enet-wol clock\n" ); - priv->clk_wol =NULL ; + err =PTR_ERR (priv->clk_wol); + goto err; } - priv->clk_eee =devm_clk_get (&priv->pdev->dev,"enet-eee" ); + priv->clk_eee =devm_clk_get_optional (&priv->pdev->dev,"enet-eee" );if (IS_ERR (priv->clk_eee)) {dev_dbg (&priv->pdev->dev,"failed to get enet-eee clock\n" ); - priv->clk_eee =NULL ; + err =PTR_ERR (priv->clk_eee); + goto err; }/* If this is an internal GPHY, power it on now, before UniMAC is
Signature · 1 line
2.26.1
PATCH v2 4/5 net: bcmgenet: Use get_unligned_beXX() and put_unaligned_beXX()
In reply to Andy ShevchenkoIt's convenient to use get_unligned_beXX() and put_unaligned_beXX() helpers to get or set MAC instead of open-coded variants.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +4 -9
@@ -2702,9 +2702,8 @@ static void bcmgenet_umac_reset(struct bcmgenet_priv *priv)static void bcmgenet_set_hw_addr (struct bcmgenet_priv *priv,unsigned char *addr) { -bcmgenet_umac_writel (priv, (addr[0 ] <<24 ) | (addr[1 ] <<16 ) | - (addr[2 ] <<8 ) | addr[3 ],UMAC_MAC0 ); -bcmgenet_umac_writel (priv, (addr[4 ] <<8 ) | addr[5 ],UMAC_MAC1 ); +bcmgenet_umac_writel (priv,get_unaligned_be32 (&addr[0 ]),UMAC_MAC0 ); +bcmgenet_umac_writel (priv,get_unaligned_be16 (&addr[4 ]),UMAC_MAC1 ); } static void bcmgenet_get_hw_addr(struct bcmgenet_priv *priv,
@@ -2713,13 +2712,9 @@ static void bcmgenet_get_hw_addr(struct bcmgenet_priv *priv,u32 addr_tmp; addr_tmp =bcmgenet_umac_readl (priv,UMAC_MAC0 ); - addr[0 ] = addr_tmp >>24 ; - addr[1 ] = (addr_tmp >>16 ) &0xff ; - addr[2 ] = (addr_tmp >>8 ) &0xff ; - addr[3 ] = addr_tmp &0xff ; +put_unaligned_be32 (addr_tmp, &addr[0 ]); addr_tmp =bcmgenet_umac_readl (priv,UMAC_MAC1 ); - addr[4 ] = (addr_tmp >>8 ) &0xff ; - addr[5 ] = addr_tmp &0xff ; +put_unaligned_be16 (addr_tmp, &addr[4 ]); }/* Returns a reusable dma control register value */
Signature · 1 line
2.26.1
PATCH v2 1/5 net: bcmgenet: Drop ACPI_PTR() to avoid compiler warning
In reply to Andy ShevchenkoWhen compiled with CONFIG_ACPI=n, ACPI_PTR() will be no-op, and thus genet_acpi_match table defined, but not used. Compiler is not happy about such data. Drop ACPI_PTR() for good.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +1 -1
@@ -3740,7 +3740,7 @@ static struct platform_driver bcmgenet_driver = { .name = "bcmgenet", .of_match_table = bcmgenet_match, .pm = &bcmgenet_pm_ops, - .acpi_match_table = ACPI_PTR(genet_acpi_match), + .acpi_match_table = genet_acpi_match, }, };module_platform_driver (bcmgenet_driver);
Signature · 1 line
2.26.1
v2 cover net: bcmgenet: Clean up after ACPI enablement
ACPI enablement series had missed some clean ups that would have been done at the same time. Here are these bits.
In v2:
- return dev_dbg() calls to avoid spamming logs when probe is deferred (Florian)
- added Ack (Florian)
- combined two, earlier sent, series together
- added couple more patches
Andy Shevchenko (5):
net: bcmgenet: Drop ACPI_PTR() to avoid compiler warning
net: bcmgenet: Drop useless OF code
net: bcmgenet: Use devm_clk_get_optional() to get the clocks
net: bcmgenet: Use get_unligned_beXX() and put_unaligned_beXX()
net: bcmgenet: Drop too many parentheses in bcmgenet_probe()
.../net/ethernet/broadcom/genet/bcmgenet.c | 49 +++++++------------ 1 file changed, 18 insertions(+), 31 deletions(-)
Signature · 1 line
2.26.1
PATCH v2 5/5 net: bcmgenet: Drop too many parentheses in bcmgenet_probe()
No need to have parentheses around plain pointer variable or negation operator. Drop them for good.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +1 -1
@@ -3529,7 +3529,7 @@ static int bcmgenet_probe(struct platform_device *pdev)if (device_get_phy_mode (&pdev->dev) ==PHY_INTERFACE_MODE_INTERNAL )bcmgenet_power_up (priv,GENET_POWER_PASSIVE ); -if ((pd) && (!IS_ERR_OR_NULL (pd->mac_address))) +if (pd && !IS_ERR_OR_NULL (pd->mac_address))ether_addr_copy (dev->dev_addr, pd->mac_address);else if (!device_get_mac_address (&pdev->dev, dev->dev_addr,ETH_ALEN ))
Signature · 1 line
2.26.1
Re: [PATCH v2 2/5] net: bcmgenet: Drop useless OF code
In reply to Andy ShevchenkoQuoted 4 lines · Andy Shevchenko
There is nothing which needs a set of OF headers, followed by redundant OF node ID check. Drop them for good.
Signed-off-by Andy Shevchenko <[email protected]>
Signature · 1 line
Florian
Re: [PATCH v2 5/5] net: bcmgenet: Drop too many parentheses in bcmgenet_probe()
In reply to Andy ShevchenkoQuoted 4 lines · Andy Shevchenko
No need to have parentheses around plain pointer variable or negation operator. Drop them for good.
Signed-off-by Andy Shevchenko <[email protected]>
Signature · 1 line
Florian
David Miller
maintainerFrom: Andy Shevchenko <[email protected]>
Date: Tue, 21 Apr 2020 00:51:16 +0300
Quoted 8 lines
ACPI enablement series had missed some clean ups that would have been done at the same time. Here are these bits.
In v2:
- returndev_dbg()calls to avoid spamming logs when probe is deferred (Florian)
- added Ack (Florian)
- combined two, earlier sent, series together
- added couple more patches
Series applied to net-next, thanks.
Jeremy Linton
Tested-byQuoted 6 lines · David Miller
From: Andy Shevchenko <[email protected]>
Date: Tue, 21 Apr 2020 00:51:16 +0300Quoted 3 lines
ACPI enablement series had missed some clean ups that would have been done at the same time. Here are these bits.
Quoted 8 lines
Quoted 5 lines
In v2:
- returndev_dbg()calls to avoid spamming logs when probe is deferred (Florian)
- added Ack (Florian)
- combined two, earlier sent, series together
- added couple more patchesSeries applied to net-next, thanks.
Well, you guys are two fast for me.. <chuckle> Or rather the couple hours it took to build the kernel on the rpi4.
Anyway, the changes looks like fine, and boots fine in ACPI mode.
Its probably to late for this but anyway:
Thanks,