Skip to content

Commit 4f0ef43

Browse files
committed
Cファイル分割の準備
1 parent a4b6b0e commit 4f0ef43

File tree

5 files changed

+39
-28
lines changed

5 files changed

+39
-28
lines changed

src/drivers/Makefile.header_from_apt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
MODULE:= rtmouse
22
obj-m:= $(MODULE).o
3-
$(MODULE)-y:= $(MODULE)_main.o
3+
$(MODULE)-y:= $(MODULE)_main.o $(MODULE)_dev.o
44
clean-files:= *.o *.ko *.mod.[co] *~
55

66
LINUX_SRC_DIR:=/usr/src/linux-headers-$(shell uname -r)
77
VERBOSE:=0
88

9-
$(MODULE).ko: $(MODULE)_main.c $(MODULE).h
9+
$(MODULE).ko: $(MODULE)_dev.c $(MODULE)_main.c $(MODULE).h
1010
make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) modules
1111

1212
clean:

src/drivers/Makefile.header_from_source

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
MODULE:= rtmouse
22
obj-m:= $(MODULE).o
3-
$(MODULE)-y:= $(MODULE)_main.o
3+
$(MODULE)-y:= $(MODULE)_main.o $(MODULE)_dev.o
44
clean-files:= *.o *.ko *.mod.[co] *~
55

66
LINUX_SRC_DIR:=/usr/src/linux
77
VERBOSE:=0
88

9-
$(MODULE).ko: $(MODULE)_main.c $(MODULE).h
9+
$(MODULE).ko: $(MODULE)_dev.c $(MODULE)_main.c $(MODULE).h
1010
make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) modules
1111

1212
clean:

src/drivers/rtmouse.h

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,30 +66,9 @@
6666
#define ID_DEV_CNT 8
6767
#define ID_DEV_SIZE 9
6868

69-
/* --- Device Numbers --- */
70-
const unsigned int NUM_DEV[ID_DEV_SIZE] = {
71-
[ID_DEV_LED] = 4, [ID_DEV_SWITCH] = 3, [ID_DEV_SENSOR] = 1,
72-
[ID_DEV_BUZZER] = 1, [ID_DEV_MOTORRAWR] = 1, [ID_DEV_MOTORRAWL] = 1,
73-
[ID_DEV_MOTOREN] = 1, [ID_DEV_MOTOR] = 1, [ID_DEV_CNT] = 2};
74-
75-
/* --- Device Names --- */
76-
const char *NAME_DEV[ID_DEV_SIZE] = {[ID_DEV_LED] = "rtled",
77-
[ID_DEV_SWITCH] = "rtswitch",
78-
[ID_DEV_SENSOR] = "rtlightsensor",
79-
[ID_DEV_BUZZER] = "rtbuzzer",
80-
[ID_DEV_MOTORRAWR] = "rtmotor_raw_r",
81-
[ID_DEV_MOTORRAWL] = "rtmotor_raw_l",
82-
[ID_DEV_MOTOREN] = "rtmotoren",
83-
[ID_DEV_MOTOR] = "rtmotor"};
84-
85-
const char *NAME_DEV_U[ID_DEV_SIZE] = {[ID_DEV_LED] = "rtled%u",
86-
[ID_DEV_SWITCH] = "rtswitch%u",
87-
[ID_DEV_SENSOR] = "rtlightsensor%u",
88-
[ID_DEV_BUZZER] = "rtbuzzer%u",
89-
[ID_DEV_MOTORRAWR] = "rtmotor_raw_r%u",
90-
[ID_DEV_MOTORRAWL] = "rtmotor_raw_l%u",
91-
[ID_DEV_MOTOREN] = "rtmotoren%u",
92-
[ID_DEV_MOTOR] = "rtmotor%u"};
69+
extern unsigned int NUM_DEV[ID_DEV_SIZE];
70+
extern char *NAME_DEV[ID_DEV_SIZE];
71+
extern char *NAME_DEV_U[ID_DEV_SIZE];
9372

9473
#define NUM_DEV_TOTAL \
9574
(NUM_DEV[ID_DEV_LED] + NUM_DEV[ID_DEV_SWITCH] + \

src/drivers/rtmouse_dev.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "rtmouse.h"
2+
3+
void tmp_func(void) {
4+
return;
5+
}

src/drivers/rtmouse_main.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,39 @@ MODULE_LICENSE("GPL");
2929
MODULE_VERSION("3.3.2");
3030
MODULE_DESCRIPTION("Raspberry Pi Mouse device driver");
3131

32+
/* --- Device Numbers --- */
33+
unsigned int NUM_DEV[ID_DEV_SIZE] = {
34+
[ID_DEV_LED] = 4, [ID_DEV_SWITCH] = 3, [ID_DEV_SENSOR] = 1,
35+
[ID_DEV_BUZZER] = 1, [ID_DEV_MOTORRAWR] = 1, [ID_DEV_MOTORRAWL] = 1,
36+
[ID_DEV_MOTOREN] = 1, [ID_DEV_MOTOR] = 1, [ID_DEV_CNT] = 2};
37+
38+
/* --- Device Names --- */
39+
char *NAME_DEV[ID_DEV_SIZE] = {[ID_DEV_LED] = "rtled",
40+
[ID_DEV_SWITCH] = "rtswitch",
41+
[ID_DEV_SENSOR] = "rtlightsensor",
42+
[ID_DEV_BUZZER] = "rtbuzzer",
43+
[ID_DEV_MOTORRAWR] = "rtmotor_raw_r",
44+
[ID_DEV_MOTORRAWL] = "rtmotor_raw_l",
45+
[ID_DEV_MOTOREN] = "rtmotoren",
46+
[ID_DEV_MOTOR] = "rtmotor"};
47+
48+
char *NAME_DEV_U[ID_DEV_SIZE] = {[ID_DEV_LED] = "rtled%u",
49+
[ID_DEV_SWITCH] = "rtswitch%u",
50+
[ID_DEV_SENSOR] = "rtlightsensor%u",
51+
[ID_DEV_BUZZER] = "rtbuzzer%u",
52+
[ID_DEV_MOTORRAWR] = "rtmotor_raw_r%u",
53+
[ID_DEV_MOTORRAWL] = "rtmotor_raw_l%u",
54+
[ID_DEV_MOTOREN] = "rtmotoren%u",
55+
[ID_DEV_MOTOR] = "rtmotor%u"};
56+
57+
// used in by register_dev() and cleanup_each_dev()
3258
static int _major_dev[ID_DEV_SIZE] = {
3359
[ID_DEV_LED] = DEV_MAJOR, [ID_DEV_SWITCH] = DEV_MAJOR,
3460
[ID_DEV_SENSOR] = DEV_MAJOR, [ID_DEV_BUZZER] = DEV_MAJOR,
3561
[ID_DEV_MOTORRAWR] = DEV_MAJOR, [ID_DEV_MOTORRAWL] = DEV_MAJOR,
3662
[ID_DEV_MOTOREN] = DEV_MAJOR, [ID_DEV_MOTOR] = DEV_MAJOR};
3763

64+
// used in register_dev() and cleanup_each_dev()
3865
static int _minor_dev[ID_DEV_SIZE] = {
3966
[ID_DEV_LED] = DEV_MINOR, [ID_DEV_SWITCH] = DEV_MINOR,
4067
[ID_DEV_SENSOR] = DEV_MINOR, [ID_DEV_BUZZER] = DEV_MINOR,

0 commit comments

Comments
 (0)