drm/amdgpu: cleanup sysfs file handling
Subsystems (2)
PATCH 1/1 drm/amdgpu: cleanup sysfs file handling
Create sysfs file using attributes.
Signed-off-by Nirmoy Das <[email protected]>
Reviewed-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 36 ++++++++-------------- 1 file changed, 12 insertions(+), 24 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +12 -24
@@ -2918,6 +2918,14 @@ static int amdgpu_device_get_job_timeout_settings(struct amdgpu_device *adev)return ret; } +static const struct attribute *amdgpu_dev_attributes[] = { + &dev_attr_product_name.attr, + &dev_attr_product_number.attr, + &dev_attr_serial_number.attr, + &dev_attr_pcie_replay_count.attr, +NULL +}; +/** * amdgpu_device_init - initialize the driver *
@@ -3267,27 +3275,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,queue_delayed_work (system_wq, &adev->delayed_init_work,msecs_to_jiffies (AMDGPU_RESUME_MS )); - r =device_create_file (adev->dev, &dev_attr_pcie_replay_count); -if (r) { -dev_err (adev->dev,"Could not create pcie_replay_count" ); -return r; - } - - r =device_create_file (adev->dev, &dev_attr_product_name); + r =sysfs_create_files (&adev->dev->kobj, amdgpu_dev_attributes);if (r) { -dev_err (adev->dev,"Could not create product_name" ); -return r; - } - - r =device_create_file (adev->dev, &dev_attr_product_number); -if (r) { -dev_err (adev->dev,"Could not create product_number" ); -return r; - } - - r =device_create_file (adev->dev, &dev_attr_serial_number); -if (r) { -dev_err (adev->dev,"Could not create serial_number" ); +dev_err (adev->dev,"Could not create amdgpu device attr\n" );return r; }
@@ -3370,12 +3360,10 @@ void amdgpu_device_fini(struct amdgpu_device *adev) adev->rmmio =NULL ;amdgpu_device_doorbell_fini (adev); -device_remove_file (adev->dev, &dev_attr_pcie_replay_count);if (adev->ucode_sysfs_en)amdgpu_ucode_sysfs_fini (adev); -device_remove_file (adev->dev, &dev_attr_product_name); -device_remove_file (adev->dev, &dev_attr_product_number); -device_remove_file (adev->dev, &dev_attr_serial_number); + +sysfs_remove_files (&adev->dev->kobj, amdgpu_dev_attributes);if (IS_ENABLED (CONFIG_PERF_EVENTS ))amdgpu_pmu_fini (adev);if (amdgpu_discovery && adev->asic_type >=CHIP_NAVI10 )
Signature · 6 lines
2.26.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 08.05.20 um 10:48 schrieb Nirmoy Das:
Quoted 4 lines
Create sysfs file using attributes.
Signed-off-by Nirmoy Das <[email protected]>Reviewed-by Alex Deucher <[email protected]>
Reviewed-by Christian König <[email protected]>
Quoted 58 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 36 ++++++++-------------- 1 file changed, 12 insertions(+), 24 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +10
-21@@ -2918,6 +2918,14 @@ static int amdgpu_device_get_job_timeout_settings(struct amdgpu_device *adev)return ret; } +static const struct attribute *amdgpu_dev_attributes[] = { + &dev_attr_product_name.attr, + &dev_attr_product_number.attr, + &dev_attr_serial_number.attr, + &dev_attr_pcie_replay_count.attr, +NULL +}; +/** * amdgpu_device_init - initialize the driver * @@ -3267,27 +3275,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,queue_delayed_work (system_wq, &adev->delayed_init_work,msecs_to_jiffies (AMDGPU_RESUME_MS )); - r =device_create_file (adev->dev, &dev_attr_pcie_replay_count); -if (r) { -dev_err (adev->dev,"Could not create pcie_replay_count" ); -return r; - } - - r =device_create_file (adev->dev, &dev_attr_product_name); + r =sysfs_create_files (&adev->dev->kobj, amdgpu_dev_attributes);if (r) { -dev_err (adev->dev,"Could not create product_name" ); -return r; - } - - r =device_create_file (adev->dev, &dev_attr_product_number); -if (r) { -dev_err (adev->dev,"Could not create product_number" ); -return r; - } - - r =device_create_file (adev->dev, &dev_attr_serial_number); -if (r) { -dev_err (adev->dev,"Could not create serial_number" ); +dev_err (adev->dev,"Could not create amdgpu device attr\n" );return r; }@@ -3370,12 +3360,10 @@ void amdgpu_device_fini(struct amdgpu_device *adev) adev->rmmio =NULL ;amdgpu_device_doorbell_fini (adev); -device_remove_file (adev->dev, &dev_attr_pcie_replay_count);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_device_fini(struct amdgpu_device *adev) · line 3369
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-3if (adev->ucode_sysfs_en)amdgpu_ucode_sysfs_fini (adev); -device_remove_file (adev->dev, &dev_attr_product_name); -device_remove_file (adev->dev, &dev_attr_product_number); -device_remove_file (adev->dev, &dev_attr_serial_number); + +sysfs_remove_files (&adev->dev->kobj, amdgpu_dev_attributes);if (IS_ENABLED (CONFIG_PERF_EVENTS ))amdgpu_pmu_fini (adev);if (amdgpu_discovery && adev->asic_type >=CHIP_NAVI10 )
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx