Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/display: throw out struct intel_load_detect_pipe

An error-valued pointer can handle all in one without the wrapper
struct.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230417153741.1074692-2-jani.nikula@intel.com

+29 -37
+9 -9
drivers/gpu/drm/i915/display/intel_crt.c
··· 822 822 struct drm_i915_private *dev_priv = to_i915(connector->dev); 823 823 struct intel_crt *crt = intel_attached_crt(to_intel_connector(connector)); 824 824 struct intel_encoder *intel_encoder = &crt->base; 825 + struct drm_atomic_state *state; 825 826 intel_wakeref_t wakeref; 826 - int status, ret; 827 - struct intel_load_detect_pipe tmp; 827 + int status; 828 828 829 829 drm_dbg_kms(&dev_priv->drm, "[CONNECTOR:%d:%s] force=%d\n", 830 830 connector->base.id, connector->name, ··· 882 882 } 883 883 884 884 /* for pre-945g platforms use load detect */ 885 - ret = intel_load_detect_get_pipe(connector, &tmp, ctx); 886 - if (ret > 0) { 885 + state = intel_load_detect_get_pipe(connector, ctx); 886 + if (IS_ERR(state)) { 887 + status = PTR_ERR(state); 888 + } else if (!state) { 889 + status = connector_status_unknown; 890 + } else { 887 891 if (intel_crt_detect_ddc(connector)) 888 892 status = connector_status_connected; 889 893 else if (DISPLAY_VER(dev_priv) < 4) ··· 897 893 status = connector_status_disconnected; 898 894 else 899 895 status = connector_status_unknown; 900 - intel_load_detect_release_pipe(connector, &tmp, ctx); 901 - } else if (ret == 0) { 902 - status = connector_status_unknown; 903 - } else { 904 - status = ret; 896 + intel_load_detect_release_pipe(connector, state, ctx); 905 897 } 906 898 907 899 out:
+8 -12
drivers/gpu/drm/i915/display/intel_load_detect.c
··· 44 44 return 0; 45 45 } 46 46 47 - int intel_load_detect_get_pipe(struct drm_connector *connector, 48 - struct intel_load_detect_pipe *old, 49 - struct drm_modeset_acquire_ctx *ctx) 47 + struct drm_atomic_state * 48 + intel_load_detect_get_pipe(struct drm_connector *connector, 49 + struct drm_modeset_acquire_ctx *ctx) 50 50 { 51 51 struct intel_encoder *encoder = 52 52 intel_attached_encoder(to_intel_connector(connector)); ··· 63 63 drm_dbg_kms(&dev_priv->drm, "[CONNECTOR:%d:%s], [ENCODER:%d:%s]\n", 64 64 connector->base.id, connector->name, 65 65 encoder->base.base.id, encoder->base.name); 66 - 67 - old->restore_state = NULL; 68 66 69 67 drm_WARN_ON(dev, !drm_modeset_is_locked(&config->connection_mutex)); 70 68 ··· 177 179 goto fail; 178 180 } 179 181 180 - old->restore_state = restore_state; 181 182 drm_atomic_state_put(state); 182 183 183 184 /* let the connector get through one full cycle before testing */ 184 185 intel_crtc_wait_for_next_vblank(crtc); 185 186 186 - return true; 187 + return restore_state; 187 188 188 189 fail: 189 190 if (state) { ··· 195 198 } 196 199 197 200 if (ret == -EDEADLK) 198 - return ret; 201 + return ERR_PTR(ret); 199 202 200 - return false; 203 + return NULL; 201 204 } 202 205 203 206 void intel_load_detect_release_pipe(struct drm_connector *connector, 204 - struct intel_load_detect_pipe *old, 207 + struct drm_atomic_state *state, 205 208 struct drm_modeset_acquire_ctx *ctx) 206 209 { 207 210 struct intel_encoder *intel_encoder = 208 211 intel_attached_encoder(to_intel_connector(connector)); 209 212 struct drm_i915_private *i915 = to_i915(intel_encoder->base.dev); 210 213 struct drm_encoder *encoder = &intel_encoder->base; 211 - struct drm_atomic_state *state = old->restore_state; 212 214 int ret; 213 215 214 216 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s], [ENCODER:%d:%s]\n", 215 217 connector->base.id, connector->name, 216 218 encoder->base.id, encoder->name); 217 219 218 - if (!state) 220 + if (IS_ERR_OR_NULL(state)) 219 221 return; 220 222 221 223 ret = drm_atomic_helper_commit_duplicated_state(state, ctx);
+4 -8
drivers/gpu/drm/i915/display/intel_load_detect.h
··· 10 10 struct drm_connector; 11 11 struct drm_modeset_acquire_ctx; 12 12 13 - struct intel_load_detect_pipe { 14 - struct drm_atomic_state *restore_state; 15 - }; 16 - 17 - int intel_load_detect_get_pipe(struct drm_connector *connector, 18 - struct intel_load_detect_pipe *old, 19 - struct drm_modeset_acquire_ctx *ctx); 13 + struct drm_atomic_state * 14 + intel_load_detect_get_pipe(struct drm_connector *connector, 15 + struct drm_modeset_acquire_ctx *ctx); 20 16 void intel_load_detect_release_pipe(struct drm_connector *connector, 21 - struct intel_load_detect_pipe *old, 17 + struct drm_atomic_state *old, 22 18 struct drm_modeset_acquire_ctx *ctx); 23 19 24 20 #endif /* __INTEL_LOAD_DETECT_H__ */
+8 -8
drivers/gpu/drm/i915/display/intel_tv.c
··· 1723 1723 return connector_status_disconnected; 1724 1724 1725 1725 if (force) { 1726 - struct intel_load_detect_pipe tmp; 1727 - int ret; 1726 + struct drm_atomic_state *state; 1728 1727 1729 - ret = intel_load_detect_get_pipe(connector, &tmp, ctx); 1730 - if (ret < 0) 1731 - return ret; 1728 + state = intel_load_detect_get_pipe(connector, ctx); 1729 + if (IS_ERR(state)) 1730 + return PTR_ERR(state); 1732 1731 1733 - if (ret > 0) { 1732 + if (state) { 1734 1733 type = intel_tv_detect_type(intel_tv, connector); 1735 - intel_load_detect_release_pipe(connector, &tmp, ctx); 1734 + intel_load_detect_release_pipe(connector, state, ctx); 1736 1735 status = type < 0 ? 1737 1736 connector_status_disconnected : 1738 1737 connector_status_connected; 1739 - } else 1738 + } else { 1740 1739 status = connector_status_unknown; 1740 + } 1741 1741 1742 1742 if (status == connector_status_connected) { 1743 1743 intel_tv->type = type;