diff options
author | Arjan van de Ven <arjan@infradead.org> | 2006-01-13 09:52:55 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-01-31 20:23:40 -0500 |
commit | ab3c81ff639fbee4ab32af84c809d283b773084a (patch) | |
tree | 6981ca653daa753d2a6d0bbebd4a62b1755d91ef /drivers/usb/atm | |
parent | a3673d3cd1cdeec6b503ffa418ca2d5aeff82fd7 (diff) |
[PATCH] USBATM: semaphore to mutex conversion
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>
Diffstat (limited to 'drivers/usb/atm')
-rw-r--r-- | drivers/usb/atm/cxacru.c | 9 | ||||
-rw-r--r-- | drivers/usb/atm/ueagle-atm.c | 27 | ||||
-rw-r--r-- | drivers/usb/atm/usbatm.c | 28 | ||||
-rw-r--r-- | drivers/usb/atm/usbatm.h | 3 |
4 files changed, 35 insertions, 32 deletions
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c index 70a96e98152c..04631dcbabbc 100644 --- a/drivers/usb/atm/cxacru.c +++ b/drivers/usb/atm/cxacru.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/device.h> /* FIXME: linux/firmware.h should include it itself */ | 37 | #include <linux/device.h> /* FIXME: linux/firmware.h should include it itself */ |
38 | #include <linux/firmware.h> | 38 | #include <linux/firmware.h> |
39 | #include <linux/mutex.h> | ||
39 | 40 | ||
40 | #include "usbatm.h" | 41 | #include "usbatm.h" |
41 | 42 | ||
@@ -160,7 +161,7 @@ struct cxacru_data { | |||
160 | struct work_struct poll_work; | 161 | struct work_struct poll_work; |
161 | 162 | ||
162 | /* contol handles */ | 163 | /* contol handles */ |
163 | struct semaphore cm_serialize; | 164 | struct mutex cm_serialize; |
164 | u8 *rcv_buf; | 165 | u8 *rcv_buf; |
165 | u8 *snd_buf; | 166 | u8 *snd_buf; |
166 | struct urb *rcv_urb; | 167 | struct urb *rcv_urb; |
@@ -219,7 +220,7 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm, | |||
219 | goto fail; | 220 | goto fail; |
220 | } | 221 | } |
221 | 222 | ||
222 | down(&instance->cm_serialize); | 223 | mutex_lock(&instance->cm_serialize); |
223 | 224 | ||
224 | /* submit reading urb before the writing one */ | 225 | /* submit reading urb before the writing one */ |
225 | init_completion(&instance->rcv_done); | 226 | init_completion(&instance->rcv_done); |
@@ -288,7 +289,7 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm, | |||
288 | ret = offd; | 289 | ret = offd; |
289 | dbg("cm %#x", cm); | 290 | dbg("cm %#x", cm); |
290 | fail: | 291 | fail: |
291 | up(&instance->cm_serialize); | 292 | mutex_unlock(&instance->cm_serialize); |
292 | return ret; | 293 | return ret; |
293 | } | 294 | } |
294 | 295 | ||
@@ -717,7 +718,7 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance, | |||
717 | instance->snd_buf, PAGE_SIZE, | 718 | instance->snd_buf, PAGE_SIZE, |
718 | cxacru_blocking_completion, &instance->snd_done, 4); | 719 | cxacru_blocking_completion, &instance->snd_done, 4); |
719 | 720 | ||
720 | init_MUTEX(&instance->cm_serialize); | 721 | mutex_init(&instance->cm_serialize); |
721 | 722 | ||
722 | INIT_WORK(&instance->poll_work, (void *)cxacru_poll_status, instance); | 723 | INIT_WORK(&instance->poll_work, (void *)cxacru_poll_status, instance); |
723 | 724 | ||
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index 956cd9e82dee..4362cfd801b5 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c | |||
@@ -63,6 +63,7 @@ | |||
63 | #include <linux/ctype.h> | 63 | #include <linux/ctype.h> |
64 | #include <linux/kthread.h> | 64 | #include <linux/kthread.h> |
65 | #include <linux/version.h> | 65 | #include <linux/version.h> |
66 | #include <linux/mutex.h> | ||
66 | #include <asm/unaligned.h> | 67 | #include <asm/unaligned.h> |
67 | 68 | ||
68 | #include "usbatm.h" | 69 | #include "usbatm.h" |
@@ -358,7 +359,7 @@ struct intr_pkt { | |||
358 | #define INTR_PKT_SIZE 28 | 359 | #define INTR_PKT_SIZE 28 |
359 | 360 | ||
360 | static struct usb_driver uea_driver; | 361 | static struct usb_driver uea_driver; |
361 | static DECLARE_MUTEX(uea_semaphore); | 362 | static DEFINE_MUTEX(uea_mutex); |
362 | static const char *chip_name[] = {"ADI930", "Eagle I", "Eagle II", "Eagle III"}; | 363 | static const char *chip_name[] = {"ADI930", "Eagle I", "Eagle II", "Eagle III"}; |
363 | 364 | ||
364 | static int modem_index; | 365 | static int modem_index; |
@@ -1418,13 +1419,13 @@ static ssize_t read_status(struct device *dev, struct device_attribute *attr, | |||
1418 | int ret = -ENODEV; | 1419 | int ret = -ENODEV; |
1419 | struct uea_softc *sc; | 1420 | struct uea_softc *sc; |
1420 | 1421 | ||
1421 | down(&uea_semaphore); | 1422 | mutex_lock(&uea_mutex); |
1422 | sc = dev_to_uea(dev); | 1423 | sc = dev_to_uea(dev); |
1423 | if (!sc) | 1424 | if (!sc) |
1424 | goto out; | 1425 | goto out; |
1425 | ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.state); | 1426 | ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.state); |
1426 | out: | 1427 | out: |
1427 | up(&uea_semaphore); | 1428 | mutex_unlock(&uea_mutex); |
1428 | return ret; | 1429 | return ret; |
1429 | } | 1430 | } |
1430 | 1431 | ||
@@ -1434,14 +1435,14 @@ static ssize_t reboot(struct device *dev, struct device_attribute *attr, | |||
1434 | int ret = -ENODEV; | 1435 | int ret = -ENODEV; |
1435 | struct uea_softc *sc; | 1436 | struct uea_softc *sc; |
1436 | 1437 | ||
1437 | down(&uea_semaphore); | 1438 | mutex_lock(&uea_mutex); |
1438 | sc = dev_to_uea(dev); | 1439 | sc = dev_to_uea(dev); |
1439 | if (!sc) | 1440 | if (!sc) |
1440 | goto out; | 1441 | goto out; |
1441 | sc->reset = 1; | 1442 | sc->reset = 1; |
1442 | ret = count; | 1443 | ret = count; |
1443 | out: | 1444 | out: |
1444 | up(&uea_semaphore); | 1445 | mutex_unlock(&uea_mutex); |
1445 | return ret; | 1446 | return ret; |
1446 | } | 1447 | } |
1447 | 1448 | ||
@@ -1453,7 +1454,7 @@ static ssize_t read_human_status(struct device *dev, struct device_attribute *at | |||
1453 | int ret = -ENODEV; | 1454 | int ret = -ENODEV; |
1454 | struct uea_softc *sc; | 1455 | struct uea_softc *sc; |
1455 | 1456 | ||
1456 | down(&uea_semaphore); | 1457 | mutex_lock(&uea_mutex); |
1457 | sc = dev_to_uea(dev); | 1458 | sc = dev_to_uea(dev); |
1458 | if (!sc) | 1459 | if (!sc) |
1459 | goto out; | 1460 | goto out; |
@@ -1473,7 +1474,7 @@ static ssize_t read_human_status(struct device *dev, struct device_attribute *at | |||
1473 | break; | 1474 | break; |
1474 | } | 1475 | } |
1475 | out: | 1476 | out: |
1476 | up(&uea_semaphore); | 1477 | mutex_unlock(&uea_mutex); |
1477 | return ret; | 1478 | return ret; |
1478 | } | 1479 | } |
1479 | 1480 | ||
@@ -1485,7 +1486,7 @@ static ssize_t read_delin(struct device *dev, struct device_attribute *attr, | |||
1485 | int ret = -ENODEV; | 1486 | int ret = -ENODEV; |
1486 | struct uea_softc *sc; | 1487 | struct uea_softc *sc; |
1487 | 1488 | ||
1488 | down(&uea_semaphore); | 1489 | mutex_lock(&uea_mutex); |
1489 | sc = dev_to_uea(dev); | 1490 | sc = dev_to_uea(dev); |
1490 | if (!sc) | 1491 | if (!sc) |
1491 | goto out; | 1492 | goto out; |
@@ -1497,7 +1498,7 @@ static ssize_t read_delin(struct device *dev, struct device_attribute *attr, | |||
1497 | else | 1498 | else |
1498 | ret = sprintf(buf, "GOOD\n"); | 1499 | ret = sprintf(buf, "GOOD\n"); |
1499 | out: | 1500 | out: |
1500 | up(&uea_semaphore); | 1501 | mutex_unlock(&uea_mutex); |
1501 | return ret; | 1502 | return ret; |
1502 | } | 1503 | } |
1503 | 1504 | ||
@@ -1511,7 +1512,7 @@ static ssize_t read_##name(struct device *dev, \ | |||
1511 | int ret = -ENODEV; \ | 1512 | int ret = -ENODEV; \ |
1512 | struct uea_softc *sc; \ | 1513 | struct uea_softc *sc; \ |
1513 | \ | 1514 | \ |
1514 | down(&uea_semaphore); \ | 1515 | mutex_lock(&uea_mutex); \ |
1515 | sc = dev_to_uea(dev); \ | 1516 | sc = dev_to_uea(dev); \ |
1516 | if (!sc) \ | 1517 | if (!sc) \ |
1517 | goto out; \ | 1518 | goto out; \ |
@@ -1519,7 +1520,7 @@ static ssize_t read_##name(struct device *dev, \ | |||
1519 | if (reset) \ | 1520 | if (reset) \ |
1520 | sc->stats.phy.name = 0; \ | 1521 | sc->stats.phy.name = 0; \ |
1521 | out: \ | 1522 | out: \ |
1522 | up(&uea_semaphore); \ | 1523 | mutex_unlock(&uea_mutex); \ |
1523 | return ret; \ | 1524 | return ret; \ |
1524 | } \ | 1525 | } \ |
1525 | \ | 1526 | \ |
@@ -1737,9 +1738,9 @@ static void uea_disconnect(struct usb_interface *intf) | |||
1737 | * Pre-firmware device has one interface | 1738 | * Pre-firmware device has one interface |
1738 | */ | 1739 | */ |
1739 | if (usb->config->desc.bNumInterfaces != 1 && ifnum == 0) { | 1740 | if (usb->config->desc.bNumInterfaces != 1 && ifnum == 0) { |
1740 | down(&uea_semaphore); | 1741 | mutex_lock(&uea_mutex); |
1741 | usbatm_usb_disconnect(intf); | 1742 | usbatm_usb_disconnect(intf); |
1742 | up(&uea_semaphore); | 1743 | mutex_unlock(&uea_mutex); |
1743 | uea_info(usb, "ADSL device removed\n"); | 1744 | uea_info(usb, "ADSL device removed\n"); |
1744 | } | 1745 | } |
1745 | 1746 | ||
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c index 5d339af16248..c1211fc037d9 100644 --- a/drivers/usb/atm/usbatm.c +++ b/drivers/usb/atm/usbatm.c | |||
@@ -823,7 +823,7 @@ static int usbatm_atm_open(struct atm_vcc *vcc) | |||
823 | return -EINVAL; | 823 | return -EINVAL; |
824 | } | 824 | } |
825 | 825 | ||
826 | down(&instance->serialize); /* vs self, usbatm_atm_close, usbatm_usb_disconnect */ | 826 | mutex_lock(&instance->serialize); /* vs self, usbatm_atm_close, usbatm_usb_disconnect */ |
827 | 827 | ||
828 | if (instance->disconnected) { | 828 | if (instance->disconnected) { |
829 | atm_dbg(instance, "%s: disconnected!\n", __func__); | 829 | atm_dbg(instance, "%s: disconnected!\n", __func__); |
@@ -867,7 +867,7 @@ static int usbatm_atm_open(struct atm_vcc *vcc) | |||
867 | set_bit(ATM_VF_PARTIAL, &vcc->flags); | 867 | set_bit(ATM_VF_PARTIAL, &vcc->flags); |
868 | set_bit(ATM_VF_READY, &vcc->flags); | 868 | set_bit(ATM_VF_READY, &vcc->flags); |
869 | 869 | ||
870 | up(&instance->serialize); | 870 | mutex_unlock(&instance->serialize); |
871 | 871 | ||
872 | atm_dbg(instance, "%s: allocated vcc data 0x%p\n", __func__, new); | 872 | atm_dbg(instance, "%s: allocated vcc data 0x%p\n", __func__, new); |
873 | 873 | ||
@@ -875,7 +875,7 @@ static int usbatm_atm_open(struct atm_vcc *vcc) | |||
875 | 875 | ||
876 | fail: | 876 | fail: |
877 | kfree(new); | 877 | kfree(new); |
878 | up(&instance->serialize); | 878 | mutex_unlock(&instance->serialize); |
879 | return ret; | 879 | return ret; |
880 | } | 880 | } |
881 | 881 | ||
@@ -896,7 +896,7 @@ static void usbatm_atm_close(struct atm_vcc *vcc) | |||
896 | 896 | ||
897 | usbatm_cancel_send(instance, vcc); | 897 | usbatm_cancel_send(instance, vcc); |
898 | 898 | ||
899 | down(&instance->serialize); /* vs self, usbatm_atm_open, usbatm_usb_disconnect */ | 899 | mutex_lock(&instance->serialize); /* vs self, usbatm_atm_open, usbatm_usb_disconnect */ |
900 | 900 | ||
901 | tasklet_disable(&instance->rx_channel.tasklet); | 901 | tasklet_disable(&instance->rx_channel.tasklet); |
902 | if (instance->cached_vcc == vcc_data) { | 902 | if (instance->cached_vcc == vcc_data) { |
@@ -919,7 +919,7 @@ static void usbatm_atm_close(struct atm_vcc *vcc) | |||
919 | clear_bit(ATM_VF_PARTIAL, &vcc->flags); | 919 | clear_bit(ATM_VF_PARTIAL, &vcc->flags); |
920 | clear_bit(ATM_VF_ADDR, &vcc->flags); | 920 | clear_bit(ATM_VF_ADDR, &vcc->flags); |
921 | 921 | ||
922 | up(&instance->serialize); | 922 | mutex_unlock(&instance->serialize); |
923 | 923 | ||
924 | atm_dbg(instance, "%s successful\n", __func__); | 924 | atm_dbg(instance, "%s successful\n", __func__); |
925 | } | 925 | } |
@@ -1009,9 +1009,9 @@ static int usbatm_do_heavy_init(void *arg) | |||
1009 | if (!ret) | 1009 | if (!ret) |
1010 | ret = usbatm_atm_init(instance); | 1010 | ret = usbatm_atm_init(instance); |
1011 | 1011 | ||
1012 | down(&instance->serialize); | 1012 | mutex_lock(&instance->serialize); |
1013 | instance->thread_pid = -1; | 1013 | instance->thread_pid = -1; |
1014 | up(&instance->serialize); | 1014 | mutex_unlock(&instance->serialize); |
1015 | 1015 | ||
1016 | complete_and_exit(&instance->thread_exited, ret); | 1016 | complete_and_exit(&instance->thread_exited, ret); |
1017 | } | 1017 | } |
@@ -1025,9 +1025,9 @@ static int usbatm_heavy_init(struct usbatm_data *instance) | |||
1025 | return ret; | 1025 | return ret; |
1026 | } | 1026 | } |
1027 | 1027 | ||
1028 | down(&instance->serialize); | 1028 | mutex_lock(&instance->serialize); |
1029 | instance->thread_pid = ret; | 1029 | instance->thread_pid = ret; |
1030 | up(&instance->serialize); | 1030 | mutex_unlock(&instance->serialize); |
1031 | 1031 | ||
1032 | wait_for_completion(&instance->thread_started); | 1032 | wait_for_completion(&instance->thread_started); |
1033 | 1033 | ||
@@ -1110,7 +1110,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id, | |||
1110 | /* private fields */ | 1110 | /* private fields */ |
1111 | 1111 | ||
1112 | kref_init(&instance->refcount); /* dropped in usbatm_usb_disconnect */ | 1112 | kref_init(&instance->refcount); /* dropped in usbatm_usb_disconnect */ |
1113 | init_MUTEX(&instance->serialize); | 1113 | mutex_init(&instance->serialize); |
1114 | 1114 | ||
1115 | instance->thread_pid = -1; | 1115 | instance->thread_pid = -1; |
1116 | init_completion(&instance->thread_started); | 1116 | init_completion(&instance->thread_started); |
@@ -1273,18 +1273,18 @@ void usbatm_usb_disconnect(struct usb_interface *intf) | |||
1273 | 1273 | ||
1274 | usb_set_intfdata(intf, NULL); | 1274 | usb_set_intfdata(intf, NULL); |
1275 | 1275 | ||
1276 | down(&instance->serialize); | 1276 | mutex_lock(&instance->serialize); |
1277 | instance->disconnected = 1; | 1277 | instance->disconnected = 1; |
1278 | if (instance->thread_pid >= 0) | 1278 | if (instance->thread_pid >= 0) |
1279 | kill_proc(instance->thread_pid, SIGTERM, 1); | 1279 | kill_proc(instance->thread_pid, SIGTERM, 1); |
1280 | up(&instance->serialize); | 1280 | mutex_unlock(&instance->serialize); |
1281 | 1281 | ||
1282 | wait_for_completion(&instance->thread_exited); | 1282 | wait_for_completion(&instance->thread_exited); |
1283 | 1283 | ||
1284 | down(&instance->serialize); | 1284 | mutex_lock(&instance->serialize); |
1285 | list_for_each_entry(vcc_data, &instance->vcc_list, list) | 1285 | list_for_each_entry(vcc_data, &instance->vcc_list, list) |
1286 | vcc_release_async(vcc_data->vcc, -EPIPE); | 1286 | vcc_release_async(vcc_data->vcc, -EPIPE); |
1287 | up(&instance->serialize); | 1287 | mutex_unlock(&instance->serialize); |
1288 | 1288 | ||
1289 | tasklet_disable(&instance->rx_channel.tasklet); | 1289 | tasklet_disable(&instance->rx_channel.tasklet); |
1290 | tasklet_disable(&instance->tx_channel.tasklet); | 1290 | tasklet_disable(&instance->tx_channel.tasklet); |
diff --git a/drivers/usb/atm/usbatm.h b/drivers/usb/atm/usbatm.h index 1cf4767007de..ff8551e93372 100644 --- a/drivers/usb/atm/usbatm.h +++ b/drivers/usb/atm/usbatm.h | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/list.h> | 34 | #include <linux/list.h> |
35 | #include <linux/stringify.h> | 35 | #include <linux/stringify.h> |
36 | #include <linux/usb.h> | 36 | #include <linux/usb.h> |
37 | #include <linux/mutex.h> | ||
37 | 38 | ||
38 | /* | 39 | /* |
39 | #define VERBOSE_DEBUG | 40 | #define VERBOSE_DEBUG |
@@ -171,7 +172,7 @@ struct usbatm_data { | |||
171 | ********************************/ | 172 | ********************************/ |
172 | 173 | ||
173 | struct kref refcount; | 174 | struct kref refcount; |
174 | struct semaphore serialize; | 175 | struct mutex serialize; |
175 | int disconnected; | 176 | int disconnected; |
176 | 177 | ||
177 | /* heavy init */ | 178 | /* heavy init */ |