Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1601521ybi; Wed, 3 Jul 2019 19:36:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCQTBiYVvFl5mjtYDiyqhVYSuBihRXUBSKEn4LRqkORSsUyi71kxxoXiydzWKbFh1BIoEd X-Received: by 2002:a63:1208:: with SMTP id h8mr39046368pgl.377.1562207797055; Wed, 03 Jul 2019 19:36:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562207797; cv=none; d=google.com; s=arc-20160816; b=KKAD7B6RLQczjVh8q55R4pnK4OBMgDPOuPSVvo2Z7y0Ynx8sEpE1wfwcBblz2KnNRD 7csnZ9WloMaFaugHs6MDi4HIuqNSIAiqD7lYRaYnbvCaifU43kGhirzsk52xi98cM6HQ DImHvw1tc7DkFlCK4L8S77ZVgz1YsfXQ4L6gmxkFXtiyvx/u+t+V6mJpl1TPEfA0hRnd F8FWsGO8ANSMAH2XnS7JUtKSZR2fr0N+JJkopBZuAYK9oOWV+sY74LvHkiIDpgBH8OVt 2iVsAUc9hZOkEfsYFz/aAVCNX2HqV+9YlNSpTg/8jyxhPym7mdK7RcfBE3xw5xcF6RQa fodg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature; bh=ojn+49ftq+z8784/6AsfYPnFGWstJKNc22LY9JyUdlw=; b=m18yoYZc5HhmlcwDPSCQdJTZ7WDi+Zip7doV88P+o5hinEvcXOC4nZYHejj4TyJiI5 lYzKlOpQFM+10OTSpBHr7Z9iOlkEtcshI4cnkz8RYx11ustxpgr1Ge8dUVGjSBIUxdWC 5ai331U1xDCNiyWK2nWkA++xCWBBL6a/6djM7pkhhKvK51YbkoIw2MZ/OScBcRXaC+tv y/tPHgwvfm4fdgOt5CWf2sWWsENaGTahSlGSMWoYD/q0wsLbOkdwrXP3wvawSxiYAG7o fttcpKs72nlnuEYV5kobAEur3YDUIV1drI6anmz17o/fB9c44mUNZMr0TQbQRpWw/bB2 Q3NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=FxhQ1cdU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q31si3784539pjc.33.2019.07.03.19.36.22; Wed, 03 Jul 2019 19:36:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=FxhQ1cdU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727213AbfGDCf4 (ORCPT + 99 others); Wed, 3 Jul 2019 22:35:56 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:38589 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726652AbfGDCfz (ORCPT ); Wed, 3 Jul 2019 22:35:55 -0400 Received: by mail-pf1-f195.google.com with SMTP id y15so2186169pfn.5; Wed, 03 Jul 2019 19:35:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ojn+49ftq+z8784/6AsfYPnFGWstJKNc22LY9JyUdlw=; b=FxhQ1cdUpPS8yct2DSlYrMBDcU04+80klCz0EsXxr2SJy/bXip/j5g5YW3RezoBXiH 6weMuHwDmJ52nHplt/mTdbYvqdzAtFr8UVX8bhRDlc+DZ+j5dxSEkzD/VdbatURStpcW fF6Jv3Ef+/zuYJZyDBuSBB+jKdMSVsTrhAL5eHpHbcvpmi9BVJiy0XVUBA/UXnUpS6rm /m2yW00jiu9cNGogxOeMKsoYRrUhCG6A8oU9KhZvlRwsBhrjo6oWeQx1LJUZjYVTZTeo oePhEQ9aOM4uVrR5VQXdi5B8biVyS7yB+hnKD5UkmpltXWz2Z23SL6IO9agQmQ9mIXsN bCwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ojn+49ftq+z8784/6AsfYPnFGWstJKNc22LY9JyUdlw=; b=iJ1rzeTYSj8DY5UxaVHV/tDZ9iw/JSdVn2bUKUd/hAvjgNT0I/F6vVD5OH5xevcT+b 03DgFTErR3UgG+GBBqV9aHiTDkiz/AOZnaYv2W3gi0+GUK4mdHEksAVab4f9Vlpx5Uc3 UCPIVBQcyhX/iWkzCi9dsxfc0R19H+NXqvrcXEWOElqqeU0X5OYZdjEOt90bM1GLBfp+ nZqEiRxTj15G0eE9fR3G9GmAq/UeA3E0Kst/HQcHOoqpxcnSNMQTLZXNcKWOiQ/oKV2R TDSXOAHnU8WfuyIofm8uuMIEfWbKHTIxIUniE+sElN93XuBkDN9YadAfR/ZDDrQ7cxR4 N4yw== X-Gm-Message-State: APjAAAWIZ5z+j/TbdSiUgJ9cj9l/HNJtsHhZyOZKxG9VwwnvO9A3VMNV Zzlq5WKp0LGC/oCZG9g1P74= X-Received: by 2002:a65:5689:: with SMTP id v9mr37803658pgs.293.1562207754394; Wed, 03 Jul 2019 19:35:54 -0700 (PDT) Received: from hfq-skylake.ipads-lab.se.sjtu.edu.cn ([202.120.40.82]) by smtp.googlemail.com with ESMTPSA id s66sm5290767pgs.39.2019.07.03.19.35.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jul 2019 19:35:54 -0700 (PDT) From: Fuqian Huang Cc: Rob Clark , Sean Paul , David Airlie , Daniel Vetter , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Fuqian Huang Subject: [Patch v2 02/10] drm/msm: using dev_get_drvdata directly Date: Thu, 4 Jul 2019 10:35:46 +0800 Message-Id: <20190704023546.4503-1-huangfq.daxian@gmail.com> X-Mailer: git-send-email 2.11.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Several drivers cast a struct device pointer to a struct platform_device pointer only to then call platform_get_drvdata(). To improve readability, these constructs can be simplified by using dev_get_drvdata() directly. Signed-off-by: Fuqian Huang --- Changes in v2: - Make the commit message more clearly. drivers/gpu/drm/msm/adreno/adreno_device.c | 6 ++---- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 13 +++++-------- drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 6 ++---- drivers/gpu/drm/msm/dsi/dsi_host.c | 6 ++---- drivers/gpu/drm/msm/msm_drv.c | 3 +-- drivers/gpu/drm/msm/msm_gpu.c | 6 +++--- 6 files changed, 15 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c index b3deb346a42b..fafd00d2574a 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_device.c +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c @@ -403,16 +403,14 @@ static const struct of_device_id dt_match[] = { #ifdef CONFIG_PM static int adreno_resume(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct msm_gpu *gpu = platform_get_drvdata(pdev); + struct msm_gpu *gpu = dev_get_drvdata(dev); return gpu->funcs->pm_resume(gpu); } static int adreno_suspend(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct msm_gpu *gpu = platform_get_drvdata(pdev); + struct msm_gpu *gpu = dev_get_drvdata(dev); return gpu->funcs->pm_suspend(gpu); } diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c index ae885e5dd07d..6c6f8ca9380f 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c @@ -1025,16 +1025,15 @@ static int dpu_bind(struct device *dev, struct device *master, void *data) static void dpu_unbind(struct device *dev, struct device *master, void *data) { - struct platform_device *pdev = to_platform_device(dev); - struct dpu_kms *dpu_kms = platform_get_drvdata(pdev); + struct dpu_kms *dpu_kms = dev_get_drvdata(dev); struct dss_module_power *mp = &dpu_kms->mp; msm_dss_put_clk(mp->clk_config, mp->num_clk); - devm_kfree(&pdev->dev, mp->clk_config); + devm_kfree(dev, mp->clk_config); mp->num_clk = 0; if (dpu_kms->rpm_enabled) - pm_runtime_disable(&pdev->dev); + pm_runtime_disable(dev); } static const struct component_ops dpu_ops = { @@ -1056,8 +1055,7 @@ static int dpu_dev_remove(struct platform_device *pdev) static int __maybe_unused dpu_runtime_suspend(struct device *dev) { int rc = -1; - struct platform_device *pdev = to_platform_device(dev); - struct dpu_kms *dpu_kms = platform_get_drvdata(pdev); + struct dpu_kms *dpu_kms = dev_get_drvdata(dev); struct drm_device *ddev; struct dss_module_power *mp = &dpu_kms->mp; @@ -1077,8 +1075,7 @@ static int __maybe_unused dpu_runtime_suspend(struct device *dev) static int __maybe_unused dpu_runtime_resume(struct device *dev) { int rc = -1; - struct platform_device *pdev = to_platform_device(dev); - struct dpu_kms *dpu_kms = platform_get_drvdata(pdev); + struct dpu_kms *dpu_kms = dev_get_drvdata(dev); struct drm_encoder *encoder; struct drm_device *ddev; struct dss_module_power *mp = &dpu_kms->mp; diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c index 901009e1f219..25d1ebb32e73 100644 --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c @@ -1052,8 +1052,7 @@ static int mdp5_dev_remove(struct platform_device *pdev) static __maybe_unused int mdp5_runtime_suspend(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct mdp5_kms *mdp5_kms = platform_get_drvdata(pdev); + struct mdp5_kms *mdp5_kms = dev_get_drvdata(dev); DBG(""); @@ -1062,8 +1061,7 @@ static __maybe_unused int mdp5_runtime_suspend(struct device *dev) static __maybe_unused int mdp5_runtime_resume(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct mdp5_kms *mdp5_kms = platform_get_drvdata(pdev); + struct mdp5_kms *mdp5_kms = dev_get_drvdata(dev); DBG(""); diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c index dbf490176c2c..882f13725819 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_host.c +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c @@ -477,8 +477,7 @@ static void dsi_bus_clk_disable(struct msm_dsi_host *msm_host) int msm_dsi_runtime_suspend(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct msm_dsi *msm_dsi = platform_get_drvdata(pdev); + struct msm_dsi *msm_dsi = dev_get_drvdata(dev); struct mipi_dsi_host *host = msm_dsi->host; struct msm_dsi_host *msm_host = to_msm_dsi_host(host); @@ -492,8 +491,7 @@ int msm_dsi_runtime_suspend(struct device *dev) int msm_dsi_runtime_resume(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct msm_dsi *msm_dsi = platform_get_drvdata(pdev); + struct msm_dsi *msm_dsi = dev_get_drvdata(dev); struct mipi_dsi_host *host = msm_dsi->host; struct msm_dsi_host *msm_host = to_msm_dsi_host(host); diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index f38d7367bd3b..0d9e46561609 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -241,8 +241,7 @@ static int vblank_ctrl_queue_work(struct msm_drm_private *priv, static int msm_drm_uninit(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct drm_device *ddev = platform_get_drvdata(pdev); + struct drm_device *ddev = dev_get_drvdata(dev); struct msm_drm_private *priv = ddev->dev_private; struct msm_kms *kms = priv->kms; struct msm_mdss *mdss = priv->mdss; diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c index b2a8411c2d84..ebbc6dff2cde 100644 --- a/drivers/gpu/drm/msm/msm_gpu.c +++ b/drivers/gpu/drm/msm/msm_gpu.c @@ -24,7 +24,7 @@ static int msm_devfreq_target(struct device *dev, unsigned long *freq, u32 flags) { - struct msm_gpu *gpu = platform_get_drvdata(to_platform_device(dev)); + struct msm_gpu *gpu = dev_get_drvdata(dev); struct dev_pm_opp *opp; opp = devfreq_recommended_opp(dev, freq, flags); @@ -45,7 +45,7 @@ static int msm_devfreq_target(struct device *dev, unsigned long *freq, static int msm_devfreq_get_dev_status(struct device *dev, struct devfreq_dev_status *status) { - struct msm_gpu *gpu = platform_get_drvdata(to_platform_device(dev)); + struct msm_gpu *gpu = dev_get_drvdata(dev); ktime_t time; if (gpu->funcs->gpu_get_freq) @@ -64,7 +64,7 @@ static int msm_devfreq_get_dev_status(struct device *dev, 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_get_drvdata(dev); if (gpu->funcs->gpu_get_freq) *freq = gpu->funcs->gpu_get_freq(gpu); -- 2.11.0