Re: [RFC 1/1] Char: tty, add io tty_insert_flip_string variants
Alan Cox napsal(a): > On Thu, 19 Apr 2007 00:35:20 +0200 (CEST) > Jiri Slaby <[EMAIL PROTECTED]> wrote: > >> Hi, >> >> don't you consider this useful for some drivers. There are many cases, when >> tty_insert_flip_stringio might be used. > > I couldn't see anyone who really benefitted when I first looked at this > but if you've got a case you want to use them then I've certainly got no > problem with it. Ah, I'm an idiot -- I should go through the code more carefully, tty_prepare_flip_string + memcpy_fromio can do the job. thanks, -- http://www.fi.muni.cz/~xslaby/Jiri Slaby faculty of informatics, masaryk university, brno, cz e-mail: jirislaby gmail com, gpg pubkey fingerprint: B674 9967 0407 CE62 ACC8 22A0 32CC 55C3 39D4 7A7E - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC 1/1] Char: tty, add io tty_insert_flip_string variants
On Thu, 19 Apr 2007 00:35:20 +0200 (CEST) Jiri Slaby <[EMAIL PROTECTED]> wrote: > Hi, > > don't you consider this useful for some drivers. There are many cases, when > tty_insert_flip_stringio might be used. I couldn't see anyone who really benefitted when I first looked at this but if you've got a case you want to use them then I've certainly got no problem with it. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC 1/1] Char: tty, add io tty_insert_flip_string variants
Hi, don't you consider this useful for some drivers. There are many cases, when tty_insert_flip_stringio might be used. -- tty, add io tty_insert_flip_string variants Signed-off-by: Jiri Slaby <[EMAIL PROTECTED]> --- commit a7dafceb31ff535b793227036f5b2b6a1e8cf233 tree 51e1bd24bfb9a2842bb12e097cec0b97a7bf3998 parent 71c2e9b72594f69e4e226006206ffa74b55c1642 author Jiri Slaby <[EMAIL PROTECTED]> Thu, 19 Apr 2007 00:27:22 +0200 committer Jiri Slaby <[EMAIL PROTECTED]> Thu, 19 Apr 2007 00:27:22 +0200 drivers/char/tty_io.c | 101 --- 1 file changed, 69 insertions(+), 32 deletions(-) diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 959a616..6b215ed 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -95,6 +95,7 @@ #include #include +#include #include #include @@ -441,6 +442,25 @@ int tty_buffer_request_room(struct tty_struct *tty, size_t size) } EXPORT_SYMBOL_GPL(tty_buffer_request_room); +#define __tty_insert_flip_string(tty, chars, flags, size, chrfun, flfun) ({ \ + int copied = 0; \ + do {\ + int space = tty_buffer_request_room(tty, size - copied);\ + struct tty_buffer *tb = tty->buf.tail; \ + /* If there is no space then tb may be NULL */ \ + if (unlikely(space == 0)) \ + break; \ + chrfun(tb->char_buf_ptr + tb->used, chars, space); \ + flfun(tb->flag_buf_ptr + tb->used, flags, space); \ + tb->used += space; \ + copied += space;\ + chars += space; \ + /* There is a small chance that we need to split the data over \ + several buffers. If this is the case we must loop */ \ + } while (unlikely(size > copied)); \ + copied; \ +}) + /** * tty_insert_flip_string - Add characters to the tty buffer * @tty: tty structure @@ -456,26 +476,33 @@ EXPORT_SYMBOL_GPL(tty_buffer_request_room); int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size) { - int copied = 0; - do { - int space = tty_buffer_request_room(tty, size - copied); - struct tty_buffer *tb = tty->buf.tail; - /* If there is no space then tb may be NULL */ - if(unlikely(space == 0)) - break; - memcpy(tb->char_buf_ptr + tb->used, chars, space); - memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space); - tb->used += space; - copied += space; - chars += space; - /* There is a small chance that we need to split the data over - several buffers. If this is the case we must loop */ - } while (unlikely(size > copied)); - return copied; + return __tty_insert_flip_string(tty, chars, TTY_NORMAL, size, + memcpy, memset); } EXPORT_SYMBOL(tty_insert_flip_string); /** + * tty_insert_flip_stringio- Add characters to the tty buffer + * @tty: tty structure + * @chars: characters + * @size: size + * + * Queue a series of bytes to the tty buffering from io memory. All the + * characters passed are marked as without error. Returns the number + * added. + * + * Locking: Called functions may take tty->buf.lock + */ + +int tty_insert_flip_stringio(struct tty_struct *tty, + const unsigned char __iomem *chars, size_t size) +{ + return __tty_insert_flip_string(tty, chars, TTY_NORMAL, size, + memcpy_fromio, memset); +} +EXPORT_SYMBOL(tty_insert_flip_stringio); + +/** * tty_insert_flip_string_flags- Add characters to the tty buffer * @tty: tty structure * @chars: characters @@ -492,27 +519,35 @@ EXPORT_SYMBOL(tty_insert_flip_string); int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size) { - int copied = 0; - do { - int space = tty_buffer_request_room(tty, size - copied); - struct tty_buffer *tb = tty->buf.tail; - /* If there is no space then tb may be NULL */ - if(unlikely(space == 0)) - break; - memcpy(tb->char_buf_ptr + tb->used, chars, space); - memcpy(tb->flag_buf_ptr + tb->used, flags, space); - tb->used += space; -
[RFC 1/1] Char: tty, add io tty_insert_flip_string variants
Hi, don't you consider this useful for some drivers. There are many cases, when tty_insert_flip_stringio might be used. -- tty, add io tty_insert_flip_string variants Signed-off-by: Jiri Slaby [EMAIL PROTECTED] --- commit a7dafceb31ff535b793227036f5b2b6a1e8cf233 tree 51e1bd24bfb9a2842bb12e097cec0b97a7bf3998 parent 71c2e9b72594f69e4e226006206ffa74b55c1642 author Jiri Slaby [EMAIL PROTECTED] Thu, 19 Apr 2007 00:27:22 +0200 committer Jiri Slaby [EMAIL PROTECTED] Thu, 19 Apr 2007 00:27:22 +0200 drivers/char/tty_io.c | 101 --- 1 file changed, 69 insertions(+), 32 deletions(-) diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 959a616..6b215ed 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -95,6 +95,7 @@ #include linux/bitops.h #include linux/delay.h +#include asm/io.h #include asm/uaccess.h #include asm/system.h @@ -441,6 +442,25 @@ int tty_buffer_request_room(struct tty_struct *tty, size_t size) } EXPORT_SYMBOL_GPL(tty_buffer_request_room); +#define __tty_insert_flip_string(tty, chars, flags, size, chrfun, flfun) ({ \ + int copied = 0; \ + do {\ + int space = tty_buffer_request_room(tty, size - copied);\ + struct tty_buffer *tb = tty-buf.tail; \ + /* If there is no space then tb may be NULL */ \ + if (unlikely(space == 0)) \ + break; \ + chrfun(tb-char_buf_ptr + tb-used, chars, space); \ + flfun(tb-flag_buf_ptr + tb-used, flags, space); \ + tb-used += space; \ + copied += space;\ + chars += space; \ + /* There is a small chance that we need to split the data over \ + several buffers. If this is the case we must loop */ \ + } while (unlikely(size copied)); \ + copied; \ +}) + /** * tty_insert_flip_string - Add characters to the tty buffer * @tty: tty structure @@ -456,26 +476,33 @@ EXPORT_SYMBOL_GPL(tty_buffer_request_room); int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size) { - int copied = 0; - do { - int space = tty_buffer_request_room(tty, size - copied); - struct tty_buffer *tb = tty-buf.tail; - /* If there is no space then tb may be NULL */ - if(unlikely(space == 0)) - break; - memcpy(tb-char_buf_ptr + tb-used, chars, space); - memset(tb-flag_buf_ptr + tb-used, TTY_NORMAL, space); - tb-used += space; - copied += space; - chars += space; - /* There is a small chance that we need to split the data over - several buffers. If this is the case we must loop */ - } while (unlikely(size copied)); - return copied; + return __tty_insert_flip_string(tty, chars, TTY_NORMAL, size, + memcpy, memset); } EXPORT_SYMBOL(tty_insert_flip_string); /** + * tty_insert_flip_stringio- Add characters to the tty buffer + * @tty: tty structure + * @chars: characters + * @size: size + * + * Queue a series of bytes to the tty buffering from io memory. All the + * characters passed are marked as without error. Returns the number + * added. + * + * Locking: Called functions may take tty-buf.lock + */ + +int tty_insert_flip_stringio(struct tty_struct *tty, + const unsigned char __iomem *chars, size_t size) +{ + return __tty_insert_flip_string(tty, chars, TTY_NORMAL, size, + memcpy_fromio, memset); +} +EXPORT_SYMBOL(tty_insert_flip_stringio); + +/** * tty_insert_flip_string_flags- Add characters to the tty buffer * @tty: tty structure * @chars: characters @@ -492,27 +519,35 @@ EXPORT_SYMBOL(tty_insert_flip_string); int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size) { - int copied = 0; - do { - int space = tty_buffer_request_room(tty, size - copied); - struct tty_buffer *tb = tty-buf.tail; - /* If there is no space then tb may be NULL */ - if(unlikely(space == 0)) - break; - memcpy(tb-char_buf_ptr + tb-used, chars, space); - memcpy(tb-flag_buf_ptr + tb-used, flags, space); -
Re: [RFC 1/1] Char: tty, add io tty_insert_flip_string variants
On Thu, 19 Apr 2007 00:35:20 +0200 (CEST) Jiri Slaby [EMAIL PROTECTED] wrote: Hi, don't you consider this useful for some drivers. There are many cases, when tty_insert_flip_stringio might be used. I couldn't see anyone who really benefitted when I first looked at this but if you've got a case you want to use them then I've certainly got no problem with it. - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC 1/1] Char: tty, add io tty_insert_flip_string variants
Alan Cox napsal(a): On Thu, 19 Apr 2007 00:35:20 +0200 (CEST) Jiri Slaby [EMAIL PROTECTED] wrote: Hi, don't you consider this useful for some drivers. There are many cases, when tty_insert_flip_stringio might be used. I couldn't see anyone who really benefitted when I first looked at this but if you've got a case you want to use them then I've certainly got no problem with it. Ah, I'm an idiot -- I should go through the code more carefully, tty_prepare_flip_string + memcpy_fromio can do the job. thanks, -- http://www.fi.muni.cz/~xslaby/Jiri Slaby faculty of informatics, masaryk university, brno, cz e-mail: jirislaby gmail com, gpg pubkey fingerprint: B674 9967 0407 CE62 ACC8 22A0 32CC 55C3 39D4 7A7E - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/