25
25
#define S5JS100_BUFF_ALIGNMENT 0
26
26
27
27
28
- SAMSUNG_S5JS100_L3IP_Driver::SAMSUNG_S5JS100_L3IP_Driver (const char * ifname, int mtu)
28
+ SAMSUNG_S5JS100_L3IP_Driver::SAMSUNG_S5JS100_L3IP_Driver (const char * ifname, int mtu)
29
29
: _io_device(NULL ),
30
30
_mtu(mtu)
31
31
{
@@ -49,31 +49,26 @@ bool SAMSUNG_S5JS100_L3IP_Driver::link_out(net_stack_mem_buf_t *buf)
49
49
const int total_len = _memory_manager->get_total_len (buf);
50
50
net_stack_mem_buf_t *cont_buf = _memory_manager->alloc_heap (total_len, S5JS100_BUFF_ALIGNMENT);
51
51
52
- if (cont_buf)
53
- {
52
+ if (cont_buf) {
54
53
uint8_t *cont_buf_ptr = (uint8_t *)_memory_manager->get_ptr (cont_buf);
55
54
56
55
/* copy all frames to continuous buffer */
57
- for (net_stack_mem_buf_t *q = buf; q != NULL ; q = _memory_manager->get_next (q))
58
- {
56
+ for (net_stack_mem_buf_t *q = buf; q != NULL ; q = _memory_manager->get_next (q)) {
59
57
const uint8_t *ptr = (const uint8_t *)_memory_manager->get_ptr (q);
60
58
const uint16_t len = _memory_manager->get_len (q);
61
59
62
60
memcpy (cont_buf_ptr, ptr, len);
63
61
cont_buf_ptr += len;
64
62
}
65
63
66
- const int sent = _io_device->write ((const char *)_memory_manager->get_ptr (cont_buf), total_len);
64
+ const int sent = _io_device->write ((const char *)_memory_manager->get_ptr (cont_buf), total_len);
67
65
tr_debug (" link_out (%s): sent %d/%d bytes" , _ifname, sent, total_len);
68
- if (sent != total_len)
69
- {
66
+ if (sent != total_len) {
70
67
result = false ;
71
68
}
72
69
73
70
_memory_manager->free (cont_buf);
74
- }
75
- else
76
- {
71
+ } else {
77
72
tr_error (" Unable to allocate buffer for TX data!" );
78
73
result = false ;
79
74
}
@@ -87,14 +82,11 @@ bool SAMSUNG_S5JS100_L3IP_Driver::power_up()
87
82
{
88
83
_io_device = getModemIoDeviceByName (_ifname);
89
84
tr_debug (" power_up: io_device = %p" , _io_device);
90
- if (_io_device)
91
- {
85
+ if (_io_device) {
92
86
_io_device->register_ReadCb (read_cb, this );
93
87
_l3ip_link_state_cb (true );
94
88
return true ;
95
- }
96
- else
97
- {
89
+ } else {
98
90
tr_error (" Unable to get modem IO device!" );
99
91
return false ;
100
92
}
@@ -150,8 +142,7 @@ void SAMSUNG_S5JS100_L3IP_Driver::set_all_multicast(bool all)
150
142
void SAMSUNG_S5JS100_L3IP_Driver::power_down ()
151
143
{
152
144
tr_debug (" power_down" );
153
- if (_io_device)
154
- {
145
+ if (_io_device) {
155
146
_io_device->register_ReadCb (NULL , NULL );
156
147
_io_device = NULL ;
157
148
}
@@ -167,22 +158,19 @@ void SAMSUNG_S5JS100_L3IP_Driver::read_cb(mio_buf *buf, void *param)
167
158
MBED_ASSERT (buf);
168
159
MBED_ASSERT (param);
169
160
170
- SAMSUNG_S5JS100_L3IP_Driver *driver = (SAMSUNG_S5JS100_L3IP_Driver*)param;
161
+ SAMSUNG_S5JS100_L3IP_Driver *driver = (SAMSUNG_S5JS100_L3IP_Driver *)param;
171
162
driver->packet_rx (buf);
172
163
}
173
164
174
- void SAMSUNG_S5JS100_L3IP_Driver::packet_rx (mio_buf * buf)
165
+ void SAMSUNG_S5JS100_L3IP_Driver::packet_rx (mio_buf *buf)
175
166
{
176
167
tr_debug (" packet_rx (%s): buf = %p, len = %d, ch = %d" , _ifname, buf->data , buf->len , buf->ch );
177
168
178
169
net_stack_mem_buf_t *read_buf = _memory_manager->alloc_heap (buf->len , S5JS100_BUFF_ALIGNMENT);
179
- if (read_buf)
180
- {
170
+ if (read_buf) {
181
171
_memory_manager->copy_to_buf (read_buf, buf->data , buf->len );
182
172
_l3ip_link_input_cb (read_buf);
183
- }
184
- else
185
- {
173
+ } else {
186
174
tr_error (" Unable to allocate buffer for RX data!" );
187
175
}
188
176
}
0 commit comments