2023-02-16 01:05:41

by Thomas Weißschuh

[permalink] [raw]
Subject: [PATCH] drm/i915: Make kobj_type structures constant

Since commit ee6d3dd4ed48 ("driver core: make kobj_type constant.")
the driver core allows the usage of const struct kobj_type.

Take advantage of this to constify the structure definitions to prevent
modification at runtime.

Signed-off-by: Thomas Weißschuh <[email protected]>
---
drivers/gpu/drm/i915/gt/intel_gt_sysfs.c | 2 +-
drivers/gpu/drm/i915/gt/sysfs_engines.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_gt_sysfs.c b/drivers/gpu/drm/i915/gt/intel_gt_sysfs.c
index 9486dd3bed99..df15b17caf89 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_sysfs.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_sysfs.c
@@ -71,7 +71,7 @@ static void kobj_gt_release(struct kobject *kobj)
{
}

-static struct kobj_type kobj_gt_type = {
+static const struct kobj_type kobj_gt_type = {
.release = kobj_gt_release,
.sysfs_ops = &kobj_sysfs_ops,
.default_groups = id_groups,
diff --git a/drivers/gpu/drm/i915/gt/sysfs_engines.c b/drivers/gpu/drm/i915/gt/sysfs_engines.c
index f2d9858d827c..b5e0fe5dbf6c 100644
--- a/drivers/gpu/drm/i915/gt/sysfs_engines.c
+++ b/drivers/gpu/drm/i915/gt/sysfs_engines.c
@@ -421,7 +421,7 @@ static void kobj_engine_release(struct kobject *kobj)
kfree(kobj);
}

-static struct kobj_type kobj_engine_type = {
+static const struct kobj_type kobj_engine_type = {
.release = kobj_engine_release,
.sysfs_ops = &kobj_sysfs_ops
};

---
base-commit: 033c40a89f55525139fd5b6342281b09b97d05bf
change-id: 20230216-kobj_type-i915-886bebc36129

Best regards,
--
Thomas Weißschuh <[email protected]>



2023-02-16 10:33:47

by Jani Nikula

[permalink] [raw]
Subject: Re: [PATCH] drm/i915: Make kobj_type structures constant

On Thu, 16 Feb 2023, Thomas Weißschuh <[email protected]> wrote:
> Since commit ee6d3dd4ed48 ("driver core: make kobj_type constant.")
> the driver core allows the usage of const struct kobj_type.
>
> Take advantage of this to constify the structure definitions to prevent
> modification at runtime.
>
> Signed-off-by: Thomas Weißschuh <[email protected]>

Reviewed-by: Jani Nikula <[email protected]>

> ---
> drivers/gpu/drm/i915/gt/intel_gt_sysfs.c | 2 +-
> drivers/gpu/drm/i915/gt/sysfs_engines.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_sysfs.c b/drivers/gpu/drm/i915/gt/intel_gt_sysfs.c
> index 9486dd3bed99..df15b17caf89 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt_sysfs.c
> +++ b/drivers/gpu/drm/i915/gt/intel_gt_sysfs.c
> @@ -71,7 +71,7 @@ static void kobj_gt_release(struct kobject *kobj)
> {
> }
>
> -static struct kobj_type kobj_gt_type = {
> +static const struct kobj_type kobj_gt_type = {
> .release = kobj_gt_release,
> .sysfs_ops = &kobj_sysfs_ops,
> .default_groups = id_groups,
> diff --git a/drivers/gpu/drm/i915/gt/sysfs_engines.c b/drivers/gpu/drm/i915/gt/sysfs_engines.c
> index f2d9858d827c..b5e0fe5dbf6c 100644
> --- a/drivers/gpu/drm/i915/gt/sysfs_engines.c
> +++ b/drivers/gpu/drm/i915/gt/sysfs_engines.c
> @@ -421,7 +421,7 @@ static void kobj_engine_release(struct kobject *kobj)
> kfree(kobj);
> }
>
> -static struct kobj_type kobj_engine_type = {
> +static const struct kobj_type kobj_engine_type = {
> .release = kobj_engine_release,
> .sysfs_ops = &kobj_sysfs_ops
> };
>
> ---
> base-commit: 033c40a89f55525139fd5b6342281b09b97d05bf
> change-id: 20230216-kobj_type-i915-886bebc36129
>
> Best regards,

--
Jani Nikula, Intel Open Source Graphics Center

2023-02-17 09:58:30

by Jani Nikula

[permalink] [raw]
Subject: Re: [PATCH] drm/i915: Make kobj_type structures constant

On Thu, 16 Feb 2023, Jani Nikula <[email protected]> wrote:
> On Thu, 16 Feb 2023, Thomas Weißschuh <[email protected]> wrote:
>> Since commit ee6d3dd4ed48 ("driver core: make kobj_type constant.")
>> the driver core allows the usage of const struct kobj_type.
>>
>> Take advantage of this to constify the structure definitions to prevent
>> modification at runtime.
>>
>> Signed-off-by: Thomas Weißschuh <[email protected]>
>
> Reviewed-by: Jani Nikula <[email protected]>

And pushed to drm-intel-gt-next, thanks for the patch.

BR,
Jani.

>
>> ---
>> drivers/gpu/drm/i915/gt/intel_gt_sysfs.c | 2 +-
>> drivers/gpu/drm/i915/gt/sysfs_engines.c | 2 +-
>> 2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_sysfs.c b/drivers/gpu/drm/i915/gt/intel_gt_sysfs.c
>> index 9486dd3bed99..df15b17caf89 100644
>> --- a/drivers/gpu/drm/i915/gt/intel_gt_sysfs.c
>> +++ b/drivers/gpu/drm/i915/gt/intel_gt_sysfs.c
>> @@ -71,7 +71,7 @@ static void kobj_gt_release(struct kobject *kobj)
>> {
>> }
>>
>> -static struct kobj_type kobj_gt_type = {
>> +static const struct kobj_type kobj_gt_type = {
>> .release = kobj_gt_release,
>> .sysfs_ops = &kobj_sysfs_ops,
>> .default_groups = id_groups,
>> diff --git a/drivers/gpu/drm/i915/gt/sysfs_engines.c b/drivers/gpu/drm/i915/gt/sysfs_engines.c
>> index f2d9858d827c..b5e0fe5dbf6c 100644
>> --- a/drivers/gpu/drm/i915/gt/sysfs_engines.c
>> +++ b/drivers/gpu/drm/i915/gt/sysfs_engines.c
>> @@ -421,7 +421,7 @@ static void kobj_engine_release(struct kobject *kobj)
>> kfree(kobj);
>> }
>>
>> -static struct kobj_type kobj_engine_type = {
>> +static const struct kobj_type kobj_engine_type = {
>> .release = kobj_engine_release,
>> .sysfs_ops = &kobj_sysfs_ops
>> };
>>
>> ---
>> base-commit: 033c40a89f55525139fd5b6342281b09b97d05bf
>> change-id: 20230216-kobj_type-i915-886bebc36129
>>
>> Best regards,

--
Jani Nikula, Intel Open Source Graphics Center