Lines Matching +full:byte +full:- +full:len

1 // SPDX-License-Identifier: GPL-2.0
2 /* IEEE-1284 operations for parport.
5 * they are used by the low-level drivers. If they have a special way
7 * the function pointers in port->ops); if not, they can just use these
31 * One-way data transfer functions. *
36 const void *buffer, size_t len, in parport_ieee1284_write_compat() argument
42 unsigned char byte; in parport_ieee1284_write_compat() local
43 struct pardevice *dev = port->physport->cad; in parport_ieee1284_write_compat()
47 if (port->irq != PARPORT_IRQ_NONE) { in parport_ieee1284_write_compat()
52 port->physport->ieee1284.phase = IEEE1284_PH_FWD_DATA; in parport_ieee1284_write_compat()
55 while (count < len) { in parport_ieee1284_write_compat()
56 unsigned long expire = jiffies + dev->timeout; in parport_ieee1284_write_compat()
112 pr_debug("%s: Timed out\n", port->name); in parport_ieee1284_write_compat()
117 byte = *addr++; in parport_ieee1284_write_compat()
118 parport_write_data (port, byte); in parport_ieee1284_write_compat()
138 port->physport->ieee1284.phase = IEEE1284_PH_FWD_IDLE; in parport_ieee1284_write_compat()
145 void *buffer, size_t len, in parport_ieee1284_read_nibble() argument
153 unsigned char byte = 0; in parport_ieee1284_read_nibble()
155 len *= 2; /* in nibbles */ in parport_ieee1284_read_nibble()
156 for (i=0; i < len; i++) { in parport_ieee1284_read_nibble()
171 port->ieee1284.phase = IEEE1284_PH_REV_DATA; in parport_ieee1284_read_nibble()
174 /* Timeout -- no more data? */ in parport_ieee1284_read_nibble()
176 port->name, i / 2); in parport_ieee1284_read_nibble()
196 /* Timeout -- no more data? */ in parport_ieee1284_read_nibble()
198 port->name); in parport_ieee1284_read_nibble()
204 byte |= nibble << 4; in parport_ieee1284_read_nibble()
205 *buf++ = byte; in parport_ieee1284_read_nibble()
207 byte = nibble; in parport_ieee1284_read_nibble()
210 if (i == len) { in parport_ieee1284_read_nibble()
215 port->name, i / 2); in parport_ieee1284_read_nibble()
221 port->physport->ieee1284.phase = IEEE1284_PH_REV_IDLE; in parport_ieee1284_read_nibble()
224 port->physport->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL; in parport_ieee1284_read_nibble()
231 /* Byte mode. */
233 void *buffer, size_t len, in parport_ieee1284_read_byte() argument
242 for (count = 0; count < len; count++) { in parport_ieee1284_read_byte()
243 unsigned char byte; in parport_ieee1284_read_byte()
259 port->physport->ieee1284.phase = IEEE1284_PH_REV_DATA; in parport_ieee1284_read_byte()
263 /* Timeout -- no more data? */ in parport_ieee1284_read_byte()
266 pr_debug("%s: Byte timeout at event 9\n", port->name); in parport_ieee1284_read_byte()
270 byte = parport_read_data (port); in parport_ieee1284_read_byte()
271 *buf++ = byte; in parport_ieee1284_read_byte()
280 /* Timeout -- no more data? */ in parport_ieee1284_read_byte()
281 pr_debug("%s: Byte timeout at event 11\n", port->name); in parport_ieee1284_read_byte()
295 if (count == len) { in parport_ieee1284_read_byte()
296 /* Read the last byte without checking data avail. */ in parport_ieee1284_read_byte()
299 pr_debug("%s: No more byte data (%zd bytes)\n", in parport_ieee1284_read_byte()
300 port->name, count); in parport_ieee1284_read_byte()
306 port->physport->ieee1284.phase = IEEE1284_PH_REV_IDLE; in parport_ieee1284_read_byte()
309 port->physport->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL; in parport_ieee1284_read_byte()
344 pr_debug("%s: ECP direction: reverse\n", port->name); in ecp_forward_to_reverse()
345 port->ieee1284.phase = IEEE1284_PH_REV_IDLE; in ecp_forward_to_reverse()
347 pr_debug("%s: ECP direction: failed to reverse\n", port->name); in ecp_forward_to_reverse()
348 port->ieee1284.phase = IEEE1284_PH_ECP_DIR_UNKNOWN; in ecp_forward_to_reverse()
373 pr_debug("%s: ECP direction: forward\n", port->name); in ecp_reverse_to_forward()
374 port->ieee1284.phase = IEEE1284_PH_FWD_IDLE; in ecp_reverse_to_forward()
377 port->name); in ecp_reverse_to_forward()
378 port->ieee1284.phase = IEEE1284_PH_ECP_DIR_UNKNOWN; in ecp_reverse_to_forward()
389 const void *buffer, size_t len, in parport_ieee1284_ecp_write_data() argument
399 port = port->physport; in parport_ieee1284_ecp_write_data()
401 if (port->ieee1284.phase != IEEE1284_PH_FWD_IDLE) in parport_ieee1284_ecp_write_data()
405 port->ieee1284.phase = IEEE1284_PH_FWD_DATA; in parport_ieee1284_ecp_write_data()
413 for (written = 0; written < len; written++, buf++) { in parport_ieee1284_ecp_write_data()
414 unsigned long expire = jiffies + port->cad->timeout; in parport_ieee1284_ecp_write_data()
415 unsigned char byte; in parport_ieee1284_ecp_write_data()
417 byte = *buf; in parport_ieee1284_ecp_write_data()
419 parport_write_data (port, byte); in parport_ieee1284_ecp_write_data()
437 pr_debug("%s: ECP transfer stalled!\n", port->name); in parport_ieee1284_ecp_write_data()
453 pr_debug("%s: Host transfer recovered\n", port->name); in parport_ieee1284_ecp_write_data()
467 port->ieee1284.phase = IEEE1284_PH_FWD_IDLE; in parport_ieee1284_ecp_write_data()
475 void *buffer, size_t len, int flags) in parport_ieee1284_ecp_read_data() argument
480 struct pardevice *dev = port->cad; in parport_ieee1284_ecp_read_data()
487 port = port->physport; in parport_ieee1284_ecp_read_data()
489 if (port->ieee1284.phase != IEEE1284_PH_REV_IDLE) in parport_ieee1284_ecp_read_data()
493 port->ieee1284.phase = IEEE1284_PH_REV_DATA; in parport_ieee1284_ecp_read_data()
501 while (count < len) { in parport_ieee1284_ecp_read_data()
502 unsigned long expire = jiffies + dev->timeout; in parport_ieee1284_ecp_read_data()
503 unsigned char byte; in parport_ieee1284_ecp_read_data()
521 if (dev->port->irq != PARPORT_IRQ_NONE) { in parport_ieee1284_ecp_read_data()
537 /* The last byte was a run-length count, so in parport_ieee1284_ecp_read_data()
545 byte = parport_read_data (port); in parport_ieee1284_ecp_read_data()
548 command or a normal data byte, don't accept it. */ in parport_ieee1284_ecp_read_data()
550 if (byte & 0x80) { in parport_ieee1284_ecp_read_data()
552 port->name, byte); in parport_ieee1284_ecp_read_data()
555 else if (port->ieee1284.mode != IEEE1284_MODE_ECPRLE) in parport_ieee1284_ecp_read_data()
557 port->name); in parport_ieee1284_ecp_read_data()
559 rle_count = byte + 1; in parport_ieee1284_ecp_read_data()
562 if (rle_count > (len - count)) { in parport_ieee1284_ecp_read_data()
564 port->name, rle_count); in parport_ieee1284_ecp_read_data()
583 port->name, byte); in parport_ieee1284_ecp_read_data()
592 /* If we just read a run-length count, fetch the data. */ in parport_ieee1284_ecp_read_data()
596 /* If this is the byte after a run-length count, decompress. */ in parport_ieee1284_ecp_read_data()
599 memset (buf, byte, rle_count); in parport_ieee1284_ecp_read_data()
603 port->name, rle_count); in parport_ieee1284_ecp_read_data()
605 /* Normal data byte. */ in parport_ieee1284_ecp_read_data()
606 *buf = byte; in parport_ieee1284_ecp_read_data()
612 port->ieee1284.phase = IEEE1284_PH_REV_IDLE; in parport_ieee1284_ecp_read_data()
619 const void *buffer, size_t len, in parport_ieee1284_ecp_write_addr() argument
629 port = port->physport; in parport_ieee1284_ecp_write_addr()
631 if (port->ieee1284.phase != IEEE1284_PH_FWD_IDLE) in parport_ieee1284_ecp_write_addr()
635 port->ieee1284.phase = IEEE1284_PH_FWD_DATA; in parport_ieee1284_ecp_write_addr()
644 for (written = 0; written < len; written++, buf++) { in parport_ieee1284_ecp_write_addr()
645 unsigned long expire = jiffies + port->cad->timeout; in parport_ieee1284_ecp_write_addr()
646 unsigned char byte; in parport_ieee1284_ecp_write_addr()
648 byte = *buf; in parport_ieee1284_ecp_write_addr()
650 parport_write_data (port, byte); in parport_ieee1284_ecp_write_addr()
668 pr_debug("%s: ECP transfer stalled!\n", port->name); in parport_ieee1284_ecp_write_addr()
684 pr_debug("%s: Host transfer recovered\n", port->name); in parport_ieee1284_ecp_write_addr()
698 port->ieee1284.phase = IEEE1284_PH_FWD_IDLE; in parport_ieee1284_ecp_write_addr()
710 const void *buffer, size_t len, in parport_ieee1284_epp_write_data() argument
724 port->ops->data_forward (port); in parport_ieee1284_epp_write_data()
725 for (; len > 0; len--, bp++) { in parport_ieee1284_epp_write_data()
754 void *buffer, size_t len, in parport_ieee1284_epp_read_data() argument
767 port->ops->data_reverse (port); in parport_ieee1284_epp_read_data()
768 for (; len > 0; len--, bp++) { in parport_ieee1284_epp_read_data()
791 port->ops->data_forward (port); in parport_ieee1284_epp_read_data()
798 const void *buffer, size_t len, in parport_ieee1284_epp_write_addr() argument
812 port->ops->data_forward (port); in parport_ieee1284_epp_write_addr()
813 for (; len > 0; len--, bp++) { in parport_ieee1284_epp_write_addr()
842 void *buffer, size_t len, in parport_ieee1284_epp_read_addr() argument
855 port->ops->data_reverse (port); in parport_ieee1284_epp_read_addr()
856 for (; len > 0; len--, bp++) { in parport_ieee1284_epp_read_addr()
879 port->ops->data_forward (port); in parport_ieee1284_epp_read_addr()