mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 01:10:04 +00:00
![Uwe Kleine-König](/assets/img/avatar_default.png)
The value returned by an spi driver's remove function is mostly ignored. (Only an error message is printed if the value is non-zero that the error is ignored.) So change the prototype of the remove function to return no value. This way driver authors are not tempted to assume that passing an error to the upper layer is a good idea. All drivers are adapted accordingly. There is no intended change of behaviour, all callbacks were prepared to return 0 before. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Jérôme Pouiller <jerome.pouiller@silabs.com> Acked-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Acked-by: Claudius Heine <ch@denx.de> Acked-by: Stefan Schmidt <stefan@datenfreihafen.org> Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Acked-by: Ulf Hansson <ulf.hansson@linaro.org> # For MMC Acked-by: Marcus Folkesson <marcus.folkesson@gmail.com> Acked-by: Łukasz Stelmach <l.stelmach@samsung.com> Acked-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20220123175201.34839-6-u.kleine-koenig@pengutronix.de Signed-off-by: Mark Brown <broonie@kernel.org>
105 lines
2.2 KiB
C
105 lines
2.2 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* SPI access for Dialog DA9052 PMICs.
|
|
*
|
|
* Copyright(c) 2011 Dialog Semiconductor Ltd.
|
|
*
|
|
* Author: David Dajun Chen <dchen@diasemi.com>
|
|
*/
|
|
|
|
#include <linux/device.h>
|
|
#include <linux/module.h>
|
|
#include <linux/input.h>
|
|
#include <linux/mfd/core.h>
|
|
#include <linux/spi/spi.h>
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/mfd/da9052/da9052.h>
|
|
|
|
static int da9052_spi_probe(struct spi_device *spi)
|
|
{
|
|
struct regmap_config config;
|
|
int ret;
|
|
const struct spi_device_id *id = spi_get_device_id(spi);
|
|
struct da9052 *da9052;
|
|
|
|
da9052 = devm_kzalloc(&spi->dev, sizeof(struct da9052), GFP_KERNEL);
|
|
if (!da9052)
|
|
return -ENOMEM;
|
|
|
|
spi->mode = SPI_MODE_0;
|
|
spi->bits_per_word = 8;
|
|
spi_setup(spi);
|
|
|
|
da9052->dev = &spi->dev;
|
|
da9052->chip_irq = spi->irq;
|
|
|
|
spi_set_drvdata(spi, da9052);
|
|
|
|
config = da9052_regmap_config;
|
|
config.read_flag_mask = 1;
|
|
config.reg_bits = 7;
|
|
config.pad_bits = 1;
|
|
config.val_bits = 8;
|
|
config.use_single_read = true;
|
|
config.use_single_write = true;
|
|
|
|
da9052->regmap = devm_regmap_init_spi(spi, &config);
|
|
if (IS_ERR(da9052->regmap)) {
|
|
ret = PTR_ERR(da9052->regmap);
|
|
dev_err(&spi->dev, "Failed to allocate register map: %d\n",
|
|
ret);
|
|
return ret;
|
|
}
|
|
|
|
return da9052_device_init(da9052, id->driver_data);
|
|
}
|
|
|
|
static void da9052_spi_remove(struct spi_device *spi)
|
|
{
|
|
struct da9052 *da9052 = spi_get_drvdata(spi);
|
|
|
|
da9052_device_exit(da9052);
|
|
}
|
|
|
|
static const struct spi_device_id da9052_spi_id[] = {
|
|
{"da9052", DA9052},
|
|
{"da9053-aa", DA9053_AA},
|
|
{"da9053-ba", DA9053_BA},
|
|
{"da9053-bb", DA9053_BB},
|
|
{"da9053-bc", DA9053_BC},
|
|
{}
|
|
};
|
|
|
|
static struct spi_driver da9052_spi_driver = {
|
|
.probe = da9052_spi_probe,
|
|
.remove = da9052_spi_remove,
|
|
.id_table = da9052_spi_id,
|
|
.driver = {
|
|
.name = "da9052",
|
|
},
|
|
};
|
|
|
|
static int __init da9052_spi_init(void)
|
|
{
|
|
int ret;
|
|
|
|
ret = spi_register_driver(&da9052_spi_driver);
|
|
if (ret != 0) {
|
|
pr_err("Failed to register DA9052 SPI driver, %d\n", ret);
|
|
return ret;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
subsys_initcall(da9052_spi_init);
|
|
|
|
static void __exit da9052_spi_exit(void)
|
|
{
|
|
spi_unregister_driver(&da9052_spi_driver);
|
|
}
|
|
module_exit(da9052_spi_exit);
|
|
|
|
MODULE_AUTHOR("David Dajun Chen <dchen@diasemi.com>");
|
|
MODULE_DESCRIPTION("SPI driver for Dialog DA9052 PMIC");
|
|
MODULE_LICENSE("GPL");
|