diff options
Diffstat (limited to 'drivers/media/rc/ir-spi.c')
-rw-r--r-- | drivers/media/rc/ir-spi.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/drivers/media/rc/ir-spi.c b/drivers/media/rc/ir-spi.c index bbc81bed4f..8fc8e496e6 100644 --- a/drivers/media/rc/ir-spi.c +++ b/drivers/media/rc/ir-spi.c @@ -4,13 +4,18 @@ // Copyright (c) 2016 Samsung Electronics Co., Ltd. // Copyright (c) Andi Shyti <andi@etezian.org> -#include <linux/delay.h> -#include <linux/fs.h> +#include <linux/bits.h> +#include <linux/device.h> +#include <linux/err.h> +#include <linux/math.h> +#include <linux/mod_devicetable.h> #include <linux/module.h> -#include <linux/mutex.h> -#include <linux/of_gpio.h> +#include <linux/property.h> #include <linux/regulator/consumer.h> #include <linux/spi/spi.h> +#include <linux/string.h> +#include <linux/types.h> + #include <media/rc-core.h> #define IR_SPI_DRIVER_NAME "ir-spi" @@ -31,8 +36,7 @@ struct ir_spi_data { struct regulator *regulator; }; -static int ir_spi_tx(struct rc_dev *dev, - unsigned int *buffer, unsigned int count) +static int ir_spi_tx(struct rc_dev *dev, unsigned int *buffer, unsigned int count) { int i; int ret; @@ -52,7 +56,7 @@ static int ir_spi_tx(struct rc_dev *dev, return -EINVAL; /* - * the first value in buffer is a pulse, so that 0, 2, 4, ... + * The first value in buffer is a pulse, so that 0, 2, 4, ... * contain a pulse duration. On the contrary, 1, 3, 5, ... * contain a space duration. */ @@ -111,15 +115,16 @@ static int ir_spi_set_duty_cycle(struct rc_dev *dev, u32 duty_cycle) static int ir_spi_probe(struct spi_device *spi) { + struct device *dev = &spi->dev; int ret; u8 dc; struct ir_spi_data *idata; - idata = devm_kzalloc(&spi->dev, sizeof(*idata), GFP_KERNEL); + idata = devm_kzalloc(dev, sizeof(*idata), GFP_KERNEL); if (!idata) return -ENOMEM; - idata->regulator = devm_regulator_get(&spi->dev, "irda_regulator"); + idata->regulator = devm_regulator_get(dev, "irda_regulator"); if (IS_ERR(idata->regulator)) return PTR_ERR(idata->regulator); @@ -135,32 +140,31 @@ static int ir_spi_probe(struct spi_device *spi) idata->rc->priv = idata; idata->spi = spi; - idata->negated = of_property_read_bool(spi->dev.of_node, - "led-active-low"); - ret = of_property_read_u8(spi->dev.of_node, "duty-cycle", &dc); + idata->negated = device_property_read_bool(dev, "led-active-low"); + ret = device_property_read_u8(dev, "duty-cycle", &dc); if (ret) dc = 50; - /* ir_spi_set_duty_cycle cannot fail, - * it returns int to be compatible with the - * rc->s_tx_duty_cycle function + /* + * ir_spi_set_duty_cycle() cannot fail, it returns int + * to be compatible with the rc->s_tx_duty_cycle function. */ ir_spi_set_duty_cycle(idata->rc, dc); idata->freq = IR_SPI_DEFAULT_FREQUENCY; - return devm_rc_register_device(&spi->dev, idata->rc); + return devm_rc_register_device(dev, idata->rc); } static const struct of_device_id ir_spi_of_match[] = { { .compatible = "ir-spi-led" }, - {}, + {} }; MODULE_DEVICE_TABLE(of, ir_spi_of_match); static const struct spi_device_id ir_spi_ids[] = { { "ir-spi-led" }, - {}, + {} }; MODULE_DEVICE_TABLE(spi, ir_spi_ids); @@ -172,7 +176,6 @@ static struct spi_driver ir_spi_driver = { .of_match_table = ir_spi_of_match, }, }; - module_spi_driver(ir_spi_driver); MODULE_AUTHOR("Andi Shyti <andi@etezian.org>"); |