linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
* [Linux-kernel-mentees] [PATCH v1 0/2] ipw2x00: use generic power management
@ 2020-06-29  7:25 Vaibhav Gupta
  2020-06-29  7:25 ` [Linux-kernel-mentees] [PATCH v1 1/2] ipw2100: " Vaibhav Gupta
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Vaibhav Gupta @ 2020-06-29  7:25 UTC (permalink / raw)
  To: Bjorn Helgaas, Bjorn Helgaas, bjorn, Vaibhav Gupta,
	David S. Miller, Stanislav Yakovlev, Kalle Valo, Jakub Kicinski
  Cc: Vaibhav Gupta, netdev, linux-wireless, linux-kernel,
	linux-kernel-mentees

Linux Kernel Mentee: Remove Legacy Power Management.

The purpose of this patch series is to remove legacy power management callbacks
from amd ethernet drivers.

The callbacks performing suspend() and resume() operations are still calling
pci_save_state(), pci_set_power_state(), etc. and handling the power management
themselves, which is not recommended.

The conversion requires the removal of the those function calls and change the
callback definition accordingly and make use of dev_pm_ops structure.

All patches are compile-tested only.

Vaibhav Gupta (2):
  ipw2100: use generic power management
  ipw2200: use generic power management

 drivers/net/wireless/intel/ipw2x00/ipw2100.c | 31 +++++---------------
 drivers/net/wireless/intel/ipw2x00/ipw2200.c | 30 +++++--------------
 2 files changed, 14 insertions(+), 47 deletions(-)

-- 
2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* [Linux-kernel-mentees] [PATCH v1 1/2] ipw2100: use generic power management
  2020-06-29  7:25 [Linux-kernel-mentees] [PATCH v1 0/2] ipw2x00: use generic power management Vaibhav Gupta
@ 2020-06-29  7:25 ` Vaibhav Gupta
  2020-07-15 10:39   ` Kalle Valo
  2020-06-29  7:25 ` [Linux-kernel-mentees] [PATCH v1 2/2] ipw2200: " Vaibhav Gupta
  2020-07-13 14:41 ` [Linux-kernel-mentees] [PATCH v1 0/2] ipw2x00: " Kalle Valo
  2 siblings, 1 reply; 8+ messages in thread
From: Vaibhav Gupta @ 2020-06-29  7:25 UTC (permalink / raw)
  To: Bjorn Helgaas, Bjorn Helgaas, bjorn, Vaibhav Gupta,
	David S. Miller, Stanislav Yakovlev, Kalle Valo, Jakub Kicinski
  Cc: Vaibhav Gupta, netdev, linux-wireless, linux-kernel,
	linux-kernel-mentees

With legacy PM, drivers themselves were responsible for managing the
device's power states and takes care of register states.

After upgrading to the generic structure, PCI core will take care of
required tasks and drivers should do only device-specific operations.

The driver was invoking PCI helper functions like pci_save/restore_state(),
pci_enable/disable_device() and pci_set_power_state(), which is not
recommended.

Compile-tested only.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
---
 drivers/net/wireless/intel/ipw2x00/ipw2100.c | 31 +++++---------------
 1 file changed, 7 insertions(+), 24 deletions(-)

diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2100.c b/drivers/net/wireless/intel/ipw2x00/ipw2100.c
index 624fe721e2b5..57ce55728808 100644
--- a/drivers/net/wireless/intel/ipw2x00/ipw2100.c
+++ b/drivers/net/wireless/intel/ipw2x00/ipw2100.c
@@ -6397,10 +6397,9 @@ static void ipw2100_pci_remove_one(struct pci_dev *pci_dev)
 	IPW_DEBUG_INFO("exit\n");
 }
 
-#ifdef CONFIG_PM
-static int ipw2100_suspend(struct pci_dev *pci_dev, pm_message_t state)
+static int __maybe_unused ipw2100_suspend(struct device *dev_d)
 {
-	struct ipw2100_priv *priv = pci_get_drvdata(pci_dev);
+	struct ipw2100_priv *priv = dev_get_drvdata(dev_d);
 	struct net_device *dev = priv->net_dev;
 
 	IPW_DEBUG_INFO("%s: Going into suspend...\n", dev->name);
@@ -6414,10 +6413,6 @@ static int ipw2100_suspend(struct pci_dev *pci_dev, pm_message_t state)
 	/* Remove the PRESENT state of the device */
 	netif_device_detach(dev);
 
-	pci_save_state(pci_dev);
-	pci_disable_device(pci_dev);
-	pci_set_power_state(pci_dev, PCI_D3hot);
-
 	priv->suspend_at = ktime_get_boottime_seconds();
 
 	mutex_unlock(&priv->action_mutex);
@@ -6425,11 +6420,11 @@ static int ipw2100_suspend(struct pci_dev *pci_dev, pm_message_t state)
 	return 0;
 }
 
-static int ipw2100_resume(struct pci_dev *pci_dev)
+static int __maybe_unused ipw2100_resume(struct device *dev_d)
 {
+	struct pci_dev *pci_dev = to_pci_dev(dev_d);
 	struct ipw2100_priv *priv = pci_get_drvdata(pci_dev);
 	struct net_device *dev = priv->net_dev;
-	int err;
 	u32 val;
 
 	if (IPW2100_PM_DISABLED)
@@ -6439,16 +6434,6 @@ static int ipw2100_resume(struct pci_dev *pci_dev)
 
 	IPW_DEBUG_INFO("%s: Coming out of suspend...\n", dev->name);
 
-	pci_set_power_state(pci_dev, PCI_D0);
-	err = pci_enable_device(pci_dev);
-	if (err) {
-		printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
-		       dev->name);
-		mutex_unlock(&priv->action_mutex);
-		return err;
-	}
-	pci_restore_state(pci_dev);
-
 	/*
 	 * Suspend/Resume resets the PCI configuration space, so we have to
 	 * re-disable the RETRY_TIMEOUT register (0x41) to keep PCI Tx retries
@@ -6473,7 +6458,6 @@ static int ipw2100_resume(struct pci_dev *pci_dev)
 
 	return 0;
 }
-#endif
 
 static void ipw2100_shutdown(struct pci_dev *pci_dev)
 {
@@ -6539,15 +6523,14 @@ static const struct pci_device_id ipw2100_pci_id_table[] = {
 
 MODULE_DEVICE_TABLE(pci, ipw2100_pci_id_table);
 
+static SIMPLE_DEV_PM_OPS(ipw2100_pm_ops, ipw2100_suspend, ipw2100_resume);
+
 static struct pci_driver ipw2100_pci_driver = {
 	.name = DRV_NAME,
 	.id_table = ipw2100_pci_id_table,
 	.probe = ipw2100_pci_init_one,
 	.remove = ipw2100_pci_remove_one,
-#ifdef CONFIG_PM
-	.suspend = ipw2100_suspend,
-	.resume = ipw2100_resume,
-#endif
+	.driver.pm = &ipw2100_pm_ops,
 	.shutdown = ipw2100_shutdown,
 };
 
-- 
2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* [Linux-kernel-mentees] [PATCH v1 2/2] ipw2200: use generic power management
  2020-06-29  7:25 [Linux-kernel-mentees] [PATCH v1 0/2] ipw2x00: use generic power management Vaibhav Gupta
  2020-06-29  7:25 ` [Linux-kernel-mentees] [PATCH v1 1/2] ipw2100: " Vaibhav Gupta
