Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 54741
b: refs/heads/master
c: 6acc369
h: refs/heads/master
i:
  54739: b1ae64b
v: v3
  • Loading branch information
Matthias Kaehlcke authored and Linus Torvalds committed May 8, 2007
1 parent e3fd7da commit 84f4b57
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d081d470446900473f2f32b9203827809b8134f0
refs/heads/master: 6acc369a43ada9b829b3e1e4daef5c8a52a2d39a
38 changes: 20 additions & 18 deletions trunk/drivers/hwmon/hdaps.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
#include <linux/platform_device.h>
#include <linux/input.h>
#include <linux/kernel.h>
#include <linux/mutex.h>
#include <linux/module.h>
#include <linux/timer.h>
#include <linux/dmi.h>
#include <linux/jiffies.h>

#include <asm/io.h>

#define HDAPS_LOW_PORT 0x1600 /* first port used by hdaps */
Expand Down Expand Up @@ -71,10 +73,10 @@ static u8 km_activity;
static int rest_x;
static int rest_y;

static DECLARE_MUTEX(hdaps_sem);
static DEFINE_MUTEX(hdaps_mtx);

/*
* __get_latch - Get the value from a given port. Callers must hold hdaps_sem.
* __get_latch - Get the value from a given port. Callers must hold hdaps_mtx.
*/
static inline u8 __get_latch(u16 port)
{
Expand All @@ -83,7 +85,7 @@ static inline u8 __get_latch(u16 port)

/*
* __check_latch - Check a port latch for a given value. Returns zero if the
* port contains the given value. Callers must hold hdaps_sem.
* port contains the given value. Callers must hold hdaps_mtx.
*/
static inline int __check_latch(u16 port, u8 val)
{
Expand All @@ -94,7 +96,7 @@ static inline int __check_latch(u16 port, u8 val)

/*
* __wait_latch - Wait up to 100us for a port latch to get a certain value,
* returning zero if the value is obtained. Callers must hold hdaps_sem.
* returning zero if the value is obtained. Callers must hold hdaps_mtx.
*/
static int __wait_latch(u16 port, u8 val)
{
Expand All @@ -111,7 +113,7 @@ static int __wait_latch(u16 port, u8 val)

/*
* __device_refresh - request a refresh from the accelerometer. Does not wait
* for refresh to complete. Callers must hold hdaps_sem.
* for refresh to complete. Callers must hold hdaps_mtx.
*/
static void __device_refresh(void)
{
Expand All @@ -125,7 +127,7 @@ static void __device_refresh(void)
/*
* __device_refresh_sync - request a synchronous refresh from the
* accelerometer. We wait for the refresh to complete. Returns zero if
* successful and nonzero on error. Callers must hold hdaps_sem.
* successful and nonzero on error. Callers must hold hdaps_mtx.
*/
static int __device_refresh_sync(void)
{
Expand All @@ -135,7 +137,7 @@ static int __device_refresh_sync(void)

/*
* __device_complete - indicate to the accelerometer that we are done reading
* data, and then initiate an async refresh. Callers must hold hdaps_sem.
* data, and then initiate an async refresh. Callers must hold hdaps_mtx.
*/
static inline void __device_complete(void)
{
Expand All @@ -153,7 +155,7 @@ static int hdaps_readb_one(unsigned int port, u8 *val)
{
int ret;

down(&hdaps_sem);
mutex_lock(&hdaps_mtx);

/* do a sync refresh -- we need to be sure that we read fresh data */
ret = __device_refresh_sync();
Expand All @@ -164,7 +166,7 @@ static int hdaps_readb_one(unsigned int port, u8 *val)
__device_complete();

out:
up(&hdaps_sem);
mutex_unlock(&hdaps_mtx);
return ret;
}

Expand Down Expand Up @@ -199,9 +201,9 @@ static int hdaps_read_pair(unsigned int port1, unsigned int port2,
{
int ret;

down(&hdaps_sem);
mutex_lock(&hdaps_mtx);
ret = __hdaps_read_pair(port1, port2, val1, val2);
up(&hdaps_sem);
mutex_unlock(&hdaps_mtx);

return ret;
}
Expand All @@ -214,7 +216,7 @@ static int hdaps_device_init(void)
{
int total, ret = -ENXIO;

down(&hdaps_sem);
mutex_lock(&hdaps_mtx);

outb(0x13, 0x1610);
outb(0x01, 0x161f);
Expand Down Expand Up @@ -280,7 +282,7 @@ static int hdaps_device_init(void)
}

out:
up(&hdaps_sem);
mutex_unlock(&hdaps_mtx);
return ret;
}

Expand Down Expand Up @@ -314,7 +316,7 @@ static struct platform_driver hdaps_driver = {
};

/*
* hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_sem.
* hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_mtx.
*/
static void hdaps_calibrate(void)
{
Expand All @@ -326,7 +328,7 @@ static void hdaps_mousedev_poll(unsigned long unused)
int x, y;

/* Cannot sleep. Try nonblockingly. If we fail, try again later. */
if (down_trylock(&hdaps_sem)) {
if (mutex_trylock(&hdaps_mtx)) {
mod_timer(&hdaps_timer,jiffies + HDAPS_POLL_PERIOD);
return;
}
Expand All @@ -341,7 +343,7 @@ static void hdaps_mousedev_poll(unsigned long unused)
mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD);

out:
up(&hdaps_sem);
mutex_unlock(&hdaps_mtx);
}


Expand Down Expand Up @@ -421,9 +423,9 @@ static ssize_t hdaps_calibrate_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
down(&hdaps_sem);
mutex_lock(&hdaps_mtx);
hdaps_calibrate();
up(&hdaps_sem);
mutex_unlock(&hdaps_mtx);

return count;
}
Expand Down

0 comments on commit 84f4b57

Please sign in to comment.