Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3499088pxf; Mon, 22 Mar 2021 07:50:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBgVtsQ0rVwbsqDWh4QWxvdDrlCTQ0YjM3k2ElaOuIAbMRl+0gWBzA8v5pEEtc8wehDhz1 X-Received: by 2002:a17:907:2513:: with SMTP id y19mr96386ejl.241.1616424646157; Mon, 22 Mar 2021 07:50:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616424646; cv=none; d=google.com; s=arc-20160816; b=XjrAO0l+Db7U6xvfxB87cVDRYoWKxIWvjQXezmNmwJGh5+ashy5jBVMJpCRTCjour7 SKtIwsAKlIeAzZMzMXcQzUOK8nwr7z8UeI2esGkmKiTsyV76s1j2jVODQGxIewZQQrfp PxZLlQR2YNnf+23dceuXakn5O3o77w/2xq7A3FKoVo7YMSXiDUbUjrQFuTxc+XO59p/0 l90VQnTXo/D2HNqoULRrLeiPMcEipMRlJXlQAnns5K02fYVj4H1VUXjbEMIrCZ+aEl+4 eTo0MkU9WJEhfAPs8TJT4PwTjUNILKU9ua7L3VdUA63Mzi2k8hkGM+twOEojVWci/+iQ GN4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ceienCZXNieK8pEqEFJXFUa0UTHwlnuF2T4Lx79t5Mg=; b=CUPYK/PjdATzSkh92zff0e+XIRB3Bc/9URPko7Q+LQNv1Pa7BQ8g56iEKMVXY9WWag +p4ywdg96aX5JwI6jUy/ibubSOS6Qr/KbYtTfMO+9LHM8RtqSUkTJpUGjbDsTn4es3nG nzb5k+c5oIXX2YMVDjs4Khhk7klHxr6O4hILRi5qofwrG5zkqpQcTe6spA+Ji3qmJhfK ixm+bqSZlN335yhzBJiEICL3NVenFtVbZDTGlNSm0VQjxekr92k9aGMdUuRWfqqN2/uI hkDSaskUUyzeO4wlTDkPRktJk09g3bNkbzH/vyuvIqQJURkG9oie7Rg7FrHhlolvExin P9Lw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o10si11921167edc.254.2021.03.22.07.50.24; Mon, 22 Mar 2021 07:50:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230321AbhCVOtc (ORCPT + 99 others); Mon, 22 Mar 2021 10:49:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230214AbhCVOs4 (ORCPT ); Mon, 22 Mar 2021 10:48:56 -0400 Received: from laurent.telenet-ops.be (laurent.telenet-ops.be [IPv6:2a02:1800:110:4::f00:19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D084C0613DC for ; Mon, 22 Mar 2021 07:48:54 -0700 (PDT) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed20:250b:f16c:c5e2:505d]) by laurent.telenet-ops.be with bizsmtp id jSos2400c2HDxaV01Sosg3; Mon, 22 Mar 2021 15:48:53 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1lOLrQ-009ZWJ-ET; Mon, 22 Mar 2021 15:48:52 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1lOLrP-004T6A-M2; Mon, 22 Mar 2021 15:48:51 +0100 From: Geert Uytterhoeven To: Robin van der Gracht , Rob Herring , Miguel Ojeda , Paul Burton , Greg Kroah-Hartman Cc: devicetree@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 08/17] auxdisplay: linedisp: Add support for changing scroll rate Date: Mon, 22 Mar 2021 15:48:39 +0100 Message-Id: <20210322144848.1065067-9-geert@linux-m68k.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210322144848.1065067-1-geert@linux-m68k.org> References: <20210322144848.1065067-1-geert@linux-m68k.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the message to display is longer than the number of characters that the display can show, the message will be scrolled. Currently the scroll rate is fixed, moving every 500 ms. Add support for changing the scroll rate through a "scroll_step_ms" device attribute in sysfs. Signed-off-by: Geert Uytterhoeven --- drivers/auxdisplay/line-display.c | 37 +++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-display.c index 3f35199bc39f511f..03e7f104aa1add32 100644 --- a/drivers/auxdisplay/line-display.c +++ b/drivers/auxdisplay/line-display.c @@ -19,6 +19,8 @@ #include "line-display.h" +#define DEFAULT_SCROLL_RATE (HZ / 2) + /** * linedisp_scroll() - scroll the display by a character * @t: really a pointer to the private data structure @@ -50,7 +52,7 @@ static void linedisp_scroll(struct timer_list *t) linedisp->scroll_pos %= linedisp->message_len; /* rearm the timer */ - if (linedisp->message_len > num_chars) + if (linedisp->message_len > num_chars && linedisp->scroll_rate) mod_timer(&linedisp->timer, jiffies + linedisp->scroll_rate); } @@ -149,8 +151,39 @@ static ssize_t message_store(struct device *dev, struct device_attribute *attr, static DEVICE_ATTR_RW(message); +static ssize_t scroll_step_ms_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct linedisp *linedisp = container_of(dev, struct linedisp, dev); + + return sysfs_emit(buf, "%u\n", jiffies_to_msecs(linedisp->scroll_rate)); +} + +static ssize_t scroll_step_ms_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct linedisp *linedisp = container_of(dev, struct linedisp, dev); + unsigned int ms; + + if (kstrtouint(buf, 10, &ms) != 0) + return -EINVAL; + + linedisp->scroll_rate = msecs_to_jiffies(ms); + if (linedisp->message && linedisp->message_len > linedisp->num_chars) { + del_timer_sync(&linedisp->timer); + if (linedisp->scroll_rate) + linedisp_scroll(&linedisp->timer); + } + + return count; +} + +static DEVICE_ATTR_RW(scroll_step_ms); + static struct attribute *linedisp_attrs[] = { &dev_attr_message.attr, + &dev_attr_scroll_step_ms.attr, NULL, }; ATTRIBUTE_GROUPS(linedisp); @@ -182,7 +215,7 @@ int linedisp_register(struct linedisp *linedisp, struct device *parent, linedisp->update = update; linedisp->buf = buf; linedisp->num_chars = num_chars; - linedisp->scroll_rate = HZ / 2; + linedisp->scroll_rate = DEFAULT_SCROLL_RATE; device_initialize(&linedisp->dev); dev_set_name(&linedisp->dev, "linedisp.%lu", -- 2.25.1