mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-27 03:30:53 +07:00
1baf665b81
In ancient times it was necessary to manually initialize the bus field of an spi_driver to spi_bus_type. These days this is done in spi_driver_register() so we can drop the manual assignment. The patch was generated using the following coccinelle semantic patch: // <smpl> @@ identifier _driver; @@ struct spi_driver _driver = { .driver = { - .bus = &spi_bus_type, }, }; // </smpl> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Cc: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
118 lines
2.5 KiB
C
118 lines
2.5 KiB
C
/*
|
|
* SPI access for Dialog DA9052 PMICs.
|
|
*
|
|
* Copyright(c) 2011 Dialog Semiconductor Ltd.
|
|
*
|
|
* Author: David Dajun Chen <dchen@diasemi.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
*/
|
|
|
|
#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 __devinit da9052_spi_probe(struct spi_device *spi)
|
|
{
|
|
int ret;
|
|
const struct spi_device_id *id = spi_get_device_id(spi);
|
|
struct da9052 *da9052 = kzalloc(sizeof(struct da9052), GFP_KERNEL);
|
|
|
|
if (!da9052)
|
|
return -ENOMEM;
|
|
|
|
spi->mode = SPI_MODE_0 | SPI_CPOL;
|
|
spi->bits_per_word = 8;
|
|
spi_setup(spi);
|
|
|
|
da9052->dev = &spi->dev;
|
|
da9052->chip_irq = spi->irq;
|
|
|
|
dev_set_drvdata(&spi->dev, da9052);
|
|
|
|
da9052_regmap_config.read_flag_mask = 1;
|
|
da9052_regmap_config.write_flag_mask = 0;
|
|
|
|
da9052->regmap = regmap_init_spi(spi, &da9052_regmap_config);
|
|
if (IS_ERR(da9052->regmap)) {
|
|
ret = PTR_ERR(da9052->regmap);
|
|
dev_err(&spi->dev, "Failed to allocate register map: %d\n",
|
|
ret);
|
|
goto err;
|
|
}
|
|
|
|
ret = da9052_device_init(da9052, id->driver_data);
|
|
if (ret != 0)
|
|
goto err_regmap;
|
|
|
|
return 0;
|
|
|
|
err_regmap:
|
|
regmap_exit(da9052->regmap);
|
|
err:
|
|
kfree(da9052);
|
|
return ret;
|
|
}
|
|
|
|
static int __devexit da9052_spi_remove(struct spi_device *spi)
|
|
{
|
|
struct da9052 *da9052 = dev_get_drvdata(&spi->dev);
|
|
|
|
da9052_device_exit(da9052);
|
|
regmap_exit(da9052->regmap);
|
|
kfree(da9052);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct spi_device_id da9052_spi_id[] = {
|
|
{"da9052", DA9052},
|
|
{"da9053-aa", DA9053_AA},
|
|
{"da9053-ba", DA9053_BA},
|
|
{"da9053-bb", DA9053_BB},
|
|
{}
|
|
};
|
|
|
|
static struct spi_driver da9052_spi_driver = {
|
|
.probe = da9052_spi_probe,
|
|
.remove = __devexit_p(da9052_spi_remove),
|
|
.id_table = da9052_spi_id,
|
|
.driver = {
|
|
.name = "da9052",
|
|
.owner = THIS_MODULE,
|
|
},
|
|
};
|
|
|
|
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");
|