+static inline int udev_user(int argc, char **argv)
+{
+ static const char short_options[] = "q:rVh";
+ int option;
+ int retval = -EINVAL;
+ struct udevice dev;
+
+ while (1) {
+ option = getopt(argc, argv, short_options);
+ if (option == -1)
+ break;
+
+ dbg("option '%c'", option);
+ switch (option) {
+ case 'q':
+ dbg("udev query: %s\n", optarg);
+ retval = udevdb_open_ro();
+ if (retval != 0) {
+ printf("unable to open udev database\n");
+ return -1;
+ }
+ retval = udevdb_get_dev(optarg, &dev);
+ if (retval == 0) {
+ printf("%s\n", dev.name);
+ } else {
+ printf("device not found in udev database\n");
+ }
+ udevdb_exit();
+ return retval;
+
+ case 'r':
+ printf("%s\n", udev_root);
+ return 0;
+
+ case 'V':
+ printf("udev, version %s\n", UDEV_VERSION);
+ return 0;
+
+ case 'h':
+ retval = 0;
+ case '?':
+ default:
+ goto help;
+ }
+ }