]> err.no Git - linux-2.6/commitdiff
[PATCH] USBATM: semaphore to mutex conversion
authorArjan van de Ven <arjan@infradead.org>
Fri, 13 Jan 2006 14:52:55 +0000 (15:52 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 1 Feb 2006 01:23:40 +0000 (17:23 -0800)
This is the usbatm part of the Arjan, Jes and Ingo
mass semaphore to mutex conversion, reworked to apply on top
of the patches I just sent to you.  This time, with correct
attribution and signed-off lines.

Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Duncan Sands <baldrick@free.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/atm/cxacru.c
drivers/usb/atm/ueagle-atm.c
drivers/usb/atm/usbatm.c
drivers/usb/atm/usbatm.h

index 70a96e98152cac082b1459c41b7adbf701d85248..04631dcbabbce2673529aeffc7e16131d796d817 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/init.h>
 #include <linux/device.h>      /* FIXME: linux/firmware.h should include it itself */
 #include <linux/firmware.h>
+#include <linux/mutex.h>
 
 #include "usbatm.h"
 
@@ -160,7 +161,7 @@ struct cxacru_data {
        struct work_struct poll_work;
 
        /* contol handles */
-       struct semaphore cm_serialize;
+       struct mutex cm_serialize;
        u8 *rcv_buf;
        u8 *snd_buf;
        struct urb *rcv_urb;
@@ -219,7 +220,7 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
                goto fail;
        }
 
-       down(&instance->cm_serialize);
+       mutex_lock(&instance->cm_serialize);
 
        /* submit reading urb before the writing one */
        init_completion(&instance->rcv_done);
@@ -288,7 +289,7 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
        ret = offd;
        dbg("cm %#x", cm);
 fail:
-       up(&instance->cm_serialize);
+       mutex_unlock(&instance->cm_serialize);
        return ret;
 }
 
@@ -717,7 +718,7 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
                        instance->snd_buf, PAGE_SIZE,
                        cxacru_blocking_completion, &instance->snd_done, 4);
 
-       init_MUTEX(&instance->cm_serialize);
+       mutex_init(&instance->cm_serialize);
 
        INIT_WORK(&instance->poll_work, (void *)cxacru_poll_status, instance);
 
index 956cd9e82dee52ddf2ea9296abc4a27552d39dc8..4362cfd801b5390f3b75bc845d2e01449d4955ed 100644 (file)
@@ -63,6 +63,7 @@
 #include <linux/ctype.h>
 #include <linux/kthread.h>
 #include <linux/version.h>
+#include <linux/mutex.h>
 #include <asm/unaligned.h>
 
 #include "usbatm.h"
@@ -358,7 +359,7 @@ struct intr_pkt {
 #define INTR_PKT_SIZE 28
 
 static struct usb_driver uea_driver;
-static DECLARE_MUTEX(uea_semaphore);
+static DEFINE_MUTEX(uea_mutex);
 static const char *chip_name[] = {"ADI930", "Eagle I", "Eagle II", "Eagle III"};
 
 static int modem_index;
@@ -1418,13 +1419,13 @@ static ssize_t read_status(struct device *dev, struct device_attribute *attr,
        int ret = -ENODEV;
        struct uea_softc *sc;
 
-       down(&uea_semaphore);
+       mutex_lock(&uea_mutex);
        sc = dev_to_uea(dev);
        if (!sc)
                goto out;
        ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.state);
 out:
-       up(&uea_semaphore);
+       mutex_unlock(&uea_mutex);
        return ret;
 }
 
@@ -1434,14 +1435,14 @@ static ssize_t reboot(struct device *dev, struct device_attribute *attr,
        int ret = -ENODEV;
        struct uea_softc *sc;
 
-       down(&uea_semaphore);
+       mutex_lock(&uea_mutex);
        sc = dev_to_uea(dev);
        if (!sc)
                goto out;
        sc->reset = 1;
        ret = count;
 out:
-       up(&uea_semaphore);
+       mutex_unlock(&uea_mutex);
        return ret;
 }
 
@@ -1453,7 +1454,7 @@ static ssize_t read_human_status(struct device *dev, struct device_attribute *at
        int ret = -ENODEV;
        struct uea_softc *sc;
 
-       down(&uea_semaphore);
+       mutex_lock(&uea_mutex);
        sc = dev_to_uea(dev);
        if (!sc)
                goto out;
@@ -1473,7 +1474,7 @@ static ssize_t read_human_status(struct device *dev, struct device_attribute *at
                break;
        }
 out:
-       up(&uea_semaphore);
+       mutex_unlock(&uea_mutex);
        return ret;
 }
 
@@ -1485,7 +1486,7 @@ static ssize_t read_delin(struct device *dev, struct device_attribute *attr,
        int ret = -ENODEV;
        struct uea_softc *sc;
 
-       down(&uea_semaphore);
+       mutex_lock(&uea_mutex);
        sc = dev_to_uea(dev);
        if (!sc)
                goto out;
@@ -1497,7 +1498,7 @@ static ssize_t read_delin(struct device *dev, struct device_attribute *attr,
        else
                ret = sprintf(buf, "GOOD\n");
 out:
-       up(&uea_semaphore);
+       mutex_unlock(&uea_mutex);
        return ret;
 }
 
@@ -1511,7 +1512,7 @@ static ssize_t read_##name(struct device *dev,                    \
        int ret = -ENODEV;                                      \
        struct uea_softc *sc;                                   \
                                                                \
-       down(&uea_semaphore);                                   \
+       mutex_lock(&uea_mutex);                                         \
        sc = dev_to_uea(dev);                                   \
        if (!sc)                                                \
                goto out;                                       \
@@ -1519,7 +1520,7 @@ static ssize_t read_##name(struct device *dev,                    \
        if (reset)                                              \
                sc->stats.phy.name = 0;                         \
 out:                                                           \
-       up(&uea_semaphore);                                     \
+       mutex_unlock(&uea_mutex);                                       \
        return ret;                                             \
 }                                                              \
                                                                \
