Use down_interruptible() wherever possible.
authorFlorian Pose <fp@igh-essen.com>
Fri, 01 Aug 2008 12:46:26 +0000
changeset 1189 acc6430bfb32
parent 1188 3b4e82d9904b
child 1190 5f2e38dddd4e
Use down_interruptible() wherever possible.
TODO
master/cdev.c
master/module.c
--- a/TODO	Fri Aug 01 12:32:53 2008 +0000
+++ b/TODO	Fri Aug 01 12:46:26 2008 +0000
@@ -10,7 +10,6 @@
 
 * Update documentation.
 * Check for possible race condition in jiffy-based frame timeout calculation.
-* Use down_interruptible() for cdev calls.
 
 Future issues:
 
--- a/master/cdev.c	Fri Aug 01 12:32:53 2008 +0000
+++ b/master/cdev.c	Fri Aug 01 12:46:26 2008 +0000
@@ -127,14 +127,16 @@
 {
     ec_ioctl_master_t data;
 
-    down(&master->master_sem);
+    if (down_interruptible(&master->master_sem))
+        return -EINTR;
     data.slave_count = master->slave_count;
     data.config_count = ec_master_config_count(master);
     data.domain_count = ec_master_domain_count(master);
     data.phase = (uint8_t) master->phase;
     up(&master->master_sem);
 
-    down(&master->device_sem);
+    if (down_interruptible(&master->device_sem))
+        return -EINTR;
     if (master->main_device.dev) {
         memcpy(data.devices[0].address,
                 master->main_device.dev->dev_addr, ETH_ALEN);
@@ -178,7 +180,8 @@
         return -EFAULT;
     }
 
-    down(&master->master_sem);
+    if (down_interruptible(&master->master_sem))
+        return -EINTR;
 
     if (!(slave = ec_master_find_slave_const(
                     master, 0, data.position))) {
@@ -237,7 +240,8 @@
         return -EFAULT;
     }
 
-    down(&master->master_sem);
+    if (down_interruptible(&master->master_sem))
+        return -EINTR;
 
     if (!(slave = ec_master_find_slave_const(
                     master, 0, data.slave_position))) {
@@ -287,7 +291,8 @@
         return -EFAULT;
     }
 
-    down(&master->master_sem);
+    if (down_interruptible(&master->master_sem))
+        return -EINTR;
 
     if (!(slave = ec_master_find_slave_const(
                     master, 0, data.slave_position))) {
@@ -344,7 +349,8 @@
         return -EFAULT;
     }
 
-    down(&master->master_sem);
+    if (down_interruptible(&master->master_sem))
+        return -EINTR;
 
     if (!(slave = ec_master_find_slave_const(
                     master, 0, data.slave_position))) {
@@ -408,7 +414,8 @@
         return -EFAULT;
     }
 
-    down(&master->master_sem);
+    if (down_interruptible(&master->master_sem))
+        return -EINTR;
 
     if (!(domain = ec_master_find_domain_const(master, data.index))) {
         up(&master->master_sem);
@@ -447,7 +454,8 @@
         return -EFAULT;
     }
 
-    down(&master->master_sem);
+    if (down_interruptible(&master->master_sem))
+        return -EINTR;
 
     if (!(domain = ec_master_find_domain_const(master, data.domain_index))) {
         up(&master->master_sem);
@@ -493,7 +501,8 @@
         return -EFAULT;
     }
 
-    down(&master->master_sem);
+    if (down_interruptible(&master->master_sem))
+        return -EINTR;
 
     if (!(domain = ec_master_find_domain_const(master, data.domain_index))) {
         up(&master->master_sem);
@@ -547,7 +556,8 @@
         return -EFAULT;
     }
 
-    down(&master->master_sem);
+    if (down_interruptible(&master->master_sem))
+        return -EINTR;
 
     if (!(slave = ec_master_find_slave(
                     master, 0, data.slave_position))) {
@@ -578,7 +588,8 @@
         return -EFAULT;
     }
 
-    down(&master->master_sem);
+    if (down_interruptible(&master->master_sem))
+        return -EINTR;
 
     if (!(slave = ec_master_find_slave_const(
                     master, 0, data.slave_position))) {
@@ -625,7 +636,8 @@
         return -EFAULT;
     }
 
-    down(&master->master_sem);
+    if (down_interruptible(&master->master_sem))
+        return -EINTR;
 
     if (!(slave = ec_master_find_slave_const(
                     master, 0, data.slave_position))) {
@@ -695,7 +707,8 @@
             data.sdo_index, data.sdo_entry_subindex);
     ecrt_sdo_request_read(&request.req);
 
-    down(&master->master_sem);
+    if (down_interruptible(&master->master_sem))
+        return -EINTR;
 
     if (!(request.slave = ec_master_find_slave(
                     master, 0, data.slave_position))) {
@@ -796,7 +809,8 @@
     ecrt_sdo_request_write(&request.req);
 
 
-    down(&master->master_sem);
+    if (down_interruptible(&master->master_sem))
+        return -EINTR;
 
     if (!(request.slave = ec_master_find_slave(
                     master, 0, data.slave_position))) {
@@ -858,7 +872,8 @@
         return -EFAULT;
     }
 
-    down(&master->master_sem);
+    if (down_interruptible(&master->master_sem))
+        return -EINTR;
 
     if (!(slave = ec_master_find_slave_const(
                     master, 0, data.slave_position))) {
@@ -921,7 +936,8 @@
         return -EFAULT;
     }
 
-    down(&master->master_sem);
+    if (down_interruptible(&master->master_sem))
+        return -EINTR;
 
     if (!(slave = ec_master_find_slave(
                     master, 0, data.slave_position))) {
@@ -984,7 +1000,8 @@
         return -EFAULT;
     }
 
-    down(&master->master_sem);
+    if (down_interruptible(&master->master_sem))
+        return -EINTR;
 
     if (!(sc = ec_master_get_config_const(
                     master, data.config_index))) {
@@ -1037,7 +1054,8 @@
         return -EINVAL;
     }
 
-    down(&master->master_sem);
+    if (down_interruptible(&master->master_sem))
+        return -EINTR;
 
     if (!(sc = ec_master_get_config_const(
                     master, data.config_index))) {
@@ -1091,7 +1109,8 @@
         return -EINVAL;
     }
 
-    down(&master->master_sem);
+    if (down_interruptible(&master->master_sem))
+        return -EINTR;
 
     if (!(sc = ec_master_get_config_const(
                     master, data.config_index))) {
@@ -1146,7 +1165,8 @@
         return -EFAULT;
     }
 
-    down(&master->master_sem);
+    if (down_interruptible(&master->master_sem))
+        return -EINTR;
 
     if (!(sc = ec_master_get_config_const(
                     master, data.config_index))) {
--- a/master/module.c	Fri Aug 01 12:32:53 2008 +0000
+++ b/master/module.c	Fri Aug 01 12:46:26 2008 +0000
@@ -473,7 +473,9 @@
     }
     master = &masters[master_index];
 
-    down(&master_sem);
+    if (down_interruptible(&master_sem))
+        goto out_return;
+
     if (master->reserved) {
         up(&master_sem);
         EC_ERR("Master %u is already in use!\n", master_index);
@@ -482,7 +484,8 @@
     master->reserved = 1;
     up(&master_sem);
 
-    down(&master->device_sem);
+    if (down_interruptible(&master->device_sem))
+        goto out_release;
     
     if (master->phase != EC_IDLE) {
         up(&master->device_sem);