projects
/
powerpc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[PATCH] hwmon: remove deprecated sysfs names of adm1025 and adm1026
[powerpc.git]
/
drivers
/
hwmon
/
lm63.c
diff --git
a/drivers/hwmon/lm63.c
b/drivers/hwmon/lm63.c
index
7c6f9ea
..
954ec24
100644
(file)
--- a/
drivers/hwmon/lm63.c
+++ b/
drivers/hwmon/lm63.c
@@
-42,8
+42,9
@@
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
#include <linux/hwmon-sysfs.h>
#include <linux/hwmon-sysfs.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
/*
* Addresses to scan
/*
* Addresses to scan
@@
-51,13
+52,12
@@
*/
static unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END };
*/
static unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END };
-static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
/*
* Insmod parameters
*/
/*
* Insmod parameters
*/
-
SENSORS
_INSMOD_1(lm63);
+
I2C_CLIENT
_INSMOD_1(lm63);
/*
* The LM63 registers
/*
* The LM63 registers
@@
-152,6
+152,7
@@
static struct i2c_driver lm63_driver = {
struct lm63_data {
struct i2c_client client;
struct lm63_data {
struct i2c_client client;
+ struct class_device *class_dev;
struct semaphore update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
struct semaphore update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
@@
-358,7
+359,7
@@
static int lm63_attach_adapter(struct i2c_adapter *adapter)
{
if (!(adapter->class & I2C_CLASS_HWMON))
return 0;
{
if (!(adapter->class & I2C_CLASS_HWMON))
return 0;
- return i2c_
detect
(adapter, &addr_data, lm63_detect);
+ return i2c_
probe
(adapter, &addr_data, lm63_detect);
}
/*
}
/*
@@
-374,11
+375,10
@@
static int lm63_detect(struct i2c_adapter *adapter, int address, int kind)
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
goto exit;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
goto exit;
- if (!(data = k
m
alloc(sizeof(struct lm63_data), GFP_KERNEL))) {
+ if (!(data = k
z
alloc(sizeof(struct lm63_data), GFP_KERNEL))) {
err = -ENOMEM;
goto exit;
}
err = -ENOMEM;
goto exit;
}
- memset(data, 0, sizeof(struct lm63_data));
/* The common I2C client data is placed right before the
LM63-specific data. */
/* The common I2C client data is placed right before the
LM63-specific data. */
@@
-437,6
+437,12
@@
static int lm63_detect(struct i2c_adapter *adapter, int address, int kind)
lm63_init_client(new_client);
/* Register sysfs hooks */
lm63_init_client(new_client);
/* Register sysfs hooks */
+ data->class_dev = hwmon_device_register(&new_client->dev);
+ if (IS_ERR(data->class_dev)) {
+ err = PTR_ERR(data->class_dev);
+ goto exit_detach;
+ }
+
if (data->config & 0x04) { /* tachometer enabled */
device_create_file(&new_client->dev,
&sensor_dev_attr_fan1_input.dev_attr);
if (data->config & 0x04) { /* tachometer enabled */
device_create_file(&new_client->dev,
&sensor_dev_attr_fan1_input.dev_attr);
@@
-462,6
+468,8
@@
static int lm63_detect(struct i2c_adapter *adapter, int address, int kind)
return 0;
return 0;
+exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(data);
exit:
exit_free:
kfree(data);
exit:
@@
-505,15
+513,15
@@
static void lm63_init_client(struct i2c_client *client)
static int lm63_detach_client(struct i2c_client *client)
{
static int lm63_detach_client(struct i2c_client *client)
{
+ struct lm63_data *data = i2c_get_clientdata(client);
int err;
int err;
- if ((err = i2c_detach_client(client))) {
- dev_err(&client->dev, "Client deregistration failed, "
- "client not detached\n");
+ hwmon_device_unregister(data->class_dev);
+
+ if ((err = i2c_detach_client(client)))
return err;
return err;
- }
- kfree(
i2c_get_clientdata(client)
);
+ kfree(
data
);
return 0;
}
return 0;
}