@ 2020-06-29  7:25 ` Vaibhav Gupta
  2020-07-13 14:41 ` [Linux-kernel-mentees] [PATCH v1 0/2] ipw2x00: " Kalle Valo
  2 siblings, 0 replies; 8+ messages in thread
From: Vaibhav Gupta @ 2020-06-29  7:25 UTC (permalink / raw)
  To: Bjorn Helgaas, Bjorn Helgaas, bjorn, Vaibhav Gupta,
	David S. Miller, Stanislav Yakovlev, Kalle Valo, Jakub Kicinski
  Cc: Vaibhav Gupta, netdev, linux-wireless, linux-kernel,
	linux-kernel-mentees

With legacy PM, drivers themselves were responsible for managing the
device's power states and takes care of register states.

After upgrading to the generic structure, PCI core will take care of
required tasks and drivers should do only device-specific operations.

The driver was invoking PCI helper functions like pci_save/restore_state(),
pci_enable/disable_device() and pci_set_power_state(), which is not
recommended.

Compile-tested only.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
---
 drivers/net/wireless/intel/ipw2x00/ipw2200.c | 30 +++++---------------
 1 file changed, 7 insertions(+), 23 deletions(-)

diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2200.c b/drivers/net/wireless/intel/ipw2x00/ipw2200.c
index 661e63bfc892..39ff3a426092 100644
--- a/drivers/net/wireless/intel/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/intel/ipw2x00/ipw2200.c
@@ -11838,10 +11838,9 @@ static void ipw_pci_remove(struct pci_dev *pdev)
 	free_firmware();
 }
 
