@@ -30,13 +30,13 @@ MODULE_VERSION("3.3.3");
30
30
MODULE_DESCRIPTION ("Raspberry Pi Mouse device driver" );
31
31
32
32
/* --- Device Numbers --- */
33
- unsigned int NUM_DEV [ID_DEV_SIZE ] = {
33
+ static const unsigned int NUM_DEV [ID_DEV_SIZE ] = {
34
34
[ID_DEV_LED ] = 4 , [ID_DEV_SWITCH ] = 3 , [ID_DEV_SENSOR ] = 1 ,
35
35
[ID_DEV_BUZZER ] = 1 , [ID_DEV_MOTORRAWR ] = 1 , [ID_DEV_MOTORRAWL ] = 1 ,
36
36
[ID_DEV_MOTOREN ] = 1 , [ID_DEV_MOTOR ] = 1 , [ID_DEV_CNT ] = 2 };
37
37
38
38
/* --- Device Names --- */
39
- char * NAME_DEV [ID_DEV_SIZE ] = {[ID_DEV_LED ] = "rtled" ,
39
+ static const char * NAME_DEV [ID_DEV_SIZE ] = {[ID_DEV_LED ] = "rtled" ,
40
40
[ID_DEV_SWITCH ] = "rtswitch" ,
41
41
[ID_DEV_SENSOR ] = "rtlightsensor" ,
42
42
[ID_DEV_BUZZER ] = "rtbuzzer" ,
@@ -45,7 +45,7 @@ char *NAME_DEV[ID_DEV_SIZE] = {[ID_DEV_LED] = "rtled",
45
45
[ID_DEV_MOTOREN ] = "rtmotoren" ,
46
46
[ID_DEV_MOTOR ] = "rtmotor" };
47
47
48
- char * NAME_DEV_U [ID_DEV_SIZE ] = {[ID_DEV_LED ] = "rtled%u" ,
48
+ static const char * NAME_DEV_U [ID_DEV_SIZE ] = {[ID_DEV_LED ] = "rtled%u" ,
49
49
[ID_DEV_SWITCH ] = "rtswitch%u" ,
50
50
[ID_DEV_SENSOR ] = "rtlightsensor%u" ,
51
51
[ID_DEV_BUZZER ] = "rtbuzzer%u" ,
@@ -55,31 +55,31 @@ char *NAME_DEV_U[ID_DEV_SIZE] = {[ID_DEV_LED] = "rtled%u",
55
55
[ID_DEV_MOTOR ] = "rtmotor%u" };
56
56
57
57
// used in by register_dev() and cleanup_each_dev()
58
- int _major_dev [ID_DEV_SIZE ] = {
58
+ static int _major_dev [ID_DEV_SIZE ] = {
59
59
[ID_DEV_LED ] = DEV_MAJOR , [ID_DEV_SWITCH ] = DEV_MAJOR ,
60
60
[ID_DEV_SENSOR ] = DEV_MAJOR , [ID_DEV_BUZZER ] = DEV_MAJOR ,
61
61
[ID_DEV_MOTORRAWR ] = DEV_MAJOR , [ID_DEV_MOTORRAWL ] = DEV_MAJOR ,
62
62
[ID_DEV_MOTOREN ] = DEV_MAJOR , [ID_DEV_MOTOR ] = DEV_MAJOR };
63
63
64
64
// used in register_dev() and cleanup_each_dev()
65
- int _minor_dev [ID_DEV_SIZE ] = {
65
+ static int _minor_dev [ID_DEV_SIZE ] = {
66
66
[ID_DEV_LED ] = DEV_MINOR , [ID_DEV_SWITCH ] = DEV_MINOR ,
67
67
[ID_DEV_SENSOR ] = DEV_MINOR , [ID_DEV_BUZZER ] = DEV_MINOR ,
68
68
[ID_DEV_MOTORRAWR ] = DEV_MINOR , [ID_DEV_MOTORRAWL ] = DEV_MINOR ,
69
69
[ID_DEV_MOTOREN ] = DEV_MINOR , [ID_DEV_MOTOR ] = DEV_MINOR };
70
70
71
71
/* --- General Options --- */
72
- struct cdev * cdev_array = NULL ;
73
- struct class * class_dev [ID_DEV_SIZE ] = {
72
+ static struct cdev * cdev_array = NULL ;
73
+ static struct class * class_dev [ID_DEV_SIZE ] = {
74
74
[ID_DEV_LED ] = NULL , [ID_DEV_SWITCH ] = NULL ,
75
75
[ID_DEV_SENSOR ] = NULL , [ID_DEV_BUZZER ] = NULL ,
76
76
[ID_DEV_MOTORRAWR ] = NULL , [ID_DEV_MOTORRAWL ] = NULL ,
77
77
[ID_DEV_MOTOREN ] = NULL , [ID_DEV_MOTOR ] = NULL };
78
78
79
79
volatile void __iomem * pwm_base ;
80
- volatile void __iomem * clk_base ;
80
+ static volatile void __iomem * clk_base ;
81
81
volatile uint32_t * gpio_base ;
82
- volatile int cdev_index = 0 ;
82
+ static volatile int cdev_index = 0 ;
83
83
struct mutex lock ;
84
84
85
85
/* --- Function Declarations --- */
@@ -90,7 +90,6 @@ static void mcp3204_remove(struct spi_device *spi);
90
90
#endif
91
91
92
92
static int mcp3204_probe (struct spi_device * spi );
93
- static unsigned int mcp3204_get_value (int channel );
94
93
95
94
#if LINUX_VERSION_CODE < KERNEL_VERSION (6 , 2 , 0 )
96
95
static int rtcnt_i2c_probe (struct i2c_client * client ,
@@ -107,7 +106,7 @@ static void rtcnt_i2c_remove(struct i2c_client *client);
107
106
108
107
/* --- Static variables --- */
109
108
/* SPI device ID */
110
- struct spi_device_id mcp3204_id [] = {
109
+ static struct spi_device_id mcp3204_id [] = {
111
110
{"mcp3204" , 0 },
112
111
{},
113
112
};
@@ -126,7 +125,7 @@ struct device *mcp320x_dev;
126
125
#endif
127
126
128
127
/* SPI Dirver Info */
129
- struct spi_driver mcp3204_driver = {
128
+ static struct spi_driver mcp3204_driver = {
130
129
.driver =
131
130
{
132
131
.name = DEVNAME_SENSOR ,
@@ -137,20 +136,18 @@ struct spi_driver mcp3204_driver = {
137
136
.remove = mcp3204_remove ,
138
137
};
139
138
140
- struct i2c_client * i2c_client_r = NULL ;
141
- struct i2c_client * i2c_client_l = NULL ;
142
- unsigned int motor_l_freq_is_positive = 1 ;
143
- unsigned int motor_r_freq_is_positive = 1 ;
139
+ static struct i2c_client * i2c_client_r = NULL ;
140
+ static struct i2c_client * i2c_client_l = NULL ;
144
141
145
142
/* I2C Device ID */
146
- struct i2c_device_id i2c_counter_id [] = {
143
+ static struct i2c_device_id i2c_counter_id [] = {
147
144
{DEVNAME_CNTL , 0 },
148
145
{DEVNAME_CNTR , 1 },
149
146
{},
150
147
};
151
148
152
149
/* I2C Dirver Info */
153
- struct i2c_driver i2c_counter_driver = {
150
+ static struct i2c_driver i2c_counter_driver = {
154
151
.driver =
155
152
{
156
153
.name = "rtcounter" ,
@@ -829,7 +826,7 @@ static void rtcnt_i2c_remove(struct i2c_client *client)
829
826
* dev_init_module - register driver module
830
827
* called by module_init(dev_init_module)
831
828
*/
832
- int dev_init_module (void )
829
+ static int dev_init_module (void )
833
830
{
834
831
int retval , i ;
835
832
int registered_devices = 0 ;
@@ -939,7 +936,7 @@ int dev_init_module(void)
939
936
* dev_cleanup_module - cleanup driver module
940
937
* called by module_exit(dev_cleanup_module)
941
938
*/
942
- void cleanup_each_dev (int id_dev )
939
+ static void cleanup_each_dev (int id_dev )
943
940
{
944
941
int i ;
945
942
dev_t devno ;
@@ -953,7 +950,7 @@ void cleanup_each_dev(int id_dev)
953
950
unregister_chrdev_region (devno_top , NUM_DEV [id_dev ]);
954
951
}
955
952
956
- void dev_cleanup_module (void )
953
+ static void dev_cleanup_module (void )
957
954
{
958
955
int i ;
959
956
0 commit comments