Skip to content

Commit e816144

Browse files
Jiri Slaby (SUSE)gregkh
authored andcommitted
tty: make tty_ldisc_ops::*buf*() hooks operate on size_t
Count passed to tty_ldisc_ops::receive_buf*(), ::lookahead_buf(), and returned from ::receive_buf2() is expected to be size_t. So set it to size_t to unify with the rest of the code. Signed-off-by: "Jiri Slaby (SUSE)" <[email protected]> Cc: William Hubbs <[email protected]> Cc: Chris Brannon <[email protected]> Cc: Kirk Reiser <[email protected]> Cc: Samuel Thibault <[email protected]> Cc: Marcel Holtmann <[email protected]> Cc: Johan Hedberg <[email protected]> Cc: Luiz Augusto von Dentz <[email protected]> Cc: Dmitry Torokhov <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Eric Dumazet <[email protected]> Cc: Jakub Kicinski <[email protected]> Cc: Paolo Abeni <[email protected]> Cc: Max Staudt <[email protected]> Cc: Wolfgang Grandegger <[email protected]> Cc: Marc Kleine-Budde <[email protected]> Cc: Dario Binacchi <[email protected]> Cc: Andreas Koensgen <[email protected]> Cc: Jeremy Kerr <[email protected]> Cc: Matt Johnston <[email protected]> Cc: Krzysztof Kozlowski <[email protected]> Cc: Liam Girdwood <[email protected]> Cc: Mark Brown <[email protected]> Cc: Jaroslav Kysela <[email protected]> Cc: Takashi Iwai <[email protected]> Acked-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 73048bd commit e816144

File tree

19 files changed

+38
-35
lines changed

19 files changed

+38
-35
lines changed

drivers/accessibility/speakup/spk_ttyio.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ static void spk_ttyio_ldisc_close(struct tty_struct *tty)
7171
kfree(tty->disc_data);
7272
}
7373

74-
static int spk_ttyio_receive_buf2(struct tty_struct *tty,
75-
const unsigned char *cp,
76-
const char *fp, int count)
74+
static size_t spk_ttyio_receive_buf2(struct tty_struct *tty,
75+
const unsigned char *cp, const char *fp,
76+
size_t count)
7777
{
7878
struct spk_ldisc_data *ldisc_data = tty->disc_data;
7979
struct spk_synth *synth = ldisc_data->synth;

drivers/bluetooth/hci_ldisc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty)
599599
* Return Value: None
600600
*/
601601
static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data,
602-
const char *flags, int count)
602+
const char *flags, size_t count)
603603
{
604604
struct hci_uart *hu = tty->disc_data;
605605

drivers/input/serio/serport.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ static void serport_ldisc_close(struct tty_struct *tty)
115115
*/
116116

117117
static void serport_ldisc_receive(struct tty_struct *tty,
118-
const unsigned char *cp, const char *fp, int count)
118+
const unsigned char *cp, const char *fp,
119+
size_t count)
119120
{
120121
struct serport *serport = tty->disc_data;
121122
unsigned long flags;

drivers/misc/ti-st/st_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ static void st_tty_close(struct tty_struct *tty)
792792
}
793793

