Skip to contentSkip to conversation

mei: simplify error handling via devres function.

PATCH In review Tomas Winkler 3 participants 3 messages Jan 26, 2017 – Jan 27, 2017

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

PATCH v3 1/1 mei: simplify error handling via devres function.

Use devm_ and pcim_ functions to make error handling simpler and code smaller and tidier.

Based on original patch by
mei: me: use managed functions pcim_* and devm_*
https://lkml.org/lkml/2016/2/1/339

---
V2: Thanks Andy for review, integratd changes:
1. Rename devm_mei_me_init back to mei_me_dev_init they don't really belong to devm_ namespace.
2. Revert pcim irq reservation change.
3. Drop setting driver data to NULL on exit.
4. Use directly mmio pointer received from pcim_iomap_table
V3: Remove pci_disable_msi, it is also handled by the system.

 drivers/misc/mei/hw-me.c   |  6 ++--
 drivers/misc/mei/hw-txe.c  |  4 +--
 drivers/misc/mei/hw-txe.h  |  2 +-
 drivers/misc/mei/pci-me.c  | 50 +++++++--------------------------
 drivers/misc/mei/pci-txe.c | 69 +++++++---------------------------------------
 5 files changed, 26 insertions(+), 105 deletions(-)
drivers/misc/mei/hw-me.c +3 -3
index a05375a3338a..14b8cf2d3cf0 100644
@@ -1389,7 +1389,7 @@ const struct mei_cfg mei_me_pch8_sps_cfg = {
  * @pdev: The pci device structure
  * @cfg: per device generation config
  *
- * Return: The mei_device_device pointer on success, NULL on failure.
+ * Return: The mei_device pointer on success, NULL on failure.
  */
 struct mei_device *mei_me_dev_init(struct pci_dev *pdev,
 				   const struct mei_cfg *cfg)
@@ -1397,8 +1397,8 @@ struct mei_device *mei_me_dev_init(struct pci_dev *pdev,
 	struct mei_device *dev;
 	struct mei_me_hw *hw;
 
-	dev = kzalloc(sizeof(struct mei_device) +
-			 sizeof(struct mei_me_hw), GFP_KERNEL);
+	dev = devm_kzalloc(&pdev->dev, sizeof(struct mei_device) +
+			   sizeof(struct mei_me_hw), GFP_KERNEL);
 	if (!dev)
 		return NULL;
 	hw = to_me_hw(dev);
drivers/misc/mei/hw-txe.c +2 -2
index e9f8c0aeec13..b973b9fca98b 100644
@@ -1207,8 +1207,8 @@ struct mei_device *mei_txe_dev_init(struct pci_dev *pdev)
 	struct mei_device *dev;
 	struct mei_txe_hw *hw;
 
-	dev = kzalloc(sizeof(struct mei_device) +
-			 sizeof(struct mei_txe_hw), GFP_KERNEL);
+	dev = devm_kzalloc(&pdev->dev, sizeof(struct mei_device) +
+			   sizeof(struct mei_txe_hw), GFP_KERNEL);
 	if (!dev)
 		return NULL;
 
drivers/misc/mei/hw-txe.h +1 -1
index ce3ed0b88b0c..e1e8b66d7648 100644
@@ -45,7 +45,7 @@
  * @intr_cause:          translated interrupt cause
  */
 struct mei_txe_hw {
-	void __iomem *mem_addr[NUM_OF_MEM_BARS];
+	void __iomem * const *mem_addr;
 	u32 aliveness;
 	u32 readiness;
 	u32 slots;
drivers/misc/mei/pci-me.c +10 -40

114 lines not on this page · raw message

drivers/misc/mei/pci-txe.c +10 -59

144 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw
Quoted 10 lines · Tomas Winkler

Use devm_ and pcim_ functions to make error handling simpler and code smaller and tidier.

Based on original patch by
mei: me: use managed functions pcim_* and devm_*
https://lkml.org/lkml/2016/2/1/339

Quoted 8 lines

---
V2: Thanks Andy for review, integratd changes:
1. Rename devm_mei_me_init back to mei_me_dev_init they don't really belong to devm_ namespace.
2. Revert pcim irq reservation change.
3. Drop setting driver data to NULL on exit.
4. Use directly mmio pointer received from pcim_iomap_table
V3: Remove pci_disable_msi, it is also handled by the system.

Andy, any objection to this version?

thanks,

greg k-h

#2 lore raw
Quoted 20 lines · Greg Kroah-Hartman
Quoted 10 lines · Tomas Winkler

Use devm_ and pcim_ functions to make error handling simpler and code smaller and tidier.

Based on original patch by
mei: me: use managed functions pcim_* and devm_*
https://lkml.org/lkml/2016/2/1/339

Quoted 8 lines

---
V2: Thanks Andy for review, integratd changes:
    1. Rename devm_mei_me_init back to mei_me_dev_init they don't really belong to devm_ namespace.
    2. Revert pcim irq reservation change.
    3. Drop setting driver data to NULL on exit.
    4. Use directly mmio pointer received from pcim_iomap_table
V3: Remove pci_disable_msi, it is also handled by the system.

Quoted 1 line

Andy, any objection to this version?

Nope, this looks exactly how I would put it!
Thanks!

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy