diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2011-08-15 15:55:55 +0300 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2011-09-30 16:16:21 +0300 |
commit | e3a26aecc0ea5ce1c2bd567439d66a0699ea7774 (patch) | |
tree | 96349d8e5473f76232f578e665f336ce5173b3cf /drivers/video/omap2/dss/manager.c | |
parent | f6dc815098bde08c09fd1219e0f77663f8a9a6c7 (diff) |
OMAP: DSS2: string parsing cleanups
Use strtobool and kstrto* functions when parsing sysfs inputs.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/video/omap2/dss/manager.c')
-rw-r--r-- | drivers/video/omap2/dss/manager.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/drivers/video/omap2/dss/manager.c b/drivers/video/omap2/dss/manager.c index 72e041b3a66..eb7833ecaf3 100644 --- a/drivers/video/omap2/dss/manager.c +++ b/drivers/video/omap2/dss/manager.c @@ -106,7 +106,7 @@ put_device: static ssize_t manager_default_color_show(struct omap_overlay_manager *mgr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%d\n", mgr->info.default_color); + return snprintf(buf, PAGE_SIZE, "%#x\n", mgr->info.default_color); } static ssize_t manager_default_color_store(struct omap_overlay_manager *mgr, @@ -116,8 +116,9 @@ static ssize_t manager_default_color_store(struct omap_overlay_manager *mgr, u32 color; int r; - if (sscanf(buf, "%d", &color) != 1) - return -EINVAL; + r = kstrtouint(buf, 0, &color); + if (r) + return r; mgr->get_manager_info(mgr, &info); @@ -184,7 +185,7 @@ static ssize_t manager_trans_key_type_store(struct omap_overlay_manager *mgr, static ssize_t manager_trans_key_value_show(struct omap_overlay_manager *mgr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%d\n", mgr->info.trans_key); + return snprintf(buf, PAGE_SIZE, "%#x\n", mgr->info.trans_key); } static ssize_t manager_trans_key_value_store(struct omap_overlay_manager *mgr, @@ -194,8 +195,9 @@ static ssize_t manager_trans_key_value_store(struct omap_overlay_manager *mgr, u32 key_value; int r; - if (sscanf(buf, "%d", &key_value) != 1) - return -EINVAL; + r = kstrtouint(buf, 0, &key_value); + if (r) + return r; mgr->get_manager_info(mgr, &info); @@ -222,15 +224,16 @@ static ssize_t manager_trans_key_enabled_store(struct omap_overlay_manager *mgr, const char *buf, size_t size) { struct omap_overlay_manager_info info; - int enable; + bool enable; int r; - if (sscanf(buf, "%d", &enable) != 1) - return -EINVAL; + r = strtobool(buf, &enable); + if (r) + return r; mgr->get_manager_info(mgr, &info); - info.trans_enabled = enable ? true : false; + info.trans_enabled = enable; r = mgr->set_manager_info(mgr, &info); if (r) @@ -254,15 +257,16 @@ static ssize_t manager_alpha_blending_enabled_store( const char *buf, size_t size) { struct omap_overlay_manager_info info; - int enable; + bool enable; int r; - if (sscanf(buf, "%d", &enable) != 1) - return -EINVAL; + r = strtobool(buf, &enable); + if (r) + return r; mgr->get_manager_info(mgr, &info); - info.alpha_enabled = enable ? true : false; + info.alpha_enabled = enable; r = mgr->set_manager_info(mgr, &info); if (r) @@ -285,19 +289,16 @@ static ssize_t manager_cpr_enable_store(struct omap_overlay_manager *mgr, const char *buf, size_t size) { struct omap_overlay_manager_info info; - int v; int r; bool enable; if (!dss_has_feature(FEAT_CPR)) return -ENODEV; - r = kstrtoint(buf, 0, &v); + r = strtobool(buf, &enable); if (r) return r; - enable = !!v; - mgr->get_manager_info(mgr, &info); if (info.cpr_enable == enable) |