From patchwork Sun Jul 15 19:04:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 1199331 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 244B240B37 for ; Sun, 15 Jul 2012 19:06:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751234Ab2GOTGh (ORCPT ); Sun, 15 Jul 2012 15:06:37 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:57636 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751580Ab2GOTFb (ORCPT ); Sun, 15 Jul 2012 15:05:31 -0400 Received: by weyx8 with SMTP id x8so3536682wey.19 for ; Sun, 15 Jul 2012 12:05:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=W/QvOWrd1S2IZsOsdIvXhRGZ4ol9dkc0OMPkxMuORhA=; b=Tqudtjjl3VAmiQrY4x35nOyH38MPi+Ei8yRLm3UachsH48yha0+Ze5BommNnLgt+e4 O8zb6X38KO+NTNKoCKH6JEoofpiqd5aRsPXDb1gHGCB2dX3fNJB5KEkPF0JBYkdkRtpa PJeL+XNNBg0ysxiu6dgI8VaYK+QfxfPoVMwTBuQm2Imx7nfLN+HNrM0kMRVxKeE+L0qp puUWvIhuFkCHlCsmd9S+pc9Nsg1Ky+vW4YxbxJUWKiLaSGvjTUmV1yyzWIJH2CdULvZn 8BITQLMNP2Ae17r/Dmgymdc/FOVyrhLLnuP0lb4vzwOYNu64dws9aaFmKBFBhZPfE8GK FPIQ== Received: by 10.216.134.169 with SMTP id s41mr4543269wei.183.1342379129082; Sun, 15 Jul 2012 12:05:29 -0700 (PDT) Received: from localhost.localdomain (stgt-5f71ba59.pool.mediaWays.net. [95.113.186.89]) by mx.google.com with ESMTPS id j6sm25479086wiy.4.2012.07.15.12.05.27 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 15 Jul 2012 12:05:28 -0700 (PDT) From: David Herrmann To: linux-kernel@vger.kernel.org Cc: Florian Tobias Schandinat , Andrew Morton , Greg Kroah-Hartman , linux-fbdev@vger.kernel.org, linux-serial@vger.kernel.org, Alan Cox , David Herrmann Subject: [PATCH v3 07/11] fblog: allow selecting fbs via sysfs Date: Sun, 15 Jul 2012 21:04:42 +0200 Message-Id: <1342379086-7583-8-git-send-email-dh.herrmann@googlemail.com> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1342379086-7583-1-git-send-email-dh.herrmann@googlemail.com> References: <1342379086-7583-1-git-send-email-dh.herrmann@googlemail.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org fblog is mainly useful during boot, reboot, panics and maintenance. In all cases you often want to control which monitors are used for console output. Moreover, in multi-seat environments it is desireable to reduce system-overhead by not drawing the console to all framebuffers. Two mechanisms to select framebuffers for fblog are added: 1) "active" module parameter: This parameter selects whether new framebuffers are opened automatically. By default this is on, that is, all framebuffers are automatically used by fblog during boot. By passing fblog.active=0 you can deactivate this. The init process can set this to 0 via /sys/modules/fblog/parameters/active, too. However, this does not affect already available and used framebuffers in any way. 2) "active" sysfs attribute for each fblog object. Reading this value returns whether a framebuffer is currently active. Writing it opens/closes the framebuffer. This allows runtime control which fbs are used. For instance, init can set these to 0 after bootup. Signed-off-by: David Herrmann --- drivers/video/console/fblog.c | 53 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/drivers/video/console/fblog.c b/drivers/video/console/fblog.c index 1c526c5..5519f91 100644 --- a/drivers/video/console/fblog.c +++ b/drivers/video/console/fblog.c @@ -44,6 +44,7 @@ struct fblog_fb { static DEFINE_MUTEX(fblog_registration_lock); static struct fblog_fb *fblog_fbs[FB_MAX]; +static bool active = 1; #define to_fblog_dev(_d) container_of(_d, struct fblog_fb, dev) @@ -115,6 +116,40 @@ static void fblog_close(struct fblog_fb *fb, bool kill_dev) mutex_unlock(&fb->lock); } +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)); +} + +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); + + 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; +} + +static DEVICE_ATTR(active, S_IRUGO | S_IWUSR | S_IWGRP, fblog_dev_active_show, + fblog_dev_active_store); + /* * fblog framebuffer list * The fblog_fbs[] array contains all currently registered framebuffers. If a @@ -148,6 +183,7 @@ static void fblog_do_unregister(struct fb_info *info) fblog_fbs[info->node] = NULL; fblog_close(fb, true); + device_remove_file(&fb->dev, &dev_attr_active); device_del(&fb->dev); put_device(&fb->dev); } @@ -156,6 +192,7 @@ static void fblog_do_register(struct fb_info *info, bool force) { struct fblog_fb *fb; int ret; + bool do_open = true; fb = fblog_fbs[info->node]; if (fb && fb->info != info) { @@ -186,7 +223,18 @@ 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"); + /* do not open fb if we cannot create control file */ + do_open = false; + } + + if (!active) + do_open = false; + + if (do_open) + fblog_open(fb); } static void fblog_register(struct fb_info *info, bool force) @@ -321,6 +369,9 @@ static void __exit fblog_exit(void) } } +module_param(active, bool, S_IRUGO | S_IWUSR | S_IWGRP); +MODULE_PARM_DESC(active, "Activate fblog by default"); + module_init(fblog_init); module_exit(fblog_exit); MODULE_LICENSE("GPL");