Input: iqs7222 - drop unused device node references
authorJeff LaBundy <jeff@labundy.com>
Sun, 23 Oct 2022 00:56:04 +0000 (19:56 -0500)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 24 Oct 2022 12:09:23 +0000 (05:09 -0700)
commitbbd16b0d839978e8c8bec2b9a162373f64fc2fbb
tree828f838747406d28cdcf0344249971c4da93589b
parent1ffb0cd82477775000cff02d2577a17308af6bbb
Input: iqs7222 - drop unused device node references

Each call to device/fwnode_get_named_child_node() must be matched
with a call to fwnode_handle_put() once the corresponding node is
no longer in use. This ensures a reference count remains balanced
in the case of dynamic device tree support.

Currently, the driver never calls fwnode_handle_put(). Solve this
problem by moving the node handling from iqs7222_parse_props() to
the new iqs7222_parse_reg_grp(), leaving the former to do nothing
but parse properties. The latter then manages the reference count
in a single location and consistent fashion.

This change drastically simplifies iqs7222_parse_all(), which can
then call iqs7222_parse_reg_grp() on every register group without
having to treat each register group differently.

For nested event nodes, common parsing code has been factored out
to the new iqs7222_parse_event() so as to allow the event node to
be dropped from as few locations as possible.

As part of this refactor, the 'linux,code' property has been made
optional. This enables applications that define an event with the
sole purpose of enabling a GPIO.

Fixes: e505edaedcb9 ("Input: add support for Azoteq IQS7222A/B/C")
Signed-off-by: Jeff LaBundy <jeff@labundy.com>
Link: https://lore.kernel.org/r/Y1SRJIQ3WPwNpC0K@nixie71
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/misc/iqs7222.c