gpiolib-cdev.c (91043f559313fb04ac18253fcf18561a40c1b045) gpiolib-cdev.c (9ce4ed5b4db13633f9934a4eac02c4cde04d5c63)
1// SPDX-License-Identifier: GPL-2.0
2
3#include <linux/anon_inodes.h>
4#include <linux/atomic.h>
5#include <linux/bitmap.h>
6#include <linux/build_bug.h>
7#include <linux/cdev.h>
8#include <linux/compat.h>

--- 216 unchanged lines hidden (view full) ---

225 if (ret)
226 return ret;
227 } else if (lflags & GPIOHANDLE_REQUEST_INPUT) {
228 ret = gpiod_direction_input(desc);
229 if (ret)
230 return ret;
231 }
232
1// SPDX-License-Identifier: GPL-2.0
2
3#include <linux/anon_inodes.h>
4#include <linux/atomic.h>
5#include <linux/bitmap.h>
6#include <linux/build_bug.h>
7#include <linux/cdev.h>
8#include <linux/compat.h>

--- 216 unchanged lines hidden (view full) ---

225 if (ret)
226 return ret;
227 } else if (lflags & GPIOHANDLE_REQUEST_INPUT) {
228 ret = gpiod_direction_input(desc);
229 if (ret)
230 return ret;
231 }
232
233 blocking_notifier_call_chain(&desc->gdev->line_state_notifier,
234 GPIO_V2_LINE_CHANGED_CONFIG,
235 desc);
233 gpiod_line_state_notify(desc, GPIO_V2_LINE_CHANGED_CONFIG);
236 }
237 return 0;
238}
239
240static long linehandle_ioctl_unlocked(struct file *file, unsigned int cmd,
241 unsigned long arg)
242{
243 struct linehandle_state *lh = file->private_data;

--- 165 unchanged lines hidden (view full) ---

409 if (ret)
410 goto out_free_lh;
411 } else if (lflags & GPIOHANDLE_REQUEST_INPUT) {
412 ret = gpiod_direction_input(desc);
413 if (ret)
414 goto out_free_lh;
415 }
416
234 }
235 return 0;
236}
237
238static long linehandle_ioctl_unlocked(struct file *file, unsigned int cmd,
239 unsigned long arg)
240{
241 struct linehandle_state *lh = file->private_data;

--- 165 unchanged lines hidden (view full) ---

407 if (ret)
408 goto out_free_lh;
409 } else if (lflags & GPIOHANDLE_REQUEST_INPUT) {
410 ret = gpiod_direction_input(desc);
411 if (ret)
412 goto out_free_lh;
413 }
414
417 blocking_notifier_call_chain(&desc->gdev->line_state_notifier,
418 GPIO_V2_LINE_CHANGED_REQUESTED, desc);
415 gpiod_line_state_notify(desc, GPIO_V2_LINE_CHANGED_REQUESTED);
419
420 dev_dbg(&gdev->dev, "registered chardev handle for line %d\n",
421 offset);
422 }
423
424 fd = get_unused_fd_flags(O_RDONLY | O_CLOEXEC);
425 if (fd < 0) {
426 ret = fd;

--- 988 unchanged lines hidden (view full) ---

1415
1416 ret = edge_detector_update(line, lc, i, edflags);
1417 if (ret)
1418 return ret;
1419 }
1420
1421 WRITE_ONCE(line->edflags, edflags);
1422
416
417 dev_dbg(&gdev->dev, "registered chardev handle for line %d\n",
418 offset);
419 }
420
421 fd = get_unused_fd_flags(O_RDONLY | O_CLOEXEC);
422 if (fd < 0) {
423 ret = fd;

--- 988 unchanged lines hidden (view full) ---

1412
1413 ret = edge_detector_update(line, lc, i, edflags);
1414 if (ret)
1415 return ret;
1416 }
1417
1418 WRITE_ONCE(line->edflags, edflags);
1419
1423 blocking_notifier_call_chain(&desc->gdev->line_state_notifier,
1424 GPIO_V2_LINE_CHANGED_CONFIG,
1425 desc);
1420 gpiod_line_state_notify(desc, GPIO_V2_LINE_CHANGED_CONFIG);
1426 }
1427 return 0;
1428}
1429
1430static long linereq_set_config(struct linereq *lr, void __user *ip)
1431{
1432 struct gpio_v2_line_config lc;
1433 int ret;

--- 298 unchanged lines hidden (view full) ---

1732 ret = edge_detector_setup(&lr->lines[i], lc, i,
1733 edflags);
1734 if (ret)
1735 goto out_free_linereq;
1736 }
1737
1738 lr->lines[i].edflags = edflags;
1739
1421 }
1422 return 0;
1423}
1424
1425static long linereq_set_config(struct linereq *lr, void __user *ip)
1426{
1427 struct gpio_v2_line_config lc;
1428 int ret;

--- 298 unchanged lines hidden (view full) ---

1727 ret = edge_detector_setup(&lr->lines[i], lc, i,
1728 edflags);
1729 if (ret)
1730 goto out_free_linereq;
1731 }
1732
1733 lr->lines[i].edflags = edflags;
1734
1740 blocking_notifier_call_chain(&desc->gdev->line_state_notifier,
1741 GPIO_V2_LINE_CHANGED_REQUESTED, desc);
1735 gpiod_line_state_notify(desc, GPIO_V2_LINE_CHANGED_REQUESTED);
1742
1743 dev_dbg(&gdev->dev, "registered chardev handle for line %d\n",
1744 offset);
1745 }
1746
1747 lr->device_unregistered_nb.notifier_call = linereq_unregistered_notify;
1748 ret = blocking_notifier_chain_register(&gdev->device_notifier,
1749 &lr->device_unregistered_nb);

--- 401 unchanged lines hidden (view full) ---

2151 le->eflags = eflags;
2152
2153 linehandle_flags_to_desc_flags(lflags, &desc->flags);
2154
2155 ret = gpiod_direction_input(desc);
2156 if (ret)
2157 goto out_free_le;
2158
1736
1737 dev_dbg(&gdev->dev, "registered chardev handle for line %d\n",
1738 offset);
1739 }
1740
1741 lr->device_unregistered_nb.notifier_call = linereq_unregistered_notify;
1742 ret = blocking_notifier_chain_register(&gdev->device_notifier,
1743 &lr->device_unregistered_nb);

--- 401 unchanged lines hidden (view full) ---

2145 le->eflags = eflags;
2146
2147 linehandle_flags_to_desc_flags(lflags, &desc->flags);
2148
2149 ret = gpiod_direction_input(desc);
2150 if (ret)
2151 goto out_free_le;
2152
2159 blocking_notifier_call_chain(&desc->gdev->line_state_notifier,
2160 GPIO_V2_LINE_CHANGED_REQUESTED, desc);
2153 gpiod_line_state_notify(desc, GPIO_V2_LINE_CHANGED_REQUESTED);
2161
2162 irq = gpiod_to_irq(desc);
2163 if (irq <= 0) {
2164 ret = -ENODEV;
2165 goto out_free_le;
2166 }
2167
2168 if (eflags & GPIOEVENT_REQUEST_RISING_EDGE)

--- 654 unchanged lines hidden ---
2154
2155 irq = gpiod_to_irq(desc);
2156 if (irq <= 0) {
2157 ret = -ENODEV;
2158 goto out_free_le;
2159 }
2160
2161 if (eflags & GPIOEVENT_REQUEST_RISING_EDGE)

--- 654 unchanged lines hidden ---