@@ -130,7 +130,6 @@ static volatile void __iomem *clk_base;
130
130
static volatile uint32_t * gpio_base ;
131
131
132
132
static volatile int cdev_index = 0 ;
133
- static volatile int open_counter = 0 ;
134
133
135
134
static struct mutex lock ;
136
135
@@ -751,36 +750,23 @@ static int gpio_unmap(void)
751
750
/* Open Device */
752
751
static int dev_open (struct inode * inode , struct file * filep )
753
752
{
754
- int retval ;
755
753
int * minor = (int * )kmalloc (sizeof (int ), GFP_KERNEL );
756
754
int major = MAJOR (inode -> i_rdev );
757
755
* minor = MINOR (inode -> i_rdev );
758
756
759
757
filep -> private_data = (void * )minor ;
760
758
761
- retval = gpio_map ();
762
- if (retval != 0 ) {
763
- printk (KERN_ERR "Can not use GPIO registers.\n" );
764
- return retval ;
765
- }
766
-
767
759
if (_major_motor == major ) {
768
760
printk (KERN_INFO "motor write\n" );
769
761
}
770
762
771
- open_counter ++ ;
772
763
return 0 ;
773
764
}
774
765
775
766
/* Close device */
776
767
static int dev_release (struct inode * inode , struct file * filep )
777
768
{
778
769
kfree (filep -> private_data );
779
-
780
- open_counter -- ;
781
- if (open_counter <= 0 ) {
782
- gpio_unmap ();
783
- }
784
770
return 0 ;
785
771
}
786
772
@@ -2099,9 +2085,6 @@ int dev_init_module(void)
2099
2085
rpi_gpio_clear32 (RPI_GPIO_P2MASK , 1 << RF_LED_BASE );
2100
2086
rpi_gpio_clear32 (RPI_GPIO_P2MASK , 1 << LF_LED_BASE );
2101
2087
2102
- /* GPIOレジスタのアンマップ */
2103
- gpio_unmap ();
2104
-
2105
2088
// printk(KERN_DEBUG "%s: gpio initialized\n", __func__);
2106
2089
2107
2090
/* cdev構造体の用意 */
@@ -2253,6 +2236,7 @@ void dev_cleanup_module(void)
2253
2236
2254
2237
/* free cdev memory */
2255
2238
kfree (cdev_array );
2239
+ gpio_unmap ();
2256
2240
printk (KERN_INFO "%s: module removed at %lu\n" , DRIVER_NAME , jiffies );
2257
2241
}
2258
2242
0 commit comments