From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Andy Shevchenko <andy@kernel.org>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Robin van der Gracht <robin@protonic.nl>,
Paul Burton <paulburton@kernel.org>
Subject: [PATCH v3 5/9] auxdisplay: ht16k33: Define a few helper macros
Date: Mon, 19 Feb 2024 18:58:04 +0200 [thread overview]
Message-ID: <20240219170337.2161754-6-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20240219170337.2161754-1-andriy.shevchenko@linux.intel.com>
Define a few helper macros — wrappers on contaoner_of)() — for easier
maintenance in the future. While at it, include missing container_of.h.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/auxdisplay/ht16k33.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c
index f016130835b1..b76c4d83528f 100644
--- a/drivers/auxdisplay/ht16k33.c
+++ b/drivers/auxdisplay/ht16k33.c
@@ -15,6 +15,7 @@
#include <linux/property.h>
#include <linux/fb.h>
#include <linux/backlight.h>
+#include <linux/container_of.h>
#include <linux/input.h>
#include <linux/input/matrix_keypad.h>
#include <linux/leds.h>
@@ -107,6 +108,15 @@ struct ht16k33_priv {
uint8_t blink;
};
+#define ht16k33_work_to_priv(p) \
+ container_of(p, struct ht16k33_priv, work.work)
+
+#define ht16k33_led_to_priv(p) \
+ container_of(p, struct ht16k33_priv, led)
+
+#define ht16k33_linedisp_to_priv(p) \
+ container_of(p, struct ht16k33_priv, seg.linedisp)
+
static const struct fb_fix_screeninfo ht16k33_fb_fix = {
.id = DRIVER_NAME,
.type = FB_TYPE_PACKED_PIXELS,
@@ -194,8 +204,7 @@ static int ht16k33_brightness_set(struct ht16k33_priv *priv,
static int ht16k33_brightness_set_blocking(struct led_classdev *led_cdev,
enum led_brightness brightness)
{
- struct ht16k33_priv *priv = container_of(led_cdev, struct ht16k33_priv,
- led);
+ struct ht16k33_priv *priv = ht16k33_led_to_priv(led_cdev);
return ht16k33_brightness_set(priv, brightness);
}
@@ -203,8 +212,7 @@ static int ht16k33_brightness_set_blocking(struct led_classdev *led_cdev,
static int ht16k33_blink_set(struct led_classdev *led_cdev,
unsigned long *delay_on, unsigned long *delay_off)
{
- struct ht16k33_priv *priv = container_of(led_cdev, struct ht16k33_priv,
- led);
+ struct ht16k33_priv *priv = ht16k33_led_to_priv(led_cdev);
unsigned int delay;
uint8_t blink;
int err;
@@ -246,8 +254,7 @@ static void ht16k33_fb_queue(struct ht16k33_priv *priv)
*/
static void ht16k33_fb_update(struct work_struct *work)
{
- struct ht16k33_priv *priv = container_of(work, struct ht16k33_priv,
- work.work);
+ struct ht16k33_priv *priv = ht16k33_work_to_priv(work);
struct ht16k33_fbdev *fbdev = &priv->fbdev;
uint8_t *p1, *p2;
@@ -441,8 +448,7 @@ static void ht16k33_keypad_stop(struct input_dev *dev)
static void ht16k33_seg7_update(struct work_struct *work)
{
- struct ht16k33_priv *priv = container_of(work, struct ht16k33_priv,
- work.work);
+ struct ht16k33_priv *priv = ht16k33_work_to_priv(work);
struct ht16k33_seg *seg = &priv->seg;
char *s = seg->linedisp.buf;
uint8_t buf[9];
@@ -462,8 +468,7 @@ static void ht16k33_seg7_update(struct work_struct *work)
static void ht16k33_seg14_update(struct work_struct *work)
{
- struct ht16k33_priv *priv = container_of(work, struct ht16k33_priv,
- work.work);
+ struct ht16k33_priv *priv = ht16k33_work_to_priv(work);
struct ht16k33_seg *seg = &priv->seg;
char *s = seg->linedisp.buf;
uint8_t buf[8];
@@ -478,8 +483,7 @@ static void ht16k33_seg14_update(struct work_struct *work)
static void ht16k33_linedisp_update(struct linedisp *linedisp)
{
- struct ht16k33_priv *priv = container_of(linedisp, struct ht16k33_priv,
- seg.linedisp);
+ struct ht16k33_priv *priv = ht16k33_linedisp_to_priv(linedisp);
schedule_delayed_work(&priv->work, 0);
}
--
2.43.0.rc1.1.gbec44491f096
next prev parent reply other threads:[~2024-02-19 17:03 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-19 16:57 [PATCH v3 0/9] auxdisplay: linedisp: Clean up and add new driver Andy Shevchenko
2024-02-19 16:58 ` [PATCH v3 1/9] auxdisplay: linedisp: Group display drivers together Andy Shevchenko
2024-02-26 15:28 ` Geert Uytterhoeven
2024-02-26 16:00 ` Andy Shevchenko
2024-02-26 16:03 ` Geert Uytterhoeven
2024-02-26 16:15 ` Andy Shevchenko
2024-02-19 16:58 ` [PATCH v3 2/9] auxdisplay: linedisp: Allocate buffer for the string Andy Shevchenko
2024-02-26 15:36 ` Geert Uytterhoeven
2024-02-19 16:58 ` [PATCH v3 3/9] auxdisplay: ht16k33: Add default to switch-cases Andy Shevchenko
2024-02-26 15:38 ` Geert Uytterhoeven
2024-02-19 16:58 ` [PATCH v3 4/9] auxdisplay: ht16k33: Move ht16k33_linedisp_ops down Andy Shevchenko
2024-02-19 16:58 ` Andy Shevchenko [this message]
2024-02-20 18:05 ` [PATCH v3 5/9] auxdisplay: ht16k33: Define a few helper macros Andy Shevchenko
2024-02-26 15:40 ` Geert Uytterhoeven
2024-02-19 16:58 ` [PATCH v3 6/9] auxdisplay: ht16k33: Switch to use line display character mapping Andy Shevchenko
2024-02-19 16:58 ` [PATCH v3 7/9] auxdisplay: ht16k33: Drop struct ht16k33_seg Andy Shevchenko
2024-02-26 15:44 ` Geert Uytterhoeven
2024-02-19 16:58 ` [PATCH v3 8/9] dt-bindings: auxdisplay: Add Maxim MAX6958/6959 Andy Shevchenko
2024-02-26 15:52 ` Geert Uytterhoeven
2024-02-26 17:03 ` Andy Shevchenko
2024-02-19 16:58 ` [PATCH v3 9/9] auxdisplay: Add driver for MAX695x 7-segment LED controllers Andy Shevchenko
2024-02-26 16:01 ` Geert Uytterhoeven
2024-02-26 16:17 ` Andy Shevchenko
2024-02-26 16:58 ` Geert Uytterhoeven
2024-02-26 17:04 ` Andy Shevchenko
2024-02-22 13:51 ` [PATCH v3 0/9] auxdisplay: linedisp: Clean up and add new driver Andy Shevchenko
2024-02-22 13:56 ` Geert Uytterhoeven
2024-02-26 14:30 ` Andy Shevchenko
2024-02-26 16:24 ` Andy Shevchenko
2024-02-26 18:00 ` Andy Shevchenko
2024-02-26 18:13 ` Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240219170337.2161754-6-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=geert@linux-m68k.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulburton@kernel.org \
--cc=robh+dt@kernel.org \
--cc=robin@protonic.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).