From patchwork Wed Jul 14 15:11:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 476967 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F289EC11F69 for ; Wed, 14 Jul 2021 15:12:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9F8D613BF for ; Wed, 14 Jul 2021 15:12:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239897AbhGNPPF (ORCPT ); Wed, 14 Jul 2021 11:15:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239563AbhGNPOu (ORCPT ); Wed, 14 Jul 2021 11:14:50 -0400 Received: from michel.telenet-ops.be (michel.telenet-ops.be [IPv6:2a02:1800:110:4::f00:18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDFB7C06129B for ; Wed, 14 Jul 2021 08:11:44 -0700 (PDT) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed10:bcf3:b2b1:dff6:480b]) by michel.telenet-ops.be with bizsmtp id V3Bf2500M4sai0K063BfXu; Wed, 14 Jul 2021 17:11:41 +0200 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 1m3gXz-001ARN-0x; Wed, 14 Jul 2021 17:11:39 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1m3gXx-00Acfw-Dk; Wed, 14 Jul 2021 17:11:37 +0200 From: Geert Uytterhoeven To: Robin van der Gracht , Rob Herring , Miguel Ojeda , Paul Burton , Greg Kroah-Hartman , Pavel Machek , Marek Behun Cc: devicetree@vger.kernel.org, linux-leds@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v3 08/19] auxdisplay: linedisp: Add support for changing scroll rate Date: Wed, 14 Jul 2021 17:11:19 +0200 Message-Id: <20210714151130.2531831-9-geert@linux-m68k.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210714151130.2531831-1-geert@linux-m68k.org> References: <20210714151130.2531831-1-geert@linux-m68k.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 --- v3: - No changes, v2: - No changes. --- 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",