Skip to content

Commit 3981738

Browse files
committed
drivers: modem: Fixed style issues of sim7080 driver
Fixed zephyr style violations. Signed-off-by: Lukas Gehreke <[email protected]>
1 parent fb69a3e commit 3981738

File tree

11 files changed

+142
-133
lines changed

11 files changed

+142
-133
lines changed

drivers/modem/simcom/sim7080/sim7080.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,13 @@ MODEM_CMD_DIRECT_DEFINE(on_cmd_tx_ready)
281281
* Handles pdp context urc.
282282
*
283283
* The urc has the form +APP PDP: <index>,<state>.
284-
* State can either be ACTIVE for activation or
285-
* DEACTIVE if disabled.
284+
* When activated ACTIVE is reported as state.
285+
* All other states will be treated as deactivated.
286286
*/
287287
MODEM_CMD_DEFINE(on_urc_app_pdp)
288288
{
289289
bool active = strcmp(argv[1], "ACTIVE") == 0;
290+
290291
if (active) {
291292
mdata.status_flags |= SIM7080_STATUS_FLAG_PDP_ACTIVE;
292293
} else {
@@ -466,12 +467,14 @@ static int modem_set_baudrate(uint32_t baudrate)
466467
char buf[sizeof("AT+IPR=##########")] = {0};
467468

468469
int ret = snprintk(buf, sizeof(buf), "AT+IPR=%u", baudrate);
470+
469471
if (ret < 0) {
470472
LOG_ERR("Failed to build command");
471473
goto out;
472474
}
473475

474-
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, buf, &mdata.sem_response, K_SECONDS(2));
476+
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, buf, &mdata.sem_response,
477+
K_SECONDS(2));
475478
if (ret != 0) {
476479
LOG_ERR("Failed to set baudrate");
477480
}
@@ -511,12 +514,12 @@ int modem_autobaud(void)
511514

512515
/**
513516
* Power on the modem and wait for operational sim card.
514-
*
517+
*
515518
* @param allow_autobaud Allow autobaud functionality.
516519
* @return 0 on success. Otherwise <0.
517-
*
520+
*
518521
* @note Autobaud is only allowed during driver setup.
519-
* In any other case a fixed baudrate should be used.
522+
* In any other case a fixed baudrate should be used.
520523
*/
521524
static int modem_boot(bool allow_autobaud)
522525
{
@@ -773,7 +776,7 @@ static int modem_init(const struct device *dev)
773776
k_sem_init(&mdata.sem_dns, 0, 1);
774777
k_sem_init(&mdata.sem_ftp, 0, 1);
775778
k_sem_init(&mdata.sem_http, 0, 1);
776-
k_sem_init(&mdata.boot_sem, 0 ,1);
779+
k_sem_init(&mdata.boot_sem, 0, 1);
777780
k_sem_init(&mdata.pdp_sem, 0, 1);
778781
k_work_queue_start(&modem_workq, modem_workq_stack,
779782
K_KERNEL_STACK_SIZEOF(modem_workq_stack), K_PRIO_COOP(7), NULL);

drivers/modem/simcom/sim7080/sim7080.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ struct socket_read_data {
175175
};
176176

177177
/*
178-
* Driver internals
178+
* Driver internals
179179
*/
180180
extern struct sim7080_data mdata;
181181
extern struct modem_context mctx;
@@ -198,6 +198,6 @@ void sim7080_handle_sock_data_indication(int fd);
198198

199199
void sim7080_handle_sock_state(int fd, uint8_t state);
200200

201-
int sim7080_utils_parse_time(uint8_t *date, uint8_t *time, struct tm *t);
201+
int sim7080_utils_parse_time(uint8_t *date, uint8_t *time_str, struct tm *t);
202202

203203
#endif /* SIMCOM_SIM7080_H */

drivers/modem/simcom/sim7080/sim7080_dns.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ MODEM_CMD_DEFINE(on_cmd_cdnsgip)
5353

5454
*ipv4 = '\0';
5555
net_addr_pton(dns_result.ai_family, ips,
56-
&((struct sockaddr_in *)&dns_result_addr)->sin_addr);
56+
&((struct sockaddr_in *)&dns_result_addr)->sin_addr);
5757
ret = 0;
5858

5959
exit:
@@ -65,7 +65,7 @@ MODEM_CMD_DEFINE(on_cmd_cdnsgip)
6565
* Perform a dns lookup.
6666
*/
6767
static int offload_getaddrinfo(const char *node, const char *service,
68-
const struct zsock_addrinfo *hints, struct zsock_addrinfo **res)
68+
const struct zsock_addrinfo *hints, struct zsock_addrinfo **res)
6969
{
7070
struct modem_cmd cmd[] = { MODEM_CMD("+CDNSGIP: ", on_cmd_cdnsgip, 2U, ",") };
7171
char sendbuf[sizeof("AT+CDNSGIP=\"\",##,#####") + 128];
@@ -117,7 +117,7 @@ static int offload_getaddrinfo(const char *node, const char *service,
117117

118118
snprintk(sendbuf, sizeof(sendbuf), "AT+CDNSGIP=\"%s\",10,20000", node);
119119
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, cmd, ARRAY_SIZE(cmd), sendbuf,
120-
&mdata.sem_dns, MDM_DNS_TIMEOUT);
120+
&mdata.sem_dns, MDM_DNS_TIMEOUT);
121121
if (ret < 0) {
122122
return ret;
123123
}