794794
static void st_tty_receive(struct tty_struct *tty, const unsigned char *data,
795-
const char *tty_flags, int count)
795+
const char *tty_flags, size_t count)
796796
{
797797
#ifdef VERBOSE
798798
print_hex_dump(KERN_DEBUG, ">in>", DUMP_PREFIX_NONE,

drivers/net/caif/caif_serial.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static inline void debugfs_tx(struct ser_device *ser, const u8 *data, int size)
159159
#endif
160160

161161
static void ldisc_receive(struct tty_struct *tty, const u8 *data,
162-
const char *flags, int count)
162+
const char *flags, size_t count)
163163
{
164164
struct sk_buff *skb = NULL;
165165
struct ser_device *ser;

drivers/net/can/can327.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ static bool can327_is_valid_rx_char(u8 c)
886886
* functions may be called in parallel.
887887
*/
888888
static void can327_ldisc_rx(struct tty_struct *tty, const unsigned char *cp,
889-
const char *fp, int count)
889+
const char *fp, size_t count)
890890
{
891891
struct can327 *elm = tty->disc_data;
892892
size_t first_new_char_idx;
@@ -904,7 +904,7 @@ static void can327_ldisc_rx(struct tty_struct *tty, const unsigned char *cp,
904904
while (count--) {
905905
if (elm->rxfill >= CAN327_SIZE_RXBUF) {
906906
netdev_err(elm->dev,
907-
"Receive buffer overflowed. Bad chip or wiring? count = %i",
907+
"Receive buffer overflowed. Bad chip or wiring? count = %zu",
908908
count);
909909
goto uart_failure;
910910
}

drivers/net/can/slcan/slcan-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ static const struct net_device_ops slcan_netdev_ops = {
776776
*/
777777
static void slcan_receive_buf(struct tty_struct *tty,
778778
const unsigned char *cp, const char *fp,
779-
int count)
779+
size_t count)
780780
{
781781
struct slcan *sl = tty->disc_data;
782782

drivers/net/hamradio/6pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ static void sixpack_write_wakeup(struct tty_struct *tty)
428428
* and sent on to some IP layer for further processing.
429429
*/
430430
static void sixpack_receive_buf(struct tty_struct *tty,
431-
const unsigned char *cp, const char *fp, int count)
431+
const unsigned char *cp, const char *fp, size_t count)
432432
{
433433
struct sixpack *sp;
434434
int count1;

drivers/net/hamradio/mkiss.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ static int mkiss_ioctl(struct tty_struct *tty, unsigned int cmd,
875875
* and sent on to the AX.25 layer for further processing.
876876
*/
877877
static void mkiss_receive_buf(struct tty_struct *tty, const unsigned char *cp,
878-
const char *fp, int count)
878+
const char *fp, size_t count)
879879
{
880880
struct mkiss *ax = mkiss_get(tty);
881881

drivers/net/mctp/mctp-serial.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ static void mctp_serial_push(struct mctp_serial *dev, unsigned char c)
392392

393393
static void mctp_serial_tty_receive_buf(struct tty_struct *tty,
394394
const unsigned char *c,
395-
const char *f, int len)
395+
const char *f, size_t len)
396396
{
397397
struct mctp_serial *dev = tty->disc_data;
398398
int i;

drivers/net/ppp/ppp_async.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ ppp_asynctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
331331
/* May sleep, don't call from interrupt level or with interrupts disabled */
332332
static void
333333
ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,
334-
const char *cflags, int count)
334+
const char *cflags, size_t count)
335335
{
336336
struct asyncppp *ap = ap_get(tty);
337337
unsigned long flags;

drivers/net/ppp/ppp_synctty.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ ppp_synctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
324324
/* May sleep, don't call from interrupt level or with interrupts disabled */
325325
static void
326326
ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf,
327-
const char *cflags, int count)
327+
const char *cflags, size_t count)
328328
{
329329
struct syncppp *ap = sp_get(tty);
330330
unsigned long flags;

drivers/net/slip/slip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ static void sl_setup(struct net_device *dev)
686686
*/
687687

688688
static void slip_receive_buf(struct tty_struct *tty, const unsigned char *cp,
689-
const char *fp, int count)
689+
const char *fp, size_t count)
690690
{
691691
struct slip *sl = tty->disc_data;
692692

drivers/tty/n_gsm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3490,7 +3490,7 @@ static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
34903490
}
34913491

34923492
static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp,
3493-
const char *fp, int count)
3493+
const char *fp, size_t count)
34943494
{
34953495
struct gsm_mux *gsm = tty->disc_data;
34963496
char flags = TTY_NORMAL;

drivers/tty/n_hdlc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,12 @@ static void n_hdlc_tty_wakeup(struct tty_struct *tty)
370370
* interpreted as one HDLC frame.
371371
*/
372372
static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,
373-
const char *flags, int count)
373+
const char *flags, size_t count)
374374
{
375375
register struct n_hdlc *n_hdlc = tty->disc_data;
376376
register struct n_hdlc_buf *buf;
377377

378-
pr_debug("%s() called count=%d\n", __func__, count);
378+
pr_debug("%s() called count=%zu\n", __func__, count);
379379

380380
if (count > maxframe) {
381381
pr_debug("rx count>maxframesize, data discarded\n");

drivers/tty/n_tty.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,7 @@ n_tty_receive_char_lnext(struct tty_struct *tty, unsigned char c, char flag)
14801480

14811481
/* Caller must ensure count > 0 */
14821482
static void n_tty_lookahead_flow_ctrl(struct tty_struct *tty, const unsigned char *cp,
1483-
const unsigned char *fp, unsigned int count)
1483+
const unsigned char *fp, size_t count)
14841484
{
14851485
struct n_tty_data *ldata = tty->disc_data;
14861486
unsigned char flag = TTY_NORMAL;
@@ -1662,12 +1662,13 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,
16621662
* claims non-exclusive %termios_rwsem
16631663
* publishes commit_head or canon_head
16641664
*/
1665-
static int
1665+
static size_t
16661666
n_tty_receive_buf_common(struct tty_struct *tty, const unsigned char *cp,
16671667
const char *fp, int count, int flow)
16681668
{
16691669
struct n_tty_data *ldata = tty->disc_data;
1670-
int room, n, rcvd = 0, overflow;
1670+
size_t rcvd = 0;
1671+
int room, n, overflow;
16711672

16721673
down_read(&tty->termios_rwsem);
16731674

@@ -1744,13 +1745,14 @@ n_tty_receive_buf_common(struct tty_struct *tty, const unsigned char *cp,
17441745
}
17451746

17461747
static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
1747-
const char *fp, int count)
1748+
const char *fp, size_t count)
17481749
{
17491750
n_tty_receive_buf_common(tty, cp, fp, count, 0);
17501751
}
17511752

1752-
static int n_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp,
1753-
const char *fp, int count)
1753+
static size_t n_tty_receive_buf2(struct tty_struct *tty,
1754+
const unsigned char *cp, const char *fp,
1755+
size_t count)
17541756
{
17551757
return n_tty_receive_buf_common(tty, cp, fp, count, 1);
17561758
}

