* [PATCH] Input: serio - add writing multiple bytes at once
@ 2018-04-30 9:03 David Engraf
2018-04-30 21:20 ` Dmitry Torokhov
0 siblings, 1 reply; 3+ messages in thread
From: David Engraf @ 2018-04-30 9:03 UTC (permalink / raw)
To: dmitry.torokhov; +Cc: linux-input, linux-kernel, David Engraf
The current version only supports forwarding a single byte to the tty
layer.
This patch adds serio_write_length() to allow a serport driver writing
multiple bytes at once. The patch also includes a fallback to
serio_write_length() when a driver did not register a single byte function.
Signed-off-by: David Engraf <david.engraf@sysgo.com>
---
drivers/input/serio/serport.c | 7 ++++---
include/linux/serio.h | 13 ++++++++++++-
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
index f8ead9f9c77e..209343f636a3 100644
--- a/drivers/input/serio/serport.c
+++ b/drivers/input/serio/serport.c
@@ -45,10 +45,11 @@ struct serport {
* Callback functions from the serio code.
*/
-static int serport_serio_write(struct serio *serio, unsigned char data)
+static int serport_serio_write_length(struct serio *serio,
+ const unsigned char *data, int count)
{
struct serport *serport = serio->port_data;
- return -(serport->tty->ops->write(serport->tty, &data, 1) != 1);
+ return -(serport->tty->ops->write(serport->tty, data, count) != count);
}
static int serport_serio_open(struct serio *serio)
@@ -176,7 +177,7 @@ static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, u
snprintf(serio->phys, sizeof(serio->phys), "%s/serio0", tty_name(tty));
serio->id = serport->id;
serio->id.type = SERIO_RS232;
- serio->write = serport_serio_write;
+ serio->write_length = serport_serio_write_length;
serio->open = serport_serio_open;
serio->close = serport_serio_close;
serio->port_data = serport;
diff --git a/include/linux/serio.h b/include/linux/serio.h
index 138a5efe863a..6f5cb92d0f22 100644
--- a/include/linux/serio.h
+++ b/include/linux/serio.h
@@ -35,6 +35,8 @@ struct serio {
spinlock_t lock;
int (*write)(struct serio *, unsigned char);
+ int (*write_length)(struct serio *serio, const unsigned char *data,
+ int count);
int (*open)(struct serio *);
void (*close)(struct serio *);
int (*start)(struct serio *);
@@ -122,12 +124,21 @@ void serio_unregister_driver(struct serio_driver *drv);
module_driver(__serio_driver, serio_register_driver, \
serio_unregister_driver)
+static inline int serio_write_length(struct serio *serio,
+ const unsigned char *data, int count)
+{
+ if (serio->write_length)
+ return serio->write_length(serio, data, count);
+ else
+ return -1;
+}
+
static inline int serio_write(struct serio *serio, unsigned char data)
{
if (serio->write)
return serio->write(serio, data);
else
- return -1;
+ return serio_write_length(serio, &data, 1);
}
static inline void serio_drv_write_wakeup(struct serio *serio)
--
2.14.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Input: serio - add writing multiple bytes at once
2018-04-30 9:03 [PATCH] Input: serio - add writing multiple bytes at once David Engraf
@ 2018-04-30 21:20 ` Dmitry Torokhov
2018-05-02 7:07 ` David Engraf
0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2018-04-30 21:20 UTC (permalink / raw)
To: David Engraf; +Cc: linux-input, linux-kernel
Hi David,
On Mon, Apr 30, 2018 at 11:03:24AM +0200, David Engraf wrote:
> The current version only supports forwarding a single byte to the tty
> layer.
>
> This patch adds serio_write_length() to allow a serport driver writing
> multiple bytes at once. The patch also includes a fallback to
> serio_write_length() when a driver did not register a single byte function.
Without users I do not see point for this API.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Input: serio - add writing multiple bytes at once
2018-04-30 21:20 ` Dmitry Torokhov
@ 2018-05-02 7:07 ` David Engraf
0 siblings, 0 replies; 3+ messages in thread
From: David Engraf @ 2018-05-02 7:07 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, linux-kernel
Hi Dmitry,
On 30.04.2018 at 23:20, Dmitry Torokhov wrote:
> Hi David,
>
> On Mon, Apr 30, 2018 at 11:03:24AM +0200, David Engraf wrote:
>> The current version only supports forwarding a single byte to the tty
>> layer.
>>
>> This patch adds serio_write_length() to allow a serport driver writing
>> multiple bytes at once. The patch also includes a fallback to
>> serio_write_length() when a driver did not register a single byte function.
>
> Without users I do not see point for this API.
Here is an incomplete list of drivers calling serio_write() in a loop:
- drivers/media/usb/rainshadow-cec/rainshadow-cec.c
- drivers/input/serio/serio_raw.c
- drivers/input/touchscreen/elo.c
I can simplify these drivers by using serio_write_length() if you want
to have some users for the new API.
Best regards
- David
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-02 7:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-30 9:03 [PATCH] Input: serio - add writing multiple bytes at once David Engraf
2018-04-30 21:20 ` Dmitry Torokhov
2018-05-02 7:07 ` David Engraf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.