Skip to content

Commit c8709a4

Browse files
committed
astyle changes on recent modem code changes.
1 parent 219f3f4 commit c8709a4

File tree

4 files changed

+122
-113
lines changed

4 files changed

+122
-113
lines changed

targets/TARGET_Samsung/TARGET_SIDK_S5JS100/mbed_main_init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ extern "C" {
2828
void s5js100_modem_start(void)
2929
{
3030
pShmemLinkDevice = new ShmemLinkDevice();
31-
pShmemLinkDevice->ShmemLinkDevice_start();
31+
pShmemLinkDevice->ShmemLinkDevice_start();
3232
}
3333

3434
void s5js100_modem_stop(void)

targets/TARGET_Samsung/TARGET_SIDK_S5JS100/modem/modem_io_device.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,38 +30,38 @@
3030
#endif
3131
#define MODEM_IO_DEVICE_DBG if (MODEM_IO_DEVICE_DBG_ON) tr_info
3232

33-
#define MODEM_IO_DEVICE_MAX sizeof(modem_io_deivce_list)/sizeof(ModemIoDevice *)
33+
#define MODEM_IO_DEVICE_MAX sizeof(modem_io_deivce_list)/sizeof(ModemIoDevice *)
3434

3535
ShmemIpcFmtDevice *ipc_fmt_dev = ShmemIpcFmtDevice::getInstance();
3636
ShmemIpcRawDevice *ipc_raw_dev = ShmemIpcRawDevice::getInstance();
3737

38-
IoDevMisc IoDev_ModemProxy( (char *)"ModemProxy", 245, ipc_fmt_dev);
39-
IoDevNet IoDev_rmnet1( (char *)"rmnet1", 1, ipc_raw_dev);
40-
IoDevMisc IoDev_shmem_save( (char *)"shmem_save", 243, ipc_raw_dev);
41-
IoDevMisc IoDev_dcxo( (char *)"dcxo", 244, ipc_raw_dev);
42-
IoDevMisc IoDev_if5( (char *)"if5", 242, ipc_raw_dev);
43-
IoDevNet IoDev_rmnet2( (char *)"rmnet2", 2, ipc_raw_dev);
44-
IoDevNet IoDev_rmnet3( (char *)"rmnet3", 3, ipc_raw_dev);
45-
IoDevNet IoDev_rmnet4( (char *)"rmnet4", 4, ipc_raw_dev);
46-
IoDevMisc IoDev_rmnet6( (char *)"rmnet6", 6, ipc_raw_dev);
47-
IoDevMisc IoDev_rmnet7( (char *)"rmnet7", 7, ipc_raw_dev);
48-
IoDevMisc IoDev_rmnet8( (char *)"rmnet8", 8, ipc_raw_dev);
49-
IoDevMisc IoDev_rmnet9( (char *)"rmnet9", 9, ipc_raw_dev);
38+
IoDevMisc IoDev_ModemProxy((char *)"ModemProxy", 245, ipc_fmt_dev);
39+
IoDevNet IoDev_rmnet1((char *)"rmnet1", 1, ipc_raw_dev);
40+
IoDevMisc IoDev_shmem_save((char *)"shmem_save", 243, ipc_raw_dev);
41+
IoDevMisc IoDev_dcxo((char *)"dcxo", 244, ipc_raw_dev);
42+
IoDevMisc IoDev_if5((char *)"if5", 242, ipc_raw_dev);
43+
IoDevNet IoDev_rmnet2((char *)"rmnet2", 2, ipc_raw_dev);
44+
IoDevNet IoDev_rmnet3((char *)"rmnet3", 3, ipc_raw_dev);
45+
IoDevNet IoDev_rmnet4((char *)"rmnet4", 4, ipc_raw_dev);
46+
IoDevMisc IoDev_rmnet6((char *)"rmnet6", 6, ipc_raw_dev);
47+
IoDevMisc IoDev_rmnet7((char *)"rmnet7", 7, ipc_raw_dev);
48+
IoDevMisc IoDev_rmnet8((char *)"rmnet8", 8, ipc_raw_dev);
49+
IoDevMisc IoDev_rmnet9((char *)"rmnet9", 9, ipc_raw_dev);
5050

5151

5252
ModemIoDevice *modem_io_deivce_list[] = {
53-
&IoDev_ModemProxy,
54-
&IoDev_rmnet1,
55-
&IoDev_shmem_save,
56-
&IoDev_dcxo,
57-
&IoDev_if5,
58-
&IoDev_rmnet2,
59-
&IoDev_rmnet3,
60-
&IoDev_rmnet4,
61-
&IoDev_rmnet6,
62-
&IoDev_rmnet7,
63-
&IoDev_rmnet8,
64-
&IoDev_rmnet9,
53+
&IoDev_ModemProxy,
54+
&IoDev_rmnet1,
55+
&IoDev_shmem_save,
56+
&IoDev_dcxo,
57+
&IoDev_if5,
58+
&IoDev_rmnet2,
59+
&IoDev_rmnet3,
60+
&IoDev_rmnet4,
61+
&IoDev_rmnet6,
62+
&IoDev_rmnet7,
63+
&IoDev_rmnet8,
64+
&IoDev_rmnet9,
6565
};
6666

6767
ModemIoDevice *getModemIoDeviceByName(char *name)
@@ -115,7 +115,7 @@ void ModemIoDevice::exynos_build_header(unsigned char *buff, unsigned short cfg,
115115
unsigned short *size = (unsigned short *)(buff + EXYNOS_LEN_OFFSET);
116116

117117
*exynos_header = EXYNOS_START_MASK;
118-
//*frame_seq = ++(seq_num.frame_cnt);
118+
//*frame_seq = ++(seq_num.frame_cnt);
119119
*frag_cfg = cfg;
120120
*size = (unsigned short)(EXYNOS_HEADER_SIZE + count);
121121
buff[EXYNOS_CH_ID_OFFSET] = id;

targets/TARGET_Samsung/TARGET_SIDK_S5JS100/modem/modem_io_device.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class IoDevMisc : public ModemIoDevice {
7979
id = ch;
8080
ipc = ipc_dev;
8181
mode = LINK_MODE_OFFLINE;
82-
ch_cnt = 0;
82+
ch_cnt = 0;
8383
read_cb = NULL;
8484
}
8585
void IoReadCallback(mio_buf *);
@@ -97,7 +97,7 @@ class IoDevNet : public ModemIoDevice {
9797
id = ch;
9898
ipc = ipc_dev;
9999
mode = LINK_MODE_OFFLINE;
100-
ch_cnt = 0;
100+
ch_cnt = 0;
101101
read_cb = NULL;
102102
}
103103
void IoReadCallback(mio_buf *);

targets/TARGET_Samsung/TARGET_SIDK_S5JS100/modem/modem_link_device_shmem.cpp

Lines changed: 93 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#endif
4444
#define MODEM_LINK_DEVICE_SHMEM_DBG if (MODEM_LINK_DEVICE_SHMEM_DBG_ON) tr_info
4545

46-
#define SHMEM_CIRC_BUFFER_ERROR (-10)
46+
#define SHMEM_CIRC_BUFFER_ERROR (-10)
4747

4848

4949

@@ -60,20 +60,22 @@ Thread *msgrxwork;
6060
Thread *irqwork;
6161
Semaphore modem_link_device_sem(0, 512);
6262

63-
bool shmem_ready=0;
63+
bool shmem_ready = 0;
6464

6565
int ShmemIpcDevice::get_txq_space(void)
6666
{
6767
unsigned int head = *txq.head;
6868
unsigned int tail = *txq.tail;
6969
int space;
7070

71-
if((head >= txq.size) || (tail >= txq.size))
72-
return SHMEM_CIRC_BUFFER_ERROR;
71+
if ((head >= txq.size) || (tail >= txq.size)) {
72+
return SHMEM_CIRC_BUFFER_ERROR;
73+
}
7374

7475
space = tail - head - 1;
75-
if(space < 0)
76-
space += txq.size;
76+
if (space < 0) {
77+
space += txq.size;
78+
}
7779

7880
return space;
7981
}
@@ -94,31 +96,37 @@ void ShmemIpcDevice::write_ipc_to_txq(mio_buf *mio)
9496

9597
/* Write HEADER to the TXQ, assume that with padding aligned on 4 bytes */
9698
i = in >> 2;
97-
for (j = 0; j < EXYNOS_HEADER_SIZE/4; j++) {
99+
for (j = 0; j < EXYNOS_HEADER_SIZE / 4; j++) {
98100
buff[i] = header[j];
99101
i ++;
100-
if(i == qsize>>2){
101-
i = 0;}
102-
MBED_ASSERT(i < qsize>>2);
102+
if (i == qsize >> 2) {
103+
i = 0;
104+
}
105+
MBED_ASSERT(i < qsize >> 2);
103106
}
104107

105108
in += EXYNOS_HEADER_SIZE;
106-
if (in >= qsize) in -= qsize;
109+
if (in >= qsize) {
110+
in -= qsize;
111+
}
107112

108113
/* Write data to the TXQ, assume that with padding aligned on 4 bytes */
109114
i = in >> 2;
110-
for (j = 0; j < (len + pad)/4; j ++) {
115+
for (j = 0; j < (len + pad) / 4; j ++) {
111116
buff[i] = src[j];
112117
i ++;
113-
if(i == qsize>>2){
114-
i = 0;}
115-
MBED_ASSERT(i < qsize>>2);
118+
if (i == qsize >> 2) {
119+
i = 0;
120+
}
121+
MBED_ASSERT(i < qsize >> 2);
116122
}
117123

118124
in += len + pad;
119-
if (in >= qsize) in -= qsize;
125+
if (in >= qsize) {
126+
in -= qsize;
127+
}
120128

121-
*txq.head = in;
129+
*txq.head = in;
122130
}
123131

124132
int ShmemIpcDevice::xmit_ipc_msg(mio_buf *msg)
@@ -153,22 +161,20 @@ int ShmemIpcDevice::xmit_ipc_msg(mio_buf *msg)
153161

154162
/* Get the size of free space in the TXQ */
155163
space = get_txq_space();
156-
if (space < 0)
157-
{
164+
if (space < 0) {
158165
/* TXQ ERROR */
159166
copied = -EIO;
160167
return copied;//break;
161168
}
162169

163170
/* TO DO - check free memory space if it fits all headres !!!
164-
Check the free space size,
171+
Check the free space size,
165172
- FMT : comparing with mxb->len
166173
- RAW : check used buffer size */
167174
chk_nospc = (space < msg->len) ? true : false;
168175

169-
if (chk_nospc)
170-
{
171-
/* TO DO - implement this back pressure to operate properly. */
176+
if (chk_nospc) {
177+
/* TO DO - implement this back pressure to operate properly. */
172178
printf("ERROR Not implement %s:%d\n", __func__, __LINE__);
173179
while (1);
174180
/* Set res_required flag for the "dev" */
@@ -434,15 +440,15 @@ void ShmemIpcDevice::done_req_ack(void)
434440

435441
void ShmemIpcDevice::recv_res_ack(unsigned short intr)
436442
{
437-
/*
438-
This method is used to nodify about receiving response
439-
from CP on req_ack sent earlier to confirm CPis alive
440-
In fact we never sent is, so nothing to receive.
441-
*/
442-
if(intr & mask_res_ack) {
443-
/* We should not get here!!! */
444-
while(1);
445-
}
443+
/*
444+
This method is used to nodify about receiving response
445+
from CP on req_ack sent earlier to confirm CPis alive
446+
In fact we never sent is, so nothing to receive.
447+
*/
448+
if (intr & mask_res_ack) {
449+
/* We should not get here!!! */
450+
while (1);
451+
}
446452
}
447453

448454
void ShmemIpcDevice::recv_req_ack(unsigned short intr)
@@ -500,12 +506,14 @@ int ShmemIpcDevice::rx_ipc_frames(void)
500506
{
501507
int i;
502508

503-
/* buffer indeces are corrupted*/
504-
if((*rxq.head >= rxq.size) || (*rxq.tail >= rxq.size))
505-
return -5;
506-
/* nothing to read */
507-
if (*rxq.head == *rxq.tail)
508-
return 0;
509+
/* buffer indeces are corrupted*/
510+
if ((*rxq.head >= rxq.size) || (*rxq.tail >= rxq.size)) {
511+
return -5;
512+
}
513+
/* nothing to read */
514+
if (*rxq.head == *rxq.tail) {
515+
return 0;
516+
}
509517

510518
ShmemLinkDevice *ld = pShmemLinkDevice;
511519

@@ -516,61 +524,63 @@ int ShmemIpcDevice::rx_ipc_frames(void)
516524
/**
517525
* variables for RX processing
518526
*/
519-
int rcvd; /* size of data in the RXQ or error */
520-
int rest; /* size of the rest data */
521-
unsigned int out; /* index to the start of current frame */
522-
int tot; /* total length including padding data */
527+
int rcvd; /* size of data in the RXQ or error */
528+
int rest; /* size of the rest data */
529+
unsigned int out; /* index to the start of current frame */
530+
int tot; /* total length including padding data */
523531

524532
rcvd = *rxq.head - *rxq.tail;
525-
if(rcvd < 0)
526-
rcvd += rxq.size;
533+
if (rcvd < 0) {
534+
rcvd += rxq.size;
535+
}
527536

528537
rest = rcvd;
529538
out = *rxq.tail;
530539

531540
while (rest > 0) {
532541
mio_buf *msg;
533542

534-
if(rest < EXYNOS_HEADER_SIZE)
535-
return -75;
536-
537-
for(i = 0; i < EXYNOS_HEADER_SIZE/4; i ++) {
538-
((unsigned int *)hdr)[i] = ((unsigned int *)rxq.buff)[out>>2];
539-
out += 4;
540-
if(out >= rxq.size)
541-
out = 0;
542-
}
543+
if (rest < EXYNOS_HEADER_SIZE) {
544+
return -75;
545+
}
546+
547+
for (i = 0; i < EXYNOS_HEADER_SIZE / 4; i ++) {
548+
((unsigned int *)hdr)[i] = ((unsigned int *)rxq.buff)[out >> 2];
549+
out += 4;
550+
if (out >= rxq.size) {
551+
out = 0;
552+
}
553+
}
543554

544555
/* Check the config field in the header */
545-
if (!exynos_start_valid(hdr))
546-
{
556+
if (!exynos_start_valid(hdr)) {
547557
goto bad_msg;
548558
}
549559

550560
/* Verify the total length of the frame (data + padding) */
551561
tot = exynos_get_total_len(hdr);
552-
if (tot > rest)
553-
{
562+
if (tot > rest) {
554563
goto bad_msg;
555564
}
556565

557566
msg = alloc_mio_buf(tot - EXYNOS_HEADER_SIZE);
558-
for(i = 0; i < (tot - EXYNOS_HEADER_SIZE)/4; i ++) {
559-
((unsigned int *)(msg->data))[i] = ((unsigned int *)rxq.buff)[out>>2];
560-
out += 4;
561-
if(out >= rxq.size)
562-
out = 0;
563-
}
567+
for (i = 0; i < (tot - EXYNOS_HEADER_SIZE) / 4; i ++) {
568+
((unsigned int *)(msg->data))[i] = ((unsigned int *)rxq.buff)[out >> 2];
569+
out += 4;
570+
if (out >= rxq.size) {
571+
out = 0;
572+
}
573+
}
564574

565575

566576
msg->ch = exynos_get_ch(hdr);
567577

568-
if(msg->ch == 254){
569-
msg->len = tot - EXYNOS_HEADER_SIZE;
570-
} else {
571-
/* Use actual frame len to pass real payload length to upper layer */
572-
msg->len = exynos_get_frame_len(hdr) - EXYNOS_HEADER_SIZE;
573-
}
578+
if (msg->ch == 254) {
579+
msg->len = tot - EXYNOS_HEADER_SIZE;
580+
} else {
581+
/* Use actual frame len to pass real payload length to upper layer */
582+
msg->len = exynos_get_frame_len(hdr) - EXYNOS_HEADER_SIZE;
583+
}
574584

575585
ld->ipc_rxq.put(msg);
576586
ld->ipc_rx_sem->release();
@@ -694,10 +704,10 @@ void msg_handler(void)
694704
ipc = ld->ipc_device[i];
695705
ret = ipc->rx_ipc_frames();
696706

697-
/* TODO review below case and handle it properly!!! */
698-
/* In case of error just return. Shall we do aything here? */
707+
/* TODO review below case and handle it properly!!! */
708+
/* In case of error just return. Shall we do aything here? */
699709
if (ret < 0)
700-
while(1);
710+
while (1);
701711

702712
ipc->done_req_ack();
703713
}
@@ -718,19 +728,18 @@ void ipc_rx_task(void)
718728
return;
719729
}
720730

721-
if(INT_VALID(int2ap)) {
722-
/* Make CP happy with our fake responses we are alive ... */
723-
/* However CP never sends it ... only SEND_R and SEND_F */
724-
/* Check and receive RES_ACK from CP */
725-
/* Check and receive REQ_ACK from CP */
726-
for (i = 0; i < MAX_IPC_DEV; i++)
727-
{
728-
ld->ipc_device[i]->recv_res_ack(int2ap);
729-
ld->ipc_device[i]->recv_req_ack(int2ap);
730-
}
731+
if (INT_VALID(int2ap)) {
732+
/* Make CP happy with our fake responses we are alive ... */
733+
/* However CP never sends it ... only SEND_R and SEND_F */
734+
/* Check and receive RES_ACK from CP */
735+
/* Check and receive REQ_ACK from CP */
736+
for (i = 0; i < MAX_IPC_DEV; i++) {
737+
ld->ipc_device[i]->recv_res_ack(int2ap);
738+
ld->ipc_device[i]->recv_req_ack(int2ap);
739+
}
731740

732-
msg_handler();
733-
}
741+
msg_handler();
742+
}
734743
}
735744

736745
void msg_rx_work(void)

0 commit comments

Comments
 (0)