Skip to content

Commit 93ad739

Browse files
committed
外部変数をヘッダファイルで宣言
1 parent 4f0ef43 commit 93ad739

File tree

2 files changed

+51
-26
lines changed

2 files changed

+51
-26
lines changed

src/drivers/rtmouse.h

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

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];
72-
7369
#define NUM_DEV_TOTAL \
7470
(NUM_DEV[ID_DEV_LED] + NUM_DEV[ID_DEV_SWITCH] + \
7571
NUM_DEV[ID_DEV_SENSOR] + NUM_DEV[ID_DEV_BUZZER] + \
@@ -230,7 +226,36 @@ extern char *NAME_DEV_U[ID_DEV_SIZE];
230226
#define SIGNED_COUNT_SIZE 32767
231227
#define MAX_PULSE_COUNT 65535
232228

233-
/* -- Buffer -- */
229+
/* --- Buffer --- */
234230
#define MAX_BUFLEN 64
235231

232+
/* --- extern --- */
233+
extern unsigned int NUM_DEV[ID_DEV_SIZE];
234+
extern char *NAME_DEV[ID_DEV_SIZE];
235+
extern char *NAME_DEV_U[ID_DEV_SIZE];
236+
extern int _major_dev[ID_DEV_SIZE];
237+
extern int _minor_dev[ID_DEV_SIZE];
238+
extern struct cdev *cdev_array;
239+
extern struct class *class_dev[ID_DEV_SIZE];
240+
extern volatile void __iomem *pwm_base;
241+
extern volatile void __iomem *clk_base;
242+
extern volatile uint32_t *gpio_base;
243+
extern volatile int cdev_index;
244+
extern struct mutex lock;
245+
extern struct spi_device_id mcp3204_id[];
246+
extern struct spi_board_info mcp3204_info;
247+
extern struct spi_driver mcp3204_driver;
248+
extern struct i2c_client *i2c_client_r;
249+
extern struct i2c_client *i2c_client_l;
250+
extern unsigned int motor_l_freq_is_positive;
251+
extern unsigned int motor_r_freq_is_positive;
252+
extern struct i2c_device_id i2c_counter_id[];
253+
extern struct i2c_driver i2c_counter_driver;
254+
255+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)
256+
extern struct device *mcp320x_dev;
257+
#endif
258+
259+
void tmp_func(void);
260+
236261
#endif // RTMOUSE_H

src/drivers/rtmouse_main.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,34 +55,32 @@ char *NAME_DEV_U[ID_DEV_SIZE] = {[ID_DEV_LED] = "rtled%u",
5555
[ID_DEV_MOTOR] = "rtmotor%u"};
5656

