Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: wwan: core: split port unregister and stop

Upcoming GNSS (NMEA) port type support requires exporting it via the
GNSS subsystem. On another hand, we still need to do basic WWAN core
work: call the port stop operation, purge queues, release the parent
WWAN device, etc. To reuse as much code as possible, split the port
unregistering function into the deregistration of a regular WWAN port
device, and the common port tearing down code.

In order to keep more code generic, break the device_unregister() call
into device_del() and put_device(), which release the port memory
uniformly.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Reviewed-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
Link: https://patch.msgid.link/20260126062158.308598-5-slark_xiao@163.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Sergey Ryazanov and committed by
Jakub Kicinski
0868ea34 dccd23a6

+18 -5
+18 -5
drivers/net/wwan/wwan_core.c
··· 475 475 return 0; 476 476 } 477 477 478 + /* Unregister a regular WWAN port (e.g. AT, MBIM, etc) */ 479 + static void wwan_port_unregister_wwan(struct wwan_port *port) 480 + { 481 + struct wwan_device *wwandev = to_wwan_dev(port->dev.parent); 482 + 483 + dev_set_drvdata(&port->dev, NULL); 484 + 485 + dev_info(&wwandev->dev, "port %s disconnected\n", dev_name(&port->dev)); 486 + 487 + device_del(&port->dev); 488 + } 489 + 478 490 struct wwan_port *wwan_create_port(struct device *parent, 479 491 enum wwan_port_type type, 480 492 const struct wwan_port_ops *ops, ··· 547 535 struct wwan_device *wwandev = to_wwan_dev(port->dev.parent); 548 536 549 537 mutex_lock(&port->ops_lock); 550 - if (port->start_count) 538 + if (port->start_count) { 551 539 port->ops->stop(port); 540 + port->start_count = 0; 541 + } 552 542 port->ops = NULL; /* Prevent any new port operations (e.g. from fops) */ 553 543 mutex_unlock(&port->ops_lock); 554 544 555 545 wake_up_interruptible(&port->waitqueue); 556 - 557 546 skb_queue_purge(&port->rxq); 558 - dev_set_drvdata(&port->dev, NULL); 559 547 560 - dev_info(&wwandev->dev, "port %s disconnected\n", dev_name(&port->dev)); 561 - device_unregister(&port->dev); 548 + wwan_port_unregister_wwan(port); 549 + 550 + put_device(&port->dev); 562 551 563 552 /* Release related wwan device */ 564 553 wwan_remove_dev(wwandev);