include/linux/tty_ldisc.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,
162162
* Optional. Can sleep.
163163
*
164164
* @receive_buf: [DRV] ``void ()(struct tty_struct *tty,
165-
* const unsigned char *cp, const char *fp, int count)``
165+
* const unsigned char *cp, const char *fp, size_t count)``
166166
*
167167
* This function is called by the low-level tty driver to send characters
168168
* received by the hardware to the line discpline for processing. @cp is
@@ -191,8 +191,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,
191191
*
192192
* Optional.
193193
*
194-
* @receive_buf2: [DRV] ``int ()(struct tty_struct *tty,
195-
* const unsigned char *cp, const char *fp, int count)``
194+
* @receive_buf2: [DRV] ``ssize_t ()(struct tty_struct *tty,
195+
* const unsigned char *cp, const char *fp, size_t count)``
196196
*
197197
* This function is called by the low-level tty driver to send characters
198198
* received by the hardware to the line discpline for processing. @cp is a
@@ -205,7 +205,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,
205205
* Optional.
206206
*
207207
* @lookahead_buf: [DRV] ``void ()(struct tty_struct *tty,
208-
* const unsigned char *cp, const char *fp, int count)``
208+
* const unsigned char *cp, const char *fp, size_t count)``
209209
*
210210
* This function is called by the low-level tty driver for characters
211211
* not eaten by ->receive_buf() or ->receive_buf2(). It is useful for
@@ -256,13 +256,13 @@ struct tty_ldisc_ops {
256256
* The following routines are called from below.
257257
*/
258258
void (*receive_buf)(struct tty_struct *tty, const unsigned char *cp,
259-
const char *fp, int count);
259+
const char *fp, size_t count);
260260
void (*write_wakeup)(struct tty_struct *tty);
261261
void (*dcd_change)(struct tty_struct *tty, bool active);
262-
int (*receive_buf2)(struct tty_struct *tty, const unsigned char *cp,
263-
const char *fp, int count);
262+
size_t (*receive_buf2)(struct tty_struct *tty, const unsigned char *cp,
263+
const char *fp, size_t count);
264264
void (*lookahead_buf)(struct tty_struct *tty, const unsigned char *cp,
265-
const unsigned char *fp, unsigned int count);
265+
const unsigned char *fp, size_t count);
266266

267267
struct module *owner;
268268
};

net/nfc/nci/uart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ static int nci_uart_default_recv_buf(struct nci_uart *nu, const u8 *data,
296296
* Return Value: None
297297
*/
298298
static void nci_uart_tty_receive(struct tty_struct *tty, const u8 *data,
299-
const char *flags, int count)
299+
const char *flags, size_t count)
300300
{
301301
struct nci_uart *nu = tty->disc_data;
302302

sound/soc/codecs/cx20442.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static void v253_hangup(struct tty_struct *tty)
259259

260260
/* Line discipline .receive_buf() */
261261
static void v253_receive(struct tty_struct *tty, const unsigned char *cp,
262-
const char *fp, int count)
262+
const char *fp, size_t count)
263263
{
264264
struct snd_soc_component *component = tty->disc_data;
265265
struct cx20442_priv *cx20442;

0 commit comments

Comments
 (0)