[PATCH 12/21] fb: Use dev_add_param_bool for enable parameter

Sascha Hauer s.hauer at pengutronix.de
Sun Apr 7 10:00:46 EDT 2013


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/video/fb.c | 33 ++++++++++++---------------------
 include/fb.h       |  1 +
 2 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/drivers/video/fb.c b/drivers/video/fb.c
index be29695..0e00cb7 100644
--- a/drivers/video/fb.c
+++ b/drivers/video/fb.c
@@ -28,31 +28,22 @@ static int fb_ioctl(struct cdev* cdev, int req, void *data)
 	return 0;
 }
 
-static int fb_enable_set(struct device_d *dev, struct param_d *param,
-		const char *val)
+static int fb_enable_set(struct param_d *param, void *priv)
 {
-	struct fb_info *info = dev->priv;
+	struct fb_info *info = priv;
 	int enable;
-	char *new;
-
-	if (!val)
-		return dev_param_set_generic(dev, param, NULL);
 
-	enable = simple_strtoul(val, NULL, 0);
+	enable = info->p_enable;
 
-	if (enable) {
-		if (!info->enabled)
-			info->fbops->fb_enable(info);
-		new = "1";
-	} else {
-		if (info->enabled)
-			info->fbops->fb_disable(info);
-		new = "0";
-	}
+	if (enable == info->enabled)
+		return 0;
 
-	dev_param_set_generic(dev, param, new);
+	if (enable)
+		info->fbops->fb_enable(info);
+	else
+		info->fbops->fb_disable(info);
 
-	info->enabled = !!enable;
+	info->enabled = enable;
 
 	return 0;
 }
@@ -165,8 +156,8 @@ static int fb_probe(struct device_d *dev)
 {
 	struct fb_info *info = dev->priv;
 
-	dev_add_param(dev, "enable", fb_enable_set, NULL, 0);
-	dev_set_param(dev, "enable", "0");
+	dev_add_param_bool(dev, "enable", fb_enable_set, NULL,
+			&info->p_enable, info);
 
 	if (info->num_modes && (info->mode_list != NULL) &&
 			(info->fbops->fb_activate_var != NULL)) {
diff --git a/include/fb.h b/include/fb.h
index c594418..23d6c6d 100644
--- a/include/fb.h
+++ b/include/fb.h
@@ -102,6 +102,7 @@ struct fb_info {
 	struct fb_bitfield transp;	/* transparency			*/
 
 	int enabled;
+	int p_enable;
 };
 
 int register_framebuffer(struct fb_info *info);
-- 
1.8.2.rc2




More information about the barebox mailing list