5757
// used in by register_dev() and cleanup_each_dev()
58-
static int _major_dev[ID_DEV_SIZE] = {
58+
int _major_dev[ID_DEV_SIZE] = {
5959
[ID_DEV_LED] = DEV_MAJOR, [ID_DEV_SWITCH] = DEV_MAJOR,
6060
[ID_DEV_SENSOR] = DEV_MAJOR, [ID_DEV_BUZZER] = DEV_MAJOR,
6161
[ID_DEV_MOTORRAWR] = DEV_MAJOR, [ID_DEV_MOTORRAWL] = DEV_MAJOR,
6262
[ID_DEV_MOTOREN] = DEV_MAJOR, [ID_DEV_MOTOR] = DEV_MAJOR};
6363

6464
// used in register_dev() and cleanup_each_dev()
65-
static int _minor_dev[ID_DEV_SIZE] = {
65+
int _minor_dev[ID_DEV_SIZE] = {
6666
[ID_DEV_LED] = DEV_MINOR, [ID_DEV_SWITCH] = DEV_MINOR,
6767
[ID_DEV_SENSOR] = DEV_MINOR, [ID_DEV_BUZZER] = DEV_MINOR,
6868
[ID_DEV_MOTORRAWR] = DEV_MINOR, [ID_DEV_MOTORRAWL] = DEV_MINOR,
6969
[ID_DEV_MOTOREN] = DEV_MINOR, [ID_DEV_MOTOR] = DEV_MINOR};
7070

7171
/* --- General Options --- */
72-
static struct cdev *cdev_array = NULL;
73-
static struct class *class_dev[ID_DEV_SIZE] = {
72+
struct cdev *cdev_array = NULL;
73+
struct class *class_dev[ID_DEV_SIZE] = {
7474
[ID_DEV_LED] = NULL, [ID_DEV_SWITCH] = NULL,
7575
[ID_DEV_SENSOR] = NULL, [ID_DEV_BUZZER] = NULL,
7676
[ID_DEV_MOTORRAWR] = NULL, [ID_DEV_MOTORRAWL] = NULL,
7777
[ID_DEV_MOTOREN] = NULL, [ID_DEV_MOTOR] = NULL};
7878

79-
static volatile void __iomem *pwm_base;
80-
static volatile void __iomem *clk_base;
81-
static volatile uint32_t *gpio_base;
82-
83-
static volatile int cdev_index = 0;
84-
85-
static struct mutex lock;
79+
volatile void __iomem *pwm_base;
80+
volatile void __iomem *clk_base;
81+
volatile uint32_t *gpio_base;
82+
volatile int cdev_index = 0;
83+
struct mutex lock;
8684

8785
/* --- Function Declarations --- */
8886
static void set_motor_r_freq(int freq);
@@ -123,13 +121,13 @@ struct mcp3204_drvdata {
123121

124122
/* --- Static variables --- */
125123
/* SPI device ID */
126-
static struct spi_device_id mcp3204_id[] = {
124+
struct spi_device_id mcp3204_id[] = {
127125
{"mcp3204", 0},
128126
{},
129127
};
130128

131129
/* SPI Info */
132-
static struct spi_board_info mcp3204_info = {
130+
struct spi_board_info mcp3204_info = {
133131
.modalias = "mcp3204",
134132
.max_speed_hz = 100000,
135133
.bus_num = 0,
@@ -138,11 +136,11 @@ static struct spi_board_info mcp3204_info = {
138136
};
139137

140138
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)
141-
static struct device *mcp320x_dev;
139+
struct device *mcp320x_dev;
142140
#endif
143141

144142
/* SPI Dirver Info */
145-
static struct spi_driver mcp3204_driver = {
143+
struct spi_driver mcp3204_driver = {
146144
.driver =
147145
{
148146
.name = DEVNAME_SENSOR,
@@ -165,20 +163,20 @@ struct rtcnt_device_info {
165163
int raw_pulse_count;
166164
};
167165

168-
static struct i2c_client *i2c_client_r = NULL;
169-
static struct i2c_client *i2c_client_l = NULL;
170-
static unsigned int motor_l_freq_is_positive = 1;
171-
static unsigned int motor_r_freq_is_positive = 1;
166+
struct i2c_client *i2c_client_r = NULL;
167+
struct i2c_client *i2c_client_l = NULL;
168+
unsigned int motor_l_freq_is_positive = 1;
169+
unsigned int motor_r_freq_is_positive = 1;
172170

173171
/* I2C Device ID */
174-
static struct i2c_device_id i2c_counter_id[] = {
172+
struct i2c_device_id i2c_counter_id[] = {
175173
{DEVNAME_CNTL, 0},
176174
{DEVNAME_CNTR, 1},
177175
{},
178176
};
179177

180178
/* I2C Dirver Info */
181-
static struct i2c_driver i2c_counter_driver = {
179+
struct i2c_driver i2c_counter_driver = {
182180
.driver =
183181
{
184182
.name = "rtcounter",
@@ -1673,6 +1671,8 @@ int dev_init_module(void)
16731671
int registered_devices = 0;
16741672
size_t size;
16751673

1674+
tmp_func();
1675+
16761676
/* log loding message */
16771677
printk(KERN_INFO "%s: loading driver...\n", DRIVER_NAME);
16781678

0 commit comments

Comments
 (0)