Skip to content

Commit

Permalink
drm/bridge: lvds-codec: Add to_lvds_codec() function
Browse files Browse the repository at this point in the history
Factor out the manual container_of() uses to a common to_lvds_codec()
macro to shorten lines (and provide better type safety, although that
won't matter much in this case).

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200224225645.28060-1-laurent.pinchart+renesas@ideasonboard.com
  • Loading branch information
Laurent Pinchart authored and Boris Brezillon committed Feb 25, 2020
1 parent 72b48ae commit 65c04ad
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions drivers/gpu/drm/bridge/lvds-codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,30 @@ struct lvds_codec {
u32 connector_type;
};

static inline struct lvds_codec *to_lvds_codec(struct drm_bridge *bridge)
{
return container_of(bridge, struct lvds_codec, bridge);
}

static int lvds_codec_attach(struct drm_bridge *bridge)
{
struct lvds_codec *lvds_codec = container_of(bridge,
struct lvds_codec, bridge);
struct lvds_codec *lvds_codec = to_lvds_codec(bridge);

return drm_bridge_attach(bridge->encoder, lvds_codec->panel_bridge,
bridge);
}

static void lvds_codec_enable(struct drm_bridge *bridge)
{
struct lvds_codec *lvds_codec = container_of(bridge,
struct lvds_codec, bridge);
struct lvds_codec *lvds_codec = to_lvds_codec(bridge);

if (lvds_codec->powerdown_gpio)
gpiod_set_value_cansleep(lvds_codec->powerdown_gpio, 0);
}

static void lvds_codec_disable(struct drm_bridge *bridge)
{
struct lvds_codec *lvds_codec = container_of(bridge,
struct lvds_codec, bridge);
struct lvds_codec *lvds_codec = to_lvds_codec(bridge);

if (lvds_codec->powerdown_gpio)
gpiod_set_value_cansleep(lvds_codec->powerdown_gpio, 1);
Expand Down

0 comments on commit 65c04ad

Please sign in to comment.