Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
e4a7167f
Commit
e4a7167f
authored
Jun 09, 2007
by
Jean Delvare
Committed by
Mark M. Hoffman
Jul 19, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hwmon/smsc47m192: Semaphore to mutex conversion
Signed-off-by:
Jean Delvare
<
khali@linux-fr.org
>
parent
0966415d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
drivers/hwmon/smsc47m192.c
drivers/hwmon/smsc47m192.c
+15
-14
No files found.
drivers/hwmon/smsc47m192.c
View file @
e4a7167f
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include <linux/hwmon-vid.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
#include <linux/err.h>
#include <linux/sysfs.h>
#include <linux/sysfs.h>
#include <linux/mutex.h>
/* Addresses to scan */
/* Addresses to scan */
static
unsigned
short
normal_i2c
[]
=
{
0x2c
,
0x2d
,
I2C_CLIENT_END
};
static
unsigned
short
normal_i2c
[]
=
{
0x2c
,
0x2d
,
I2C_CLIENT_END
};
...
@@ -97,7 +98,7 @@ static inline int TEMP_FROM_REG(s8 val)
...
@@ -97,7 +98,7 @@ static inline int TEMP_FROM_REG(s8 val)
struct
smsc47m192_data
{
struct
smsc47m192_data
{
struct
i2c_client
client
;
struct
i2c_client
client
;
struct
class_device
*
class_dev
;
struct
class_device
*
class_dev
;
struct
semaphore
update_lock
;
struct
mutex
update_lock
;
char
valid
;
/* !=0 if following fields are valid */
char
valid
;
/* !=0 if following fields are valid */
unsigned
long
last_updated
;
/* In jiffies */
unsigned
long
last_updated
;
/* In jiffies */
...
@@ -164,11 +165,11 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
...
@@ -164,11 +165,11 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
struct
smsc47m192_data
*
data
=
i2c_get_clientdata
(
client
);
struct
smsc47m192_data
*
data
=
i2c_get_clientdata
(
client
);
unsigned
long
val
=
simple_strtoul
(
buf
,
NULL
,
10
);
unsigned
long
val
=
simple_strtoul
(
buf
,
NULL
,
10
);
down
(
&
data
->
update_lock
);
mutex_lock
(
&
data
->
update_lock
);
data
->
in_min
[
nr
]
=
IN_TO_REG
(
val
,
nr
);
data
->
in_min
[
nr
]
=
IN_TO_REG
(
val
,
nr
);
i2c_smbus_write_byte_data
(
client
,
SMSC47M192_REG_IN_MIN
(
nr
),
i2c_smbus_write_byte_data
(
client
,
SMSC47M192_REG_IN_MIN
(
nr
),
data
->
in_min
[
nr
]);
data
->
in_min
[
nr
]);
up
(
&
data
->
update_lock
);
mutex_unlock
(
&
data
->
update_lock
);
return
count
;
return
count
;
}
}
...
@@ -181,11 +182,11 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
...
@@ -181,11 +182,11 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
struct
smsc47m192_data
*
data
=
i2c_get_clientdata
(
client
);
struct
smsc47m192_data
*
data
=
i2c_get_clientdata
(
client
);
unsigned
long
val
=
simple_strtoul
(
buf
,
NULL
,
10
);
unsigned
long
val
=
simple_strtoul
(
buf
,
NULL
,
10
);
down
(
&
data
->
update_lock
);
mutex_lock
(
&
data
->
update_lock
);
data
->
in_max
[
nr
]
=
IN_TO_REG
(
val
,
nr
);
data
->
in_max
[
nr
]
=
IN_TO_REG
(
val
,
nr
);
i2c_smbus_write_byte_data
(
client
,
SMSC47M192_REG_IN_MAX
(
nr
),
i2c_smbus_write_byte_data
(
client
,
SMSC47M192_REG_IN_MAX
(
nr
),
data
->
in_max
[
nr
]);
data
->
in_max
[
nr
]);
up
(
&
data
->
update_lock
);
mutex_unlock
(
&
data
->
update_lock
);
return
count
;
return
count
;
}
}
...
@@ -243,11 +244,11 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
...
@@ -243,11 +244,11 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
struct
smsc47m192_data
*
data
=
i2c_get_clientdata
(
client
);
struct
smsc47m192_data
*
data
=
i2c_get_clientdata
(
client
);
long
val
=
simple_strtol
(
buf
,
NULL
,
10
);
long
val
=
simple_strtol
(
buf
,
NULL
,
10
);
down
(
&
data
->
update_lock
);
mutex_lock
(
&
data
->
update_lock
);
data
->
temp_min
[
nr
]
=
TEMP_TO_REG
(
val
);
data
->
temp_min
[
nr
]
=
TEMP_TO_REG
(
val
);
i2c_smbus_write_byte_data
(
client
,
SMSC47M192_REG_TEMP_MIN
[
nr
],
i2c_smbus_write_byte_data
(
client
,
SMSC47M192_REG_TEMP_MIN
[
nr
],
data
->
temp_min
[
nr
]);
data
->
temp_min
[
nr
]);
up
(
&
data
->
update_lock
);
mutex_unlock
(
&
data
->
update_lock
);
return
count
;
return
count
;
}
}
...
@@ -260,11 +261,11 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
...
@@ -260,11 +261,11 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
struct
smsc47m192_data
*
data
=
i2c_get_clientdata
(
client
);
struct
smsc47m192_data
*
data
=
i2c_get_clientdata
(
client
);
long
val
=
simple_strtol
(
buf
,
NULL
,
10
);
long
val
=
simple_strtol
(
buf
,
NULL
,
10
);
down
(
&
data
->
update_lock
);
mutex_lock
(
&
data
->
update_lock
);
data
->
temp_max
[
nr
]
=
TEMP_TO_REG
(
val
);
data
->
temp_max
[
nr
]
=
TEMP_TO_REG
(
val
);
i2c_smbus_write_byte_data
(
client
,
SMSC47M192_REG_TEMP_MAX
[
nr
],
i2c_smbus_write_byte_data
(
client
,
SMSC47M192_REG_TEMP_MAX
[
nr
],
data
->
temp_max
[
nr
]);
data
->
temp_max
[
nr
]);
up
(
&
data
->
update_lock
);
mutex_unlock
(
&
data
->
update_lock
);
return
count
;
return
count
;
}
}
...
@@ -287,7 +288,7 @@ static ssize_t set_temp_offset(struct device *dev, struct device_attribute
...
@@ -287,7 +288,7 @@ static ssize_t set_temp_offset(struct device *dev, struct device_attribute
u8
sfr
=
i2c_smbus_read_byte_data
(
client
,
SMSC47M192_REG_SFR
);
u8
sfr
=
i2c_smbus_read_byte_data
(
client
,
SMSC47M192_REG_SFR
);
long
val
=
simple_strtol
(
buf
,
NULL
,
10
);
long
val
=
simple_strtol
(
buf
,
NULL
,
10
);
down
(
&
data
->
update_lock
);
mutex_lock
(
&
data
->
update_lock
);
data
->
temp_offset
[
nr
]
=
TEMP_TO_REG
(
val
);
data
->
temp_offset
[
nr
]
=
TEMP_TO_REG
(
val
);
if
(
nr
>
1
)
if
(
nr
>
1
)
i2c_smbus_write_byte_data
(
client
,
i2c_smbus_write_byte_data
(
client
,
...
@@ -303,7 +304,7 @@ static ssize_t set_temp_offset(struct device *dev, struct device_attribute
...
@@ -303,7 +304,7 @@ static ssize_t set_temp_offset(struct device *dev, struct device_attribute
}
else
if
((
sfr
&
0x10
)
==
(
nr
==
0
?
0x10
:
0
))
}
else
if
((
sfr
&
0x10
)
==
(
nr
==
0
?
0x10
:
0
))
i2c_smbus_write_byte_data
(
client
,
i2c_smbus_write_byte_data
(
client
,
SMSC47M192_REG_TEMP_OFFSET
(
nr
),
0
);
SMSC47M192_REG_TEMP_OFFSET
(
nr
),
0
);
up
(
&
data
->
update_lock
);
mutex_unlock
(
&
data
->
update_lock
);
return
count
;
return
count
;
}
}
...
@@ -531,7 +532,7 @@ static int smsc47m192_detect(struct i2c_adapter *adapter, int address,
...
@@ -531,7 +532,7 @@ static int smsc47m192_detect(struct i2c_adapter *adapter, int address,
/* Fill in the remaining client fields and put into the global list */
/* Fill in the remaining client fields and put into the global list */
strlcpy
(
client
->
name
,
"smsc47m192"
,
I2C_NAME_SIZE
);
strlcpy
(
client
->
name
,
"smsc47m192"
,
I2C_NAME_SIZE
);
data
->
vrm
=
vid_which_vrm
();
data
->
vrm
=
vid_which_vrm
();
init_MUTEX
(
&
data
->
update_lock
);
mutex_init
(
&
data
->
update_lock
);
/* Tell the I2C layer a new client has arrived */
/* Tell the I2C layer a new client has arrived */
if
((
err
=
i2c_attach_client
(
client
)))
if
((
err
=
i2c_attach_client
(
client
)))
...
@@ -594,7 +595,7 @@ static struct smsc47m192_data *smsc47m192_update_device(struct device *dev)
...
@@ -594,7 +595,7 @@ static struct smsc47m192_data *smsc47m192_update_device(struct device *dev)
struct
smsc47m192_data
*
data
=
i2c_get_clientdata
(
client
);
struct
smsc47m192_data
*
data
=
i2c_get_clientdata
(
client
);
int
i
,
config
;
int
i
,
config
;
down
(
&
data
->
update_lock
);
mutex_lock
(
&
data
->
update_lock
);
if
(
time_after
(
jiffies
,
data
->
last_updated
+
HZ
+
HZ
/
2
)
if
(
time_after
(
jiffies
,
data
->
last_updated
+
HZ
+
HZ
/
2
)
||
!
data
->
valid
)
{
||
!
data
->
valid
)
{
...
@@ -645,7 +646,7 @@ static struct smsc47m192_data *smsc47m192_update_device(struct device *dev)
...
@@ -645,7 +646,7 @@ static struct smsc47m192_data *smsc47m192_update_device(struct device *dev)
data
->
valid
=
1
;
data
->
valid
=
1
;
}
}
up
(
&
data
->
update_lock
);
mutex_unlock
(
&
data
->
update_lock
);
return
data
;
return
data
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment