/* * userio kernel serio device emulation module * Copyright (C) 2015 Red Hat * Copyright (C) 2015 Stephen Chandler Paul <thatslyude@gmail.com> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details.
*/
/** * userio_device_write - Write data from serio to a userio device in userspace * @id: The serio port for the userio device * @val: The data to write to the device
*/ staticint userio_device_write(struct serio *id, unsignedchar val)
{ struct userio_device *userio = id->port_data;
if (userio->running) { /* * Don't free the serio port here, serio_unregister_port() * does it for us.
*/
serio_unregister_port(userio->serio);
} else {
kfree(userio->serio);
}
if (copylen) if (copy_to_user(user_buffer, buf, copylen)) return -EFAULT;
return copylen;
}
staticint userio_execute_cmd(struct userio_device *userio, conststruct userio_cmd *cmd)
{ switch (cmd->type) { case USERIO_CMD_REGISTER: if (!userio->serio->id.type) {
dev_warn(userio_misc.this_device, "No port type given on /dev/userio\n"); return -EINVAL;
}
if (userio->running) {
dev_warn(userio_misc.this_device, "Begin command sent, but we're already running\n"); return -EBUSY;
}
case USERIO_CMD_SET_PORT_TYPE: if (userio->running) {
dev_warn(userio_misc.this_device, "Can't change port type on an already running userio instance\n"); return -EBUSY;
}
userio->serio->id.type = cmd->data; break;
case USERIO_CMD_SEND_INTERRUPT: if (!userio->running) {
dev_warn(userio_misc.this_device, "The device must be registered before sending interrupts\n"); return -ENODEV;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.