Skip to contentSkip to conversation

lpc_ich: use devres API to allocate private data

PATCH Applied Aaron Sierra 2 participants 3 messages Feb 14, 2013 – Feb 15, 2013 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 774339a2-e7cc-4204-a935-0a1b59e2ece8@zimbra

#1 lore raw

PATCH 1/1 lpc_ich: use devres API to allocate private data

---
 drivers/mfd/lpc_ich.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/mfd/lpc_ich.c +2 -5
index a0cfdf9..1264b68 100644
@@ -878,7 +878,8 @@ static int lpc_ich_probe(struct pci_dev *dev,
 	int ret;
 	bool cell_added = false;
 
-	priv = kmalloc(GFP_KERNEL, sizeof(struct lpc_ich_priv));
+	priv = devm_kzalloc(&dev->dev,
+			    sizeof(struct lpc_ich_priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
@@ -914,7 +915,6 @@ static int lpc_ich_probe(struct pci_dev *dev,
 		dev_warn(&dev->dev, "No MFD cells added\n");
 		lpc_ich_restore_config_space(dev);
 		pci_set_drvdata(dev, NULL);
-		kfree(priv);
 		return -ENODEV;
 	}
 
@@ -923,12 +923,9 @@ static int lpc_ich_probe(struct pci_dev *dev,
 
 static void lpc_ich_remove(struct pci_dev *dev)
 {
-	void *priv = pci_get_drvdata(dev);
-
 	mfd_remove_devices(&dev->dev);
 	lpc_ich_restore_config_space(dev);
 	pci_set_drvdata(dev, NULL);
-	kfree(priv);
 }
 
 static struct pci_driver lpc_ich_driver = {
Signature · 1 line
1.7.9.5
#2 lore raw

----- Original Message -----

Quoted 9 lines

From: "Aaron Sierra" <[email protected]>
To: "Samuel Ortiz" <[email protected]>
Cc: "LKML" <[email protected]>
Sent: Thursday, February 14, 2013 11:35:04 AM
Subject: [PATCH] lpc_ich: use devres API to allocate private data

---

[trim]

drivers/mfd/lpc_ich.c static int lpc_ich_probe(struct pci_dev *dev, · line 882

Quoted 3 lines
drivers/mfd/lpc_ich.c +2 -1
-	priv = kmalloc(GFP_KERNEL, sizeof(struct lpc_ich_priv));
+	priv = devm_kzalloc(&dev->dev,
+			    sizeof(struct lpc_ich_priv), GFP_KERNEL);

Samuel,
Perhaps this should now include a comment about this patch also resolving the issue that Anatol reported yesterday?

-Aaron