public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sui Jingfeng <sui.jingfeng@linux.dev>
To: Phong LE <ple@baylibre.com>, Neil Armstrong <neil.armstrong@linaro.org>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Sui Jingfeng <suijingfeng@loongson.cn>
Subject: [PATCH 2/8] drm/bridge: it66121: Add bridge_to_it66121() helper and use it
Date: Tue, 14 Nov 2023 23:01:24 +0800	[thread overview]
Message-ID: <20231114150130.497915-3-sui.jingfeng@linux.dev> (raw)
In-Reply-To: <20231114150130.497915-1-sui.jingfeng@linux.dev>

From: Sui Jingfeng <suijingfeng@loongson.cn>

Instead of using the container_of() directly, which avoid the code lines
too long in horizontial. Just trivial cleanup, no functional change.

Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn>
---
 drivers/gpu/drm/bridge/ite-it66121.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/ite-it66121.c
index 6e5c10cfa0bc..83dbdbfc9ed8 100644
--- a/drivers/gpu/drm/bridge/ite-it66121.c
+++ b/drivers/gpu/drm/bridge/ite-it66121.c
@@ -315,6 +315,11 @@ struct it66121_ctx {
 	const struct it66121_chip_info *info;
 };
 
+static inline struct it66121_ctx *bridge_to_it66121(struct drm_bridge *bridge)
+{
+	return container_of(bridge, struct it66121_ctx, bridge);
+}
+
 static const struct regmap_range_cfg it66121_regmap_banks[] = {
 	{
 		.name = "it66121",
@@ -588,7 +593,7 @@ static bool it66121_is_hpd_detect(struct it66121_ctx *ctx)
 static int it66121_bridge_attach(struct drm_bridge *bridge,
 				 enum drm_bridge_attach_flags flags)
 {
-	struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
+	struct it66121_ctx *ctx = bridge_to_it66121(bridge);
 	int ret;
 
 	if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR))
@@ -699,7 +704,7 @@ static u32 *it66121_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
 						     u32 output_fmt,
 						     unsigned int *num_input_fmts)
 {
-	struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
+	struct it66121_ctx *ctx = bridge_to_it66121(bridge);
 	u32 *input_fmts;
 
 	*num_input_fmts = 0;
@@ -723,7 +728,7 @@ static u32 *it66121_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
 static void it66121_bridge_enable(struct drm_bridge *bridge,
 				  struct drm_bridge_state *bridge_state)
 {
-	struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
+	struct it66121_ctx *ctx = bridge_to_it66121(bridge);
 	struct drm_atomic_state *state = bridge_state->base.state;
 
 	ctx->connector = drm_atomic_get_new_connector_for_encoder(state, bridge->encoder);
@@ -734,7 +739,7 @@ static void it66121_bridge_enable(struct drm_bridge *bridge,
 static void it66121_bridge_disable(struct drm_bridge *bridge,
 				   struct drm_bridge_state *bridge_state)
 {
-	struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
+	struct it66121_ctx *ctx = bridge_to_it66121(bridge);
 
 	it66121_set_mute(ctx, true);
 
@@ -746,7 +751,7 @@ static int it66121_bridge_check(struct drm_bridge *bridge,
 				struct drm_crtc_state *crtc_state,
 				struct drm_connector_state *conn_state)
 {
-	struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
+	struct it66121_ctx *ctx = bridge_to_it66121(bridge);
 
 	if (ctx->info->id == ID_IT6610) {
 		/* The IT6610 only supports these settings */
@@ -765,7 +770,7 @@ void it66121_bridge_mode_set(struct drm_bridge *bridge,
 			     const struct drm_display_mode *adjusted_mode)
 {
 	u8 buf[HDMI_INFOFRAME_SIZE(AVI)];
-	struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
+	struct it66121_ctx *ctx = bridge_to_it66121(bridge);
 	int ret;
 
 	mutex_lock(&ctx->lock);
@@ -831,7 +836,7 @@ static enum drm_mode_status it66121_bridge_mode_valid(struct drm_bridge *bridge,
 						      const struct drm_display_info *info,
 						      const struct drm_display_mode *mode)
 {
-	struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
+	struct it66121_ctx *ctx = bridge_to_it66121(bridge);
 	unsigned long max_clock;
 
 	max_clock = (ctx->bus_width == 12) ? 74250 : 148500;
@@ -847,7 +852,7 @@ static enum drm_mode_status it66121_bridge_mode_valid(struct drm_bridge *bridge,
 
 static enum drm_connector_status it66121_bridge_detect(struct drm_bridge *bridge)
 {
-	struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
+	struct it66121_ctx *ctx = bridge_to_it66121(bridge);
 
 	return it66121_is_hpd_detect(ctx) ? connector_status_connected
 					  : connector_status_disconnected;
@@ -855,7 +860,7 @@ static enum drm_connector_status it66121_bridge_detect(struct drm_bridge *bridge
 
 static void it66121_bridge_hpd_enable(struct drm_bridge *bridge)
 {
-	struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
+	struct it66121_ctx *ctx = bridge_to_it66121(bridge);
 	int ret;
 
 	ret = regmap_write_bits(ctx->regmap, IT66121_INT_MASK1_REG, IT66121_INT_MASK1_HPD, 0);
@@ -865,7 +870,7 @@ static void it66121_bridge_hpd_enable(struct drm_bridge *bridge)
 
 static void it66121_bridge_hpd_disable(struct drm_bridge *bridge)
 {
-	struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
+	struct it66121_ctx *ctx = bridge_to_it66121(bridge);
 	int ret;
 
 	ret = regmap_write_bits(ctx->regmap, IT66121_INT_MASK1_REG,
@@ -877,7 +882,7 @@ static void it66121_bridge_hpd_disable(struct drm_bridge *bridge)
 static struct edid *it66121_bridge_get_edid(struct drm_bridge *bridge,
 					    struct drm_connector *connector)
 {
-	struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
+	struct it66121_ctx *ctx = bridge_to_it66121(bridge);
 	struct edid *edid;
 	int ret;
 
-- 
2.34.1


  parent reply	other threads:[~2023-11-14 15:09 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-14 15:01 [PATCH 0/8] Allow link the it66121 display bridge driver as a lib Sui Jingfeng
2023-11-14 15:01 ` [PATCH 1/8] drm/bridge: it66121: Use dev replace ctx->dev in the it66121_probe() Sui Jingfeng
2023-11-14 16:01   ` Dmitry Baryshkov
2023-11-14 15:01 ` Sui Jingfeng [this message]
2023-11-14 16:01   ` [PATCH 2/8] drm/bridge: it66121: Add bridge_to_it66121() helper and use it Dmitry Baryshkov
2023-11-14 15:01 ` [PATCH 3/8] drm/bridge: it66121: Add a helper function to read bus width Sui Jingfeng
2023-11-14 16:03   ` Dmitry Baryshkov
2023-11-14 15:01 ` [PATCH 4/8] drm/bridge: it66121: Add a helper function to get the next bridge Sui Jingfeng
2023-11-14 16:05   ` Dmitry Baryshkov
2023-11-23  5:25     ` Sui Jingfeng
2023-11-23  7:54       ` Dmitry Baryshkov
2023-11-14 15:01 ` [PATCH 5/8] drm/bridge: it66121: Add a helper function to read chip id Sui Jingfeng
2023-11-14 16:06   ` Dmitry Baryshkov
2023-11-16 12:18     ` Sui Jingfeng
2023-11-16 13:00       ` Dmitry Baryshkov
2023-11-16 18:29         ` Sui Jingfeng
2023-11-16 22:00           ` Dmitry Baryshkov
2023-11-23  5:37         ` Sui Jingfeng
2023-11-23  7:48           ` Dmitry Baryshkov
2023-11-23 13:03             ` Sui Jingfeng
2023-11-14 15:01 ` [PATCH 6/8] drm/bridge: it66121: Add a helper to initialize the DRM bridge structure Sui Jingfeng
2023-11-14 16:10   ` Dmitry Baryshkov
2023-11-14 15:01 ` [PATCH 7/8] drm/bridge: it66121: Add another implementation for getting match data Sui Jingfeng
2023-11-14 16:00   ` Dmitry Baryshkov
2023-11-14 15:01 ` [PATCH 8/8] drm/bridge: it66121: Allow link this driver as a lib Sui Jingfeng
2023-11-14 16:30   ` Dmitry Baryshkov
2023-11-16  9:14     ` Sui Jingfeng
2023-11-16  9:30       ` Dmitry Baryshkov
2023-11-16 10:12         ` Sui Jingfeng
2023-11-16 11:19           ` Dmitry Baryshkov
2023-11-23  5:05             ` Sui Jingfeng
2023-11-23  8:08               ` Dmitry Baryshkov
2023-11-23 13:39                 ` Neil Armstrong
2023-11-23 16:20                   ` Sui Jingfeng
2023-11-23 15:41                 ` Sui Jingfeng
2023-11-23 16:06                   ` Dmitry Baryshkov
2023-11-23 16:29                     ` Sui Jingfeng
2023-11-23 17:04                 ` Sui Jingfeng
2023-11-23 17:39                   ` Dmitry Baryshkov
2023-11-23 17:52                 ` Sui Jingfeng
2023-11-24  7:38                   ` Maxime Ripard
2023-11-24  7:51                     ` Sui Jingfeng
2023-11-24  8:13                       ` Maxime Ripard
2023-11-24  8:48                         ` Sui Jingfeng
2023-11-25  2:30                         ` Sui Jingfeng
2023-11-16 10:29     ` Sui Jingfeng
2023-11-16 11:11       ` Dmitry Baryshkov
2023-11-16 11:15         ` Jani Nikula
2023-11-16 11:18     ` Sui Jingfeng
2023-11-16 11:29       ` Dmitry Baryshkov
2023-11-16 11:53         ` Sui Jingfeng
2023-11-16 12:07           ` Sui Jingfeng
2023-11-16 15:23             ` Dmitry Baryshkov
2023-11-16 17:18               ` Sui Jingfeng
2023-11-17  9:52                 ` Maxime Ripard
2023-11-17  4:24               ` Sui Jingfeng
2023-11-17  9:03                 ` Dmitry Baryshkov
2023-11-17 17:14                   ` Sui Jingfeng
2023-11-20  8:23                     ` Neil Armstrong
2023-11-17 17:35                   ` Sui Jingfeng
2023-11-20 10:06                     ` Dmitry Baryshkov
2023-11-17 12:13                 ` Maxime Ripard
2023-11-15 13:02   ` kernel test robot
2023-11-20  9:08   ` kernel test robot

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=20231114150130.497915-3-sui.jingfeng@linux.dev \
    --to=sui.jingfeng@linux.dev \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=ple@baylibre.com \
    --cc=suijingfeng@loongson.cn \
    --cc=tzimmermann@suse.de \
    /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