-#ifdef CONFIG_PM
-static int ipw_pci_suspend(struct pci_dev *pdev, pm_message_t state)
+static int __maybe_unused ipw_pci_suspend(struct device *dev_d)
 {
-	struct ipw_priv *priv = pci_get_drvdata(pdev);
+	struct ipw_priv *priv = dev_get_drvdata(dev_d);
 	struct net_device *dev = priv->net_dev;
 
 	printk(KERN_INFO "%s: Going into suspend...\n", dev->name);
@@ -11852,33 +11851,20 @@ static int ipw_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 	/* Remove the PRESENT state of the device */
 	netif_device_detach(dev);
 
-	pci_save_state(pdev);
-	pci_disable_device(pdev);
-	pci_set_power_state(pdev, pci_choose_state(pdev, state));
-
 	priv->suspend_at = ktime_get_boottime_seconds();
 
 	return 0;
 }
 
-static int ipw_pci_resume(struct pci_dev *pdev)
+static int __maybe_unused ipw_pci_resume(struct device *dev_d)
 {
+	struct pci_dev *pdev = to_pci_dev(dev_d);
 	struct ipw_priv *priv = pci_get_drvdata(pdev);
 	struct net_device *dev = priv->net_dev;
-	int err;
 	u32 val;
 
 	printk(KERN_INFO "%s: Coming out of suspend...\n", dev->name);
 
-	pci_set_power_state(pdev, PCI_D0);
-	err = pci_enable_device(pdev);
-	if (err) {
-		printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
-		       dev->name);
-		return err;
-	}
-	pci_restore_state(pdev);
-
 	/*
 	 * Suspend/Resume resets the PCI configuration space, so we have to
 	 * re-disable the RETRY_TIMEOUT register (0x41) to keep PCI Tx retries
@@ -11900,7 +11886,6 @@ static int ipw_pci_resume(struct pci_dev *pdev)
 
 	return 0;
 }
-#endif
 
 static void ipw_pci_shutdown(struct pci_dev *pdev)
 {
@@ -11912,16 +11897,15 @@ static void ipw_pci_shutdown(struct pci_dev *pdev)
 	pci_disable_device(pdev);
 }
 
+static SIMPLE_DEV_PM_OPS(ipw_pci_pm_ops, ipw_pci_suspend, ipw_pci_resume);
+
 /* driver initialization stuff */
 static struct pci_driver ipw_driver = {
 	.name = DRV_NAME,
 	.id_table = card_ids,
 	.probe = ipw_pci_probe,
 	.remove = ipw_pci_remove,
-#ifdef CONFIG_PM
-	.suspend = ipw_pci_suspend,
-	.resume = ipw_pci_resume,
-#endif
+	.driver.pm = &ipw_pci_pm_ops,
 	.shutdown = ipw_pci_shutdown,
 };
 
-- 
2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* Re: [Linux-kernel-mentees] [PATCH v1 0/2] ipw2x00: use generic power management
  2020-06-29  7:25 [Linux-kernel-mentees] [PATCH v1 0/2] ipw2x00: use generic power management Vaibhav Gupta
  2020-06-29  7:25 ` [Linux-kernel-mentees] [PATCH v1 1/2] ipw2100: " Vaibhav Gupta
  2020-06-29  7:25 ` [Linux-kernel-mentees] [PATCH v1 2/2] ipw2200: " Vaibhav Gupta
@ 2020-07-13 14:41 ` Kalle Valo
  2020-07-13 14:45   ` Vaibhav Gupta
  2 siblings, 1 reply; 8+ messages in thread
From: Kalle Valo @ 2020-07-13 14:41 UTC (permalink / raw)
  To: Vaibhav Gupta
  Cc: linux-wireless, linux-kernel, Bjorn Helgaas, netdev,
	Bjorn Helgaas, Jakub Kicinski, linux-kernel-mentees,
	David S. Miller, Stanislav Yakovlev

Vaibhav Gupta <vaibhavgupta40@gmail.com> writes:

