@@ -557,7 +557,6 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269,
const struct fwnode_handle *ch_node)
{
struct i2c_client *client = iqs269->client;
- struct fwnode_handle *ev_node;
struct iqs269_ch_reg *ch_reg;
u16 engine_a, engine_b;
unsigned int reg, val;
@@ -734,47 +733,49 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269,
}
for (i = 0; i < ARRAY_SIZE(iqs269_events); i++) {
- ev_node = fwnode_get_named_child_node(ch_node,
- iqs269_events[i].name);
- if (!ev_node)
- continue;
-
- if (!fwnode_property_read_u32(ev_node, "azoteq,thresh", &val)) {
- if (val > IQS269_CHx_THRESH_MAX) {
- dev_err(&client->dev,
- "Invalid channel %u threshold: %u\n",
- reg, val);
- fwnode_handle_put(ev_node);
- return -EINVAL;
+ {
+ struct fwnode_handle *ev_node __free(fwnode_handle)
+ = fwnode_get_named_child_node(ch_node,
+ iqs269_events[i].name);
+
+ if (!ev_node)
+ continue;
+
+ if (!fwnode_property_read_u32(ev_node, "azoteq,thresh", &val)) {
+ if (val > IQS269_CHx_THRESH_MAX) {
+ dev_err(&client->dev,
+ "Invalid channel %u threshold: %u\n",
+ reg, val);
+ return -EINVAL;
+ }
+
+ ch_reg->thresh[iqs269_events[i].th_offs] = val;
}
- ch_reg->thresh[iqs269_events[i].th_offs] = val;
- }
-
- if (!fwnode_property_read_u32(ev_node, "azoteq,hyst", &val)) {
- u8 *hyst = &ch_reg->hyst;
-
- if (val > IQS269_CHx_HYST_MAX) {
- dev_err(&client->dev,
- "Invalid channel %u hysteresis: %u\n",
- reg, val);
- fwnode_handle_put(ev_node);
- return -EINVAL;
+ if (!fwnode_property_read_u32(ev_node, "azoteq,hyst", &val)) {
+ u8 *hyst = &ch_reg->hyst;
+
+ if (val > IQS269_CHx_HYST_MAX) {
+ dev_err(&client->dev,
+ "Invalid channel %u hysteresis: %u\n",
+ reg, val);
+ return -EINVAL;
+ }
+
+ if (i == IQS269_EVENT_DEEP_DN ||
+ i == IQS269_EVENT_DEEP_UP) {
+ *hyst &= ~IQS269_CHx_HYST_DEEP_MASK;
+ *hyst |= (val << IQS269_CHx_HYST_DEEP_SHIFT);
+ } else if (i == IQS269_EVENT_TOUCH_DN ||
+ i == IQS269_EVENT_TOUCH_UP) {
+ *hyst &= ~IQS269_CHx_HYST_TOUCH_MASK;
+ *hyst |= val;
+ }
}
- if (i == IQS269_EVENT_DEEP_DN ||
- i == IQS269_EVENT_DEEP_UP) {
- *hyst &= ~IQS269_CHx_HYST_DEEP_MASK;
- *hyst |= (val << IQS269_CHx_HYST_DEEP_SHIFT);
- } else if (i == IQS269_EVENT_TOUCH_DN ||
- i == IQS269_EVENT_TOUCH_UP) {
- *hyst &= ~IQS269_CHx_HYST_TOUCH_MASK;
- *hyst |= val;
- }
+ error = fwnode_property_read_u32(ev_node, "linux,code", &val);
}
- error = fwnode_property_read_u32(ev_node, "linux,code", &val);
- fwnode_handle_put(ev_node);
if (error == -EINVAL) {
continue;
} else if (error) {