From 641f8791f031d6133e5c3e9ce036b3e942416e9d Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Sat, 27 Jan 2007 10:34:55 +0100 Subject: firewire: use atomic type for fw_device.state Signed-off-by: Stefan Richter --- drivers/firewire/fw-card.c | 2 +- drivers/firewire/fw-device.c | 6 +++--- drivers/firewire/fw-device.h | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c index f94874ce58a..7f5dc43ec13 100644 --- a/drivers/firewire/fw-card.c +++ b/drivers/firewire/fw-card.c @@ -302,7 +302,7 @@ fw_card_bm_work(struct work_struct *work) /* Either link_on is false, or we failed to read the * config rom. In either case, pick another root. */ new_root_id = card->local_node->node_id; - } else if (root->state != FW_DEVICE_RUNNING) { + } else if (atomic_read(&root->state) != FW_DEVICE_RUNNING) { /* If we haven't probed this device yet, bail out now * and let's try again once that's done. */ spin_unlock_irqrestore(&card->lock, flags); diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c index 4ea8d4d08a6..85b6f2cfa41 100644 --- a/drivers/firewire/fw-device.c +++ b/drivers/firewire/fw-device.c @@ -494,7 +494,7 @@ static void fw_device_init(struct work_struct *work) * necessary. We have to use the atomic cmpxchg here to avoid * racing with the FW_NODE_DESTROYED case in * fw_node_event(). */ - if (cmpxchg(&device->state, + if (atomic_cmpxchg(&device->state, FW_DEVICE_INITIALIZING, FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN) fw_device_shutdown(&device->work.work); @@ -551,7 +551,7 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event) * device_for_each_child() in FW_NODE_UPDATED is * doesn't freak out. */ device_initialize(&device->device); - device->state = FW_DEVICE_INITIALIZING; + atomic_set(&device->state, FW_DEVICE_INITIALIZING); device->card = fw_card_get(card); device->node = fw_node_get(node); device->node_id = node->node_id; @@ -596,7 +596,7 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event) * the device in shutdown state to have that code fail * to create the device. */ device = node->data; - if (xchg(&device->state, + if (atomic_xchg(&device->state, FW_DEVICE_SHUTDOWN) == FW_DEVICE_RUNNING) { INIT_DELAYED_WORK(&device->work, fw_device_shutdown); schedule_delayed_work(&device->work, 0); diff --git a/drivers/firewire/fw-device.h b/drivers/firewire/fw-device.h index 5399b48f553..402a785ceed 100644 --- a/drivers/firewire/fw-device.h +++ b/drivers/firewire/fw-device.h @@ -24,6 +24,7 @@ #include #include +#include enum fw_device_state { FW_DEVICE_INITIALIZING, @@ -32,7 +33,7 @@ enum fw_device_state { }; struct fw_device { - int state; + atomic_t state; struct fw_node *node; int node_id; int generation; -- cgit v1.2.3-70-g09d2