From 93ad739e6abbfca757a6ddfa9c4817b192ee36f8 Mon Sep 17 00:00:00 2001 From: YusukeKato Date: Tue, 5 Nov 2024 14:23:49 +0900 Subject: [PATCH] =?UTF-8?q?=E5=A4=96=E9=83=A8=E5=A4=89=E6=95=B0=E3=82=92?= =?UTF-8?q?=E3=83=98=E3=83=83=E3=83=80=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=81=A7=E5=AE=A3=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/drivers/rtmouse.h | 35 ++++++++++++++++++++++++++----- src/drivers/rtmouse_main.c | 42 +++++++++++++++++++------------------- 2 files changed, 51 insertions(+), 26 deletions(-) diff --git a/src/drivers/rtmouse.h b/src/drivers/rtmouse.h index ac78318..084b108 100644 --- a/src/drivers/rtmouse.h +++ b/src/drivers/rtmouse.h @@ -66,10 +66,6 @@ #define ID_DEV_CNT 8 #define ID_DEV_SIZE 9 -extern unsigned int NUM_DEV[ID_DEV_SIZE]; -extern char *NAME_DEV[ID_DEV_SIZE]; -extern char *NAME_DEV_U[ID_DEV_SIZE]; - #define NUM_DEV_TOTAL \ (NUM_DEV[ID_DEV_LED] + NUM_DEV[ID_DEV_SWITCH] + \ NUM_DEV[ID_DEV_SENSOR] + NUM_DEV[ID_DEV_BUZZER] + \ @@ -230,7 +226,36 @@ extern char *NAME_DEV_U[ID_DEV_SIZE]; #define SIGNED_COUNT_SIZE 32767 #define MAX_PULSE_COUNT 65535 -/* -- Buffer -- */ +/* --- Buffer --- */ #define MAX_BUFLEN 64 +/* --- extern --- */ +extern unsigned int NUM_DEV[ID_DEV_SIZE]; +extern char *NAME_DEV[ID_DEV_SIZE]; +extern char *NAME_DEV_U[ID_DEV_SIZE]; +extern int _major_dev[ID_DEV_SIZE]; +extern int _minor_dev[ID_DEV_SIZE]; +extern struct cdev *cdev_array; +extern struct class *class_dev[ID_DEV_SIZE]; +extern volatile void __iomem *pwm_base; +extern volatile void __iomem *clk_base; +extern volatile uint32_t *gpio_base; +extern volatile int cdev_index; +extern struct mutex lock; +extern struct spi_device_id mcp3204_id[]; +extern struct spi_board_info mcp3204_info; +extern struct spi_driver mcp3204_driver; +extern struct i2c_client *i2c_client_r; +extern struct i2c_client *i2c_client_l; +extern unsigned int motor_l_freq_is_positive; +extern unsigned int motor_r_freq_is_positive; +extern struct i2c_device_id i2c_counter_id[]; +extern struct i2c_driver i2c_counter_driver; + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) +extern struct device *mcp320x_dev; +#endif + +void tmp_func(void); + #endif // RTMOUSE_H diff --git a/src/drivers/rtmouse_main.c b/src/drivers/rtmouse_main.c index c17092f..197ec8e 100644 --- a/src/drivers/rtmouse_main.c +++ b/src/drivers/rtmouse_main.c @@ -55,34 +55,32 @@ char *NAME_DEV_U[ID_DEV_SIZE] = {[ID_DEV_LED] = "rtled%u", [ID_DEV_MOTOR] = "rtmotor%u"}; // used in by register_dev() and cleanup_each_dev() -static int _major_dev[ID_DEV_SIZE] = { +int _major_dev[ID_DEV_SIZE] = { [ID_DEV_LED] = DEV_MAJOR, [ID_DEV_SWITCH] = DEV_MAJOR, [ID_DEV_SENSOR] = DEV_MAJOR, [ID_DEV_BUZZER] = DEV_MAJOR, [ID_DEV_MOTORRAWR] = DEV_MAJOR, [ID_DEV_MOTORRAWL] = DEV_MAJOR, [ID_DEV_MOTOREN] = DEV_MAJOR, [ID_DEV_MOTOR] = DEV_MAJOR}; // used in register_dev() and cleanup_each_dev() -static int _minor_dev[ID_DEV_SIZE] = { +int _minor_dev[ID_DEV_SIZE] = { [ID_DEV_LED] = DEV_MINOR, [ID_DEV_SWITCH] = DEV_MINOR, [ID_DEV_SENSOR] = DEV_MINOR, [ID_DEV_BUZZER] = DEV_MINOR, [ID_DEV_MOTORRAWR] = DEV_MINOR, [ID_DEV_MOTORRAWL] = DEV_MINOR, [ID_DEV_MOTOREN] = DEV_MINOR, [ID_DEV_MOTOR] = DEV_MINOR}; /* --- General Options --- */ -static struct cdev *cdev_array = NULL; -static struct class *class_dev[ID_DEV_SIZE] = { +struct cdev *cdev_array = NULL; +struct class *class_dev[ID_DEV_SIZE] = { [ID_DEV_LED] = NULL, [ID_DEV_SWITCH] = NULL, [ID_DEV_SENSOR] = NULL, [ID_DEV_BUZZER] = NULL, [ID_DEV_MOTORRAWR] = NULL, [ID_DEV_MOTORRAWL] = NULL, [ID_DEV_MOTOREN] = NULL, [ID_DEV_MOTOR] = NULL}; -static volatile void __iomem *pwm_base; -static volatile void __iomem *clk_base; -static volatile uint32_t *gpio_base; - -static volatile int cdev_index = 0; - -static struct mutex lock; +volatile void __iomem *pwm_base; +volatile void __iomem *clk_base; +volatile uint32_t *gpio_base; +volatile int cdev_index = 0; +struct mutex lock; /* --- Function Declarations --- */ static void set_motor_r_freq(int freq); @@ -123,13 +121,13 @@ struct mcp3204_drvdata { /* --- Static variables --- */ /* SPI device ID */ -static struct spi_device_id mcp3204_id[] = { +struct spi_device_id mcp3204_id[] = { {"mcp3204", 0}, {}, }; /* SPI Info */ -static struct spi_board_info mcp3204_info = { +struct spi_board_info mcp3204_info = { .modalias = "mcp3204", .max_speed_hz = 100000, .bus_num = 0, @@ -138,11 +136,11 @@ static struct spi_board_info mcp3204_info = { }; #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) -static struct device *mcp320x_dev; +struct device *mcp320x_dev; #endif /* SPI Dirver Info */ -static struct spi_driver mcp3204_driver = { +struct spi_driver mcp3204_driver = { .driver = { .name = DEVNAME_SENSOR, @@ -165,20 +163,20 @@ struct rtcnt_device_info { int raw_pulse_count; }; -static struct i2c_client *i2c_client_r = NULL; -static struct i2c_client *i2c_client_l = NULL; -static unsigned int motor_l_freq_is_positive = 1; -static unsigned int motor_r_freq_is_positive = 1; +struct i2c_client *i2c_client_r = NULL; +struct i2c_client *i2c_client_l = NULL; +unsigned int motor_l_freq_is_positive = 1; +unsigned int motor_r_freq_is_positive = 1; /* I2C Device ID */ -static struct i2c_device_id i2c_counter_id[] = { +struct i2c_device_id i2c_counter_id[] = { {DEVNAME_CNTL, 0}, {DEVNAME_CNTR, 1}, {}, }; /* I2C Dirver Info */ -static struct i2c_driver i2c_counter_driver = { +struct i2c_driver i2c_counter_driver = { .driver = { .name = "rtcounter", @@ -1673,6 +1671,8 @@ int dev_init_module(void) int registered_devices = 0; size_t size; + tmp_func(); + /* log loding message */ printk(KERN_INFO "%s: loading driver...\n", DRIVER_NAME);