From: "Christian König" <christian.koenig@amd.com>
To: Bernard Zhao <bernard@vivo.com>,
Alex Deucher <alexander.deucher@amd.com>,
"David (ChunMing) Zhou" <David1.Zhou@amd.com>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
Tom St Denis <tom.stdenis@amd.com>,
Sam Ravnborg <sam@ravnborg.org>,
Ori Messinger <Ori.Messinger@amd.com>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Cc: opensource.kernel@vivo.com
Subject: Re: [PATCH v2] drm/amd/amdgpu: cleanup coding style a bit
Date: Thu, 7 May 2020 11:22:11 +0200 [thread overview]
Message-ID: <462b6a26-2c25-f83a-887e-6d3a30072e71@amd.com> (raw)
In-Reply-To: <20200507091311.10898-1-bernard@vivo.com>
Am 07.05.20 um 11:13 schrieb Bernard Zhao:
> There is DEVICE_ATTR mechanism in separate attribute define.
> So this change is to use attr array, also use
> sysfs_create_files in init function & sysfs_remove_files in
> fini function.
> This maybe make the code a bit readable.
>
> Signed-off-by: Bernard Zhao <bernard@vivo.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
>
> Changes since V1:
> *Use DEVICE_ATTR mechanism
>
> Link for V1:
> *https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fpatchwork%2Fpatch%2F1228076%2F&data=02%7C01%7Cchristian.koenig%40amd.com%7C073b9043be5346b3c90c08d7f266e6fb%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637244396096735223&sdata=PjFsYvmw2pvVisZ6TzMqOyoSr0m3DsFN%2F0q%2B%2FfBxACg%3D&reserved=0
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 43 ++++++--------------
> 1 file changed, 13 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> index 82a3299e53c0..57bbc70662ff 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> @@ -148,6 +148,15 @@ static DEVICE_ATTR(mem_info_vis_vram_used, S_IRUGO,
> static DEVICE_ATTR(mem_info_vram_vendor, S_IRUGO,
> amdgpu_mem_info_vram_vendor, NULL);
>
> +static struct attribute *amdgpu_vram_mgr_attributes[] = {
> + &dev_attr_mem_info_vram_total.attr,
> + &dev_attr_mem_info_vis_vram_total.attr,
> + &dev_attr_mem_info_vram_used.attr,
> + &dev_attr_mem_info_vis_vram_used.attr,
> + &dev_attr_mem_info_vram_vendor.attr,
> + NULL
> +};
> +
> /**
> * amdgpu_vram_mgr_init - init VRAM manager and DRM MM
> *
> @@ -172,31 +181,9 @@ static int amdgpu_vram_mgr_init(struct ttm_mem_type_manager *man,
> man->priv = mgr;
>
> /* Add the two VRAM-related sysfs files */
> - ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_total);
> - if (ret) {
> - DRM_ERROR("Failed to create device file mem_info_vram_total\n");
> - return ret;
> - }
> - ret = device_create_file(adev->dev, &dev_attr_mem_info_vis_vram_total);
> - if (ret) {
> - DRM_ERROR("Failed to create device file mem_info_vis_vram_total\n");
> - return ret;
> - }
> - ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_used);
> - if (ret) {
> - DRM_ERROR("Failed to create device file mem_info_vram_used\n");
> - return ret;
> - }
> - ret = device_create_file(adev->dev, &dev_attr_mem_info_vis_vram_used);
> - if (ret) {
> - DRM_ERROR("Failed to create device file mem_info_vis_vram_used\n");
> - return ret;
> - }
> - ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_vendor);
> - if (ret) {
> - DRM_ERROR("Failed to create device file mem_info_vram_vendor\n");
> - return ret;
> - }
> + ret = sysfs_create_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes);
> + if (ret)
> + DRM_ERROR("Failed to register sysfs\n");
>
> return 0;
> }
> @@ -219,11 +206,7 @@ static int amdgpu_vram_mgr_fini(struct ttm_mem_type_manager *man)
> spin_unlock(&mgr->lock);
> kfree(mgr);
> man->priv = NULL;
> - device_remove_file(adev->dev, &dev_attr_mem_info_vram_total);
> - device_remove_file(adev->dev, &dev_attr_mem_info_vis_vram_total);
> - device_remove_file(adev->dev, &dev_attr_mem_info_vram_used);
> - device_remove_file(adev->dev, &dev_attr_mem_info_vis_vram_used);
> - device_remove_file(adev->dev, &dev_attr_mem_info_vram_vendor);
> + sysfs_remove_files(&adev->dev->kobj, amdgpu_vram_mgr_attributes);
> return 0;
> }
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2020-05-07 9:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-07 9:13 [PATCH v2] drm/amd/amdgpu: cleanup coding style a bit Bernard Zhao
2020-05-07 9:22 ` Christian König [this message]
2020-05-07 19:30 ` Alex Deucher
2020-05-08 15:45 ` Ruhl, Michael J
2020-05-11 13:26 ` Bernard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=462b6a26-2c25-f83a-887e-6d3a30072e71@amd.com \
--to=christian.koenig@amd.com \
--cc=David1.Zhou@amd.com \
--cc=Ori.Messinger@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=bernard@vivo.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=opensource.kernel@vivo.com \
--cc=sam@ravnborg.org \
--cc=tom.stdenis@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).