diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c index bf759ea..61524d2 100644 --- a/drivers/hwmon/hdaps.c +++ b/drivers/hwmon/hdaps.c @@ -449,6 +449,18 @@ static ssize_t hdaps_invert_store(struct device *dev, return count; } +static int hdaps_mousedev_open(struct input_dev *dev) +{ + add_timer(&hdaps_timer); + return 0; +} + +static int hdaps_mousedev_close(struct input_dev *dev) +{ + del_timer_sync(&hdaps_timer); + return 0; +} + static DEVICE_ATTR(position, 0444, hdaps_position_show, NULL); static DEVICE_ATTR(variance, 0444, hdaps_variance_show, NULL); static DEVICE_ATTR(temp1, 0444, hdaps_temp1_show, NULL); @@ -570,10 +582,17 @@ static int __init hdaps_init(void) /* initial calibrate for the input device */ hdaps_calibrate(); + /* start up our timer for the input device */ + init_timer(&hdaps_timer); + hdaps_timer.function = hdaps_mousedev_poll; + hdaps_timer.expires = jiffies + HDAPS_POLL_PERIOD; + /* initialize the input class */ hdaps_idev->name = "hdaps"; hdaps_idev->cdev.dev = &pdev->dev; hdaps_idev->evbit[0] = BIT(EV_ABS); + hdaps_idev->open = hdaps_mousedev_open; + hdaps_idev->close = hdaps_mousedev_close; input_set_abs_params(hdaps_idev, ABS_X, -256, 256, HDAPS_INPUT_FUZZ, HDAPS_INPUT_FLAT); input_set_abs_params(hdaps_idev, ABS_Y, @@ -583,12 +602,6 @@ static int __init hdaps_init(void) if (ret) goto out_idev; - /* start up our timer for the input device */ - init_timer(&hdaps_timer); - hdaps_timer.function = hdaps_mousedev_poll; - hdaps_timer.expires = jiffies + HDAPS_POLL_PERIOD; - add_timer(&hdaps_timer); - printk(KERN_INFO "hdaps: driver successfully loaded.\n"); return 0; @@ -609,7 +622,6 @@ out: static void __exit hdaps_exit(void) { - del_timer_sync(&hdaps_timer); input_unregister_device(hdaps_idev); sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group); platform_device_unregister(pdev);