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
4f0447b8
Commit
4f0447b8
authored
May 21, 2010
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get rid of home-grown mutex in cris eeprom.c
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
48c1e44a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
19 deletions
+8
-19
arch/cris/arch-v10/drivers/eeprom.c
arch/cris/arch-v10/drivers/eeprom.c
+8
-19
No files found.
arch/cris/arch-v10/drivers/eeprom.c
View file @
4f0447b8
...
@@ -73,8 +73,7 @@ struct eeprom_type
...
@@ -73,8 +73,7 @@ struct eeprom_type
int
adapt_state
;
/* 1 = To high , 0 = Even, -1 = To low */
int
adapt_state
;
/* 1 = To high , 0 = Even, -1 = To low */
/* this one is to keep the read/write operations atomic */
/* this one is to keep the read/write operations atomic */
wait_queue_head_t
wait_q
;
struct
mutex
lock
;
volatile
int
busy
;
int
retry_cnt_addr
;
/* Used to keep track of number of retries for
int
retry_cnt_addr
;
/* Used to keep track of number of retries for
adaptive timing adjustments */
adaptive timing adjustments */
int
retry_cnt_read
;
int
retry_cnt_read
;
...
@@ -115,8 +114,7 @@ const struct file_operations eeprom_fops =
...
@@ -115,8 +114,7 @@ const struct file_operations eeprom_fops =
int
__init
eeprom_init
(
void
)
int
__init
eeprom_init
(
void
)
{
{
init_waitqueue_head
(
&
eeprom
.
wait_q
);
mutex_init
(
&
eeprom
.
lock
);
eeprom
.
busy
=
0
;
#ifdef CONFIG_ETRAX_I2C_EEPROM_PROBE
#ifdef CONFIG_ETRAX_I2C_EEPROM_PROBE
#define EETEXT "Found"
#define EETEXT "Found"
...
@@ -461,12 +459,9 @@ static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t
...
@@ -461,12 +459,9 @@ static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t
return
-
EFAULT
;
return
-
EFAULT
;
}
}
wait_event_interruptible
(
eeprom
.
wait_q
,
!
eeprom
.
busy
);
if
(
mutex_lock_interruptible
(
&
eeprom
.
lock
))
if
(
signal_pending
(
current
))
return
-
EINTR
;
return
-
EINTR
;
eeprom
.
busy
++
;
page
=
(
unsigned
char
)
(
p
>>
8
);
page
=
(
unsigned
char
)
(
p
>>
8
);
if
(
!
eeprom_address
(
p
))
if
(
!
eeprom_address
(
p
))
...
@@ -476,8 +471,7 @@ static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t
...
@@ -476,8 +471,7 @@ static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t
i2c_stop
();
i2c_stop
();
/* don't forget to wake them up */
/* don't forget to wake them up */
eeprom
.
busy
--
;
mutex_unlock
(
&
eeprom
.
lock
);
wake_up_interruptible
(
&
eeprom
.
wait_q
);
return
-
EFAULT
;
return
-
EFAULT
;
}
}
...
@@ -504,8 +498,7 @@ static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t
...
@@ -504,8 +498,7 @@ static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t
file
->
f_pos
+=
read
;
file
->
f_pos
+=
read
;
}
}
eeprom
.
busy
--
;
mutex_unlock
(
&
eeprom
.
lock
);
wake_up_interruptible
(
&
eeprom
.
wait_q
);
return
read
;
return
read
;
}
}
...
@@ -534,11 +527,9 @@ static ssize_t eeprom_write(struct file * file, const char * buf, size_t count,
...
@@ -534,11 +527,9 @@ static ssize_t eeprom_write(struct file * file, const char * buf, size_t count,
return
-
EFAULT
;
return
-
EFAULT
;
}
}
wait_event_interruptible
(
eeprom
.
wait_q
,
!
eeprom
.
busy
);
/* bail out if we get interrupted */
/* bail out if we get interrupted */
if
(
signal_pending
(
current
))
if
(
mutex_lock_interruptible
(
&
eeprom
.
lock
))
return
-
EINTR
;
return
-
EINTR
;
eeprom
.
busy
++
;
for
(
i
=
0
;
(
i
<
EEPROM_RETRIES
)
&&
(
restart
>
0
);
i
++
)
for
(
i
=
0
;
(
i
<
EEPROM_RETRIES
)
&&
(
restart
>
0
);
i
++
)
{
{
restart
=
0
;
restart
=
0
;
...
@@ -556,8 +547,7 @@ static ssize_t eeprom_write(struct file * file, const char * buf, size_t count,
...
@@ -556,8 +547,7 @@ static ssize_t eeprom_write(struct file * file, const char * buf, size_t count,
i2c_stop
();
i2c_stop
();
/* don't forget to wake them up */
/* don't forget to wake them up */
eeprom
.
busy
--
;
mutex_unlock
(
&
eeprom
.
lock
);
wake_up_interruptible
(
&
eeprom
.
wait_q
);
return
-
EFAULT
;
return
-
EFAULT
;
}
}
#ifdef EEPROM_ADAPTIVE_TIMING
#ifdef EEPROM_ADAPTIVE_TIMING
...
@@ -669,8 +659,7 @@ static ssize_t eeprom_write(struct file * file, const char * buf, size_t count,
...
@@ -669,8 +659,7 @@ static ssize_t eeprom_write(struct file * file, const char * buf, size_t count,
}
/* while */
}
/* while */
}
/* for */
}
/* for */
eeprom
.
busy
--
;
mutex_unlock
(
&
eeprom
.
lock
);
wake_up_interruptible
(
&
eeprom
.
wait_q
);
if
(
written
==
0
&&
file
->
f_pos
>=
eeprom
.
size
){
if
(
written
==
0
&&
file
->
f_pos
>=
eeprom
.
size
){
return
-
ENOSPC
;
return
-
ENOSPC
;
}
}
...
...
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