Skip to content

Commit 71e498d

Browse files
de-nordiccarlescufi
authored andcommitted
mgmt/mcumgr: Rename zst pointers to smp_transport to smpt
Cosmetic change: the zst was short for zephyr_smp_transport, now it is just smp_transport so smpt makes more sense. Signed-off-by: Dominik Ermel <[email protected]>
1 parent a7e40b3 commit 71e498d

File tree

5 files changed

+74
-75
lines changed

5 files changed

+74
-75
lines changed

include/zephyr/mgmt/mcumgr/smp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ struct zephyr_smp_transport {
128128
/**
129129
* @brief Initializes a Zephyr SMP transport object.
130130
*
131-
* @param zst The transport to construct.
131+
* @param smpt The transport to construct.
132132
* @param output_func The transport's send function.
133133
* @param get_mtu_func The transport's get-MTU function.
134134
* @param ud_copy_func The transport buffer user_data copy function.
135135
* @param ud_free_func The transport buffer user_data free function.
136136
*/
137-
void smp_transport_init(struct smp_transport *zst,
137+
void smp_transport_init(struct smp_transport *smpt,
138138
smp_transport_out_fn output_func,
139139
smp_transport_get_mtu_fn get_mtu_func,
140140
smp_transport_ud_copy_fn ud_copy_func,

subsys/mgmt/mcumgr/smp.c

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void *smp_alloc_rsp(const void *req, void *arg)
4949
{
5050
const struct net_buf *req_nb;
5151
struct net_buf *rsp_nb;
52-
struct smp_transport *zst = arg;
52+
struct smp_transport *smpt = arg;
5353

5454
req_nb = req;
5555

@@ -58,8 +58,8 @@ void *smp_alloc_rsp(const void *req, void *arg)
5858
return NULL;
5959
}
6060

61-
if (zst->zst_ud_copy) {
62-
zst->zst_ud_copy(rsp_nb, req_nb);
61+
if (smpt->zst_ud_copy) {
62+
smpt->zst_ud_copy(rsp_nb, req_nb);
6363
} else {
6464
memcpy(net_buf_user_data(rsp_nb),
6565
net_buf_user_data((void *)req_nb),
@@ -71,14 +71,14 @@ void *smp_alloc_rsp(const void *req, void *arg)
7171

7272
void smp_free_buf(void *buf, void *arg)
7373
{
74-
struct smp_transport *zst = arg;
74+
struct smp_transport *smpt = arg;
7575

7676
if (!buf) {
7777
return;
7878
}
7979

80-
if (zst->zst_ud_free) {
81-
zst->zst_ud_free(net_buf_user_data((struct net_buf *)buf));
80+
if (smpt->zst_ud_free) {
81+
smpt->zst_ud_free(net_buf_user_data((struct net_buf *)buf));
8282
}
8383

8484
mcumgr_buf_free(buf);
@@ -88,8 +88,7 @@ void smp_free_buf(void *buf, void *arg)
8888
* Processes a single SMP packet and sends the corresponding response(s).
8989
*/
9090
static int
91-
smp_process_packet(struct smp_transport *zst,
92-
struct net_buf *nb)
91+
smp_process_packet(struct smp_transport *smpt, struct net_buf *nb)
9392
{
9493
struct cbor_nb_reader reader;
9594
struct cbor_nb_writer writer;
@@ -99,7 +98,7 @@ smp_process_packet(struct smp_transport *zst,
9998
streamer = (struct smp_streamer) {
10099
.reader = &reader,
101100
.writer = &writer,
102-
.smpt = zst,
101+
.smpt = smpt,
103102
};
104103

105104
rc = smp_process_request_packet(&streamer, nb);
@@ -112,52 +111,52 @@ smp_process_packet(struct smp_transport *zst,
112111
static void
113112
smp_handle_reqs(struct k_work *work)
114113
{
115-
struct smp_transport *zst;
114+
struct smp_transport *smpt;
116115
struct net_buf *nb;
117116

118-
zst = (void *)work;
117+
smpt = (void *)work;
119118

120-
while ((nb = net_buf_get(&zst->zst_fifo, K_NO_WAIT)) != NULL) {
121-
smp_process_packet(zst, nb);
119+
while ((nb = net_buf_get(&smpt->zst_fifo, K_NO_WAIT)) != NULL) {
120+
smp_process_packet(smpt, nb);
122121
}
123122
}
124123

125124
void
126-
smp_transport_init(struct smp_transport *zst,
125+
smp_transport_init(struct smp_transport *smpt,
127126
smp_transport_out_fn output_func,
128127
smp_transport_get_mtu_fn get_mtu_func,
129128
smp_transport_ud_copy_fn ud_copy_func,
130129
smp_transport_ud_free_fn ud_free_func)
131130
{
132-
*zst = (struct smp_transport) {
131+
*smpt = (struct smp_transport) {
133132
.zst_output = output_func,
134133
.zst_get_mtu = get_mtu_func,
135134
.zst_ud_copy = ud_copy_func,
136135
.zst_ud_free = ud_free_func,
137136
};
138137

139138
#ifdef CONFIG_MCUMGR_SMP_REASSEMBLY
140-
smp_reassembly_init(zst);
139+
smp_reassembly_init(smpt);
141140
#endif
142141

143-
k_work_init(&zst->zst_work, smp_handle_reqs);
144-
k_fifo_init(&zst->zst_fifo);
142+
k_work_init(&smpt->zst_work, smp_handle_reqs);
143+
k_fifo_init(&smpt->zst_fifo);
145144
}
146145

147146
/**
148147
* @brief Enqueues an incoming SMP request packet for processing.
149148
*
150149
* This function always consumes the supplied net_buf.
151150
*
152-
* @param zst The transport to use to send the corresponding
151+
* @param smpt The transport to use to send the corresponding
153152
* response(s).
154153
* @param nb The request packet to process.
155154
*/
156155
WEAK void
157-
smp_rx_req(struct smp_transport *zst, struct net_buf *nb)
156+
smp_rx_req(struct smp_transport *smpt, struct net_buf *nb)
158157
{
159-
net_buf_put(&zst->zst_fifo, nb);
160-
k_work_submit_to_queue(&smp_work_queue, &zst->zst_work);
158+
net_buf_put(&smpt->zst_fifo, nb);
159+
k_work_submit_to_queue(&smp_work_queue, &smpt->zst_work);
161160
}
162161

163162
static int smp_init(const struct device *dev)

subsys/mgmt/mcumgr/smp_internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ struct net_buf;
2121
*
2222
* This function always consumes the supplied net_buf.
2323
*
24-
* @param zst The transport to use to send the corresponding
24+
* @param smtp The transport to use to send the corresponding
2525
* response(s).
2626
* @param nb The request packet to process.
2727
*/
28-
void smp_rx_req(struct smp_transport *zst, struct net_buf *nb);
28+
void smp_rx_req(struct smp_transport *smtp, struct net_buf *nb);
2929

3030
static inline
3131
void zephyr_smp_rx_req(struct zephyr_smp_transport *smpt, struct net_buf *nb)

subsys/mgmt/mcumgr/smp_reassembly.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@
1313
#include <smp/smp.h>
1414
#include "smp_internal.h"
1515

16-
void smp_reassembly_init(struct smp_transport *zst)
16+
void smp_reassembly_init(struct smp_transport *smpt)
1717
{
18-
zst->__reassembly.current = NULL;
19-
zst->__reassembly.expected = 0;
18+
smpt->__reassembly.current = NULL;
19+
smpt->__reassembly.expected = 0;
2020
}
2121

22-
int smp_reassembly_expected(const struct smp_transport *zst)
22+
int smp_reassembly_expected(const struct smp_transport *smpt)
2323
{
24-
if (zst->__reassembly.current == NULL) {
24+
if (smpt->__reassembly.current == NULL) {
2525
return -EINVAL;
2626
}
2727

28-
return zst->__reassembly.expected;
28+
return smpt->__reassembly.expected;
2929
}
3030

31-
int smp_reassembly_collect(struct smp_transport *zst, const void *buf, uint16_t len)
31+
int smp_reassembly_collect(struct smp_transport *smpt, const void *buf, uint16_t len)
3232
{
33-
if (zst->__reassembly.current == NULL) {
33+
if (smpt->__reassembly.current == NULL) {
3434
/*
3535
* Collecting the first fragment: need to allocate buffer for it and prepare
3636
* the reassembly context.
@@ -54,9 +54,9 @@ int smp_reassembly_collect(struct smp_transport *zst, const void *buf, uint16_t
5454
return -EOVERFLOW;
5555
}
5656

57-
zst->__reassembly.current = mcumgr_buf_alloc();
58-
if (zst->__reassembly.current != NULL) {
59-
zst->__reassembly.expected = expected;
57+
smpt->__reassembly.current = mcumgr_buf_alloc();
58+
if (smpt->__reassembly.current != NULL) {
59+
smpt->__reassembly.expected = expected;
6060
} else {
6161
return -ENOMEM;
6262
}
@@ -67,53 +67,53 @@ int smp_reassembly_collect(struct smp_transport *zst, const void *buf, uint16_t
6767
}
6868

6969
/* len is expected to be > 0 */
70-
if (zst->__reassembly.expected >= len) {
71-
net_buf_add_mem(zst->__reassembly.current, buf, len);
72-
zst->__reassembly.expected -= len;
70+
if (smpt->__reassembly.expected >= len) {
71+
net_buf_add_mem(smpt->__reassembly.current, buf, len);
72+
smpt->__reassembly.expected -= len;
7373
} else {
7474
/*
7575
* A fragment is longer than the expected size and will not fit into the buffer.
7676
*/
7777
return -EOVERFLOW;
7878
}
7979

80-
return zst->__reassembly.expected;
80+
return smpt->__reassembly.expected;
8181
}
8282

83-
int smp_reassembly_complete(struct smp_transport *zst, bool force)
83+
int smp_reassembly_complete(struct smp_transport *smpt, bool force)
8484
{
85-
if (zst->__reassembly.current == NULL) {
85+
if (smpt->__reassembly.current == NULL) {
8686
return -EINVAL;
8787
}
8888

89-
if (zst->__reassembly.expected == 0 || force) {
90-
int expected = zst->__reassembly.expected;
89+
if (smpt->__reassembly.expected == 0 || force) {
90+
int expected = smpt->__reassembly.expected;
9191

92-
smp_rx_req(zst, zst->__reassembly.current);
93-
zst->__reassembly.expected = 0;
94-
zst->__reassembly.current = NULL;
92+
smp_rx_req(smpt, smpt->__reassembly.current);
93+
smpt->__reassembly.expected = 0;
94+
smpt->__reassembly.current = NULL;
9595
return expected;
9696
}
9797
return -ENODATA;
9898
}
9999

100-
int smp_reassembly_drop(struct smp_transport *zst)
100+
int smp_reassembly_drop(struct smp_transport *smpt)
101101
{
102-
if (zst->__reassembly.current == NULL) {
102+
if (smpt->__reassembly.current == NULL) {
103103
return -EINVAL;
104104
}
105105

106-
mcumgr_buf_free(zst->__reassembly.current);
107-
zst->__reassembly.expected = 0;
108-
zst->__reassembly.current = NULL;
106+
mcumgr_buf_free(smpt->__reassembly.current);
107+
smpt->__reassembly.expected = 0;
108+
smpt->__reassembly.current = NULL;
109109

110110
return 0;
111111
}
112112

113-
void *smp_reassembly_get_ud(const struct smp_transport *zst)
113+
void *smp_reassembly_get_ud(const struct smp_transport *smpt)
114114
{
115-
if (zst->__reassembly.current != NULL) {
116-
return net_buf_user_data(zst->__reassembly.current);
115+
if (smpt->__reassembly.current != NULL) {
116+
return net_buf_user_data(smpt->__reassembly.current);
117117
}
118118

119119
return NULL;

subsys/mgmt/mcumgr/smp_reassembly.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ struct smp_transport;
1616
/**
1717
* Initialize re-assembly context within smp_transport
1818
*
19-
* @param zst the SMP transport.
19+
* @param smpt the SMP transport.
2020
*
21-
* Note: for efficiency there is no NULL check on @p zst pointer and it is caller's responsibility
21+
* Note: for efficiency there is no NULL check on @p smpt pointer and it is caller's responsibility
2222
* to validate the pointer before passing it to this function.
2323
*/
24-
void smp_reassembly_init(struct smp_transport *zst);
24+
void smp_reassembly_init(struct smp_transport *smpt);
2525

2626
/**
2727
* Collect data to re-assembly buffer
@@ -32,11 +32,11 @@ void smp_reassembly_init(struct smp_transport *zst);
3232
* Note: Currently the function is not able to concatenate buffers so re-assembled packet needs
3333
* to fit into one buffer.
3434
*
35-
* @param zst the SMP transport;
35+
* @param smpt the SMP transport;
3636
* @param buf buffer with data to add;
3737
* @param len length of data to add;
3838
*
39-
* Note: For efficiency there are ot NULL checks on @p zst and @p buf pointers and it is caller's
39+
* Note: For efficiency there are ot NULL checks on @p smpt and @p buf pointers and it is caller's
4040
* responsibility to make sure these are not NULL. Also @p len should not be 0 as there is no
4141
* point in passing an empty fragment for re-assembly.
4242
*
@@ -50,35 +50,35 @@ void smp_reassembly_init(struct smp_transport *zst);
5050
* -ENODATA if the first received fragment was not big enough to figure out a size
5151
* of the packet; MTU is set too low;
5252
*/
53-
int smp_reassembly_collect(struct smp_transport *zst, const void *buf, uint16_t len);
53+
int smp_reassembly_collect(struct smp_transport *smpt, const void *buf, uint16_t len);
5454

5555
/**
5656
* Return number of expected bytes to complete the packet
5757
*
58-
* @param zst the SMP transport;
58+
* @param smpt the SMP transport;
5959
*
60-
* Note: for efficiency there is no NULL check on @p zst pointer and it is caller's responsibility
60+
* Note: for efficiency there is no NULL check on @p smpt pointer and it is caller's responsibility
6161
* to validate the pointer before passing it to this function.
6262
*
6363
* @return number of bytes needed to complete the packet;
6464
* -EINVAL if there is no packet in re-assembly;
6565
*/
66-
int smp_reassembly_expected(const struct smp_transport *zst);
66+
int smp_reassembly_expected(const struct smp_transport *smpt);
6767

6868
/**
6969
* Pass packet for further processing
7070
*
7171
* Checks if the packet has enough data to be re-assembled and passes it for further processing.
72-
* If successful then the re-assembly context in @p zst will indicate that there is no
72+
* If successful then the re-assembly context in @p smpt will indicate that there is no
7373
* re-assembly in progress.
7474
* The function can be forced to pass a data for processing even if the packet is not complete,
7575
* in which case it is users responsibility to use the user data, passed with the packet, to notify
7676
* receiving end of such case.
7777
*
78-
* @param zst the SMP transport;
78+
* @param smpt the SMP transport;
7979
* @param force process anyway;
8080
*
81-
* Note: for efficiency there is no NULL check on @p zst pointer and it is caller's responsibility
81+
* Note: for efficiency there is no NULL check on @p smpt pointer and it is caller's responsibility
8282
* to validate the pointer before passing it to this function.
8383
*
8484
* @return 0 on success and not forced;
@@ -87,33 +87,33 @@ int smp_reassembly_expected(const struct smp_transport *zst);
8787
* -ENODATA if there is not enough data to consider packet re-assembled, it has not
8888
* been passed further.
8989
*/
90-
int smp_reassembly_complete(struct smp_transport *zst, bool force);
90+
int smp_reassembly_complete(struct smp_transport *smpt, bool force);
9191

9292
/**
9393
* Drop packet and release buffer
9494
*
95-
* @param zst the SMP transport;
95+
* @param smpt the SMP transport;
9696
*
97-
* Note: for efficiency there is no NULL check on @p zst pointer and it is caller's responsibility
97+
* Note: for efficiency there is no NULL check on @p smpt pointer and it is caller's responsibility
9898
* to validate the pointer before passing it to this function.
9999
*
100100
* @return 0 on success;
101101
* -EINVAL if there is no re-assembly in progress.
102102
*/
103-
int smp_reassembly_drop(struct smp_transport *zst);
103+
int smp_reassembly_drop(struct smp_transport *smpt);
104104

105105
/**
106106
* Get "user data" pointer for current packet re-assembly
107107
*
108-
* @param zst the SMP transport;
108+
* @param smpt the SMP transport;
109109
*
110-
* Note: for efficiency there is no NULL check on @p zst pointer and it is caller's responsibility
110+
* Note: for efficiency there is no NULL check on @p smpt pointer and it is caller's responsibility
111111
* to validate the pointer before passing it to this function.
112112
*
113113
* @return pointer to "user data" of CONFIG_MCUMGR_BUF_USER_DATA_SIZE size;
114114
* NULL if no re-assembly in progress.
115115
*/
116-
void *smp_reassembly_get_ud(const struct smp_transport *zst);
116+
void *smp_reassembly_get_ud(const struct smp_transport *smpt);
117117

118118
#ifdef __cplusplus
119119
}

0 commit comments

Comments
 (0)