Commit 81c7c0a3 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: serio - make write method mandatory

Given that all serio drivers except one implement write() method
let's make it mandatory to avoid testing for its presence whenever
we attempt to use it.

Link: https://lore.kernel.org/r/YFgUxG/TljMuVeQ3@google.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 9aa75914
...@@ -89,6 +89,11 @@ static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id) ...@@ -89,6 +89,11 @@ static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int ams_delta_serio_write(struct serio *serio, u8 data)
{
return -EINVAL;
}
static int ams_delta_serio_open(struct serio *serio) static int ams_delta_serio_open(struct serio *serio)
{ {
struct ams_delta_serio *priv = serio->port_data; struct ams_delta_serio *priv = serio->port_data;
...@@ -157,6 +162,7 @@ static int ams_delta_serio_init(struct platform_device *pdev) ...@@ -157,6 +162,7 @@ static int ams_delta_serio_init(struct platform_device *pdev)
priv->serio = serio; priv->serio = serio;
serio->id.type = SERIO_8042; serio->id.type = SERIO_8042;
serio->write = ams_delta_serio_write;
serio->open = ams_delta_serio_open; serio->open = ams_delta_serio_open;
serio->close = ams_delta_serio_close; serio->close = ams_delta_serio_close;
strlcpy(serio->name, "AMS DELTA keyboard adapter", sizeof(serio->name)); strlcpy(serio->name, "AMS DELTA keyboard adapter", sizeof(serio->name));
......
...@@ -694,6 +694,11 @@ EXPORT_SYMBOL(serio_reconnect); ...@@ -694,6 +694,11 @@ EXPORT_SYMBOL(serio_reconnect);
*/ */
void __serio_register_port(struct serio *serio, struct module *owner) void __serio_register_port(struct serio *serio, struct module *owner)
{ {
if (!serio->write) {
pr_err("%s: refusing to register %s without write method\n",
__func__, serio->name);
return;
}
serio_init_port(serio); serio_init_port(serio);
serio_queue_event(serio, owner, SERIO_REGISTER_PORT); serio_queue_event(serio, owner, SERIO_REGISTER_PORT);
} }
......
...@@ -121,10 +121,7 @@ void serio_unregister_driver(struct serio_driver *drv); ...@@ -121,10 +121,7 @@ void serio_unregister_driver(struct serio_driver *drv);
static inline int serio_write(struct serio *serio, unsigned char data) static inline int serio_write(struct serio *serio, unsigned char data)
{ {
if (serio->write) return serio->write(serio, data);
return serio->write(serio, data);
else
return -1;
} }
static inline void serio_drv_write_wakeup(struct serio *serio) static inline void serio_drv_write_wakeup(struct serio *serio)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment