Skip to content

Commit 82c6531

Browse files
galakcarlescufi
authored andcommitted
drivers: ppp: Move to DTS for uart device
Move from using Kconfig NET_PPP_UART_NAME to a devicetree chosen property ("zephyr,ppp-uart"). This is similar to a number of other functions like "zephyr,shell-uart" or "zephyr,bt-uart". As part of this we rework the init code a little to use DEVICE_DT_GET for the modem gsm-ppp case. Signed-off-by: Kumar Gala <[email protected]>
1 parent 3cbf653 commit 82c6531

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

doc/build/dts/api/api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,8 @@ device.
422422
- Used by the OpenThread to specify UART device for Spinel protocol
423423
* - zephyr,pcie-controller
424424
- The node corresponding to the PCIe Controller
425+
* - zephyr,ppp-uart
426+
- Sets UART device used by PPP
425427
* - zephyr,settings-partition
426428
- Fixed partition node. If defined this selects the partition used
427429
by the NVS and FCB settings backends.

drivers/net/Kconfig

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ config NET_PPP_ASYNC_UART
2323
depends on UART_ASYNC_API
2424
depends on !GSM_MUX
2525

26-
config NET_PPP_UART_NAME
27-
string "UART device name the PPP is connected to"
28-
depends on !MODEM_GSM_PPP
29-
3026
config NET_PPP_DRV_NAME
3127
string "PPP Driver name"
3228
default "ppp"

drivers/net/ppp.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,8 +1018,6 @@ static int ppp_start(const struct device *dev)
10181018
*/
10191019
#if !defined(CONFIG_NET_TEST)
10201020
if (atomic_cas(&context->modem_init_done, false, true)) {
1021-
const char *dev_name = NULL;
1022-
10231021
/* Now try to figure out what device to open. If GSM muxing
10241022
* is enabled, then use it. If not, then check if modem
10251023
* configuration is enabled, and use that. If none are enabled,
@@ -1035,22 +1033,17 @@ static int ppp_start(const struct device *dev)
10351033
return -ENOENT;
10361034
}
10371035

1038-
dev_name = mux->name;
1036+
context->dev = mux;
10391037
#elif IS_ENABLED(CONFIG_MODEM_GSM_PPP)
1040-
dev_name = DT_BUS_LABEL(DT_INST(0, zephyr_gsm_ppp));
1038+
context->dev = DEVICE_DT_GET(DT_BUS(DT_INST(0, zephyr_gsm_ppp)));
10411039
#else
1042-
dev_name = CONFIG_NET_PPP_UART_NAME;
1040+
/* dts chosen zephyr,ppp-uart case */
1041+
context->dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_ppp_uart));
10431042
#endif
1044-
if (dev_name == NULL || dev_name[0] == '\0') {
1045-
LOG_ERR("UART configuration is wrong!");
1046-
return -EINVAL;
1047-
}
1048-
1049-
LOG_INF("Initializing PPP to use %s", dev_name);
1043+
LOG_INF("Initializing PPP to use %s", context->dev->name);
10501044

1051-
context->dev = device_get_binding(dev_name);
1052-
if (!context->dev) {
1053-
LOG_ERR("Cannot find dev %s", dev_name);
1045+
if (!device_is_ready(context->dev)) {
1046+
LOG_ERR("Device %s is not ready", context->dev->name);
10541047
return -ENODEV;
10551048
}
10561049
#if defined(CONFIG_NET_PPP_ASYNC_UART)

0 commit comments

Comments
 (0)