Re: [PATCH 07/11] fblog: allow selecting fbs via sysfs and module-parameters
From: David Herrmann <hidden>
Date: 2012-08-14 11:07:09
Also in:
linux-fbdev, linux-serial
Hi Ryan On Mon, Aug 13, 2012 at 2:04 AM, Ryan Mallon [off-list ref] wrote:
On 13/08/12 00:53, David Herrmann wrote:quoted
+static ssize_t fblog_dev_active_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct fblog_fb *fb = to_fblog_dev(dev); + + return snprintf(buf, PAGE_SIZE, "%d\n", + !!test_bit(FBLOG_OPEN, &fb->flags));Nitpick. sprintf is okay here, %d is rarely longer than PAGE_SIZE :-).quoted
+} + +static ssize_t fblog_dev_active_store(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t count) +{ + struct fblog_fb *fb = to_fblog_dev(dev); + unsigned long num; + int ret = 0; + + num = simple_strtoul(buf, NULL, 10);kstrtoul is preferred these days I think, it also catches errors.quoted
+ + mutex_lock(&fb->info->lock); + if (num) + ret = fblog_open(fb); + else + fblog_close(fb, false); + mutex_unlock(&fb->info->lock); + + return ret ? ret : count;Nitpick, you can use gcc's shortcut form of the ? operator here: return ret ?: count;quoted
@@ -186,7 +228,20 @@ static void fblog_do_register(struct fb_info *info, bool force) return; } - fblog_open(fb); + ret = device_create_file(&fb->dev, &dev_attr_active); + if (ret) { + pr_err("fblog: cannot create sysfs entry");Shouldn't need the "fblog: " prefix, since you have pr_fmt defined.quoted
+ /* do not open fb if we cannot create control file */ + do_open = false; + } + + if (!activate_on_hotplug) + do_open = false; + if (main_only && info->node != 0) + do_open = false; + + if (do_open) + fblog_open(fb); } static void fblog_register(struct fb_info *info, bool force)
All four fixes make sense, thanks! David