2013-05-29 09:02:26

by Yijing Wang

[permalink] [raw]
Subject: [PATCH] tg3: remove redundant pm init code

Pci_enable_device() will set device pm state to D0, so
it's no need to do it again in tg3_init_one().

Signed-off-by: Yijing Wang <[email protected]>
---
drivers/net/ethernet/broadcom/tg3.c | 20 +-------------------
1 files changed, 1 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 728d42a..1396ab3 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -17042,25 +17042,10 @@ static int tg3_init_one(struct pci_dev *pdev,

pci_set_master(pdev);

- /* Find power-management capability. */
- pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
- if (pm_cap == 0) {
- dev_err(&pdev->dev,
- "Cannot find Power Management capability, aborting\n");
- err = -EIO;
- goto err_out_free_res;
- }
-
- err = pci_set_power_state(pdev, PCI_D0);
- if (err) {
- dev_err(&pdev->dev, "Transition to D0 failed, aborting\n");
- goto err_out_free_res;
- }
-
dev = alloc_etherdev_mq(sizeof(*tp), TG3_IRQ_MAX_VECS);
if (!dev) {
err = -ENOMEM;
- goto err_out_power_down;
+ goto err_out_free_res;
}

SET_NETDEV_DEV(dev, &pdev->dev);
@@ -17406,9 +17391,6 @@ err_out_iounmap:
err_out_free_dev:
free_netdev(dev);

-err_out_power_down:
- pci_set_power_state(pdev, PCI_D3hot);
-
err_out_free_res:
pci_release_regions(pdev);

--
1.7.1


2013-05-29 23:22:50

by Michael Chan

[permalink] [raw]
Subject: Re: [PATCH] tg3: remove redundant pm init code

On Wed, 2013-05-29 at 17:00 +0800, Yijing Wang wrote:
> Pci_enable_device() will set device pm state to D0, so
> it's no need to do it again in tg3_init_one().
>
> Signed-off-by: Yijing Wang <[email protected]>

Acked-by: Michael Chan <[email protected]>

> ---
> drivers/net/ethernet/broadcom/tg3.c | 20 +-------------------
> 1 files changed, 1 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
> index 728d42a..1396ab3 100644
> --- a/drivers/net/ethernet/broadcom/tg3.c
> +++ b/drivers/net/ethernet/broadcom/tg3.c
> @@ -17042,25 +17042,10 @@ static int tg3_init_one(struct pci_dev *pdev,
>
> pci_set_master(pdev);
>
> - /* Find power-management capability. */
> - pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
> - if (pm_cap == 0) {
> - dev_err(&pdev->dev,
> - "Cannot find Power Management capability, aborting\n");
> - err = -EIO;
> - goto err_out_free_res;
> - }
> -
> - err = pci_set_power_state(pdev, PCI_D0);
> - if (err) {
> - dev_err(&pdev->dev, "Transition to D0 failed, aborting\n");
> - goto err_out_free_res;
> - }
> -
> dev = alloc_etherdev_mq(sizeof(*tp), TG3_IRQ_MAX_VECS);
> if (!dev) {
> err = -ENOMEM;
> - goto err_out_power_down;
> + goto err_out_free_res;
> }
>
> SET_NETDEV_DEV(dev, &pdev->dev);
> @@ -17406,9 +17391,6 @@ err_out_iounmap:
> err_out_free_dev:
> free_netdev(dev);
>
> -err_out_power_down:
> - pci_set_power_state(pdev, PCI_D3hot);
> -
> err_out_free_res:
> pci_release_regions(pdev);
>


2013-06-03 07:13:14

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] tg3: remove redundant pm init code

From: Yijing Wang <[email protected]>
Date: Wed, 29 May 2013 17:00:32 +0800

> Pci_enable_device() will set device pm state to D0, so
> it's no need to do it again in tg3_init_one().
>
> Signed-off-by: Yijing Wang <[email protected]>

This patch introduces a warning:

drivers/net/ethernet/broadcom/tg3.c: In function ?tg3_init_one?:
drivers/net/ethernet/broadcom/tg3.c:17231:13: warning: ?pm_cap? may be used uninitialized in this function [-Wuninitialized]
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2013-06-03 07:16:33

by Yijing Wang

[permalink] [raw]
Subject: Re: [PATCH] tg3: remove redundant pm init code

On 2013/6/3 15:13, David Miller wrote:
> From: Yijing Wang <[email protected]>
> Date: Wed, 29 May 2013 17:00:32 +0800
>
>> Pci_enable_device() will set device pm state to D0, so
>> it's no need to do it again in tg3_init_one().
>>
>> Signed-off-by: Yijing Wang <[email protected]>
>
> This patch introduces a warning:
>
> drivers/net/ethernet/broadcom/tg3.c: In function ?tg3_init_one?:
> drivers/net/ethernet/broadcom/tg3.c:17231:13: warning: ?pm_cap? may be used uninitialized in this function [-Wuninitialized]
>
Sorry, I will update it and resend soon.

Thanks!
Yijing.

--
Thanks!
Yijing