It's deprecated and only should be used by drivers which still use drm_platform_init, not by anyone else. And indeed it's entirely unused and can be nuked. This required a bit more fudging, but I guess kirin_dc_ops really wants to operate on the platform_device, not something else. Also bonus points for implementing abstraction, and then storing the vfunc in a global variable. v2: Don't break the build soooo badly :( Note that the cleanup function is a bit confused: ade_data was never set as drvdata, and calling drm_crtc_cleanup directly is a bug - this is called indirectly through drm_mode_config_cleanup, which calls into crtc->destroy, which already has the call to drm_crtc_cleanup. Which means we can just nuke it. Note this is the 2nd attempt after the first one failed and had to be reverted again in commit 9cd2e854d61ccfa51686f3ed7b0c917708fc641f Author: Daniel Vetter <daniel.vetter@ffwll.ch> Date: Wed Aug 17 13:59:40 2016 +0200 Revert "drm/hisilicon: Don't set drm_device->platformdev"
Unified · Split
| @@ -973,9 +973,9 @@ static int ade_dts_parse(struct platform_device *pdev, struct ade_hw_ctx *ctx) · 972 unmodified lines | ||
| 973 | 973 | return 0; |
| 974 | 974 | } |
| 975 | 975 | |
| 976 | −static int ade_drm_init(struct drm_device *dev) | |
| 976 | +static int ade_drm_init(struct platform_device *pdev) | |
| 977 | 977 | { |
| 978 | − struct platform_device *pdev = dev->platformdev; | |
| 978 | + struct drm_device *dev = platform_get_drvdata(pdev); | |
| 979 | 979 | struct ade_data *ade; |
| 980 | 980 | struct ade_hw_ctx *ctx; |
| 981 | 981 | struct ade_crtc *acrtc; |
| @@ -1034,13 +1034,8 @@ static int ade_drm_init(struct drm_device *dev) · 52 unmodified lines | ||
| 1034 | 1034 | return 0; |
| 1035 | 1035 | } |
| 1036 | 1036 | |
| 1037 | −static void ade_drm_cleanup(struct drm_device *dev) | |
| 1037 | +static void ade_drm_cleanup(struct platform_device *pdev) | |
| 1038 | 1038 | { |
| 1039 | − struct platform_device *pdev = dev->platformdev; | |
| 1040 | − struct ade_data *ade = platform_get_drvdata(pdev); | |
| 1041 | − struct drm_crtc *crtc = &ade->acrtc.base; | |
| 1042 | − | |
| 1043 | − drm_crtc_cleanup(crtc); | |
| 1044 | 1039 | } |
| 1045 | 1040 | |
| 1046 | 1041 | const struct kirin_dc_ops ade_dc_ops = { |
| @@ -42,7 +42,7 @@ static int kirin_drm_kms_cleanup(struct drm_device *dev) · 41 unmodified lines | ||
| 42 | 42 | #endif |
| 43 | 43 | drm_kms_helper_poll_fini(dev); |
| 44 | 44 | drm_vblank_cleanup(dev); |
| 45 | − dc_ops->cleanup(dev); | |
| 45 | + dc_ops->cleanup(to_platform_device(dev->dev)); | |
| 46 | 46 | drm_mode_config_cleanup(dev); |
| 47 | 47 | devm_kfree(dev->dev, priv); |
| 48 | 48 | dev->dev_private = NULL; |
| @@ -104,7 +104,7 @@ static int kirin_drm_kms_init(struct drm_device *dev) · 55 unmodified lines | ||
| 104 | 104 | kirin_drm_mode_config_init(dev); |
| 105 | 105 | |
| 106 | 106 | /* display controller init */ |
| 107 | − ret = dc_ops->init(dev); | |
| 107 | + ret = dc_ops->init(to_platform_device(dev->dev)); | |
| 108 | 108 | if (ret) |
| 109 | 109 | goto err_mode_config_cleanup; |
| 110 | 110 | |
| @@ -138,7 +138,7 @@ static int kirin_drm_kms_init(struct drm_device *dev) · 27 unmodified lines | ||
| 138 | 138 | err_unbind_all: |
| 139 | 139 | component_unbind_all(dev->dev, dev); |
| 140 | 140 | err_dc_cleanup: |
| 141 | − dc_ops->cleanup(dev); | |
| 141 | + dc_ops->cleanup(to_platform_device(dev->dev)); | |
| 142 | 142 | err_mode_config_cleanup: |
| 143 | 143 | drm_mode_config_cleanup(dev); |
| 144 | 144 | devm_kfree(dev->dev, priv); |
| @@ -209,8 +209,6 @@ static int kirin_drm_bind(struct device *dev) · 64 unmodified lines | ||
| 209 | 209 | if (IS_ERR(drm_dev)) |
| 210 | 210 | return PTR_ERR(drm_dev); |
| 211 | 211 | |
| 212 | − drm_dev->platformdev = to_platform_device(dev); | |
| 213 | − | |
| 214 | 212 | ret = kirin_drm_kms_init(drm_dev); |
| 215 | 213 | if (ret) |
| 216 | 214 | goto err_drm_dev_unref; |
| @@ -15,8 +15,8 @@ · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | /* display controller init/cleanup ops */ |
| 17 | 17 | struct kirin_dc_ops { |
| 18 | − int (*init)(struct drm_device *dev); | |
| 19 | − void (*cleanup)(struct drm_device *dev); | |
| 18 | + int (*init)(struct platform_device *pdev); | |
| 19 | + void (*cleanup)(struct platform_device *pdev); | |
| 20 | 20 | }; |
| 21 | 21 | |
| 22 | 22 | struct kirin_drm_private { |