> Linux Kernel Mentee: Remove Legacy Power Management.
>
> The purpose of this patch series is to remove legacy power management callbacks
> from amd ethernet drivers.
>
> The callbacks performing suspend() and resume() operations are still calling
> pci_save_state(), pci_set_power_state(), etc. and handling the power management
> themselves, which is not recommended.
>
> The conversion requires the removal of the those function calls and change the
> callback definition accordingly and make use of dev_pm_ops structure.
>
> All patches are compile-tested only.
>
> Vaibhav Gupta (2):
>   ipw2100: use generic power management
>   ipw2200: use generic power management
>
>  drivers/net/wireless/intel/ipw2x00/ipw2100.c | 31 +++++---------------
>  drivers/net/wireless/intel/ipw2x00/ipw2200.c | 30 +++++--------------

amd ethernet drivers? That must be a copy paste error. But no need to
resend because of this.

-- 
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* Re: [Linux-kernel-mentees] [PATCH v1 0/2] ipw2x00: use generic power management
  2020-07-13 14:41 ` [Linux-kernel-mentees] [PATCH v1 0/2] ipw2x00: " Kalle Valo
@ 2020-07-13 14:45   ` Vaibhav Gupta
  2020-07-13 14:56     ` Kalle Valo
  0 siblings, 1 reply; 8+ messages in thread
From: Vaibhav Gupta @ 2020-07-13 14:45 UTC (permalink / raw)
  To: Kalle Valo
  Cc: linux-wireless, linux-kernel, Bjorn Helgaas, netdev,
	Bjorn Helgaas, Jakub Kicinski, linux-kernel-mentees,
	David S. Miller, Stanislav Yakovlev


[-- Attachment #1.1: Type: text/plain, Size: 1353 bytes --]

On Mon, Jul 13, 2020, 8:12 PM Kalle Valo <kvalo@codeaurora.org> wrote:

> Vaibhav Gupta <vaibhavgupta40@gmail.com> writes:
>
> > Linux Kernel Mentee: Remove Legacy Power Management.
> >
> > The purpose of this patch series is to remove legacy power management
> callbacks
> > from amd ethernet drivers.
> >
> > The callbacks performing suspend() and resume() operations are still
> calling
> > pci_save_state(), pci_set_power_state(), etc. and handling the power
> management
> > themselves, which is not recommended.
> >
> > The conversion requires the removal of the those function calls and
> change the
> > callback definition accordingly and make use of dev_pm_ops structure.
> >
> > All patches are compile-tested only.
> >
> > Vaibhav Gupta (2):
> >   ipw2100: use generic power management
> >   ipw2200: use generic power management
> >
> >  drivers/net/wireless/intel/ipw2x00/ipw2100.c | 31 +++++---------------
> >  drivers/net/wireless/intel/ipw2x00/ipw2200.c | 30 +++++--------------
>
> amd ethernet drivers? That must be a copy paste error. But no need to
> resend because of this.
>
Yes. I am genuinely sorry for this. My two patch-series had same changes,
so I copy-pasted the cover letter. Forgot to replace the name.

Thanks
-- Vaibhav Gupta

>
> --
>
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
>

[-- Attachment #1.2: Type: text/html, Size: 2249 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* Re: [Linux-kernel-mentees] [PATCH v1 0/2] ipw2x00: use generic power management
  2020-07-13 14:45   ` Vaibhav Gupta
