/* Map for pending configure tasks. */
static enum cfg_task_t chp_cfg_task[__MAX_CSSID + 1][__MAX_CHPID + 1];
static DEFINE_SPINLOCK(cfg_lock);
-static int cfg_busy;
/* Map for channel-path status. */
static struct sclp_chp_info chp_info;
chp_cfg_task[chpid.cssid][chpid.id] = cfg;
}
+/* Fetch the first configure task. Set chpid accordingly. */
+static enum cfg_task_t chp_cfg_fetch_task(struct chp_id *chpid)
+{
+ enum cfg_task_t t = cfg_none;
+
+ chp_id_for_each(chpid) {
+ t = cfg_get_task(*chpid);
+ if (t != cfg_none)
+ break;
+ }
+
+ return t;
+}
+
/* Perform one configure/deconfigure request. Reschedule work function until
* last request. */
static void cfg_func(struct work_struct *work)
int rc;
spin_lock(&cfg_lock);
- t = cfg_none;
- chp_id_for_each(&chpid) {
- t = cfg_get_task(chpid);
- if (t != cfg_none) {
- cfg_set_task(chpid, cfg_none);
- break;
- }
- }
+ t = chp_cfg_fetch_task(&chpid);
spin_unlock(&cfg_lock);
switch (t) {
case cfg_none:
/* Get updated information after last change. */
info_update();
- spin_lock(&cfg_lock);
- cfg_busy = 0;
- spin_unlock(&cfg_lock);
wake_up_interruptible(&cfg_wait_queue);
return;
}
+ spin_lock(&cfg_lock);
+ if (t == cfg_get_task(chpid))
+ cfg_set_task(chpid, cfg_none);
+ spin_unlock(&cfg_lock);
schedule_work(&cfg_work);
}
configure);
spin_lock(&cfg_lock);
cfg_set_task(chpid, configure ? cfg_configure : cfg_deconfigure);
- cfg_busy = 1;
spin_unlock(&cfg_lock);
schedule_work(&cfg_work);
}
spin_unlock(&cfg_lock);
}
+static bool cfg_idle(void)
+{
+ struct chp_id chpid;
+ enum cfg_task_t t;
+
+ spin_lock(&cfg_lock);
+ t = chp_cfg_fetch_task(&chpid);
+ spin_unlock(&cfg_lock);
+
+ return t == cfg_none;
+}
+
static int cfg_wait_idle(void)
{
- if (wait_event_interruptible(cfg_wait_queue, !cfg_busy))
+ if (wait_event_interruptible(cfg_wait_queue, cfg_idle()))
return -ERESTARTSYS;
return 0;
}