From nobody Sun Feb 8 12:36:30 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABFAB28DD6; Thu, 8 Feb 2024 18:49:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418173; cv=none; b=cQqEUaGapcICa89GV1cg8CDwL/m9oW4YrKcvkzUF/fFLw5JtjzrE19jdRwPxKUonQ6kSAp03vW0z42GaIImJqAYky23toXHQVUMqwpiOxRXAqmvBpOxq85rB2gBkLYWfyVrd8Lz4dT86jJEZseCagJGmfwPmnLgM3kmsc3JOuTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707418173; c=relaxed/simple; bh=fRF6aaXYm3WO7lZKrdtFCzyzTyXPONtxX7sbViupAFA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gd3vdTWd9MiVKxWC2h2iQMTOoK7aoxvN87yDp5w/B2Kdk6DFCUl7CwTnh4cmAViiFgWzDw8JaPFS6VhjlE1qXZHDD3BLTSYepDXcjFBGcEb8Lc8X64CYKmGurKsM5uCSQwtrtQqeNIRk6UTxcfvjunUPyLpW3fyyTQ8bc/cmn30= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=CcExyo2Z; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CcExyo2Z" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707418171; x=1738954171; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fRF6aaXYm3WO7lZKrdtFCzyzTyXPONtxX7sbViupAFA=; b=CcExyo2Zl2E3fY/QTEIm1qF3w0bkIdBGCSx7vDv779w3UmhXqq4dWkKp kMHsdnWmpR6SOAABYlkqqmh6LC/0khTJUVwyX86Z4M/jOBO/j/7ghNcIU MIAgso2Yp/GMLejrPnqw/3j9k8ZpamuPalQgkhkyD/ZeCEvbioX16Yrgd 5t+1zse7TlfRz7UJ8R+PD0DBNvM++H0rbHRPuIweauax+jMM6c3EMBrY7 jq0Q6WivrTXx/zA/EH7+mR/5UDdsi9OHKz+GBLPiGzsl4LmiMakyM5xk1 8X12a5OuWOtOhabmIvRZAUwURBwXncnz/v5tWveFWNC5UxBp/ubh9vr71 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="1186120" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="1186120" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 10:49:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="934215533" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208";a="934215533" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Feb 2024 10:49:25 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7B81FBA3; Thu, 8 Feb 2024 20:49:21 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Miguel Ojeda , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin van der Gracht , Paul Burton , Geert Uytterhoeven Subject: [PATCH v1 08/15] auxdisplay: linedisp: Provide struct linedisp_ops for future extension Date: Thu, 8 Feb 2024 20:48:06 +0200 Message-ID: <20240208184919.2224986-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240208184919.2224986-1-andriy.shevchenko@linux.intel.com> References: <20240208184919.2224986-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently the line display library doesn't scale in case we want to provide more operations. Prepare the library to take a newly created struct linedisp_ops that scales. Signed-off-by: Andy Shevchenko --- drivers/auxdisplay/ht16k33.c | 7 +++++-- drivers/auxdisplay/img-ascii-lcd.c | 19 ++++++++++++------- drivers/auxdisplay/line-display.c | 11 +++++------ drivers/auxdisplay/line-display.h | 17 +++++++++++++---- 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c index c6a42c5c128f..0cdf3fbdf81e 100644 --- a/drivers/auxdisplay/ht16k33.c +++ b/drivers/auxdisplay/ht16k33.c @@ -448,6 +448,10 @@ static void ht16k33_linedisp_update(struct linedisp *l= inedisp) schedule_delayed_work(&priv->work, 0); } =20 +static const struct linedisp_ops ht16k33_linedisp_ops =3D { + .update =3D ht16k33_linedisp_update, +}; + static void ht16k33_seg7_update(struct work_struct *work) { struct ht16k33_priv *priv =3D container_of(work, struct ht16k33_priv, @@ -696,8 +700,7 @@ static int ht16k33_seg_probe(struct device *dev, struct= ht16k33_priv *priv, if (err) return err; =20 - err =3D linedisp_register(&seg->linedisp, dev, 4, seg->curr, - ht16k33_linedisp_update); + err =3D linedisp_register(&seg->linedisp, dev, 4, seg->curr, &ht16k33_lin= edisp_ops); if (err) goto err_remove_map_file; =20 diff --git a/drivers/auxdisplay/img-ascii-lcd.c b/drivers/auxdisplay/img-as= cii-lcd.c index c571e54d9eb5..c0ec7d9a1c62 100644 --- a/drivers/auxdisplay/img-ascii-lcd.c +++ b/drivers/auxdisplay/img-ascii-lcd.c @@ -22,12 +22,12 @@ struct img_ascii_lcd_ctx; * struct img_ascii_lcd_config - Configuration information about an LCD mo= del * @num_chars: the number of characters the LCD can display * @external_regmap: true if registers are in a system controller, else fa= lse - * @update: function called to update the LCD + * @ops: character line display operations */ struct img_ascii_lcd_config { unsigned int num_chars; bool external_regmap; - void (*update)(struct linedisp *linedisp); + const struct linedisp_ops ops; }; =20 /** @@ -75,7 +75,9 @@ static void boston_update(struct linedisp *linedisp) =20 static struct img_ascii_lcd_config boston_config =3D { .num_chars =3D 8, - .update =3D boston_update, + .ops =3D { + .update =3D boston_update, + }, }; =20 /* @@ -103,7 +105,9 @@ static void malta_update(struct linedisp *linedisp) static struct img_ascii_lcd_config malta_config =3D { .num_chars =3D 8, .external_regmap =3D true, - .update =3D malta_update, + .ops =3D { + .update =3D malta_update, + }, }; =20 /* @@ -203,7 +207,9 @@ static void sead3_update(struct linedisp *linedisp) static struct img_ascii_lcd_config sead3_config =3D { .num_chars =3D 16, .external_regmap =3D true, - .update =3D sead3_update, + .ops =3D { + .update =3D sead3_update, + }, }; =20 static const struct of_device_id img_ascii_lcd_matches[] =3D { @@ -247,8 +253,7 @@ static int img_ascii_lcd_probe(struct platform_device *= pdev) return PTR_ERR(ctx->base); } =20 - err =3D linedisp_register(&ctx->linedisp, dev, cfg->num_chars, ctx->curr, - cfg->update); + err =3D linedisp_register(&ctx->linedisp, dev, cfg->num_chars, ctx->curr,= &cfg->ops); if (err) return err; =20 diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-di= splay.c index 851b2c0f9443..62e8a911bb12 100644 --- a/drivers/auxdisplay/line-display.c +++ b/drivers/auxdisplay/line-display.c @@ -50,7 +50,7 @@ static void linedisp_scroll(struct timer_list *t) } =20 /* update the display */ - linedisp->update(linedisp); + linedisp->ops->update(linedisp); =20 /* move on to the next character */ linedisp->scroll_pos++; @@ -94,7 +94,7 @@ static int linedisp_display(struct linedisp *linedisp, co= nst char *msg, linedisp->message =3D NULL; linedisp->message_len =3D 0; memset(linedisp->buf, ' ', linedisp->num_chars); - linedisp->update(linedisp); + linedisp->ops->update(linedisp); return 0; } =20 @@ -216,20 +216,19 @@ static const struct device_type linedisp_type =3D { * @parent: parent device * @num_chars: the number of characters that can be displayed * @buf: pointer to a buffer that can hold @num_chars characters - * @update: Function called to update the display. This must not sleep! + * @ops: character line display operations * * Return: zero on success, else a negative error code. */ int linedisp_register(struct linedisp *linedisp, struct device *parent, - unsigned int num_chars, char *buf, - void (*update)(struct linedisp *linedisp)) + unsigned int num_chars, char *buf, const struct linedisp_ops *ops) { int err; =20 memset(linedisp, 0, sizeof(*linedisp)); linedisp->dev.parent =3D parent; linedisp->dev.type =3D &linedisp_type; - linedisp->update =3D update; + linedisp->ops =3D ops; linedisp->buf =3D buf; linedisp->num_chars =3D num_chars; linedisp->scroll_rate =3D DEFAULT_SCROLL_RATE; diff --git a/drivers/auxdisplay/line-display.h b/drivers/auxdisplay/line-di= splay.h index d72c1899dc50..a4f0d1bf5848 100644 --- a/drivers/auxdisplay/line-display.h +++ b/drivers/auxdisplay/line-display.h @@ -14,12 +14,22 @@ #include #include =20 +struct linedisp; + +/** + * struct linedisp_ops - character line display operations + * @update: Function called to update the display. This must not sleep! + */ +struct linedisp_ops { + void (*update)(struct linedisp *linedisp); +}; + /** * struct linedisp - character line display private data structure * @dev: the line display device * @id: instance id of this display * @timer: timer used to implement scrolling - * @update: function called to update the display + * @ops: character line display operations * @buf: pointer to the buffer for the string currently displayed * @message: the full message to display or scroll on the display * @num_chars: the number of characters that can be displayed @@ -31,7 +41,7 @@ struct linedisp { struct device dev; unsigned int id; struct timer_list timer; - void (*update)(struct linedisp *linedisp); + const struct linedisp_ops *ops; char *buf; char *message; unsigned int num_chars; @@ -41,8 +51,7 @@ struct linedisp { }; =20 int linedisp_register(struct linedisp *linedisp, struct device *parent, - unsigned int num_chars, char *buf, - void (*update)(struct linedisp *linedisp)); + unsigned int num_chars, char *buf, const struct linedisp_ops *ops); void linedisp_unregister(struct linedisp *linedisp); =20 #endif /* LINEDISP_H */ --=20 2.43.0.rc1.1.gbec44491f096