|
@@ -36,6 +36,7 @@ struct cashd_device {
|
|
|
unsigned int status_changed;
|
|
unsigned int status_changed;
|
|
|
int last_status;
|
|
int last_status;
|
|
|
int first_read;
|
|
int first_read;
|
|
|
|
|
+ int open_count;
|
|
|
struct delayed_work delay_work1;
|
|
struct delayed_work delay_work1;
|
|
|
struct delayed_work delay_work2;
|
|
struct delayed_work delay_work2;
|
|
|
void __iomem *gpio_ctl_reg_base;
|
|
void __iomem *gpio_ctl_reg_base;
|
|
@@ -100,6 +101,7 @@ static int cashd_open(struct inode *inode, struct file *filp)
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ dev->open_count++;
|
|
|
|
|
|
|
|
if (!dev) {
|
|
if (!dev) {
|
|
|
pr_err("cashd: Device not initialized for minor %d\n", minor);
|
|
pr_err("cashd: Device not initialized for minor %d\n", minor);
|
|
@@ -107,7 +109,6 @@ static int cashd_open(struct inode *inode, struct file *filp)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
filp->private_data = dev;
|
|
filp->private_data = dev;
|
|
|
- dev->first_read = 0;
|
|
|
|
|
pr_info("cashd: Device /dev/cashd%d opened\n", minor);
|
|
pr_info("cashd: Device /dev/cashd%d opened\n", minor);
|
|
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
@@ -115,8 +116,12 @@ static int cashd_open(struct inode *inode, struct file *filp)
|
|
|
|
|
|
|
|
static int cashd_release(struct inode *inode, struct file *filp)
|
|
static int cashd_release(struct inode *inode, struct file *filp)
|
|
|
{
|
|
{
|
|
|
- unsigned int minor = iminor(inode);
|
|
|
|
|
- pr_info("cashd: Device /dev/cashd%d closed\n", minor);
|
|
|
|
|
|
|
+ struct cashd_device *dev = filp->private_data;
|
|
|
|
|
+ dev->open_count--;
|
|
|
|
|
+ if(dev->open_count == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ dev->first_read = 0;
|
|
|
|
|
+ }
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -329,6 +334,7 @@ int cashd_init(void)
|
|
|
cashd_devices[i]->gpio_status_reg_base = ioremap(GPIO1_STATUS, 4);
|
|
cashd_devices[i]->gpio_status_reg_base = ioremap(GPIO1_STATUS, 4);
|
|
|
}
|
|
}
|
|
|
cashd_devices[i]->last_status = readl(cashd_devices[i]->gpio_status_reg_base) & 0x2;
|
|
cashd_devices[i]->last_status = readl(cashd_devices[i]->gpio_status_reg_base) & 0x2;
|
|
|
|
|
+ cashd_devices[i]->open_count = 0;
|
|
|
schedule_delayed_work(&cashd_devices[i]->delay_work2, msecs_to_jiffies(100));
|
|
schedule_delayed_work(&cashd_devices[i]->delay_work2, msecs_to_jiffies(100));
|
|
|
|
|
|
|
|
pr_info("cashd: Created /dev/cashd%d\n", i);
|
|
pr_info("cashd: Created /dev/cashd%d\n", i);
|