提交 ad8ce834 编写于 作者: A Andy Shevchenko 提交者: Greg Kroah-Hartman

parport: Convert to use managed functions pcim_* and devm_*

This makes the error handling much more simpler than open-coding everything
and in addition makes the probe function smaller an tidier.
Tested-by: NNikola Ciprich <nikola.ciprich@linuxbox.cz>
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: NSudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 1089c911
...@@ -620,27 +620,23 @@ static int parport_serial_pci_probe(struct pci_dev *dev, ...@@ -620,27 +620,23 @@ static int parport_serial_pci_probe(struct pci_dev *dev,
struct parport_serial_private *priv; struct parport_serial_private *priv;
int err; int err;
priv = kzalloc (sizeof *priv, GFP_KERNEL); priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
pci_set_drvdata (dev, priv); pci_set_drvdata (dev, priv);
err = pci_enable_device (dev); err = pcim_enable_device(dev);
if (err) { if (err)
kfree (priv);
return err; return err;
}
if (parport_register (dev, id)) { if (parport_register(dev, id))
kfree (priv);
return -ENODEV; return -ENODEV;
}
if (serial_register (dev, id)) { if (serial_register (dev, id)) {
int i; int i;
for (i = 0; i < priv->num_par; i++) for (i = 0; i < priv->num_par; i++)
parport_pc_unregister_port (priv->port[i]); parport_pc_unregister_port (priv->port[i]);
kfree (priv);
return -ENODEV; return -ENODEV;
} }
...@@ -660,7 +656,6 @@ static void parport_serial_pci_remove(struct pci_dev *dev) ...@@ -660,7 +656,6 @@ static void parport_serial_pci_remove(struct pci_dev *dev)
for (i = 0; i < priv->num_par; i++) for (i = 0; i < priv->num_par; i++)
parport_pc_unregister_port (priv->port[i]); parport_pc_unregister_port (priv->port[i]);
kfree (priv);
return; return;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册