Skip to contentSkip to conversation

mtd: rawnand: cafe: Use generic power management

PATCH Superseded Vaibhav Gupta 3 participants 5 messages Feb 16 – Feb 25

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: rawnand: cafe: Use generic power management

Switch to the generic PCI power management framework and remove legacy callbacks like .resume(). With the generic framework, the standard PCI related work like:
- pci_save/restore_state()
- pci_enable/disable_device()
- pci_set_power_state()
is handled by the PCI core.

This driver should implement only cafe_nand specific operations in its callback function for resume.

---
 drivers/mtd/nand/raw/cafe_nand.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/cafe_nand.c +5 -2
index 66385c4fb994..af771c379ec1 100644
@@ -837,9 +837,10 @@ static const struct pci_device_id cafe_nand_tbl[] = {
 
 MODULE_DEVICE_TABLE(pci, cafe_nand_tbl);
 
-static int cafe_nand_resume(struct pci_dev *pdev)
+static int cafe_nand_resume(struct device *dev)
 {
 	uint32_t ctrl;
+	struct pci_dev *pdev = to_pci_dev(dev);
 	struct mtd_info *mtd = pci_get_drvdata(pdev);
 	struct nand_chip *chip = mtd_to_nand(mtd);
 	struct cafe_priv *cafe = nand_get_controller_data(chip);
@@ -877,12 +878,14 @@ static int cafe_nand_resume(struct pci_dev *pdev)
 	return 0;
 }
 
+static DEFINE_SIMPLE_DEV_PM_OPS(cafe_nand_ops, NULL, cafe_nand_resume);
+
 static struct pci_driver cafe_nand_pci_driver = {
 	.name = "CAFÉ NAND",
 	.id_table = cafe_nand_tbl,
 	.probe = cafe_nand_probe,
 	.remove = cafe_nand_remove,
-	.resume = cafe_nand_resume,
+	.driver.pm = &cafe_nand_ops,
 };
 
 module_pci_driver(cafe_nand_pci_driver);
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw

Re: [PATCH v1] mtd: rawnand: cafe: Use generic power management'

Quoted 10 lines · Vaibhav Gupta

Switch to the generic PCI power management framework and remove legacy callbacks like .resume(). With the generic framework, the standard PCI related work like:
- pci_save/restore_state()
- pci_enable/disable_device()
- pci_set_power_state()
is handled by the PCI core.

This driver should implement only cafe_nand specific operations in its callback function for resume.

Looks good to me, thanks for doing this!

I think the commit log is a bit overly specific since this driver never did any of the PCI-related work it mentions. IMO something like this would be sufficient:

Switch from PCI power management to the generic power management framework so the pci_driver hooks can eventually be retired.

Quoted 40 lines
---
 drivers/mtd/nand/raw/cafe_nand.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/cafe_nand.c +5 -2
index 66385c4fb994..af771c379ec1 100644
@@ -837,9 +837,10 @@ static const struct pci_device_id cafe_nand_tbl[] = {
 
 MODULE_DEVICE_TABLE(pci, cafe_nand_tbl);
 
-static int cafe_nand_resume(struct pci_dev *pdev)
+static int cafe_nand_resume(struct device *dev)
 {
 	uint32_t ctrl;
+	struct pci_dev *pdev = to_pci_dev(dev);
 	struct mtd_info *mtd = pci_get_drvdata(pdev);
 	struct nand_chip *chip = mtd_to_nand(mtd);
 	struct cafe_priv *cafe = nand_get_controller_data(chip);
@@ -877,12 +878,14 @@ static int cafe_nand_resume(struct pci_dev *pdev)
 	return 0;
 }
 
+static DEFINE_SIMPLE_DEV_PM_OPS(cafe_nand_ops, NULL, cafe_nand_resume);
+
 static struct pci_driver cafe_nand_pci_driver = {
 	.name = "CAFÉ NAND",
 	.id_table = cafe_nand_tbl,
 	.probe = cafe_nand_probe,
 	.remove = cafe_nand_remove,
-	.resume = cafe_nand_resume,
+	.driver.pm = &cafe_nand_ops,
 };
 
 module_pci_driver(cafe_nand_pci_driver);
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH v1] mtd: rawnand: cafe: Use generic power management'

Quoted 14 lines · Bjorn Helgaas
Quoted 10 lines · Vaibhav Gupta

Switch to the generic PCI power management framework and remove legacy callbacks like .resume(). With the generic framework, the standard PCI related work like:
- pci_save/restore_state()
- pci_enable/disable_device()
- pci_set_power_state()
is handled by the PCI core.

This driver should implement only cafe_nand specific operations in its callback function for resume.

Looks good to me, thanks for doing this!

Quoted 9 lines

I think the commit log is a bit overly specific since this driver never did any of the PCI-related work it mentions. IMO something like this would be sufficient:

Switch from PCI power management to the generic power management framework so the pci_driver hooks can eventually be retired.

Hey Bjorn,

Thanks for the review. I will send a v2, and I will add your review tag there.

Thanks!

-- Vaibhav

Quoted 40 lines
Quoted 40 lines
---
 drivers/mtd/nand/raw/cafe_nand.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/cafe_nand.c +5 -2
index 66385c4fb994..af771c379ec1 100644
@@ -837,9 +837,10 @@ static const struct pci_device_id cafe_nand_tbl[] = {
 
 MODULE_DEVICE_TABLE(pci, cafe_nand_tbl);
 
-static int cafe_nand_resume(struct pci_dev *pdev)
+static int cafe_nand_resume(struct device *dev)
 {
 	uint32_t ctrl;
+	struct pci_dev *pdev = to_pci_dev(dev);
 	struct mtd_info *mtd = pci_get_drvdata(pdev);
 	struct nand_chip *chip = mtd_to_nand(mtd);
 	struct cafe_priv *cafe = nand_get_controller_data(chip);
@@ -877,12 +878,14 @@ static int cafe_nand_resume(struct pci_dev *pdev)
 	return 0;
 }
 
+static DEFINE_SIMPLE_DEV_PM_OPS(cafe_nand_ops, NULL, cafe_nand_resume);
+
 static struct pci_driver cafe_nand_pci_driver = {
 	.name = "CAFÉ NAND",
 	.id_table = cafe_nand_tbl,
 	.probe = cafe_nand_probe,
 	.remove = cafe_nand_remove,
-	.resume = cafe_nand_resume,
+	.driver.pm = &cafe_nand_ops,
 };
 
 module_pci_driver(cafe_nand_pci_driver);
Signature · 1 line
2.53.0
#3 lore raw

PATCH v2 1/1 mtd: rawnand: cafe: Use generic power management

In reply to Vaibhav Gupta

Switch from PCI power management to the generic power management framework so the pci_driver hooks can eventually be retired.

---

v2: Reformat the commit message as per the suggestion of Bjorn.

---
 drivers/mtd/nand/raw/cafe_nand.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/cafe_nand.c +5 -2
index 66385c4fb994..af771c379ec1 100644
@@ -837,9 +837,10 @@ static const struct pci_device_id cafe_nand_tbl[] = {
 
 MODULE_DEVICE_TABLE(pci, cafe_nand_tbl);
 
-static int cafe_nand_resume(struct pci_dev *pdev)
+static int cafe_nand_resume(struct device *dev)
 {
 	uint32_t ctrl;
+	struct pci_dev *pdev = to_pci_dev(dev);
 	struct mtd_info *mtd = pci_get_drvdata(pdev);
 	struct nand_chip *chip = mtd_to_nand(mtd);
 	struct cafe_priv *cafe = nand_get_controller_data(chip);
@@ -877,12 +878,14 @@ static int cafe_nand_resume(struct pci_dev *pdev)
 	return 0;
 }
 
+static DEFINE_SIMPLE_DEV_PM_OPS(cafe_nand_ops, NULL, cafe_nand_resume);
+
 static struct pci_driver cafe_nand_pci_driver = {
 	.name = "CAFÉ NAND",
 	.id_table = cafe_nand_tbl,
 	.probe = cafe_nand_probe,
 	.remove = cafe_nand_remove,
-	.resume = cafe_nand_resume,
+	.driver.pm = &cafe_nand_ops,
 };
 
 module_pci_driver(cafe_nand_pci_driver);
Signature · 1 line
2.53.0
maintainer Applied
#4 lore raw
Quoted 4 lines · Vaibhav Gupta

Switch from PCI power management to the generic power management framework so the pci_driver hooks can eventually be retired.

Applied to nand/next, thanks!

[1/1] mtd: rawnand: cafe: Use generic power management

      commit: d9a2a92b4209838c513f31eecc6c8bef4a107ab2

Patche(s) should be available on mtd/linux.git and will be part of the next PR (provided that no robot complains by then).

Kind regards,
Miquèl