* [PATCH 01/10] n_gsm: drop unneeded gsm_dlci->fifo field
@ 2020-02-19 8:49 Jiri Slaby
2020-02-19 8:49 ` [PATCH 02/10] n_gsm: introduce enum gsm_dlci_state Jiri Slaby
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: Jiri Slaby @ 2020-02-19 8:49 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
gsm_dlci->fifo always points to gsm_dlci->_fifo. So drop the pointer and
rename _fifo to fifo. And update all the users (add & to them).
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/n_gsm.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 5f8c30f0538e..828c0c7babdd 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -129,8 +129,7 @@ struct gsm_dlci {
int retries;
/* Uplink tty if active */
struct tty_port port; /* The tty bound to this DLCI if there is one */
- struct kfifo *fifo; /* Queue fifo for the DLCI */
- struct kfifo _fifo; /* For new fifo API porting only */
+ struct kfifo fifo; /* Queue fifo for the DLCI */
int adaption; /* Adaption layer in use */
int prev_adaption;
u32 modem_rx; /* Our incoming virtual modem lines */
@@ -796,7 +795,7 @@ static int gsm_dlci_data_output(struct gsm_mux *gsm, struct gsm_dlci *dlci)
total_size = 0;
while (1) {
- len = kfifo_len(dlci->fifo);
+ len = kfifo_len(&dlci->fifo);
if (len == 0)
return total_size;
@@ -820,7 +819,7 @@ static int gsm_dlci_data_output(struct gsm_mux *gsm, struct gsm_dlci *dlci)
*dp++ = gsm_encode_modem(dlci);
break;
}
- WARN_ON(kfifo_out_locked(dlci->fifo, dp , len, &dlci->lock) != len);
+ WARN_ON(kfifo_out_locked(&dlci->fifo, dp , len, &dlci->lock) != len);
__gsm_data_queue(dlci, msg);
total_size += size;
}
@@ -1424,7 +1423,7 @@ static void gsm_dlci_close(struct gsm_dlci *dlci)
dlci->state = DLCI_CLOSED;
if (dlci->addr != 0) {
tty_port_tty_hangup(&dlci->port, false);
- kfifo_reset(dlci->fifo);
+ kfifo_reset(&dlci->fifo);
} else
dlci->gsm->dead = 1;
wake_up(&dlci->gsm->event);
@@ -1645,8 +1644,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
return NULL;
spin_lock_init(&dlci->lock);
mutex_init(&dlci->mutex);
- dlci->fifo = &dlci->_fifo;
- if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
+ if (kfifo_alloc(&dlci->fifo, 4096, GFP_KERNEL) < 0) {
kfree(dlci);
return NULL;
}
@@ -1681,7 +1679,7 @@ static void gsm_dlci_free(struct tty_port *port)
del_timer_sync(&dlci->t1);
dlci->gsm->dlci[dlci->addr] = NULL;
- kfifo_free(dlci->fifo);
+ kfifo_free(&dlci->fifo);
while ((dlci->skb = skb_dequeue(&dlci->skb_list)))
dev_kfree_skb(dlci->skb);
kfree(dlci);
@@ -3030,7 +3028,7 @@ static int gsmtty_write(struct tty_struct *tty, const unsigned char *buf,
if (dlci->state == DLCI_CLOSED)
return -EINVAL;
/* Stuff the bytes into the fifo queue */
- sent = kfifo_in_locked(dlci->fifo, buf, len, &dlci->lock);
+ sent = kfifo_in_locked(&dlci->fifo, buf, len, &dlci->lock);
/* Need to kick the channel */
gsm_dlci_data_kick(dlci);
return sent;
@@ -3041,7 +3039,7 @@ static int gsmtty_write_room(struct tty_struct *tty)
struct gsm_dlci *dlci = tty->driver_data;
if (dlci->state == DLCI_CLOSED)
return -EINVAL;
- return TX_SIZE - kfifo_len(dlci->fifo);
+ return TX_SIZE - kfifo_len(&dlci->fifo);
}
static int gsmtty_chars_in_buffer(struct tty_struct *tty)
@@ -3049,7 +3047,7 @@ static int gsmtty_chars_in_buffer(struct tty_struct *tty)
struct gsm_dlci *dlci = tty->driver_data;
if (dlci->state == DLCI_CLOSED)
return -EINVAL;
- return kfifo_len(dlci->fifo);
+ return kfifo_len(&dlci->fifo);
}
static void gsmtty_flush_buffer(struct tty_struct *tty)
@@ -3061,7 +3059,7 @@ static void gsmtty_flush_buffer(struct tty_struct *tty)
then the data being transmitted can't simply be junked once
it has first hit the stack. Until then we can just blow it
away */
- kfifo_reset(dlci->fifo);
+ kfifo_reset(&dlci->fifo);
/* Need to unhook this DLCI from the transmit queue logic */
}
--
2.25.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 02/10] n_gsm: introduce enum gsm_dlci_state
2020-02-19 8:49 [PATCH 01/10] n_gsm: drop unneeded gsm_dlci->fifo field Jiri Slaby
@ 2020-02-19 8:49 ` Jiri Slaby
2020-02-19 8:49 ` [PATCH 03/10] n_gsm: introduce enum gsm_dlci_mode Jiri Slaby
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2020-02-19 8:49 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
gsm_dlci->state is clearly an enumeration. So introduce one and use it
-- compiler now checks if valid values are assigned to the field.
Note that a compiler warns about unhandled cases in switch. Add default
cases with a pr_debug (which is not printed by default).
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/n_gsm.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 828c0c7babdd..1d0a140027ff 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -100,6 +100,13 @@ struct gsm_msg {
unsigned char buffer[];
};
+enum gsm_dlci_state {
+ DLCI_CLOSED,
+ DLCI_OPENING, /* Sending SABM not seen UA */
+ DLCI_OPEN, /* SABM/UA complete */
+ DLCI_CLOSING, /* Sending DISC not seen UA/DM */
+};
+
/*
* Each active data link has a gsm_dlci structure associated which ties
* the link layer to an optional tty (if the tty side is open). To avoid
@@ -113,11 +120,7 @@ struct gsm_msg {
struct gsm_dlci {
struct gsm_mux *gsm;
int addr;
- int state;
-#define DLCI_CLOSED 0
-#define DLCI_OPENING 1 /* Sending SABM not seen UA */
-#define DLCI_OPEN 2 /* SABM/UA complete */
-#define DLCI_CLOSING 3 /* Sending DISC not seen UA/DM */
+ enum gsm_dlci_state state;
struct mutex mutex;
/* Link layer */
@@ -1495,6 +1498,9 @@ static void gsm_dlci_t1(struct timer_list *t)
} else
gsm_dlci_close(dlci);
break;
+ default:
+ pr_debug("%s: unhandled state: %d\n", __func__, dlci->state);
+ break;
}
}
@@ -1808,6 +1814,10 @@ static void gsm_queue(struct gsm_mux *gsm)
case DLCI_OPENING:
gsm_dlci_open(dlci);
break;
+ default:
+ pr_debug("%s: unhandled state: %d\n", __func__,
+ dlci->state);
+ break;
}
break;
case DM: /* DM can be valid unsolicited */
--
2.25.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 03/10] n_gsm: introduce enum gsm_dlci_mode
2020-02-19 8:49 [PATCH 01/10] n_gsm: drop unneeded gsm_dlci->fifo field Jiri Slaby
2020-02-19 8:49 ` [PATCH 02/10] n_gsm: introduce enum gsm_dlci_state Jiri Slaby
@ 2020-02-19 8:49 ` Jiri Slaby
2020-02-19 8:49 ` [PATCH 04/10] n_gsm: introduce enum gsm_mux_state Jiri Slaby
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2020-02-19 8:49 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
gsm_dlci->mode is clearly an enumeration. So introduce one and use it
-- compiler now checks if valid values are assigned to the field.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/n_gsm.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 1d0a140027ff..7fee5a580f21 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -107,6 +107,11 @@ enum gsm_dlci_state {
DLCI_CLOSING, /* Sending DISC not seen UA/DM */
};
+enum gsm_dlci_mode {
+ DLCI_MODE_ABM, /* Normal Asynchronous Balanced Mode */
+ DLCI_MODE_ADM, /* Asynchronous Disconnected Mode */
+};
+
/*
* Each active data link has a gsm_dlci structure associated which ties
* the link layer to an optional tty (if the tty side is open). To avoid
@@ -124,9 +129,7 @@ struct gsm_dlci {
struct mutex mutex;
/* Link layer */
- int mode;
-#define DLCI_MODE_ABM 0 /* Normal Asynchronous Balanced Mode */
-#define DLCI_MODE_ADM 1 /* Asynchronous Disconnected Mode */
+ enum gsm_dlci_mode mode;
spinlock_t lock; /* Protects the internal state */
struct timer_list t1; /* Retransmit timer for SABM and UA */
int retries;
--
2.25.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 04/10] n_gsm: introduce enum gsm_mux_state
2020-02-19 8:49 [PATCH 01/10] n_gsm: drop unneeded gsm_dlci->fifo field Jiri Slaby
2020-02-19 8:49 ` [PATCH 02/10] n_gsm: introduce enum gsm_dlci_state Jiri Slaby
2020-02-19 8:49 ` [PATCH 03/10] n_gsm: introduce enum gsm_dlci_mode Jiri Slaby
@ 2020-02-19 8:49 ` Jiri Slaby
2020-02-19 8:49 ` [PATCH 05/10] n_gsm: add missing __user annotations Jiri Slaby
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2020-02-19 8:49 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
gsm_mux->state is clearly an enumeration. So introduce one and use it
-- compiler now checks if valid values are assigned to the field.
Note that a compiler warns about unhandled cases in switch. Add default
cases with a pr_debug (which is not printed by default).
The values of the states are preserved thanks to the nature of enum.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/n_gsm.c | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 7fee5a580f21..82e3d88c1f3f 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -173,6 +173,20 @@ struct gsm_control {
int error; /* Error if any */
};
+enum gsm_mux_state {
+ GSM_SEARCH,
+ GSM_START,
+ GSM_ADDRESS,
+ GSM_CONTROL,
+ GSM_LEN,
+ GSM_DATA,
+ GSM_FCS,
+ GSM_OVERRUN,
+ GSM_LEN0,
+ GSM_LEN1,
+ GSM_SSOF,
+};
+
/*
* Each GSM mux we have is represented by this structure. If we are
* operating as an ldisc then we use this structure as our ldisc
@@ -197,18 +211,7 @@ struct gsm_mux {
/* Framing Layer */
unsigned char *buf;
- int state;
-#define GSM_SEARCH 0
-#define GSM_START 1
-#define GSM_ADDRESS 2
-#define GSM_CONTROL 3
-#define GSM_LEN 4
-#define GSM_DATA 5
-#define GSM_FCS 6
-#define GSM_OVERRUN 7
-#define GSM_LEN0 8
-#define GSM_LEN1 9
-#define GSM_SSOF 10
+ enum gsm_mux_state state;
unsigned int len;
unsigned int address;
unsigned int count;
@@ -1934,6 +1937,9 @@ static void gsm0_receive(struct gsm_mux *gsm, unsigned char c)
break;
}
break;
+ default:
+ pr_debug("%s: unhandled state: %d\n", __func__, gsm->state);
+ break;
}
}
@@ -2008,6 +2014,9 @@ static void gsm1_receive(struct gsm_mux *gsm, unsigned char c)
break;
case GSM_OVERRUN: /* Over-long - eg a dropped SOF */
break;
+ default:
+ pr_debug("%s: unhandled state: %d\n", __func__, gsm->state);
+ break;
}
}
--
2.25.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 05/10] n_gsm: add missing __user annotations
2020-02-19 8:49 [PATCH 01/10] n_gsm: drop unneeded gsm_dlci->fifo field Jiri Slaby
` (2 preceding siblings ...)
2020-02-19 8:49 ` [PATCH 04/10] n_gsm: introduce enum gsm_mux_state Jiri Slaby
@ 2020-02-19 8:49 ` Jiri Slaby
2020-02-19 8:49 ` [PATCH 06/10] n_gsm: add missing \n to prints Jiri Slaby
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2020-02-19 8:49 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
sparse warns about incorrect types:
n_gsm.c:2638:35: warning: incorrect type in argument 1 (different address spaces)
n_gsm.c:2638:35: expected void [noderef] <asn:1> *to
n_gsm.c:2638:35: got void *
The ioctl handler casts its `arg' to (void *) without __user. Add that.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/n_gsm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 82e3d88c1f3f..d866884c105b 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -2638,11 +2638,11 @@ static int gsmld_ioctl(struct tty_struct *tty, struct file *file,
switch (cmd) {
case GSMIOC_GETCONF:
gsm_copy_config_values(gsm, &c);
- if (copy_to_user((void *)arg, &c, sizeof(c)))
+ if (copy_to_user((void __user *)arg, &c, sizeof(c)))
return -EFAULT;
return 0;
case GSMIOC_SETCONF:
- if (copy_from_user(&c, (void *)arg, sizeof(c)))
+ if (copy_from_user(&c, (void __user *)arg, sizeof(c)))
return -EFAULT;
return gsm_config(gsm, &c);
case GSMIOC_GETFIRST:
--
2.25.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 06/10] n_gsm: add missing \n to prints
2020-02-19 8:49 [PATCH 01/10] n_gsm: drop unneeded gsm_dlci->fifo field Jiri Slaby
` (3 preceding siblings ...)
2020-02-19 8:49 ` [PATCH 05/10] n_gsm: add missing __user annotations Jiri Slaby
@ 2020-02-19 8:49 ` Jiri Slaby
2020-02-19 8:49 ` [PATCH 07/10] n_gsm: switch dead to bool Jiri Slaby
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2020-02-19 8:49 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/n_gsm.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index d866884c105b..8afe635a04fd 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -2789,7 +2789,7 @@ static void gsm_destroy_network(struct gsm_dlci *dlci)
{
struct gsm_mux_net *mux_net;
- pr_debug("destroy network interface");
+ pr_debug("destroy network interface\n");
if (!dlci->net)
return;
mux_net = netdev_priv(dlci->net);
@@ -2818,7 +2818,7 @@ static int gsm_create_network(struct gsm_dlci *dlci, struct gsm_netconfig *nc)
if (nc->adaption != 3 && nc->adaption != 4)
return -EPROTONOSUPPORT;
- pr_debug("create network interface");
+ pr_debug("create network interface\n");
netname = "gsm%d";
if (nc->if_name[0] != '\0')
@@ -2826,7 +2826,7 @@ static int gsm_create_network(struct gsm_dlci *dlci, struct gsm_netconfig *nc)
net = alloc_netdev(sizeof(struct gsm_mux_net), netname,
NET_NAME_UNKNOWN, gsm_mux_net_init);
if (!net) {
- pr_err("alloc_netdev failed");
+ pr_err("alloc_netdev failed\n");
return -ENOMEM;
}
net->mtu = dlci->gsm->mtu;
@@ -2844,7 +2844,7 @@ static int gsm_create_network(struct gsm_dlci *dlci, struct gsm_netconfig *nc)
dlci->data = gsm_mux_rx_netchar;
dlci->net = net;
- pr_debug("register netdev");
+ pr_debug("register netdev\n");
retval = register_netdev(net);
if (retval) {
pr_err("network register fail %d\n", retval);
--
2.25.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 07/10] n_gsm: switch dead to bool
2020-02-19 8:49 [PATCH 01/10] n_gsm: drop unneeded gsm_dlci->fifo field Jiri Slaby
` (4 preceding siblings ...)
2020-02-19 8:49 ` [PATCH 06/10] n_gsm: add missing \n to prints Jiri Slaby
@ 2020-02-19 8:49 ` Jiri Slaby
2020-02-19 8:49 ` [PATCH 08/10] n_gsm: switch throttled " Jiri Slaby
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2020-02-19 8:49 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
Both gsm_dlci->dead and gsm_mux->dead are used as bools, so treat them
as such.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/n_gsm.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 8afe635a04fd..24ce46e4fb45 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -140,7 +140,7 @@ struct gsm_dlci {
int prev_adaption;
u32 modem_rx; /* Our incoming virtual modem lines */
u32 modem_tx; /* Our outgoing modem lines */
- int dead; /* Refuse re-open */
+ bool dead; /* Refuse re-open */
/* Flow control */
int throttled; /* Private copy of throttle state */
int constipated; /* Throttle status for outgoing */
@@ -232,7 +232,7 @@ struct gsm_mux {
unsigned int mru;
unsigned int mtu;
int initiator; /* Did we initiate connection */
- int dead; /* Has the mux been shut down */
+ bool dead; /* Has the mux been shut down */
struct gsm_dlci *dlci[NUM_DLCI];
int constipated; /* Asked by remote to shut up */
@@ -1207,8 +1207,8 @@ static void gsm_control_message(struct gsm_mux *gsm, unsigned int command,
struct gsm_dlci *dlci = gsm->dlci[0];
/* Modem wishes to close down */
if (dlci) {
- dlci->dead = 1;
- gsm->dead = 1;
+ dlci->dead = true;
+ gsm->dead = true;
gsm_dlci_begin_close(dlci);
}
}
@@ -1434,7 +1434,7 @@ static void gsm_dlci_close(struct gsm_dlci *dlci)
tty_port_tty_hangup(&dlci->port, false);
kfifo_reset(&dlci->fifo);
} else
- dlci->gsm->dead = 1;
+ dlci->gsm->dead = true;
wake_up(&dlci->gsm->event);
/* A DLCI 0 close is a MUX termination so we need to kick that
back to userspace somehow */
@@ -2081,7 +2081,7 @@ static void gsm_cleanup_mux(struct gsm_mux *gsm)
struct gsm_dlci *dlci = gsm->dlci[0];
struct gsm_msg *txq, *ntxq;
- gsm->dead = 1;
+ gsm->dead = true;
spin_lock(&gsm_mux_lock);
for (i = 0; i < MAX_MUX; i++) {
@@ -2098,7 +2098,7 @@ static void gsm_cleanup_mux(struct gsm_mux *gsm)
del_timer_sync(&gsm->t2_timer);
/* Now we are sure T2 has stopped */
if (dlci)
- dlci->dead = 1;
+ dlci->dead = true;
/* Free up any link layer users */
mutex_lock(&gsm->mutex);
@@ -2152,7 +2152,7 @@ static int gsm_activate_mux(struct gsm_mux *gsm)
dlci = gsm_dlci_alloc(gsm, 0);
if (dlci == NULL)
return -ENOMEM;
- gsm->dead = 0; /* Tty opens are now permissible */
+ gsm->dead = false; /* Tty opens are now permissible */
return 0;
}
@@ -2236,7 +2236,7 @@ static struct gsm_mux *gsm_alloc_mux(void)
gsm->encoding = 1;
gsm->mru = 64; /* Default to encoding 1 so these should be 64 */
gsm->mtu = 64;
- gsm->dead = 1; /* Avoid early tty opens */
+ gsm->dead = true; /* Avoid early tty opens */
return gsm;
}
--
2.25.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 08/10] n_gsm: switch throttled to bool
2020-02-19 8:49 [PATCH 01/10] n_gsm: drop unneeded gsm_dlci->fifo field Jiri Slaby
` (5 preceding siblings ...)
2020-02-19 8:49 ` [PATCH 07/10] n_gsm: switch dead to bool Jiri Slaby
@ 2020-02-19 8:49 ` Jiri Slaby
2020-02-19 8:49 ` [PATCH 09/10] n_gsm: switch constipated " Jiri Slaby
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2020-02-19 8:49 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
gsm_dlci->throttled is used as a bool, so treat it as such.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/n_gsm.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 24ce46e4fb45..6bd51d309c32 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -142,7 +142,7 @@ struct gsm_dlci {
u32 modem_tx; /* Our outgoing modem lines */
bool dead; /* Refuse re-open */
/* Flow control */
- int throttled; /* Private copy of throttle state */
+ bool throttled; /* Private copy of throttle state */
int constipated; /* Throttle status for outgoing */
/* Packetised I/O */
struct sk_buff *skb; /* Frame being sent */
@@ -3172,7 +3172,7 @@ static void gsmtty_throttle(struct tty_struct *tty)
return;
if (C_CRTSCTS(tty))
dlci->modem_tx &= ~TIOCM_DTR;
- dlci->throttled = 1;
+ dlci->throttled = true;
/* Send an MSC with DTR cleared */
gsmtty_modem_update(dlci, 0);
}
@@ -3184,7 +3184,7 @@ static void gsmtty_unthrottle(struct tty_struct *tty)
return;
if (C_CRTSCTS(tty))
dlci->modem_tx |= TIOCM_DTR;
- dlci->throttled = 0;
+ dlci->throttled = false;
/* Send an MSC with DTR set */
gsmtty_modem_update(dlci, 0);
}
--
2.25.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 09/10] n_gsm: switch constipated to bool
2020-02-19 8:49 [PATCH 01/10] n_gsm: drop unneeded gsm_dlci->fifo field Jiri Slaby
` (6 preceding siblings ...)
2020-02-19 8:49 ` [PATCH 08/10] n_gsm: switch throttled " Jiri Slaby
@ 2020-02-19 8:49 ` Jiri Slaby
2020-02-19 8:49 ` [PATCH 10/10] n_gsm: switch escape " Jiri Slaby
2020-02-20 19:44 ` [PATCH 01/10] n_gsm: drop unneeded gsm_dlci->fifo field Tony Lindgren
9 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2020-02-19 8:49 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
Both gsm_dlci->constipated and gsm_mux->constipated are used as bools,
so treat them as such.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/n_gsm.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 6bd51d309c32..e0283bb24bb5 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -143,7 +143,7 @@ struct gsm_dlci {
bool dead; /* Refuse re-open */
/* Flow control */
bool throttled; /* Private copy of throttle state */
- int constipated; /* Throttle status for outgoing */
+ bool constipated; /* Throttle status for outgoing */
/* Packetised I/O */
struct sk_buff *skb; /* Frame being sent */
struct sk_buff_head skb_list; /* Queued frames */
@@ -234,7 +234,7 @@ struct gsm_mux {
int initiator; /* Did we initiate connection */
bool dead; /* Has the mux been shut down */
struct gsm_dlci *dlci[NUM_DLCI];
- int constipated; /* Asked by remote to shut up */
+ bool constipated; /* Asked by remote to shut up */
spinlock_t tx_lock;
unsigned int tx_bytes; /* TX data outstanding */
@@ -1042,9 +1042,9 @@ static void gsm_process_modem(struct tty_struct *tty, struct gsm_dlci *dlci,
fc = (modem & MDM_FC) || !(modem & MDM_RTR);
if (fc && !dlci->constipated) {
/* Need to throttle our output on this device */
- dlci->constipated = 1;
+ dlci->constipated = true;
} else if (!fc && dlci->constipated) {
- dlci->constipated = 0;
+ dlci->constipated = false;
gsm_dlci_data_kick(dlci);
}
@@ -1219,7 +1219,7 @@ static void gsm_control_message(struct gsm_mux *gsm, unsigned int command,
break;
case CMD_FCON:
/* Modem can accept data again */
- gsm->constipated = 0;
+ gsm->constipated = false;
gsm_control_reply(gsm, CMD_FCON, NULL, 0);
/* Kick the link in case it is idling */
spin_lock_irqsave(&gsm->tx_lock, flags);
@@ -1228,7 +1228,7 @@ static void gsm_control_message(struct gsm_mux *gsm, unsigned int command,
break;
case CMD_FCOFF:
/* Modem wants us to STFU */
- gsm->constipated = 1;
+ gsm->constipated = true;
gsm_control_reply(gsm, CMD_FCOFF, NULL, 0);
break;
case CMD_MSC:
--
2.25.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 10/10] n_gsm: switch escape to bool
2020-02-19 8:49 [PATCH 01/10] n_gsm: drop unneeded gsm_dlci->fifo field Jiri Slaby
` (7 preceding siblings ...)
2020-02-19 8:49 ` [PATCH 09/10] n_gsm: switch constipated " Jiri Slaby
@ 2020-02-19 8:49 ` Jiri Slaby
2020-02-20 19:44 ` [PATCH 01/10] n_gsm: drop unneeded gsm_dlci->fifo field Tony Lindgren
9 siblings, 0 replies; 11+ messages in thread
From: Jiri Slaby @ 2020-02-19 8:49 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby
gsm_mux->escape is used as a bool, so treat it as such.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/n_gsm.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index e0283bb24bb5..d77ed82a4840 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -215,7 +215,7 @@ struct gsm_mux {
unsigned int len;
unsigned int address;
unsigned int count;
- int escape;
+ bool escape;
int encoding;
u8 control;
u8 fcs;
@@ -1976,7 +1976,7 @@ static void gsm1_receive(struct gsm_mux *gsm, unsigned char c)
}
if (c == GSM1_ESCAPE) {
- gsm->escape = 1;
+ gsm->escape = true;
return;
}
@@ -1986,7 +1986,7 @@ static void gsm1_receive(struct gsm_mux *gsm, unsigned char c)
if (gsm->escape) {
c ^= GSM1_ESCAPE_BITS;
- gsm->escape = 0;
+ gsm->escape = false;
}
switch (gsm->state) {
case GSM_START: /* First byte after SOF */
--
2.25.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 01/10] n_gsm: drop unneeded gsm_dlci->fifo field
2020-02-19 8:49 [PATCH 01/10] n_gsm: drop unneeded gsm_dlci->fifo field Jiri Slaby
` (8 preceding siblings ...)
2020-02-19 8:49 ` [PATCH 10/10] n_gsm: switch escape " Jiri Slaby
@ 2020-02-20 19:44 ` Tony Lindgren
9 siblings, 0 replies; 11+ messages in thread
From: Tony Lindgren @ 2020-02-20 19:44 UTC (permalink / raw)
To: Jiri Slaby; +Cc: gregkh, linux-serial, linux-kernel
Hi,
* Jiri Slaby <jslaby@suse.cz> [700101 00:00]:
> gsm_dlci->fifo always points to gsm_dlci->_fifo. So drop the pointer and
> rename _fifo to fifo. And update all the users (add & to them).
I gave this series a quick test with my pending n_gsm serdev changes
and things work fine for me.
So for the whole series, please feel free to add:
Tested-by: Tony Lindgren <tony@atomide.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2020-02-20 19:44 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19 8:49 [PATCH 01/10] n_gsm: drop unneeded gsm_dlci->fifo field Jiri Slaby
2020-02-19 8:49 ` [PATCH 02/10] n_gsm: introduce enum gsm_dlci_state Jiri Slaby
2020-02-19 8:49 ` [PATCH 03/10] n_gsm: introduce enum gsm_dlci_mode Jiri Slaby
2020-02-19 8:49 ` [PATCH 04/10] n_gsm: introduce enum gsm_mux_state Jiri Slaby
2020-02-19 8:49 ` [PATCH 05/10] n_gsm: add missing __user annotations Jiri Slaby
2020-02-19 8:49 ` [PATCH 06/10] n_gsm: add missing \n to prints Jiri Slaby
2020-02-19 8:49 ` [PATCH 07/10] n_gsm: switch dead to bool Jiri Slaby
2020-02-19 8:49 ` [PATCH 08/10] n_gsm: switch throttled " Jiri Slaby
2020-02-19 8:49 ` [PATCH 09/10] n_gsm: switch constipated " Jiri Slaby
2020-02-19 8:49 ` [PATCH 10/10] n_gsm: switch escape " Jiri Slaby
2020-02-20 19:44 ` [PATCH 01/10] n_gsm: drop unneeded gsm_dlci->fifo field Tony Lindgren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).