serial: max310x: Make use of device properties
[ Upstream commit c808fab604ca62cff19ee6b261211483830807aa ] Device property API allows to gather device resources from different sources, such as ACPI. Convert the drivers to unleash the power of device property API. Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20201007084635.594991-1-andy.shevchenko@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Stable-dep-of: b35f8dbbce81 ("serial: max310x: prevent infinite while() loop in port startup") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Sasha Levin

parent
c7e9e6d5ee
commit
32e32ab1da
@@ -15,8 +15,8 @@
|
|||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
#include <linux/gpio/driver.h>
|
#include <linux/gpio/driver.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of.h>
|
#include <linux/mod_devicetable.h>
|
||||||
#include <linux/of_device.h>
|
#include <linux/property.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
#include <linux/serial_core.h>
|
#include <linux/serial_core.h>
|
||||||
#include <linux/serial.h>
|
#include <linux/serial.h>
|
||||||
@@ -271,7 +271,7 @@ struct max310x_one {
|
|||||||
container_of(_port, struct max310x_one, port)
|
container_of(_port, struct max310x_one, port)
|
||||||
|
|
||||||
struct max310x_port {
|
struct max310x_port {
|
||||||
struct max310x_devtype *devtype;
|
const struct max310x_devtype *devtype;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
#ifdef CONFIG_GPIOLIB
|
#ifdef CONFIG_GPIOLIB
|
||||||
@@ -1262,7 +1262,7 @@ static int max310x_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int max310x_probe(struct device *dev, struct max310x_devtype *devtype,
|
static int max310x_probe(struct device *dev, const struct max310x_devtype *devtype,
|
||||||
struct regmap *regmap, int irq)
|
struct regmap *regmap, int irq)
|
||||||
{
|
{
|
||||||
int i, ret, fmin, fmax, freq;
|
int i, ret, fmin, fmax, freq;
|
||||||
@@ -1488,7 +1488,7 @@ static struct regmap_config regcfg = {
|
|||||||
#ifdef CONFIG_SPI_MASTER
|
#ifdef CONFIG_SPI_MASTER
|
||||||
static int max310x_spi_probe(struct spi_device *spi)
|
static int max310x_spi_probe(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
struct max310x_devtype *devtype;
|
const struct max310x_devtype *devtype;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -1500,18 +1500,9 @@ static int max310x_spi_probe(struct spi_device *spi)
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (spi->dev.of_node) {
|
devtype = device_get_match_data(&spi->dev);
|
||||||
const struct of_device_id *of_id =
|
if (!devtype)
|
||||||
of_match_device(max310x_dt_ids, &spi->dev);
|
devtype = (struct max310x_devtype *)spi_get_device_id(spi)->driver_data;
|
||||||
if (!of_id)
|
|
||||||
return -ENODEV;
|
|
||||||
|
|
||||||
devtype = (struct max310x_devtype *)of_id->data;
|
|
||||||
} else {
|
|
||||||
const struct spi_device_id *id_entry = spi_get_device_id(spi);
|
|
||||||
|
|
||||||
devtype = (struct max310x_devtype *)id_entry->driver_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
regcfg.max_register = devtype->nr * 0x20 - 1;
|
regcfg.max_register = devtype->nr * 0x20 - 1;
|
||||||
regmap = devm_regmap_init_spi(spi, ®cfg);
|
regmap = devm_regmap_init_spi(spi, ®cfg);
|
||||||
@@ -1536,7 +1527,7 @@ MODULE_DEVICE_TABLE(spi, max310x_id_table);
|
|||||||
static struct spi_driver max310x_spi_driver = {
|
static struct spi_driver max310x_spi_driver = {
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = MAX310X_NAME,
|
.name = MAX310X_NAME,
|
||||||
.of_match_table = of_match_ptr(max310x_dt_ids),
|
.of_match_table = max310x_dt_ids,
|
||||||
.pm = &max310x_pm_ops,
|
.pm = &max310x_pm_ops,
|
||||||
},
|
},
|
||||||
.probe = max310x_spi_probe,
|
.probe = max310x_spi_probe,
|
||||||
|
Reference in New Issue
Block a user