Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F133209300
D26286.id76658.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D26286.id76658.diff
View Options
Index: head/sys/cam/cam_sim.c
===================================================================
--- head/sys/cam/cam_sim.c
+++ head/sys/cam/cam_sim.c
@@ -124,14 +124,15 @@
void
cam_sim_free(struct cam_sim *sim, int free_devq)
{
- struct mtx *mtx = sim->mtx;
+ struct mtx *mtx;
int error;
- if (mtx) {
- mtx_assert(mtx, MA_OWNED);
- } else {
+ if (sim->mtx == NULL) {
mtx = &cam_sim_free_mtx;
mtx_lock(mtx);
+ } else {
+ mtx = sim->mtx;
+ mtx_assert(mtx, MA_OWNED);
}
sim->refcount--;
if (sim->refcount > 0) {
@@ -139,7 +140,7 @@
KASSERT(error == 0, ("invalid error value for msleep(9)"));
}
KASSERT(sim->refcount == 0, ("sim->refcount == 0"));
- if (sim->mtx == NULL)
+ if (mtx == &cam_sim_free_mtx) /* sim->mtx == NULL */
mtx_unlock(mtx);
if (free_devq)
@@ -150,17 +151,16 @@
void
cam_sim_release(struct cam_sim *sim)
{
- struct mtx *mtx = sim->mtx;
+ struct mtx *mtx;
- if (mtx) {
- if (!mtx_owned(mtx))
- mtx_lock(mtx);
- else
- mtx = NULL;
- } else {
+ if (sim->mtx == NULL)
mtx = &cam_sim_free_mtx;
+ else if (!mtx_owned(sim->mtx))
+ mtx = sim->mtx;
+ else
+ mtx = NULL; /* We hold the lock. */
+ if (mtx)
mtx_lock(mtx);
- }
KASSERT(sim->refcount >= 1, ("sim->refcount >= 1"));
sim->refcount--;
if (sim->refcount == 0)
@@ -172,17 +172,16 @@
void
cam_sim_hold(struct cam_sim *sim)
{
- struct mtx *mtx = sim->mtx;
+ struct mtx *mtx;
- if (mtx) {
- if (!mtx_owned(mtx))
- mtx_lock(mtx);
- else
- mtx = NULL;
- } else {
+ if (sim->mtx == NULL)
mtx = &cam_sim_free_mtx;
+ else if (!mtx_owned(sim->mtx))
+ mtx = sim->mtx;
+ else
+ mtx = NULL; /* We hold the lock. */
+ if (mtx)
mtx_lock(mtx);
- }
KASSERT(sim->refcount >= 1, ("sim->refcount >= 1"));
sim->refcount++;
if (mtx)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 25, 12:02 AM (3 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
24136154
Default Alt Text
D26286.id76658.diff (1 KB)
Attached To
Mode
D26286: cam_sim: harmonize code related to acquiring a mtx
Attached
Detach File
Event Timeline
Log In to Comment