Message ID | 1607343333-26552-4-git-send-email-claudiu.beznea@microchip.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: macb: add support for sama7g5 | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Guessed tree name to be net-next |
netdev/subject_prefix | success | Link |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 57 this patch: 57 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | warning | WARNING: line length of 83 exceeds 80 columns WARNING: line length of 85 exceeds 80 columns |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 57 this patch: 57 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
Hi Claudiu > static int macb_clk_init(struct platform_device *pdev, struct clk **pclk, > struct clk **hclk, struct clk **tx_clk, > struct clk **rx_clk, struct clk **tsu_clk) > @@ -3743,40 +3753,37 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk, > err = clk_prepare_enable(*hclk); > if (err) { > dev_err(&pdev->dev, "failed to enable hclk (%d)\n", err); > - goto err_disable_pclk; > + hclk = NULL; > + tx_clk = NULL; > + rx_clk = NULL; > + goto err_disable_clks; > } > > err = clk_prepare_enable(*tx_clk); > if (err) { > dev_err(&pdev->dev, "failed to enable tx_clk (%d)\n", err); > - goto err_disable_hclk; > + tx_clk = NULL; > + rx_clk = NULL; > + goto err_disable_clks; > } > > err = clk_prepare_enable(*rx_clk); > if (err) { > dev_err(&pdev->dev, "failed to enable rx_clk (%d)\n", err); > - goto err_disable_txclk; > + rx_clk = NULL; > + goto err_disable_clks; > } > > err = clk_prepare_enable(*tsu_clk); > if (err) { > dev_err(&pdev->dev, "failed to enable tsu_clk (%d)\n", err); > - goto err_disable_rxclk; > + goto err_disable_clks; > } > > return 0; > > -err_disable_rxclk: > - clk_disable_unprepare(*rx_clk); > - > -err_disable_txclk: > - clk_disable_unprepare(*tx_clk); > - > -err_disable_hclk: > - clk_disable_unprepare(*hclk); > - > -err_disable_pclk: > - clk_disable_unprepare(*pclk); > +err_disable_clks: > + macb_clks_disable(*pclk, *hclk, *tx_clk, *rx_clk, NULL); Personal taste, but i would of not changed this. > > return err; > } > @@ -4755,11 +4762,7 @@ static int macb_probe(struct platform_device *pdev) > free_netdev(dev); > > err_disable_clocks: > - clk_disable_unprepare(tx_clk); > - clk_disable_unprepare(hclk); > - clk_disable_unprepare(pclk); > - clk_disable_unprepare(rx_clk); > - clk_disable_unprepare(tsu_clk); > + macb_clks_disable(bp->pclk, bp->hclk, bp->tx_clk, bp->rx_clk, bp->tsu_clk); > pm_runtime_disable(&pdev->dev); > pm_runtime_set_suspended(&pdev->dev); > pm_runtime_dont_use_autosuspend(&pdev->dev); > @@ -4784,11 +4787,8 @@ static int macb_remove(struct platform_device *pdev) > pm_runtime_disable(&pdev->dev); > pm_runtime_dont_use_autosuspend(&pdev->dev); > if (!pm_runtime_suspended(&pdev->dev)) { > - clk_disable_unprepare(bp->tx_clk); > - clk_disable_unprepare(bp->hclk); > - clk_disable_unprepare(bp->pclk); > - clk_disable_unprepare(bp->rx_clk); > - clk_disable_unprepare(bp->tsu_clk); > + macb_clks_disable(bp->pclk, bp->hclk, bp->tx_clk, > + bp->rx_clk, bp->tsu_clk); > pm_runtime_set_suspended(&pdev->dev); > } > phylink_destroy(bp->phylink); > @@ -4966,14 +4966,16 @@ static int __maybe_unused macb_runtime_suspend(struct device *dev) > { > struct net_device *netdev = dev_get_drvdata(dev); > struct macb *bp = netdev_priv(netdev); > + struct clk *pclk = NULL, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL; > > if (!(device_may_wakeup(dev))) { > - clk_disable_unprepare(bp->tx_clk); > - clk_disable_unprepare(bp->hclk); > - clk_disable_unprepare(bp->pclk); > - clk_disable_unprepare(bp->rx_clk); > + pclk = bp->pclk; > + hclk = bp->hclk; > + tx_clk = bp->tx_clk; > + rx_clk = bp->rx_clk; > } > - clk_disable_unprepare(bp->tsu_clk); > + > + macb_clks_disable(pclk, hclk, tx_clk, rx_clk, bp->tsu_clk); Maybe if (!(device_may_wakeup(dev))) macb_clks_disable(bp->pclk, bp->hclk, pb->tx_clk, bp->rx_clk, bp->tsu_clk); else macb_clks_disable(NULL, NULL, NULL, NULL, bp->tsu_clk); is more readable? Andrew
On Tue, 8 Dec 2020 19:48:56 +0100 Andrew Lunn wrote: > > -err_disable_rxclk: > > - clk_disable_unprepare(*rx_clk); > > - > > -err_disable_txclk: > > - clk_disable_unprepare(*tx_clk); > > - > > -err_disable_hclk: > > - clk_disable_unprepare(*hclk); > > - > > -err_disable_pclk: > > - clk_disable_unprepare(*pclk); > > +err_disable_clks: > > + macb_clks_disable(*pclk, *hclk, *tx_clk, *rx_clk, NULL); > > Personal taste, but i would of not changed this. +1 FWIW
On 12/7/20 4:15 AM, Claudiu Beznea wrote: > Add function to disable all macb clocks. > > Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> > Suggested-by: Andrew Lunn <andrew@lunn.ch> > --- > drivers/net/ethernet/cadence/macb_main.c | 62 ++++++++++++++++---------------- > 1 file changed, 32 insertions(+), 30 deletions(-) > > diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c > index b23e986ac6dc..6b8e1109dfd3 100644 > --- a/drivers/net/ethernet/cadence/macb_main.c > +++ b/drivers/net/ethernet/cadence/macb_main.c > @@ -3694,6 +3694,16 @@ static void macb_probe_queues(void __iomem *mem, > *num_queues = hweight32(*queue_mask); > } > > +static void macb_clks_disable(struct clk *pclk, struct clk *hclk, struct clk *tx_clk, > + struct clk *rx_clk, struct clk *tsu_clk) > +{ > + clk_disable_unprepare(tx_clk); > + clk_disable_unprepare(hclk); > + clk_disable_unprepare(pclk); > + clk_disable_unprepare(rx_clk); > + clk_disable_unprepare(tsu_clk); Looks like you should consider using the CLK bulk API: clk_bulk_disable_unprepare() and friends.
Hi Claudiu,
I love your patch! Perhaps something to improve:
[auto build test WARNING on robh/for-next]
[also build test WARNING on net-next/master net/master linus/master v5.10-rc7 next-20201208]
[cannot apply to sparc-next/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Claudiu-Beznea/net-macb-add-support-for-sama7g5/20201207-201959
base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: arm64-randconfig-r021-20201208 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 1968804ac726e7674d5de22bc2204b45857da344)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/0day-ci/linux/commit/7a9fff9938fe9b459aa67f4afb0e817313d3d54a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Claudiu-Beznea/net-macb-add-support-for-sama7g5/20201207-201959
git checkout 7a9fff9938fe9b459aa67f4afb0e817313d3d54a
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
>> drivers/net/ethernet/cadence/macb_main.c:4506:6: warning: variable 'bp' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!dev) {
^~~~
drivers/net/ethernet/cadence/macb_main.c:4641:20: note: uninitialized use occurs here
macb_clks_disable(bp->pclk, bp->hclk, bp->tx_clk, bp->rx_clk, bp->tsu_clk);
^~
drivers/net/ethernet/cadence/macb_main.c:4506:2: note: remove the 'if' if its condition is always false
if (!dev) {
^~~~~~~~~~~
drivers/net/ethernet/cadence/macb_main.c:4474:17: note: initialize the variable 'bp' to silence this warning
struct macb *bp;
^
= NULL
1 warning generated.
vim +4506 drivers/net/ethernet/cadence/macb_main.c
83a77e9ec4150e drivers/net/ethernet/cadence/macb.c Bartosz Folta 2016-12-14 4456
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4457 static int macb_probe(struct platform_device *pdev)
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4458 {
83a77e9ec4150e drivers/net/ethernet/cadence/macb.c Bartosz Folta 2016-12-14 4459 const struct macb_config *macb_config = &default_gem_config;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4460 int (*clk_init)(struct platform_device *, struct clk **,
f5473d1d44e4b4 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4461 struct clk **, struct clk **, struct clk **,
f5473d1d44e4b4 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4462 struct clk **) = macb_config->clk_init;
83a77e9ec4150e drivers/net/ethernet/cadence/macb.c Bartosz Folta 2016-12-14 4463 int (*init)(struct platform_device *) = macb_config->init;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4464 struct device_node *np = pdev->dev.of_node;
aead88bd0e9905 drivers/net/ethernet/cadence/macb.c shubhrajyoti.datta@xilinx.com 2016-08-16 4465 struct clk *pclk, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL;
f5473d1d44e4b4 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4466 struct clk *tsu_clk = NULL;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4467 unsigned int queue_mask, num_queues;
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4468 bool native_io;
0c65b2b90d13c1 drivers/net/ethernet/cadence/macb_main.c Andrew Lunn 2019-11-04 4469 phy_interface_t interface;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4470 struct net_device *dev;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4471 struct resource *regs;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4472 void __iomem *mem;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4473 const char *mac;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4474 struct macb *bp;
404cd086f29e86 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2018-07-06 4475 int err, val;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4476
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4477 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4478 mem = devm_ioremap_resource(&pdev->dev, regs);
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4479 if (IS_ERR(mem))
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4480 return PTR_ERR(mem);
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4481
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4482 if (np) {
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4483 const struct of_device_id *match;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4484
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4485 match = of_match_node(macb_dt_ids, np);
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4486 if (match && match->data) {
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4487 macb_config = match->data;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4488 clk_init = macb_config->clk_init;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4489 init = macb_config->init;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4490 }
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4491 }
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4492
f5473d1d44e4b4 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4493 err = clk_init(pdev, &pclk, &hclk, &tx_clk, &rx_clk, &tsu_clk);
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4494 if (err)
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4495 return err;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4496
d54f89af6cc4d6 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4497 pm_runtime_set_autosuspend_delay(&pdev->dev, MACB_PM_TIMEOUT);
d54f89af6cc4d6 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4498 pm_runtime_use_autosuspend(&pdev->dev);
d54f89af6cc4d6 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4499 pm_runtime_get_noresume(&pdev->dev);
d54f89af6cc4d6 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4500 pm_runtime_set_active(&pdev->dev);
d54f89af6cc4d6 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4501 pm_runtime_enable(&pdev->dev);
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4502 native_io = hw_is_native_io(mem);
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4503
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4504 macb_probe_queues(mem, native_io, &queue_mask, &num_queues);
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4505 dev = alloc_etherdev_mq(sizeof(*bp), num_queues);
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 @4506 if (!dev) {
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4507 err = -ENOMEM;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4508 goto err_disable_clocks;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4509 }
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4510
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4511 dev->base_addr = regs->start;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4512
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4513 SET_NETDEV_DEV(dev, &pdev->dev);
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4514
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4515 bp = netdev_priv(dev);
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4516 bp->pdev = pdev;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4517 bp->dev = dev;
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4518 bp->regs = mem;
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4519 bp->native_io = native_io;
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4520 if (native_io) {
7a6e0706c09b12 drivers/net/ethernet/cadence/macb.c David S. Miller 2015-07-27 4521 bp->macb_reg_readl = hw_readl_native;
7a6e0706c09b12 drivers/net/ethernet/cadence/macb.c David S. Miller 2015-07-27 4522 bp->macb_reg_writel = hw_writel_native;
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4523 } else {
7a6e0706c09b12 drivers/net/ethernet/cadence/macb.c David S. Miller 2015-07-27 4524 bp->macb_reg_readl = hw_readl;
7a6e0706c09b12 drivers/net/ethernet/cadence/macb.c David S. Miller 2015-07-27 4525 bp->macb_reg_writel = hw_writel;
f2ce8a9e48385f drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4526 }
421d9df0628be1 drivers/net/ethernet/cadence/macb.c Cyrille Pitchen 2015-03-07 4527 bp->num_queues = num_queues;
bfa0914afa95d4 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4528 bp->queue_mask = queue_mask;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4529 if (macb_config)
f6970505defd0e drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4530 bp->dma_burst_length = macb_config->dma_burst_length;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4531 bp->pclk = pclk;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4532 bp->hclk = hclk;
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4533 bp->tx_clk = tx_clk;
aead88bd0e9905 drivers/net/ethernet/cadence/macb.c shubhrajyoti.datta@xilinx.com 2016-08-16 4534 bp->rx_clk = rx_clk;
f5473d1d44e4b4 drivers/net/ethernet/cadence/macb_main.c Harini Katakam 2019-03-01 4535 bp->tsu_clk = tsu_clk;
f36dbe6a285e06 drivers/net/ethernet/cadence/macb.c Andy Shevchenko 2015-07-24 4536 if (macb_config)
98b5a0f4a2282f drivers/net/ethernet/cadence/macb.c Harini Katakam 2015-05-06 4537 bp->jumbo_max_len = macb_config->jumbo_max_len;
98b5a0f4a2282f drivers/net/ethernet/cadence/macb.c Harini Katakam 2015-05-06 4538
3e2a5e15390643 drivers/net/ethernet/cadence/macb.c Sergio Prado 2016-02-09 4539 bp->wol = 0;
7c4a1d0cfdc169 drivers/net/ethernet/cadence/macb.c Sergio Prado 2016-02-16 4540 if (of_get_property(np, "magic-packet", NULL))
3e2a5e15390643 drivers/net/ethernet/cadence/macb.c Sergio Prado 2016-02-09 4541 bp->wol |= MACB_WOL_HAS_MAGIC_PACKET;
ced4799d063759 drivers/net/ethernet/cadence/macb_main.c Nicolas Ferre 2020-07-10 4542 device_set_wakeup_capable(&pdev->dev, bp->wol & MACB_WOL_HAS_MAGIC_PACKET);
3e2a5e15390643 drivers/net/ethernet/cadence/macb.c Sergio Prado 2016-02-09 4543
5c14e373350d7e drivers/net/ethernet/cadence/macb_main.c Claudiu Beznea 2020-12-07 4544 bp->usrio = macb_config->usrio;
5c14e373350d7e drivers/net/ethernet/cadence/macb_main.c Claudiu Beznea 2020-12-07 4545
c69618b3e4f220 drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4546 spin_lock_init(&bp->lock);
f6970505defd0e drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4547
ad78347f06581e drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4548 /* setup capabilities */
f6970505defd0e drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4549 macb_configure_caps(bp, macb_config);
f6970505defd0e drivers/net/ethernet/cadence/macb.c Nicolas Ferre 2015-03-31 4550
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index b23e986ac6dc..6b8e1109dfd3 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -3694,6 +3694,16 @@ static void macb_probe_queues(void __iomem *mem, *num_queues = hweight32(*queue_mask); } +static void macb_clks_disable(struct clk *pclk, struct clk *hclk, struct clk *tx_clk, + struct clk *rx_clk, struct clk *tsu_clk) +{ + clk_disable_unprepare(tx_clk); + clk_disable_unprepare(hclk); + clk_disable_unprepare(pclk); + clk_disable_unprepare(rx_clk); + clk_disable_unprepare(tsu_clk); +} + static int macb_clk_init(struct platform_device *pdev, struct clk **pclk, struct clk **hclk, struct clk **tx_clk, struct clk **rx_clk, struct clk **tsu_clk) @@ -3743,40 +3753,37 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk, err = clk_prepare_enable(*hclk); if (err) { dev_err(&pdev->dev, "failed to enable hclk (%d)\n", err); - goto err_disable_pclk; + hclk = NULL; + tx_clk = NULL; + rx_clk = NULL; + goto err_disable_clks; } err = clk_prepare_enable(*tx_clk); if (err) { dev_err(&pdev->dev, "failed to enable tx_clk (%d)\n", err); - goto err_disable_hclk; + tx_clk = NULL; + rx_clk = NULL; + goto err_disable_clks; } err = clk_prepare_enable(*rx_clk); if (err) { dev_err(&pdev->dev, "failed to enable rx_clk (%d)\n", err); - goto err_disable_txclk; + rx_clk = NULL; + goto err_disable_clks; } err = clk_prepare_enable(*tsu_clk); if (err) { dev_err(&pdev->dev, "failed to enable tsu_clk (%d)\n", err); - goto err_disable_rxclk; + goto err_disable_clks; } return 0; -err_disable_rxclk: - clk_disable_unprepare(*rx_clk); - -err_disable_txclk: - clk_disable_unprepare(*tx_clk); - -err_disable_hclk: - clk_disable_unprepare(*hclk); - -err_disable_pclk: - clk_disable_unprepare(*pclk); +err_disable_clks: + macb_clks_disable(*pclk, *hclk, *tx_clk, *rx_clk, NULL); return err; } @@ -4755,11 +4762,7 @@ static int macb_probe(struct platform_device *pdev) free_netdev(dev); err_disable_clocks: - clk_disable_unprepare(tx_clk); - clk_disable_unprepare(hclk); - clk_disable_unprepare(pclk); - clk_disable_unprepare(rx_clk); - clk_disable_unprepare(tsu_clk); + macb_clks_disable(bp->pclk, bp->hclk, bp->tx_clk, bp->rx_clk, bp->tsu_clk); pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev); @@ -4784,11 +4787,8 @@ static int macb_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev); if (!pm_runtime_suspended(&pdev->dev)) { - clk_disable_unprepare(bp->tx_clk); - clk_disable_unprepare(bp->hclk); - clk_disable_unprepare(bp->pclk); - clk_disable_unprepare(bp->rx_clk); - clk_disable_unprepare(bp->tsu_clk); + macb_clks_disable(bp->pclk, bp->hclk, bp->tx_clk, + bp->rx_clk, bp->tsu_clk); pm_runtime_set_suspended(&pdev->dev); } phylink_destroy(bp->phylink); @@ -4966,14 +4966,16 @@ static int __maybe_unused macb_runtime_suspend(struct device *dev) { struct net_device *netdev = dev_get_drvdata(dev); struct macb *bp = netdev_priv(netdev); + struct clk *pclk = NULL, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL; if (!(device_may_wakeup(dev))) { - clk_disable_unprepare(bp->tx_clk); - clk_disable_unprepare(bp->hclk); - clk_disable_unprepare(bp->pclk); - clk_disable_unprepare(bp->rx_clk); + pclk = bp->pclk; + hclk = bp->hclk; + tx_clk = bp->tx_clk; + rx_clk = bp->rx_clk; } - clk_disable_unprepare(bp->tsu_clk); + + macb_clks_disable(pclk, hclk, tx_clk, rx_clk, bp->tsu_clk); return 0; }
Add function to disable all macb clocks. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Suggested-by: Andrew Lunn <andrew@lunn.ch> --- drivers/net/ethernet/cadence/macb_main.c | 62 ++++++++++++++++---------------- 1 file changed, 32 insertions(+), 30 deletions(-)