Message ID | 20231128-kms-hdmi-connector-state-v4-43-c7602158306e@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/connector: Create HDMI Connector infrastructure | expand |
Hi, On 2023/11/28 18:24, Maxime Ripard wrote: > container_of_const() allows to preserve the pointer constness and is > thus more flexible than inline functions. > > Let's switch all our instances of container_of() to container_of_const(). > > Signed-off-by: Maxime Ripard <mripard@kernel.org> LGTM, Reviewed-by: Sui Jingfeng <sui.jingfeng@linux.dev> > --- > drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 16 ++++------------ > 1 file changed, 4 insertions(+), 12 deletions(-) > > diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c > index bae69d696765..c276d984da6b 100644 > --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c > +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c > @@ -30,19 +30,11 @@ > #include "sun4i_drv.h" > #include "sun4i_hdmi.h" > > -static inline struct sun4i_hdmi * > -drm_encoder_to_sun4i_hdmi(struct drm_encoder *encoder) > -{ > - return container_of(encoder, struct sun4i_hdmi, > - encoder); > -} > +#define drm_encoder_to_sun4i_hdmi(e) \ > + container_of_const(e, struct sun4i_hdmi, encoder) > > -static inline struct sun4i_hdmi * > -drm_connector_to_sun4i_hdmi(struct drm_connector *connector) > -{ > - return container_of(connector, struct sun4i_hdmi, > - connector); > -} > +#define drm_connector_to_sun4i_hdmi(c) \ > + container_of_const(c, struct sun4i_hdmi, connector) > > static int sun4i_hdmi_setup_avi_infoframes(struct sun4i_hdmi *hdmi, > struct drm_display_mode *mode)
diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c index bae69d696765..c276d984da6b 100644 --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c @@ -30,19 +30,11 @@ #include "sun4i_drv.h" #include "sun4i_hdmi.h" -static inline struct sun4i_hdmi * -drm_encoder_to_sun4i_hdmi(struct drm_encoder *encoder) -{ - return container_of(encoder, struct sun4i_hdmi, - encoder); -} +#define drm_encoder_to_sun4i_hdmi(e) \ + container_of_const(e, struct sun4i_hdmi, encoder) -static inline struct sun4i_hdmi * -drm_connector_to_sun4i_hdmi(struct drm_connector *connector) -{ - return container_of(connector, struct sun4i_hdmi, - connector); -} +#define drm_connector_to_sun4i_hdmi(c) \ + container_of_const(c, struct sun4i_hdmi, connector) static int sun4i_hdmi_setup_avi_infoframes(struct sun4i_hdmi *hdmi, struct drm_display_mode *mode)
container_of_const() allows to preserve the pointer constness and is thus more flexible than inline functions. Let's switch all our instances of container_of() to container_of_const(). Signed-off-by: Maxime Ripard <mripard@kernel.org> --- drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)