Commit 69a9313b authored by Rob Clark's avatar Rob Clark

drm/msm/gpu: Add dev_to_gpu() helper

In a later patch, the drvdata will not directly be 'struct msm_gpu *',
so add a helper to reduce the churn.
Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
Reviewed-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent 2fc7b156
...@@ -282,7 +282,7 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev) ...@@ -282,7 +282,7 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev)
int ret; int ret;
if (pdev) if (pdev)
gpu = platform_get_drvdata(pdev); gpu = dev_to_gpu(&pdev->dev);
if (!gpu) { if (!gpu) {
dev_err_once(dev->dev, "no GPU device was found\n"); dev_err_once(dev->dev, "no GPU device was found\n");
...@@ -425,7 +425,7 @@ static int adreno_bind(struct device *dev, struct device *master, void *data) ...@@ -425,7 +425,7 @@ static int adreno_bind(struct device *dev, struct device *master, void *data)
static void adreno_unbind(struct device *dev, struct device *master, static void adreno_unbind(struct device *dev, struct device *master,
void *data) void *data)
{ {
struct msm_gpu *gpu = dev_get_drvdata(dev); struct msm_gpu *gpu = dev_to_gpu(dev);
pm_runtime_force_suspend(dev); pm_runtime_force_suspend(dev);
gpu->funcs->destroy(gpu); gpu->funcs->destroy(gpu);
...@@ -490,16 +490,14 @@ static const struct of_device_id dt_match[] = { ...@@ -490,16 +490,14 @@ static const struct of_device_id dt_match[] = {
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int adreno_resume(struct device *dev) static int adreno_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct msm_gpu *gpu = dev_to_gpu(dev);
struct msm_gpu *gpu = platform_get_drvdata(pdev);
return gpu->funcs->pm_resume(gpu); return gpu->funcs->pm_resume(gpu);
} }
static int adreno_suspend(struct device *dev) static int adreno_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct msm_gpu *gpu = dev_to_gpu(dev);
struct msm_gpu *gpu = platform_get_drvdata(pdev);
return gpu->funcs->pm_suspend(gpu); return gpu->funcs->pm_suspend(gpu);
} }
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
static int msm_devfreq_target(struct device *dev, unsigned long *freq, static int msm_devfreq_target(struct device *dev, unsigned long *freq,
u32 flags) u32 flags)
{ {
struct msm_gpu *gpu = platform_get_drvdata(to_platform_device(dev)); struct msm_gpu *gpu = dev_to_gpu(dev);
struct dev_pm_opp *opp; struct dev_pm_opp *opp;
opp = devfreq_recommended_opp(dev, freq, flags); opp = devfreq_recommended_opp(dev, freq, flags);
...@@ -47,7 +47,7 @@ static int msm_devfreq_target(struct device *dev, unsigned long *freq, ...@@ -47,7 +47,7 @@ static int msm_devfreq_target(struct device *dev, unsigned long *freq,
static int msm_devfreq_get_dev_status(struct device *dev, static int msm_devfreq_get_dev_status(struct device *dev,
struct devfreq_dev_status *status) struct devfreq_dev_status *status)
{ {
struct msm_gpu *gpu = platform_get_drvdata(to_platform_device(dev)); struct msm_gpu *gpu = dev_to_gpu(dev);
ktime_t time; ktime_t time;
if (gpu->funcs->gpu_get_freq) if (gpu->funcs->gpu_get_freq)
...@@ -66,7 +66,7 @@ static int msm_devfreq_get_dev_status(struct device *dev, ...@@ -66,7 +66,7 @@ static int msm_devfreq_get_dev_status(struct device *dev,
static int msm_devfreq_get_cur_freq(struct device *dev, unsigned long *freq) static int msm_devfreq_get_cur_freq(struct device *dev, unsigned long *freq)
{ {
struct msm_gpu *gpu = platform_get_drvdata(to_platform_device(dev)); struct msm_gpu *gpu = dev_to_gpu(dev);
if (gpu->funcs->gpu_get_freq) if (gpu->funcs->gpu_get_freq)
*freq = gpu->funcs->gpu_get_freq(gpu); *freq = gpu->funcs->gpu_get_freq(gpu);
......
...@@ -144,6 +144,11 @@ struct msm_gpu { ...@@ -144,6 +144,11 @@ struct msm_gpu {
bool hw_apriv; bool hw_apriv;
}; };
static inline struct msm_gpu *dev_to_gpu(struct device *dev)
{
return dev_get_drvdata(dev);
}
/* It turns out that all targets use the same ringbuffer size */ /* It turns out that all targets use the same ringbuffer size */
#define MSM_GPU_RINGBUFFER_SZ SZ_32K #define MSM_GPU_RINGBUFFER_SZ SZ_32K
#define MSM_GPU_RINGBUFFER_BLKSIZE 32 #define MSM_GPU_RINGBUFFER_BLKSIZE 32
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment