srmcons_do_write(struct tty_port *port, const char *buf, int count)
 {
        static char str_cr[1] = "\r";
-       long c, remaining = count;
+       size_t c;
        srmcons_result result;
        int need_cr;
 
-       while (remaining > 0) {
+       while (count > 0) {
                need_cr = 0;
                /* 
                 * Break it up into reasonable size chunks to allow a chance
                 * for input to get in
                 */
-               for (c = 0; c < min_t(long, 128L, remaining) && !need_cr; c++)
+               for (c = 0; c < min_t(size_t, 128U, count) && !need_cr; c++)
                        if (buf[c] == '\n')
                                need_cr = 1;
                
                while (c > 0) {
                        result.as_long = callback_puts(0, buf, c);
                        c -= result.bits.c;
-                       remaining -= result.bits.c;
+                       count -= result.bits.c;
                        buf += result.bits.c;
 
                        /*