@@ -1737,9 +1738,9 @@ static void uea_disconnect(struct usb_interface *intf)
         * Pre-firmware device has one interface
         */
        if (usb->config->desc.bNumInterfaces != 1 && ifnum == 0) {
-               down(&uea_semaphore);
+               mutex_lock(&uea_mutex);
                usbatm_usb_disconnect(intf);
-               up(&uea_semaphore);
+               mutex_unlock(&uea_mutex);
                uea_info(usb, "ADSL device removed\n");
        }
 
index 5d339af16248921ec382be25544c52b364e9ac37..c1211fc037d997b8a30cee323ded090d72d9da63 100644 (file)
@@ -823,7 +823,7 @@ static int usbatm_atm_open(struct atm_vcc *vcc)
                return -EINVAL;
        }
 
-       down(&instance->serialize);     /* vs self, usbatm_atm_close, usbatm_usb_disconnect */
+       mutex_lock(&instance->serialize);       /* vs self, usbatm_atm_close, usbatm_usb_disconnect */
 
        if (instance->disconnected) {
                atm_dbg(instance, "%s: disconnected!\n", __func__);
@@ -867,7 +867,7 @@ static int usbatm_atm_open(struct atm_vcc *vcc)
        set_bit(ATM_VF_PARTIAL, &vcc->flags);
        set_bit(ATM_VF_READY, &vcc->flags);
 
-       up(&instance->serialize);
+       mutex_unlock(&instance->serialize);
 
        atm_dbg(instance, "%s: allocated vcc data 0x%p\n", __func__, new);
 
@@ -875,7 +875,7 @@ static int usbatm_atm_open(struct atm_vcc *vcc)
 
 fail:
        kfree(new);
-       up(&instance->serialize);
+       mutex_unlock(&instance->serialize);
        return ret;
 }
 
@@ -896,7 +896,7 @@ static void usbatm_atm_close(struct atm_vcc *vcc)
 
        usbatm_cancel_send(instance, vcc);
 
-       down(&instance->serialize);     /* vs self, usbatm_atm_open, usbatm_usb_disconnect */
+       mutex_lock(&instance->serialize);       /* vs self, usbatm_atm_open, usbatm_usb_disconnect */
 
        tasklet_disable(&instance->rx_channel.tasklet);
        if (instance->cached_vcc == vcc_data) {
@@ -919,7 +919,7 @@ static void usbatm_atm_close(struct atm_vcc *vcc)
        clear_bit(ATM_VF_PARTIAL, &vcc->flags);
        clear_bit(ATM_VF_ADDR, &vcc->flags);
 
-       up(&instance->serialize);
+       mutex_unlock(&instance->serialize);
 
        atm_dbg(instance, "%s successful\n", __func__);
 }
@@ -1009,9 +1009,9 @@ static int usbatm_do_heavy_init(void *arg)
        if (!ret)
                ret = usbatm_atm_init(instance);
 
-       down(&instance->serialize);
+       mutex_lock(&instance->serialize);
        instance->thread_pid = -1;
-       up(&instance->serialize);
+       mutex_unlock(&instance->serialize);
 
        complete_and_exit(&instance->thread_exited, ret);
 }
@@ -1025,9 +1025,9 @@ static int usbatm_heavy_init(struct usbatm_data *instance)
                return ret;
        }
 
-       down(&instance->serialize);
+       mutex_lock(&instance->serialize);
        instance->thread_pid = ret;
-       up(&instance->serialize);
+       mutex_unlock(&instance->serialize);
 
        wait_for_completion(&instance->thread_started);
 
@@ -1110,7 +1110,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
        /* private fields */
 
        kref_init(&instance->refcount);         /* dropped in usbatm_usb_disconnect */
-       init_MUTEX(&instance->serialize);
+       mutex_init(&instance->serialize);
 
        instance->thread_pid = -1;
        init_completion(&instance->thread_started);
@@ -1273,18 +1273,18 @@ void usbatm_usb_disconnect(struct usb_interface *intf)
 
        usb_set_intfdata(intf, NULL);
 
-       down(&instance->serialize);
+       mutex_lock(&instance->serialize);
        instance->disconnected = 1;
        if (instance->thread_pid >= 0)
                kill_proc(instance->thread_pid, SIGTERM, 1);
-       up(&instance->serialize);
+       mutex_unlock(&instance->serialize);
 
        wait_for_completion(&instance->thread_exited);
 
-       down(&instance->serialize);
+       mutex_lock(&instance->serialize);
        list_for_each_entry(vcc_data, &instance->vcc_list, list)
                vcc_release_async(vcc_data->vcc, -EPIPE);
-       up(&instance->serialize);
+       mutex_unlock(&instance->serialize);
 
        tasklet_disable(&instance->rx_channel.tasklet);
        tasklet_disable(&instance->tx_channel.tasklet);
index 1cf4767007ded2f98e7461996da06b2df14eb756..ff8551e933723c25e16f9524a88458e413e4454b 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/list.h>
 #include <linux/stringify.h>
 #include <linux/usb.h>
+#include <linux/mutex.h>
 
 /*
 #define VERBOSE_DEBUG
@@ -171,7 +172,7 @@ struct usbatm_data {
         ********************************/
 
        struct kref refcount;
-       struct semaphore serialize;
+       struct mutex serialize;
        int disconnected;
 
        /* heavy init */