Skip to content

Commit 5b87686

Browse files
Zhenguo Zhaogregkh
authored andcommitted
tty: n_gsm: Modify gsmtty driver register method when config requester
As requester,because n_gsm has no uevent report for application,the application can't know dlci connect or disconnect. The application will control every dlcl dev by uevent,when application receive gsmtty0 dev remove uevent,it will close mux function,and change to normal mode. Example: Before modify: gsmld receive DLC0 DISC,no event report to application gsmld receive DLC1 SABM,no event report to application gsmld receive DLC1 DISC,no event report to application After modify: Receive DLC0 DISC,report "/devices/virtual/tty/gsmtty0" remove uevent Receive DLC1 SABM,report "/devices/virtual/tty/gsmtty1" add uevent Receive DLC1 DISC,report "/devices/virtual/tty/gsmtty1" remove uevent Signed-off-by: Zhenguo Zhao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent cbff2b3 commit 5b87686

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

drivers/tty/n_gsm.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,6 +1433,8 @@ static void gsm_dlci_close(struct gsm_dlci *dlci)
14331433
kfifo_reset(&dlci->fifo);
14341434
} else
14351435
dlci->gsm->dead = true;
1436+
/* Unregister gsmtty driver,report gsmtty dev remove uevent for user */
1437+
tty_unregister_device(gsm_tty_driver, dlci->addr);
14361438
wake_up(&dlci->gsm->event);
14371439
/* A DLCI 0 close is a MUX termination so we need to kick that
14381440
back to userspace somehow */
@@ -1454,6 +1456,8 @@ static void gsm_dlci_open(struct gsm_dlci *dlci)
14541456
dlci->state = DLCI_OPEN;
14551457
if (debug & 8)
14561458
pr_debug("DLCI %d goes open.\n", dlci->addr);
1459+
/* Register gsmtty driver,report gsmtty dev add uevent for user */
1460+
tty_register_device(gsm_tty_driver, dlci->addr, NULL);
14571461
wake_up(&dlci->gsm->event);
14581462
}
14591463

@@ -2388,17 +2392,19 @@ static int gsmld_attach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
23882392
else {
23892393
/* Don't register device 0 - this is the control channel and not
23902394
a usable tty interface */
2391-
base = mux_num_to_base(gsm); /* Base for this MUX */
2392-
for (i = 1; i < NUM_DLCI; i++) {
2393-
struct device *dev;
2395+
if (gsm->initiator) {
2396+
base = mux_num_to_base(gsm); /* Base for this MUX */
2397+
for (i = 1; i < NUM_DLCI; i++) {
2398+
struct device *dev;
23942399

2395-
dev = tty_register_device(gsm_tty_driver,
2400+
dev = tty_register_device(gsm_tty_driver,
23962401
base + i, NULL);
2397-
if (IS_ERR(dev)) {
2398-
for (i--; i >= 1; i--)
2399-
tty_unregister_device(gsm_tty_driver,
2400-
base + i);
2401-
return PTR_ERR(dev);
2402+
if (IS_ERR(dev)) {
2403+
for (i--; i >= 1; i--)
2404+
tty_unregister_device(gsm_tty_driver,
2405+
base + i);
2406+
return PTR_ERR(dev);
2407+
}
24022408
}
24032409
}
24042410
}
@@ -2420,8 +2426,10 @@ static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
24202426
int i;
24212427

24222428
WARN_ON(tty != gsm->tty);
2423-
for (i = 1; i < NUM_DLCI; i++)
2424-
tty_unregister_device(gsm_tty_driver, base + i);
2429+
if (gsm->initiator) {
2430+
for (i = 1; i < NUM_DLCI; i++)
2431+
tty_unregister_device(gsm_tty_driver, base + i);
2432+
}
24252433
gsm_cleanup_mux(gsm);
24262434
tty_kref_put(gsm->tty);
24272435
gsm->tty = NULL;

0 commit comments

Comments
 (0)