mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 20:51:44 +00:00
eeprom: eeprom_93xx46: use resource management
Use resource managed variants of nvmem_register() and kzalloc(). Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
3790e28cdb
commit
c853d6904f
@ -439,7 +439,7 @@ static int eeprom_93xx46_probe(struct spi_device *spi)
|
|||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
edev = kzalloc(sizeof(*edev), GFP_KERNEL);
|
edev = devm_kzalloc(&spi->dev, sizeof(*edev), GFP_KERNEL);
|
||||||
if (!edev)
|
if (!edev)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@ -449,8 +449,7 @@ static int eeprom_93xx46_probe(struct spi_device *spi)
|
|||||||
edev->addrlen = 6;
|
edev->addrlen = 6;
|
||||||
else {
|
else {
|
||||||
dev_err(&spi->dev, "unspecified address type\n");
|
dev_err(&spi->dev, "unspecified address type\n");
|
||||||
err = -EINVAL;
|
return -EINVAL;
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_init(&edev->lock);
|
mutex_init(&edev->lock);
|
||||||
@ -473,11 +472,9 @@ static int eeprom_93xx46_probe(struct spi_device *spi)
|
|||||||
edev->nvmem_config.word_size = 1;
|
edev->nvmem_config.word_size = 1;
|
||||||
edev->nvmem_config.size = edev->size;
|
edev->nvmem_config.size = edev->size;
|
||||||
|
|
||||||
edev->nvmem = nvmem_register(&edev->nvmem_config);
|
edev->nvmem = devm_nvmem_register(&spi->dev, &edev->nvmem_config);
|
||||||
if (IS_ERR(edev->nvmem)) {
|
if (IS_ERR(edev->nvmem))
|
||||||
err = PTR_ERR(edev->nvmem);
|
return PTR_ERR(edev->nvmem);
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev_info(&spi->dev, "%d-bit eeprom %s\n",
|
dev_info(&spi->dev, "%d-bit eeprom %s\n",
|
||||||
(pd->flags & EE_ADDR8) ? 8 : 16,
|
(pd->flags & EE_ADDR8) ? 8 : 16,
|
||||||
@ -490,21 +487,15 @@ static int eeprom_93xx46_probe(struct spi_device *spi)
|
|||||||
|
|
||||||
spi_set_drvdata(spi, edev);
|
spi_set_drvdata(spi, edev);
|
||||||
return 0;
|
return 0;
|
||||||
fail:
|
|
||||||
kfree(edev);
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int eeprom_93xx46_remove(struct spi_device *spi)
|
static int eeprom_93xx46_remove(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
struct eeprom_93xx46_dev *edev = spi_get_drvdata(spi);
|
struct eeprom_93xx46_dev *edev = spi_get_drvdata(spi);
|
||||||
|
|
||||||
nvmem_unregister(edev->nvmem);
|
|
||||||
|
|
||||||
if (!(edev->pdata->flags & EE_READONLY))
|
if (!(edev->pdata->flags & EE_READONLY))
|
||||||
device_remove_file(&spi->dev, &dev_attr_erase);
|
device_remove_file(&spi->dev, &dev_attr_erase);
|
||||||
|
|
||||||
kfree(edev);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user