i2c: i801: Use managed devm_* memory and irq allocation
This simplifies the error and remove paths. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
This commit is contained in:
parent
256493c586
commit
1621c59d94
1 changed files with 6 additions and 11 deletions
|
@ -1138,7 +1138,7 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||||
int err, i;
|
int err, i;
|
||||||
struct i801_priv *priv;
|
struct i801_priv *priv;
|
||||||
|
|
||||||
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
|
priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL);
|
||||||
if (!priv)
|
if (!priv)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -1253,8 +1253,9 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||||
if (priv->features & FEATURE_IRQ) {
|
if (priv->features & FEATURE_IRQ) {
|
||||||
init_waitqueue_head(&priv->waitq);
|
init_waitqueue_head(&priv->waitq);
|
||||||
|
|
||||||
err = request_irq(dev->irq, i801_isr, IRQF_SHARED,
|
err = devm_request_irq(&dev->dev, dev->irq, i801_isr,
|
||||||
dev_driver_string(&dev->dev), priv);
|
IRQF_SHARED,
|
||||||
|
dev_driver_string(&dev->dev), priv);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(&dev->dev, "Failed to allocate irq %d: %d\n",
|
dev_err(&dev->dev, "Failed to allocate irq %d: %d\n",
|
||||||
dev->irq, err);
|
dev->irq, err);
|
||||||
|
@ -1275,7 +1276,7 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||||
err = i2c_add_adapter(&priv->adapter);
|
err = i2c_add_adapter(&priv->adapter);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(&dev->dev, "Failed to add SMBus adapter\n");
|
dev_err(&dev->dev, "Failed to add SMBus adapter\n");
|
||||||
goto exit_free_irq;
|
goto exit_release;
|
||||||
}
|
}
|
||||||
|
|
||||||
i801_probe_optional_slaves(priv);
|
i801_probe_optional_slaves(priv);
|
||||||
|
@ -1286,12 +1287,9 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
exit_free_irq:
|
exit_release:
|
||||||
if (priv->features & FEATURE_IRQ)
|
|
||||||
free_irq(dev->irq, priv);
|
|
||||||
pci_release_region(dev, SMBBAR);
|
pci_release_region(dev, SMBBAR);
|
||||||
exit:
|
exit:
|
||||||
kfree(priv);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1303,11 +1301,8 @@ static void i801_remove(struct pci_dev *dev)
|
||||||
i2c_del_adapter(&priv->adapter);
|
i2c_del_adapter(&priv->adapter);
|
||||||
pci_write_config_byte(dev, SMBHSTCFG, priv->original_hstcfg);
|
pci_write_config_byte(dev, SMBHSTCFG, priv->original_hstcfg);
|
||||||
|
|
||||||
if (priv->features & FEATURE_IRQ)
|
|
||||||
free_irq(dev->irq, priv);
|
|
||||||
pci_release_region(dev, SMBBAR);
|
pci_release_region(dev, SMBBAR);
|
||||||
|
|
||||||
kfree(priv);
|
|
||||||
/*
|
/*
|
||||||
* do not call pci_disable_device(dev) since it can cause hard hangs on
|
* do not call pci_disable_device(dev) since it can cause hard hangs on
|
||||||
* some systems during power-off (eg. Fujitsu-Siemens Lifebook E8010)
|
* some systems during power-off (eg. Fujitsu-Siemens Lifebook E8010)
|
||||||
|
|
Loading…
Add table
Reference in a new issue