diff options
Diffstat (limited to 'drivers/misc/ti_dac7512.c')
| -rw-r--r-- | drivers/misc/ti_dac7512.c | 49 | 
1 files changed, 26 insertions, 23 deletions
diff --git a/drivers/misc/ti_dac7512.c b/drivers/misc/ti_dac7512.c index d3f229a3a77..cb0289b44a1 100644 --- a/drivers/misc/ti_dac7512.c +++ b/drivers/misc/ti_dac7512.c @@ -20,11 +20,8 @@   */  #include <linux/module.h> -#include <linux/init.h>  #include <linux/spi/spi.h> - -#define DAC7512_DRV_NAME	"dac7512" -#define DRIVER_VERSION		"1.0" +#include <linux/of.h>  static ssize_t dac7512_store_val(struct device *dev,  				 struct device_attribute *attr, @@ -33,9 +30,11 @@ static ssize_t dac7512_store_val(struct device *dev,  	struct spi_device *spi = to_spi_device(dev);  	unsigned char tmp[2];  	unsigned long val; +	int ret; -	if (strict_strtoul(buf, 10, &val) < 0) -		return -EINVAL; +	ret = kstrtoul(buf, 10, &val); +	if (ret) +		return ret;  	tmp[0] = val >> 8;  	tmp[1] = val & 0xff; @@ -54,7 +53,7 @@ static const struct attribute_group dac7512_attr_group = {  	.attrs = dac7512_attributes,  }; -static int __devinit dac7512_probe(struct spi_device *spi) +static int dac7512_probe(struct spi_device *spi)  {  	int ret; @@ -67,35 +66,39 @@ static int __devinit dac7512_probe(struct spi_device *spi)  	return sysfs_create_group(&spi->dev.kobj, &dac7512_attr_group);  } -static int __devexit dac7512_remove(struct spi_device *spi) +static int dac7512_remove(struct spi_device *spi)  {  	sysfs_remove_group(&spi->dev.kobj, &dac7512_attr_group);  	return 0;  } +static const struct spi_device_id dac7512_id_table[] = { +	{ "dac7512", 0 }, +	{ } +}; +MODULE_DEVICE_TABLE(spi, dac7512_id_table); + +#ifdef CONFIG_OF +static const struct of_device_id dac7512_of_match[] = { +	{ .compatible = "ti,dac7512", }, +	{ } +}; +MODULE_DEVICE_TABLE(of, dac7512_of_match); +#endif +  static struct spi_driver dac7512_driver = {  	.driver = { -		.name	= DAC7512_DRV_NAME, +		.name	= "dac7512",  		.owner	= THIS_MODULE, +		.of_match_table = of_match_ptr(dac7512_of_match),  	},  	.probe	= dac7512_probe, -	.remove	= __devexit_p(dac7512_remove), +	.remove	= dac7512_remove, +	.id_table = dac7512_id_table,  }; -static int __init dac7512_init(void) -{ -	return spi_register_driver(&dac7512_driver); -} - -static void __exit dac7512_exit(void) -{ -	spi_unregister_driver(&dac7512_driver); -} +module_spi_driver(dac7512_driver);  MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");  MODULE_DESCRIPTION("DAC7512 16-bit DAC");  MODULE_LICENSE("GPL v2"); -MODULE_VERSION(DRIVER_VERSION); - -module_init(dac7512_init); -module_exit(dac7512_exit);  | 
