uterm: vt: add helpers to (de)activate all VTs at once
Two new helpers to activate or deactivate all VTs at once. They return the total count of VT switches that are pending or an error code. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
a24b2e5478
commit
3b07517b13
@ -335,6 +335,9 @@ int uterm_vt_master_new(struct uterm_vt_master **out,
|
||||
void uterm_vt_master_ref(struct uterm_vt_master *vtm);
|
||||
void uterm_vt_master_unref(struct uterm_vt_master *vtm);
|
||||
|
||||
int uterm_vt_master_activate_all(struct uterm_vt_master *vtm);
|
||||
int uterm_vt_master_deactivate_all(struct uterm_vt_master *vtm);
|
||||
|
||||
int uterm_vt_allocate(struct uterm_vt_master *vt, struct uterm_vt **out,
|
||||
const char *seat, struct uterm_input *input,
|
||||
const char *vt_for_seat0, uterm_vt_cb cb, void *data);
|
||||
|
@ -658,3 +658,53 @@ void uterm_vt_master_unref(struct uterm_vt_master *vtm)
|
||||
ev_eloop_unref(vtm->eloop);
|
||||
free(vtm);
|
||||
}
|
||||
|
||||
int uterm_vt_master_activate_all(struct uterm_vt_master *vtm)
|
||||
{
|
||||
struct uterm_vt *vt;
|
||||
struct shl_dlist *iter;
|
||||
int ret, res = 0;
|
||||
unsigned int in_progress = 0;
|
||||
|
||||
if (!vtm)
|
||||
return -EINVAL;
|
||||
|
||||
shl_dlist_for_each(iter, &vtm->vts) {
|
||||
vt = shl_dlist_entry(iter, struct uterm_vt, list);
|
||||
ret = uterm_vt_activate(vt);
|
||||
if (ret == -EINPROGRESS)
|
||||
in_progress++;
|
||||
else if (ret)
|
||||
res = ret;
|
||||
}
|
||||
|
||||
if (in_progress)
|
||||
return in_progress;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int uterm_vt_master_deactivate_all(struct uterm_vt_master *vtm)
|
||||
{
|
||||
struct uterm_vt *vt;
|
||||
struct shl_dlist *iter;
|
||||
int ret, res = 0;
|
||||
unsigned int in_progress = 0;
|
||||
|
||||
if (!vtm)
|
||||
return -EINVAL;
|
||||
|
||||
shl_dlist_for_each(iter, &vtm->vts) {
|
||||
vt = shl_dlist_entry(iter, struct uterm_vt, list);
|
||||
ret = uterm_vt_deactivate(vt);
|
||||
if (ret == -EINPROGRESS)
|
||||
in_progress++;
|
||||
else if (ret)
|
||||
res = ret;
|
||||
}
|
||||
|
||||
if (in_progress)
|
||||
return in_progress;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user