diff options
Diffstat (limited to 'drivers/hwmon/ad7314.c')
| -rw-r--r-- | drivers/hwmon/ad7314.c | 24 | 
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/hwmon/ad7314.c b/drivers/hwmon/ad7314.c index cfec802cf9c..37c01e72d69 100644 --- a/drivers/hwmon/ad7314.c +++ b/drivers/hwmon/ad7314.c @@ -87,10 +87,18 @@ static ssize_t ad7314_show_temperature(struct device *dev,  	}  } +static ssize_t ad7314_show_name(struct device *dev, +				struct device_attribute *devattr, char *buf) +{ +	return sprintf(buf, "%s\n", to_spi_device(dev)->modalias); +} + +static DEVICE_ATTR(name, S_IRUGO, ad7314_show_name, NULL);  static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO,  			  ad7314_show_temperature, NULL, 0);  static struct attribute *ad7314_attributes[] = { +	&dev_attr_name.attr,  	&sensor_dev_attr_temp1_input.dev_attr.attr,  	NULL,  }; @@ -104,16 +112,16 @@ static int __devinit ad7314_probe(struct spi_device *spi_dev)  	int ret;  	struct ad7314_data *chip; -	chip = kzalloc(sizeof(*chip), GFP_KERNEL); -	if (chip == NULL) { -		ret = -ENOMEM; -		goto error_ret; -	} +	chip = devm_kzalloc(&spi_dev->dev, sizeof(*chip), GFP_KERNEL); +	if (chip == NULL) +		return -ENOMEM; +  	dev_set_drvdata(&spi_dev->dev, chip);  	ret = sysfs_create_group(&spi_dev->dev.kobj, &ad7314_group);  	if (ret < 0) -		goto error_free_chip; +		return ret; +  	chip->hwmon_dev = hwmon_device_register(&spi_dev->dev);  	if (IS_ERR(chip->hwmon_dev)) {  		ret = PTR_ERR(chip->hwmon_dev); @@ -124,9 +132,6 @@ static int __devinit ad7314_probe(struct spi_device *spi_dev)  	return 0;  error_remove_group:  	sysfs_remove_group(&spi_dev->dev.kobj, &ad7314_group); -error_free_chip: -	kfree(chip); -error_ret:  	return ret;  } @@ -136,7 +141,6 @@ static int __devexit ad7314_remove(struct spi_device *spi_dev)  	hwmon_device_unregister(chip->hwmon_dev);  	sysfs_remove_group(&spi_dev->dev.kobj, &ad7314_group); -	kfree(chip);  	return 0;  }  |