Skip to content

Commit 9fefca7

Browse files
committed
gpiolib: notify user-space about line status changes after flags are set
Currently we emit the REQUESTED line state event after the line is requested but before the flags are configured. This is obviously wrong as we want to pass the updated lineinfo to user-space together with the event. Since the flags can be configured in different ways depending on how the line is being requested - we need to call the notifier chain in different places separately. Fixes: 51c1064 ("gpiolib: add new ioctl() for monitoring changes in line info") Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 333830a commit 9fefca7

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

drivers/gpio/gpiolib.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,10 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip)
729729
if (ret)
730730
goto out_free_descs;
731731
}
732+
733+
atomic_notifier_call_chain(&desc->gdev->notifier,
734+
GPIOLINE_CHANGED_REQUESTED, desc);
735+
732736
dev_dbg(&gdev->dev, "registered chardev handle for line %d\n",
733737
offset);
734738
}
@@ -1083,6 +1087,9 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
10831087
if (ret)
10841088
goto out_free_desc;
10851089

1090+
atomic_notifier_call_chain(&desc->gdev->notifier,
1091+
GPIOLINE_CHANGED_REQUESTED, desc);
1092+
10861093
le->irq = gpiod_to_irq(desc);
10871094
if (le->irq <= 0) {
10881095
ret = -ENODEV;
@@ -2998,8 +3005,6 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
29983005
}
29993006
done:
30003007
spin_unlock_irqrestore(&gpio_lock, flags);
3001-
atomic_notifier_call_chain(&desc->gdev->notifier,
3002-
GPIOLINE_CHANGED_REQUESTED, desc);
30033008
return ret;
30043009
}
30053010

@@ -4961,6 +4966,9 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
49614966
return ERR_PTR(ret);
49624967
}
49634968

4969+
atomic_notifier_call_chain(&desc->gdev->notifier,
4970+
GPIOLINE_CHANGED_REQUESTED, desc);
4971+
49644972
return desc;
49654973
}
49664974
EXPORT_SYMBOL_GPL(gpiod_get_index);
@@ -5026,6 +5034,9 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
50265034
return ERR_PTR(ret);
50275035
}
50285036

5037+
atomic_notifier_call_chain(&desc->gdev->notifier,
5038+
GPIOLINE_CHANGED_REQUESTED, desc);
5039+
50295040
return desc;
50305041
}
50315042
EXPORT_SYMBOL_GPL(fwnode_get_named_gpiod);

0 commit comments

Comments
 (0)