drivers/modem/simcom/sim7080/sim7080_ftp.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ MODEM_CMD_DEFINE(on_cmd_ftpget)
4040
}
4141

4242
out_len = net_buf_linearize(mdata.ftp.read_buffer, mdata.ftp.nread, data->rx_buf,
43-
bytes_to_skip, nbytes);
43+
bytes_to_skip, nbytes);
4444
if (out_len != nbytes) {
4545
LOG_WRN("FTP read size differs!");
4646
}
@@ -59,7 +59,7 @@ int mdm_sim7080_ftp_get_read(char *dst, size_t *size)
5959

6060
/* Some error occurred. */
6161
if (mdata.ftp.state == SIM7080_FTP_CONNECTION_STATE_ERROR ||
62-
mdata.ftp.state == SIM7080_FTP_CONNECTION_STATE_INITIAL) {
62+
mdata.ftp.state == SIM7080_FTP_CONNECTION_STATE_INITIAL) {
6363
return SIM7080_FTP_RC_ERROR;
6464
}
6565

@@ -86,7 +86,7 @@ int mdm_sim7080_ftp_get_read(char *dst, size_t *size)
8686
}
8787

8888
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, cmds, ARRAY_SIZE(cmds), buffer,
89-
&mdata.sem_response, MDM_CMD_TIMEOUT);
89+
&mdata.sem_response, MDM_CMD_TIMEOUT);
9090
if (ret < 0) {
9191
*size = 0;
9292
return SIM7080_FTP_RC_ERROR;
@@ -99,7 +99,7 @@ int mdm_sim7080_ftp_get_read(char *dst, size_t *size)
9999
}
100100

101101
int mdm_sim7080_ftp_get_start(const char *server, const char *user, const char *passwd,
102-
const char *file, const char *path)
102+
const char *file, const char *path)
103103
{
104104
int ret;
105105
char buffer[256];
@@ -113,7 +113,7 @@ int mdm_sim7080_ftp_get_start(const char *server, const char *user, const char *
113113

114114
/* Set connection id for ftp. */
115115
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, "AT+FTPCID=0",
116-
&mdata.sem_response, MDM_CMD_TIMEOUT);
116+
&mdata.sem_response, MDM_CMD_TIMEOUT);
117117
if (ret < 0) {
118118
LOG_WRN("Failed to set FTP Cid!");
119119
return -1;
@@ -127,7 +127,7 @@ int mdm_sim7080_ftp_get_start(const char *server, const char *user, const char *
127127
}
128128

129129
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, buffer, &mdata.sem_response,
130-
MDM_CMD_TIMEOUT);
130+
MDM_CMD_TIMEOUT);
131131
if (ret < 0) {
132132
LOG_WRN("Failed to set FTP Cid!");
133133
return -1;
@@ -141,7 +141,7 @@ int mdm_sim7080_ftp_get_start(const char *server, const char *user, const char *
141141
}
142142

143143
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, buffer, &mdata.sem_response,
144-
MDM_CMD_TIMEOUT);
144+
MDM_CMD_TIMEOUT);
145145
if (ret < 0) {
146146
LOG_WRN("Failed to set ftp user!");
147147
return -1;
@@ -155,7 +155,7 @@ int mdm_sim7080_ftp_get_start(const char *server, const char *user, const char *
155155
}
156156

157157
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, buffer, &mdata.sem_response,
158-
MDM_CMD_TIMEOUT);
158+
MDM_CMD_TIMEOUT);
159159
if (ret < 0) {
160160
LOG_WRN("Failed to set ftp password!");
161161
return -1;
@@ -169,7 +169,7 @@ int mdm_sim7080_ftp_get_start(const char *server, const char *user, const char *
169169
}
170170

171171
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, buffer, &mdata.sem_response,
172-
MDM_CMD_TIMEOUT);
172+
MDM_CMD_TIMEOUT);
173173
if (ret < 0) {
174174
LOG_WRN("Failed to set ftp filename!");
175175
return -1;
@@ -183,7 +183,7 @@ int mdm_sim7080_ftp_get_start(const char *server, const char *user, const char *
183183
}
184184

185185
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, buffer, &mdata.sem_response,
186-
MDM_CMD_TIMEOUT);
186+
MDM_CMD_TIMEOUT);
187187
if (ret < 0) {
188188
LOG_WRN("Failed to set ftp filename!");
189189
return -1;
@@ -197,7 +197,7 @@ int mdm_sim7080_ftp_get_start(const char *server, const char *user, const char *
197197
}
198198

199199
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, buffer, &mdata.sem_response,
200-
MDM_CMD_TIMEOUT);
200+
MDM_CMD_TIMEOUT);
201201
if (ret < 0) {
202202
LOG_WRN("Failed to set ftp path!");
203203
return -1;
@@ -210,7 +210,7 @@ int mdm_sim7080_ftp_get_start(const char *server, const char *user, const char *
210210

211211
/* Start the ftp session. */
212212
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, "AT+FTPGET=1",
213-
&mdata.sem_ftp, MDM_CMD_TIMEOUT);
213+
&mdata.sem_ftp, MDM_CMD_TIMEOUT);
214214
if (ret < 0) {
215215
LOG_WRN("Failed to start session!");
216216
return -1;

drivers/modem/simcom/sim7080/sim7080_gps.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ int mdm_sim7080_query_gnss(struct sim7080_gnss_data *data)
246246
return -1;
247247
}
248248

