]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/mmc/core/sdio_irq.c
sdio: make sleep on error interruptable
[linux-2.6-omap-h63xx.git] / drivers / mmc / core / sdio_irq.c
index f78ffeefed52618e56571e8de92a78daf4a4b7ed..722924cdf595b495dbad8f87fd0f5c7749cebc83 100644 (file)
@@ -5,6 +5,8 @@
  * Created:     June 18, 2007
  * Copyright:   MontaVista Software Inc.
  *
+ * Copyright 2008 Pierre Ossman
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at
@@ -44,17 +46,23 @@ static int process_sdio_pending_irqs(struct mmc_card *card)
                        if (!func) {
                                printk(KERN_WARNING "%s: pending IRQ for "
                                        "non-existant function\n",
-                                       sdio_func_id(func));
+                                       mmc_card_id(card));
+                               ret = -EINVAL;
                        } else if (func->irq_handler) {
                                func->irq_handler(func);
                                count++;
-                       } else
+                       } else {
                                printk(KERN_WARNING "%s: pending IRQ with no handler\n",
                                       sdio_func_id(func));
+                               ret = -EINVAL;
+                       }
                }
        }
 
-       return count;
+       if (count)
+               return count;
+
+       return ret;
 }
 
 static int sdio_irq_thread(void *_host)
@@ -101,11 +109,14 @@ static int sdio_irq_thread(void *_host)
 
                /*
                 * Give other threads a chance to run in the presence of
-                * errors.  FIXME: determine if due to card removal and
-                * possibly exit this thread if so.
+                * errors.
                 */
-               if (ret < 0)
-                       ssleep(1);
+               if (ret < 0) {
+                       set_current_state(TASK_INTERRUPTIBLE);
+                       if (!kthread_should_stop())
+                               schedule_timeout(HZ);
+                       set_current_state(TASK_RUNNING);
+               }
 
                /*
                 * Adaptive polling frequency based on the assumption
@@ -122,12 +133,12 @@ static int sdio_irq_thread(void *_host)
                        }
                }
 
-               set_task_state(current, TASK_INTERRUPTIBLE);
+               set_current_state(TASK_INTERRUPTIBLE);
                if (host->caps & MMC_CAP_SDIO_IRQ)
                        host->ops->enable_sdio_irq(host, 1);
                if (!kthread_should_stop())
                        schedule_timeout(period);
-               set_task_state(current, TASK_RUNNING);
+               set_current_state(TASK_RUNNING);
        } while (!kthread_should_stop());
 
        if (host->caps & MMC_CAP_SDIO_IRQ)