diff options
Diffstat (limited to 'drivers/hwmon/smsc47b397.c')
| -rw-r--r-- | drivers/hwmon/smsc47b397.c | 124 | 
1 files changed, 61 insertions, 63 deletions
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index f46d936c12d..bd89e87bd6a 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c @@ -1,30 +1,32 @@  /* -    smsc47b397.c - Part of lm_sensors, Linux kernel modules -			for hardware monitoring - -    Supports the SMSC LPC47B397-NC Super-I/O chip. - -    Author/Maintainer: Mark M. Hoffman <mhoffman@lightlink.com> -	Copyright (C) 2004 Utilitek Systems, Inc. - -    derived in part from smsc47m1.c: -	Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> -	Copyright (C) 2004 Jean Delvare <khali@linux-fr.org> - -    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. - -    This program is distributed in the hope that it will be useful, -    but WITHOUT ANY WARRANTY; without even the implied warranty of -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -    GNU General Public License for more details. - -    You should have received a copy of the GNU General Public License -    along with this program; if not, write to the Free Software -    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + * smsc47b397.c - Part of lm_sensors, Linux kernel modules + * for hardware monitoring + * + * Supports the SMSC LPC47B397-NC Super-I/O chip. + * + * Author/Maintainer: Mark M. Hoffman <mhoffman@lightlink.com> + * Copyright (C) 2004 Utilitek Systems, Inc. + * + * derived in part from smsc47m1.c: + * Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> + * Copyright (C) 2004 Jean Delvare <jdelvare@suse.de> + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt  #include <linux/module.h>  #include <linux/slab.h> @@ -111,7 +113,7 @@ struct smsc47b397_data {  	u8 temp[4];  }; -static int smsc47b397_read_value(struct smsc47b397_data* data, u8 reg) +static int smsc47b397_read_value(struct smsc47b397_data *data, u8 reg)  {  	int res; @@ -155,8 +157,10 @@ static struct smsc47b397_data *smsc47b397_update_device(struct device *dev)  	return data;  } -/* TEMP: 0.001C/bit (-128C to +127C) -   REG: 1C/bit, two's complement */ +/* + * TEMP: 0.001C/bit (-128C to +127C) + * REG: 1C/bit, two's complement + */  static int temp_from_reg(u8 reg)  {  	return (s8)reg * 1000; @@ -175,8 +179,10 @@ static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1);  static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2);  static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3); -/* FAN: 1 RPM/bit -   REG: count of 90kHz pulses / revolution */ +/* + * FAN: 1 RPM/bit + * REG: count of 90kHz pulses / revolution + */  static int fan_from_reg(u16 reg)  {  	if (reg == 0 || reg == 0xffff) @@ -222,16 +228,12 @@ static const struct attribute_group smsc47b397_group = {  	.attrs = smsc47b397_attributes,  }; -static int __devexit smsc47b397_remove(struct platform_device *pdev) +static int smsc47b397_remove(struct platform_device *pdev)  {  	struct smsc47b397_data *data = platform_get_drvdata(pdev); -	struct resource *res;  	hwmon_device_unregister(data->hwmon_dev);  	sysfs_remove_group(&pdev->dev.kobj, &smsc47b397_group); -	res = platform_get_resource(pdev, IORESOURCE_IO, 0); -	release_region(res->start, SMSC_EXTENT); -	kfree(data);  	return 0;  } @@ -244,10 +246,10 @@ static struct platform_driver smsc47b397_driver = {  		.name	= DRVNAME,  	},  	.probe		= smsc47b397_probe, -	.remove		= __devexit_p(smsc47b397_remove), +	.remove		= smsc47b397_remove,  }; -static int __devinit smsc47b397_probe(struct platform_device *pdev) +static int smsc47b397_probe(struct platform_device *pdev)  {  	struct device *dev = &pdev->dev;  	struct smsc47b397_data *data; @@ -255,18 +257,17 @@ static int __devinit smsc47b397_probe(struct platform_device *pdev)  	int err = 0;  	res = platform_get_resource(pdev, IORESOURCE_IO, 0); -	if (!request_region(res->start, SMSC_EXTENT, -			    smsc47b397_driver.driver.name)) { +	if (!devm_request_region(dev, res->start, SMSC_EXTENT, +				 smsc47b397_driver.driver.name)) {  		dev_err(dev, "Region 0x%lx-0x%lx already in use!\n",  			(unsigned long)res->start,  			(unsigned long)res->start + SMSC_EXTENT - 1);  		return -EBUSY;  	} -	if (!(data = kzalloc(sizeof(struct smsc47b397_data), GFP_KERNEL))) { -		err = -ENOMEM; -		goto error_release; -	} +	data = devm_kzalloc(dev, sizeof(struct smsc47b397_data), GFP_KERNEL); +	if (!data) +		return -ENOMEM;  	data->addr = res->start;  	data->name = "smsc47b397"; @@ -274,8 +275,9 @@ static int __devinit smsc47b397_probe(struct platform_device *pdev)  	mutex_init(&data->update_lock);  	platform_set_drvdata(pdev, data); -	if ((err = sysfs_create_group(&dev->kobj, &smsc47b397_group))) -		goto error_free; +	err = sysfs_create_group(&dev->kobj, &smsc47b397_group); +	if (err) +		return err;  	data->hwmon_dev = hwmon_device_register(dev);  	if (IS_ERR(data->hwmon_dev)) { @@ -287,10 +289,6 @@ static int __devinit smsc47b397_probe(struct platform_device *pdev)  error_remove:  	sysfs_remove_group(&dev->kobj, &smsc47b397_group); -error_free: -	kfree(data); -error_release: -	release_region(res->start, SMSC_EXTENT);  	return err;  } @@ -311,21 +309,19 @@ static int __init smsc47b397_device_add(unsigned short address)  	pdev = platform_device_alloc(DRVNAME, address);  	if (!pdev) {  		err = -ENOMEM; -		printk(KERN_ERR DRVNAME ": Device allocation failed\n"); +		pr_err("Device allocation failed\n");  		goto exit;  	}  	err = platform_device_add_resources(pdev, &res, 1);  	if (err) { -		printk(KERN_ERR DRVNAME ": Device resource addition failed " -		       "(%d)\n", err); +		pr_err("Device resource addition failed (%d)\n", err);  		goto exit_device_put;  	}  	err = platform_device_add(pdev);  	if (err) { -		printk(KERN_ERR DRVNAME ": Device addition failed (%d)\n", -		       err); +		pr_err("Device addition failed (%d)\n", err);  		goto exit_device_put;  	} @@ -337,15 +333,16 @@ exit:  	return err;  } -static int __init smsc47b397_find(unsigned short *addr) +static int __init smsc47b397_find(void)  {  	u8 id, rev;  	char *name; +	unsigned short addr;  	superio_enter();  	id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID); -	switch(id) { +	switch (id) {  	case 0x81:  		name = "SCH5307-NS";  		break; @@ -364,15 +361,14 @@ static int __init smsc47b397_find(unsigned short *addr)  	rev = superio_inb(SUPERIO_REG_DEVREV);  	superio_select(SUPERIO_REG_LD8); -	*addr = (superio_inb(SUPERIO_REG_BASE_MSB) << 8) +	addr = (superio_inb(SUPERIO_REG_BASE_MSB) << 8)  		 |  superio_inb(SUPERIO_REG_BASE_LSB); -	printk(KERN_INFO DRVNAME ": found SMSC %s " -		"(base address 0x%04x, revision %u)\n", -		name, *addr, rev); +	pr_info("found SMSC %s (base address 0x%04x, revision %u)\n", +		name, addr, rev);  	superio_exit(); -	return 0; +	return addr;  }  static int __init smsc47b397_init(void) @@ -380,8 +376,10 @@ static int __init smsc47b397_init(void)  	unsigned short address;  	int ret; -	if ((ret = smsc47b397_find(&address))) +	ret = smsc47b397_find(); +	if (ret < 0)  		return ret; +	address = ret;  	ret = platform_driver_register(&smsc47b397_driver);  	if (ret)  | 
