diff options
author | Sakari Ailus <sakari.ailus@iki.fi> | 2011-10-07 18:38:08 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2011-10-08 13:32:28 +0200 |
commit | fa46b9ec30558c5c3680b167e7a4b4966c6e9e46 (patch) | |
tree | f441a2c1889683f7c6e2ebd96e73ac9814091ea0 | |
parent | 2738635d82da5f010bae6a60472a6306df949ea5 (diff) |
Remove extra verbosity
Remove extra verbosity by default; "-v" option brings back what used to be
there. The error messages are now being printed by main.c with the possibly
helpful error code attached.
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r-- | src/main.c | 48 | ||||
-rw-r--r-- | src/mediactl.c | 21 | ||||
-rw-r--r-- | src/mediactl.h | 6 |
3 files changed, 50 insertions, 25 deletions
@@ -288,10 +288,16 @@ int main(int argc, char **argv) return EXIT_FAILURE; /* Open the media device and enumerate entities, pads and links. */ - media = media_open_debug(media_opts.devname, media_opts.verbose, - (void (*)(void *, ...))fprintf, stdout); - if (media == NULL) + if (media_opts.verbose) + media = media_open_debug( + media_opts.devname, + (void (*)(void *, ...))fprintf, stdout); + else + media = media_open(media_opts.devname); + if (media == NULL) { + printf("Failed to open %s\n", media_opts.devname); goto out; + } if (media_opts.entity) { struct media_entity *entity; @@ -326,15 +332,34 @@ int main(int argc, char **argv) } if (media_opts.reset) { - printf("Resetting all links to inactive\n"); - media_reset_links(media); + if (media_opts.verbose) + printf("Resetting all links to inactive\n"); + ret = media_reset_links(media); + if (ret) { + printf("Unable to reset links: %s (%d)\n", + strerror(-ret), -ret); + goto out; + } } - if (media_opts.links) - media_parse_setup_links(media, media_opts.links); + if (media_opts.links) { + ret = media_parse_setup_links(media, media_opts.links); + if (ret) { + printf("Unable to parse link: %s (%d)\n", + strerror(-ret), -ret); + goto out; + } + } - if (media_opts.formats) - v4l2_subdev_parse_setup_formats(media, media_opts.formats); + if (media_opts.formats) { + ret = v4l2_subdev_parse_setup_formats(media, + media_opts.formats); + if (ret) { + printf("Unable to parse format: %s (%d)\n", + strerror(-ret), -ret); + goto out; + } + } if (media_opts.interactive) { while (1) { @@ -348,7 +373,10 @@ int main(int argc, char **argv) if (buffer[0] == '\n') break; - media_parse_setup_link(media, buffer, &end); + ret = media_parse_setup_link(media, buffer, &end); + if (ret) + printf("Unable to parse link: %s (%d)\n", + strerror(-ret), -ret); } } diff --git a/src/mediactl.c b/src/mediactl.c index 43d1b6a..b9c2a10 100644 --- a/src/mediactl.c +++ b/src/mediactl.c @@ -270,7 +270,7 @@ static inline void media_udev_close(struct udev *udev) } static int media_get_devname_udev(struct udev *udev, - struct media_entity *entity, int verbose) + struct media_entity *entity) { struct udev_device *device; dev_t devnum; @@ -281,9 +281,8 @@ static int media_get_devname_udev(struct udev *udev, return -EINVAL; devnum = makedev(entity->info.v4l.major, entity->info.v4l.minor); - if (verbose) - media_dbg(entity->media, "looking up device: %u:%u\n", - major(devnum), minor(devnum)); + media_dbg(entity->media, "looking up device: %u:%u\n", + major(devnum), minor(devnum)); device = udev_device_new_from_devnum(udev, 'c', devnum); if (device) { p = udev_device_get_devnode(device); @@ -308,7 +307,7 @@ static inline int media_udev_open(struct udev **udev) { return 0; } static inline void media_udev_close(struct udev *udev) { } static inline int media_get_devname_udev(struct udev *udev, - struct media_entity *entity, int verbose) + struct media_entity *entity) { return -ENOTSUP; } @@ -351,7 +350,7 @@ static int media_get_devname_sysfs(struct media_entity *entity) return 0; } -static int media_enum_entities(struct media_device *media, int verbose) +static int media_enum_entities(struct media_device *media) { struct media_entity *entity; struct udev *udev; @@ -400,7 +399,7 @@ static int media_enum_entities(struct media_device *media, int verbose) continue; /* Try to get the device name via udev */ - if (!media_get_devname_udev(udev, entity, verbose)) + if (!media_get_devname_udev(udev, entity)) continue; /* Fall back to get the device name via sysfs */ @@ -429,7 +428,7 @@ void media_debug_set_handler(struct media_device *media, } struct media_device *media_open_debug( - const char *name, int verbose, void (*debug_handler)(void *, ...), + const char *name, void (*debug_handler)(void *, ...), void *debug_priv) { struct media_device *media; @@ -453,7 +452,7 @@ struct media_device *media_open_debug( media_dbg(media, "Enumerating entities\n"); - ret = media_enum_entities(media, verbose); + ret = media_enum_entities(media); if (ret < 0) { media_dbg(media, @@ -478,9 +477,9 @@ struct media_device *media_open_debug( return media; } -struct media_device *media_open(const char *name, int verbose) +struct media_device *media_open(const char *name) { - return media_open_debug(name, verbose, NULL, NULL); + return media_open_debug(name, NULL, NULL); } void media_close(struct media_device *media) diff --git a/src/mediactl.h b/src/mediactl.h index b5b5965..cddf272 100644 --- a/src/mediactl.h +++ b/src/mediactl.h @@ -79,7 +79,6 @@ void media_debug_set_handler( /** * @brief Open a media device with debugging enabled. * @param name - name (including path) of the device node. - * @param verbose - whether to print verbose information on the standard output. * @param debug_handler - debug message handler * @param debug_priv - first argument to debug message handler * @@ -95,13 +94,12 @@ void media_debug_set_handler( * media_close when the device isn't needed anymore. */ struct media_device *media_open_debug( - const char *name, int verbose, void (*debug_handler)(void *, ...), + const char *name, void (*debug_handler)(void *, ...), void *debug_priv); /** * @brief Open a media device. * @param name - name (including path) of the device node. - * @param verbose - whether to print verbose information on the standard output. * * Open the media device referenced by @a name and enumerate entities, pads and * links. @@ -110,7 +108,7 @@ struct media_device *media_open_debug( * success and NULL on failure. The returned pointer must be freed with * media_close when the device isn't needed anymore. */ -struct media_device *media_open(const char *name, int verbose); +struct media_device *media_open(const char *name); /** * @brief Close a media device. |