summaryrefslogtreecommitdiff
path: root/test/dm/gpio.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2014-10-04 11:29:49 -0600
committerSimon Glass <sjg@chromium.org>2014-10-23 19:29:52 -0600
commitd44f597b12b8f8099c3c52c3eb09540966cafe79 (patch)
treeaeecc26ed1a0938d0e567b08af389b63088d4664 /test/dm/gpio.c
parent4b8f11c2cc1dc23cf721073e6440c4e151b89bdd (diff)
downloadu-boot-imx-d44f597b12b8f8099c3c52c3eb09540966cafe79.zip
u-boot-imx-d44f597b12b8f8099c3c52c3eb09540966cafe79.tar.gz
u-boot-imx-d44f597b12b8f8099c3c52c3eb09540966cafe79.tar.bz2
dm: gpio: Add gpio_requestf() helper for printf() strings
Add a helper which permits a printf()-style format string for the requester string. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/dm/gpio.c')
-rw-r--r--test/dm/gpio.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/dm/gpio.c b/test/dm/gpio.c
index ad56ca5..5174ced 100644
--- a/test/dm/gpio.c
+++ b/test/dm/gpio.c
@@ -120,3 +120,21 @@ static int dm_test_gpio_anon(struct dm_test_state *dms)
return 0;
}
DM_TEST(dm_test_gpio_anon, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test that gpio_requestf() works as expected */
+static int dm_test_gpio_requestf(struct dm_test_state *dms)
+{
+ unsigned int offset, gpio;
+ struct udevice *dev;
+ char buf[80];
+
+ ut_assertok(gpio_lookup_name("b5", &dev, &offset, &gpio));
+ ut_assertok(gpio_requestf(gpio, "testing %d %s", 1, "hi"));
+ sandbox_gpio_set_direction(dev, offset, 1);
+ sandbox_gpio_set_value(dev, offset, 1);
+ ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf)));
+ ut_asserteq_str("b5: output: 1 [x] testing 1 hi", buf);
+
+ return 0;
+}
+DM_TEST(dm_test_gpio_requestf, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);