249-
memset(&gnss_data, 0, sizeof(gnss_data));
249+
memset(&gnss_data, 0, sizeof(gnss_data));
250250

251251
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, cmds, ARRAY_SIZE(cmds), "AT+CGNSINF",
252-
&mdata.sem_response, K_SECONDS(2));
252+
&mdata.sem_response, K_SECONDS(2));
253253
if (ret < 0) {
254254
return ret;
255255
}
@@ -282,6 +282,7 @@ MODEM_CMD_DEFINE(on_cmd_cgnsxtra)
282282
xtra_diff_h = (int16_t)strtol(argv[0], NULL, 10);
283283
xtra_duration_h = (int16_t)strtol(argv[1], NULL, 10);
284284
int ret = sim7080_utils_parse_time(argv[2], argv[3], xtra_inject);
285+
285286
LOG_INF("XTRA validity: diff=%d, duration=%d, inject=%s,%s",
286287
xtra_diff_h,
287288
xtra_duration_h,
@@ -302,7 +303,7 @@ int mdm_sim7080_query_xtra_validity(int16_t *diff_h, int16_t *duration_h, struct
302303
xtra_inject = inject;
303304

304305
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, cmds, ARRAY_SIZE(cmds), "AT+CGNSXTRA",
305-
&mdata.sem_response, K_SECONDS(2));
306+
&mdata.sem_response, K_SECONDS(2));
306307
if (ret != 0) {
307308
LOG_ERR("Failed to query xtra validity");
308309
goto out;
@@ -331,7 +332,7 @@ static int sim7080_start_gnss_ext(bool xtra)
331332

332333
/* Power GNSS unit */
333334
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, "AT+CGNSPWR=1",
334-
&mdata.sem_response, K_SECONDS(2));
335+
&mdata.sem_response, K_SECONDS(2));
335336
if (ret < 0) {
336337
LOG_ERR("Failed to power on gnss: %d", ret);
337338
goto out;
@@ -347,7 +348,7 @@ static int sim7080_start_gnss_ext(bool xtra)
347348

348349
/* Copy the xtra file to gnss unit */
349350
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, cmds, ARRAY_SIZE(cmds), "AT+CGNSCPY",
350-
&mdata.sem_response, K_SECONDS(5));
351+
&mdata.sem_response, K_SECONDS(5));
351352
if (ret < 0) {
352353
LOG_WRN("Failed to copy xtra file. Performing cold start");
353354
goto coldstart;
@@ -375,15 +376,15 @@ static int sim7080_start_gnss_ext(bool xtra)
375376

376377
/* Enable xtra functionality */
377378
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, "AT+CGNSXTRA=1",
378-
&mdata.sem_response, K_SECONDS(5));
379+
&mdata.sem_response, K_SECONDS(5));
379380
if (ret < 0) {
380381
LOG_WRN("Failed to enable xtra. Performing cold start");
381382
goto coldstart;
382383
}
383384

384385
coldstart:
385386
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, "AT+CGNSCOLD",
386-
&mdata.sem_response, K_SECONDS(2));
387+
&mdata.sem_response, K_SECONDS(2));
387388
if (ret < 0) {
388389
LOG_ERR("Failed to start gnss: %d", ret);
389390
goto out;
@@ -414,7 +415,7 @@ int mdm_sim7080_stop_gnss(void)
414415
}
415416

416417
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, "AT+CGNSPWR=0",
417-
&mdata.sem_response, K_SECONDS(2));
418+
&mdata.sem_response, K_SECONDS(2));
418419
if (ret < 0) {
419420
LOG_ERR("Failed to power on gnss: %d", ret);
420421
goto out;
@@ -446,7 +447,7 @@ int mdm_sim7080_download_xtra(uint8_t server_id, const char *f_name)
446447

447448
/* Download xtra file */
448449
ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, buf,
449-
&mdata.sem_response, K_SECONDS(2));
450+
&mdata.sem_response, K_SECONDS(2));
450451
if (ret < 0) {
451452
LOG_ERR("Failed to download xtra file");
452453
goto out;

0 commit comments

Comments
 (0)