Skip to content

Commit b3ad61c

Browse files
linosanfilippo-kunbusl1k
authored andcommitted
pibridge-serdev: Move definitions in new header file pibridge.h
Move structure definitions for GATE and IO packet headers as well as the macro for the fifo size into the new header file pibridge.h. By doing this extend the fifo size to a power of 2 since this is what the kfifo API will extend the fifo to, anyway. Also rename the macro from PIBRIDGE_RECV_BUFFER_SIZE to the more appropriate PIBRIDGE_RECV_FIFO_SIZE. This is in preparation of implementing tracing macros which are defined in a seperate header file but need access to the definitions mentioned above. Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com>
1 parent 6d8fdeb commit b3ad61c

2 files changed

Lines changed: 27 additions & 19 deletions

File tree

drivers/tty/serdev/pibridge.c

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
#include <linux/pibridge_comm.h>
88
#include <linux/wait.h>
99

10+
#include "pibridge.h"
11+
1012
#define PIBRIDGE_BAUDRATE 115200
1113
#define PIBRIDGE_IO_TIMEOUT 10 // msec
12-
#define PIBRIDGE_RECV_BUFFER_SIZE 100
1314
#define PIBRIDGE_BC_ADDR 0xff
1415

1516
#define PIBRIDGE_RESP_CMD 0x3fff
@@ -23,22 +24,6 @@ struct pibridge {
2324
wait_queue_head_t read_queue;
2425
};
2526

26-
struct pibridge_pkthdr_gate {
27-
u8 dst;
28-
u8 src;
29-
u16 cmd;
30-
u16 seq;
31-
u8 len;
32-
} __attribute__((packed));
33-
34-
struct pibridge_pkthdr_io {
35-
u8 addr :6;
36-
u8 type :1; /* 0 for unicast, 1 for broadcast */
37-
u8 rsp :1; /* 0 for request, 1 for response */
38-
u8 len :5;
39-
u8 cmd :3; /* 0 for broadcast*/
40-
} __attribute__((packed));
41-
4227
static struct pibridge *pibridge_s; /* unique instance of the pibridge */
4328

4429
static u8 pibridge_crc8(u8 base, void *data, u16 len)
@@ -121,8 +106,7 @@ static int pibridge_probe(struct serdev_device *serdev)
121106
mutex_init(&pi->lock);
122107
init_waitqueue_head(&pi->read_queue);
123108

124-
ret = kfifo_alloc(&pi->read_fifo, PIBRIDGE_RECV_BUFFER_SIZE,
125-
GFP_KERNEL);
109+
ret = kfifo_alloc(&pi->read_fifo, PIBRIDGE_RECV_FIFO_SIZE, GFP_KERNEL);
126110
if (ret)
127111
return ret;
128112

drivers/tty/serdev/pibridge.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#ifndef DRIVERS_PIBRIDGE_H
2+
#define DRIVERS_PIBRIDGE_H
3+
4+
#include <linux/types.h>
5+
6+
#define PIBRIDGE_RECV_FIFO_SIZE 128
7+
8+
struct pibridge_pkthdr_gate {
9+
u8 dst;
10+
u8 src;
11+
u16 cmd;
12+
u16 seq;
13+
u8 len;
14+
} __attribute__((packed));
15+
16+
struct pibridge_pkthdr_io {
17+
u8 addr :6;
18+
u8 type :1; /* 0 for unicast, 1 for broadcast */
19+
u8 rsp :1; /* 0 for request, 1 for response */
20+
u8 len :5;
21+
u8 cmd :3; /* 0 for broadcast*/
22+
} __attribute__((packed));
23+
24+
#endif /* DRIVERS_PIBRIDGE_H */

0 commit comments

Comments
 (0)