@ 2020-07-13 14:56     ` Kalle Valo
  0 siblings, 0 replies; 8+ messages in thread
From: Kalle Valo @ 2020-07-13 14:56 UTC (permalink / raw)
  To: Vaibhav Gupta
  Cc: linux-wireless, linux-kernel, Bjorn Helgaas, netdev,
	Bjorn Helgaas, Jakub Kicinski, linux-kernel-mentees,
	David S. Miller, Stanislav Yakovlev

Vaibhav Gupta <vaibhavgupta40@gmail.com> writes:

> On Mon, Jul 13, 2020, 8:12 PM Kalle Valo <kvalo@codeaurora.org> wrote:
>
>     Vaibhav Gupta <vaibhavgupta40@gmail.com> writes:
>     
>     > Linux Kernel Mentee: Remove Legacy Power Management.
>     >
>     > The purpose of this patch series is to remove legacy power
>     management callbacks
>     > from amd ethernet drivers.
>     >
>     > The callbacks performing suspend() and resume() operations are
>     still calling
>     > pci_save_state(), pci_set_power_state(), etc. and handling the
>     power management
>     > themselves, which is not recommended.
>     >
>     > The conversion requires the removal of the those function calls
>     and change the
>     > callback definition accordingly and make use of dev_pm_ops
>     structure.
>     >
>     > All patches are compile-tested only.
>     >
>     > Vaibhav Gupta (2):
>     > ipw2100: use generic power management
>     > ipw2200: use generic power management
>     >
>     > drivers/net/wireless/intel/ipw2x00/ipw2100.c | 31
>     +++++---------------
>     > drivers/net/wireless/intel/ipw2x00/ipw2200.c | 30
>     +++++--------------
>     
>     amd ethernet drivers? That must be a copy paste error. But no need
>     to
>     resend because of this.
>     
>
> Yes. I am genuinely sorry for this. My two patch-series had same
> changes, so I copy-pasted the cover letter. Forgot to replace the
> name.

No worries. But PLEASE don't send HTML email, lists filter those out:

Content-Type: text/html; charset="UTF-8"

-- 
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* Re: [Linux-kernel-mentees] [PATCH v1 1/2] ipw2100: use generic power management
  2020-06-29  7:25 ` [Linux-kernel-mentees] [PATCH v1 1/2] ipw2100: " Vaibhav Gupta
@ 2020-07-15 10:39   ` Kalle Valo
  0 siblings, 0 replies; 8+ messages in thread
From: Kalle Valo @ 2020-07-15 10:39 UTC (permalink / raw)
  To: Vaibhav Gupta
  Cc: Vaibhav Gupta, linux-wireless, linux-kernel, Bjorn Helgaas,
	netdev, Bjorn Helgaas, Jakub Kicinski, linux-kernel-mentees,
	David S. Miller, Stanislav Yakovlev

Vaibhav Gupta <vaibhavgupta40@gmail.com> wrote:

> With legacy PM, drivers themselves were responsible for managing the
> device's power states and takes care of register states.
> 
> After upgrading to the generic structure, PCI core will take care of
> required tasks and drivers should do only device-specific operations.
> 
> The driver was invoking PCI helper functions like pci_save/restore_state(),
> pci_enable/disable_device() and pci_set_power_state(), which is not
> recommended.
> 
> Compile-tested only.
> 
> Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>

2 patches applied to wireless-drivers-next.git, thanks.

814db61adb86 ipw2100: use generic power management
77b4ad07699f ipw2200: use generic power management

-- 
https://patchwork.kernel.org/patch/11632343/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* [Linux-kernel-mentees] [PATCH v1 1/2] ipw2100: use generic power management
  2020-06-29  3:32 Vaibhav Gupta
@ 2020-06-29  3:32 ` Vaibhav Gupta
  0 siblings, 0 replies; 8+ messages in thread
From: Vaibhav Gupta @ 2020-06-29  3:32 UTC (permalink / raw)
  To: Bjorn Helgaas, Bjorn Helgaas, bjorn, Vaibhav Gupta,
	David S. Miller, Stanislav Yakovlev, Kalle Valo, Jakub Kicinski
  Cc: netdev, linux-kernel-mentees, linux-kernel, Vaibhav Gupta

With legacy PM, drivers themselves were responsible for managing the
device's power states and takes care of register states.

After upgrading to the generic structure, PCI core will take care of
required tasks and drivers should do only device-specific operations.

The driver was invoking PCI helper functions like pci_save/restore_state(),
pci_enable/disable_device() and pci_set_power_state(), which is not
recommended.

Compile-tested only.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
---
 drivers/net/wireless/intel/ipw2x00/ipw2100.c | 31 +++++---------------
 1 file changed, 7 insertions(+), 24 deletions(-)

diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2100.c b/drivers/net/wireless/intel/ipw2x00/ipw2100.c
index 624fe721e2b5..57ce55728808 100644
--- a/drivers/net/wireless/intel/ipw2x00/ipw2100.c
+++ b/drivers/net/wireless/intel/ipw2x00/ipw2100.c
@@ -6397,10 +6397,9 @@ static void ipw2100_pci_remove_one(struct pci_dev *pci_dev)
 	IPW_DEBUG_INFO("exit\n");
 }
 
