forked from luck/tmp_suning_uos_patched
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;
|
||||
}
|
||||
|
||||
edev = kzalloc(sizeof(*edev), GFP_KERNEL);
|
||||
edev = devm_kzalloc(&spi->dev, sizeof(*edev), GFP_KERNEL);
|
||||
if (!edev)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -449,8 +449,7 @@ static int eeprom_93xx46_probe(struct spi_device *spi)
|
|||
edev->addrlen = 6;
|
||||
else {
|
||||
dev_err(&spi->dev, "unspecified address type\n");
|
||||
err = -EINVAL;
|
||||
goto fail;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
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.size = edev->size;
|
||||
|
||||
edev->nvmem = nvmem_register(&edev->nvmem_config);
|
||||
if (IS_ERR(edev->nvmem)) {
|
||||
err = PTR_ERR(edev->nvmem);
|
||||
goto fail;
|
||||
}
|
||||
edev->nvmem = devm_nvmem_register(&spi->dev, &edev->nvmem_config);
|
||||
if (IS_ERR(edev->nvmem))
|
||||
return PTR_ERR(edev->nvmem);
|
||||
|
||||
dev_info(&spi->dev, "%d-bit eeprom %s\n",
|
||||
(pd->flags & EE_ADDR8) ? 8 : 16,
|
||||
|
@ -490,21 +487,15 @@ static int eeprom_93xx46_probe(struct spi_device *spi)
|
|||
|
||||
spi_set_drvdata(spi, edev);
|
||||
return 0;
|
||||
fail:
|
||||
kfree(edev);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int eeprom_93xx46_remove(struct spi_device *spi)
|
||||
{
|
||||
struct eeprom_93xx46_dev *edev = spi_get_drvdata(spi);
|
||||
|
||||
nvmem_unregister(edev->nvmem);
|
||||
|
||||
if (!(edev->pdata->flags & EE_READONLY))
|
||||
device_remove_file(&spi->dev, &dev_attr_erase);
|
||||
|
||||
kfree(edev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user