@@ -25,7 +25,8 @@ static void loongson_pin_mode(struct rt_device *device, rt_base_t pin, rt_base_t
2525 gpio = (void * )device -> user_data ;
2626 m = (rt_uint64_t )1 << pin ;
2727
28- switch (mode ) {
28+ switch (mode )
29+ {
2930 case PIN_MODE_OUTPUT :
3031 gpio -> GPIO0_OEN &= ~m ;
3132 break ;
@@ -52,7 +53,8 @@ static void loongson_pin_write(struct rt_device *device, rt_base_t pin, rt_base_
5253 struct loongson_gpio * gpio ;
5354 rt_uint64_t m ;
5455
55- if (pin < 0 || pin >= 60 ) {
56+ if (pin < 0 || pin >= 60 )
57+ {
5658 rt_kprintf ("error\n" );
5759 return ;
5860 }
@@ -90,19 +92,19 @@ static rt_err_t loongson_pin_attach_irq(struct rt_device *device, rt_int32_t pin
9092
9193 gpio = (void * )device -> user_data ;
9294
93- if (pin < 4 )
95+ if (pin < 4 )
9496 {
9597 index = pin ;
9698 }
97- else if (pin < 32 )
99+ else if (pin < 32 )
98100 {
99101 index = 5 ;
100102 }
101103 else
102104 {
103105 index = 6 ;
104106 }
105-
107+
106108 _g_gpio_irq_tbl [index ].irq_cb [pin ] = hdr ;
107109 _g_gpio_irq_tbl [index ].irq_arg [pin ] = args ;
108110 _g_gpio_irq_tbl [index ].irq_type [pin ] = mode ;
@@ -120,11 +122,11 @@ static rt_err_t loongson_pin_detach_irq(struct rt_device *device, rt_int32_t pin
120122 gpio = (void * )device -> user_data ;
121123
122124 rt_uint8_t index ;
123- if (pin < 4 )
125+ if (pin < 4 )
124126 {
125127 index = pin ;
126128 }
127- else if (pin < 32 )
129+ else if (pin < 32 )
128130 {
129131 index = 5 ;
130132 }
@@ -146,11 +148,11 @@ static rt_err_t loongson_pin_irq_enable(struct rt_device *device, rt_base_t pin,
146148 gpio = (void * )device -> user_data ;
147149
148150 rt_uint8_t index ;
149- if (pin < 4 )
151+ if (pin < 4 )
150152 {
151153 index = pin ;
152154 }
153- else if (pin < 32 )
155+ else if (pin < 32 )
154156 {
155157 index = 5 ;
156158 }
@@ -173,36 +175,36 @@ static void gpio_irq_handler(int irq, void *param)
173175 rt_uint32_t value ;
174176 rt_uint32_t tmpvalue ;
175177
176- if (irq == LS2K_GPIO0_INT_IRQ )
178+ if (irq == LS2K_GPIO0_INT_IRQ )
177179 {
178180 pin = 0 ;
179181 }
180- else if (irq == LS2K_GPIO1_INT_IRQ )
182+ else if (irq == LS2K_GPIO1_INT_IRQ )
181183 {
182184 pin = 1 ;
183185 }
184- else if (irq == LS2K_GPIO2_INT_IRQ )
186+ else if (irq == LS2K_GPIO2_INT_IRQ )
185187 {
186188 pin = 2 ;
187189 }
188- else if (irq == LS2K_GPIO3_INT_IRQ )
190+ else if (irq == LS2K_GPIO3_INT_IRQ )
189191 {
190192 pin = 3 ;
191193 }
192- else if (irq == LS2K_GPIO_INTLO_IRQ )
194+ else if (irq == LS2K_GPIO_INTLO_IRQ )
193195 {
194196 pin = 4 ;
195197 }
196198 else
197199 {
198200 pin = 32 ;
199201 }
200-
202+
201203 while (value )
202204 {
203205 if ((value & 0x1 ) && (irq_def -> irq_cb [pin ] != RT_NULL ))
204206 {
205- if (irq_def -> state [pin ])
207+ if (irq_def -> state [pin ])
206208 {
207209 irq_def -> irq_cb [pin ](irq_def -> irq_arg [pin ]);
208210 }
@@ -212,7 +214,8 @@ static void gpio_irq_handler(int irq, void *param)
212214 }
213215}
214216
215- static struct rt_pin_ops loongson_pin_ops = {
217+ static struct rt_pin_ops loongson_pin_ops =
218+ {
216219 .pin_mode = loongson_pin_mode ,
217220 .pin_write = loongson_pin_write ,
218221 .pin_read = loongson_pin_read ,
0 commit comments