-#ifdef CONFIG_PM
-static int ipw2100_suspend(struct pci_dev *pci_dev, pm_message_t state)
+static int __maybe_unused ipw2100_suspend(struct device *dev_d)
 {
-	struct ipw2100_priv *priv = pci_get_drvdata(pci_dev);
+	struct ipw2100_priv *priv = dev_get_drvdata(dev_d);
 	struct net_device *dev = priv->net_dev;
 
 	IPW_DEBUG_INFO("%s: Going into suspend...\n", dev->name);
@@ -6414,10 +6413,6 @@ static int ipw2100_suspend(struct pci_dev *pci_dev, pm_message_t state)
 	/* Remove the PRESENT state of the device */
 	netif_device_detach(dev);
 
-	pci_save_state(pci_dev);
-	pci_disable_device(pci_dev);
-	pci_set_power_state(pci_dev, PCI_D3hot);
-
 	priv->suspend_at = ktime_get_boottime_seconds();
 
 	mutex_unlock(&priv->action_mutex);
@@ -6425,11 +6420,11 @@ static int ipw2100_suspend(struct pci_dev *pci_dev, pm_message_t state)
 	return 0;
 }
 
-static int ipw2100_resume(struct pci_dev *pci_dev)
+static int __maybe_unused ipw2100_resume(struct device *dev_d)
 {
+	struct pci_dev *pci_dev = to_pci_dev(dev_d);
 	struct ipw2100_priv *priv = pci_get_drvdata(pci_dev);
 	struct net_device *dev = priv->net_dev;
-	int err;
 	u32 val;
 
 	if (IPW2100_PM_DISABLED)
@@ -6439,16 +6434,6 @@ static int ipw2100_resume(struct pci_dev *pci_dev)
 
 	IPW_DEBUG_INFO("%s: Coming out of suspend...\n", dev->name);
 
-	pci_set_power_state(pci_dev, PCI_D0);
-	err = pci_enable_device(pci_dev);
-	if (err) {
-		printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
-		       dev->name);
-		mutex_unlock(&priv->action_mutex);
-		return err;
-	}
-	pci_restore_state(pci_dev);
-
 	/*
 	 * Suspend/Resume resets the PCI configuration space, so we have to
 	 * re-disable the RETRY_TIMEOUT register (0x41) to keep PCI Tx retries
@@ -6473,7 +6458,6 @@ static int ipw2100_resume(struct pci_dev *pci_dev)
 
 	return 0;
 }
-#endif
 
 static void ipw2100_shutdown(struct pci_dev *pci_dev)
 {
@@ -6539,15 +6523,14 @@ static const struct pci_device_id ipw2100_pci_id_table[] = {
 
 MODULE_DEVICE_TABLE(pci, ipw2100_pci_id_table);
 
+static SIMPLE_DEV_PM_OPS(ipw2100_pm_ops, ipw2100_suspend, ipw2100_resume);
+
 static struct pci_driver ipw2100_pci_driver = {
 	.name = DRV_NAME,
 	.id_table = ipw2100_pci_id_table,
 	.probe = ipw2100_pci_init_one,
 	.remove = ipw2100_pci_remove_one,
-#ifdef CONFIG_PM
-	.suspend = ipw2100_suspend,
-	.resume = ipw2100_resume,
-#endif
+	.driver.pm = &ipw2100_pm_ops,
 	.shutdown = ipw2100_shutdown,
 };
 
-- 
2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

end of thread, other threads:[~2020-07-15 10:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-29  7:25 [Linux-kernel-mentees] [PATCH v1 0/2] ipw2x00: use generic power management Vaibhav Gupta
2020-06-29  7:25 ` [Linux-kernel-mentees] [PATCH v1 1/2] ipw2100: " Vaibhav Gupta
2020-07-15 10:39   ` Kalle Valo
2020-06-29  7:25 ` [Linux-kernel-mentees] [PATCH v1 2/2] ipw2200: " Vaibhav Gupta
2020-07-13 14:41 ` [Linux-kernel-mentees] [PATCH v1 0/2] ipw2x00: " Kalle Valo
2020-07-13 14:45   ` Vaibhav Gupta
2020-07-13 14:56     ` Kalle Valo
  -- strict thread matches above, loose matches on Subject: below --
2020-06-29  3:32 Vaibhav Gupta
2020-06-29  3:32 ` [Linux-kernel-mentees] [PATCH v1 1/2] ipw2100: " Vaibhav Gupta

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).