c
    // In gpio_chardev_data structure definition
    atomic_t watched_lines_refcount;

    // In gpio_chrdev_release
    if (atomic_dec_and_test(&cdev->watched_lines_refcount)) {
        bitmap_free(cdev->watched_lines);
    }

    // When acquiring watched_lines elsewhere in the code
    atomic_inc(&cdev->watched_lines_refcount);
    