From bbf19db37e8be3fa6d6fe3e26e50da068b44a0e8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 6 Feb 2007 14:49:38 -0500 Subject: [PATCH] firewire: Use atomic_t's for serial numbers. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Kristian Høgsberg Use atomic_inc_return. Signed-off-by: Stefan Richter --- drivers/firewire/fw-card.c | 4 ++-- drivers/firewire/fw-device.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c index f785b10052..3f8661a52a 100644 --- a/drivers/firewire/fw-card.c +++ b/drivers/firewire/fw-card.c @@ -367,9 +367,9 @@ void fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver, struct device *device) { - static int index; + static atomic_t index = ATOMIC_INIT(-1); - card->index = index++; + card->index = atomic_inc_return(&index); card->driver = driver; card->device = device; card->current_tlabel = 0; diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c index db7556c487..df2e9296ad 100644 --- a/drivers/firewire/fw-device.c +++ b/drivers/firewire/fw-device.c @@ -434,7 +434,7 @@ static void fw_device_shutdown(struct work_struct *work) static void fw_device_init(struct work_struct *work) { - static int serial; + static atomic_t serial = ATOMIC_INIT(-1); struct fw_device *device = container_of(work, struct fw_device, work.work); @@ -460,7 +460,7 @@ static void fw_device_init(struct work_struct *work) device->device.release = fw_device_release; device->device.parent = device->card->device; snprintf(device->device.bus_id, sizeof device->device.bus_id, - "fw%d", serial++); + "fw%d", atomic_inc_return(&serial)); if (alloc_chrdev_region(&device->device.devt, 0, 1, "fw")) { fw_error("Failed to register char device region.\n"); -- 2.39.5