Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1681627 > unrolled thread
| Started by | Suzuki K Poulose <Suzuki.Poulose@arm.com> |
|---|---|
| First post | 2017-07-05 18:10 +0200 |
| Last post | 2017-07-06 10:50 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH] bus: arm-cci: constify attribute_group structures. Suzuki K Poulose <Suzuki.Poulose@arm.com> - 2017-07-05 18:10 +0200
Re: [PATCH] bus: arm-cci: constify attribute_group structures. Arvind Yadav <arvind.yadav.cs@gmail.com> - 2017-07-06 07:00 +0200
Re: [PATCH] bus: arm-cci: constify attribute_group structures. Suzuki K Poulose <Suzuki.Poulose@arm.com> - 2017-07-06 10:50 +0200
| From | Suzuki K Poulose <Suzuki.Poulose@arm.com> |
|---|---|
| Date | 2017-07-05 18:10 +0200 |
| Subject | Re: [PATCH] bus: arm-cci: constify attribute_group structures. |
| Message-ID | <tZV2j-8vO-43@gated-at.bofh.it> |
On 03/07/17 08:46, Arvind Yadav wrote:
> attribute_groups are not supposed to change at runtime. All functions
> working with attribute_groups provided by <linux/sysfs.h> work with const
> attribute_group. So mark the non-const structs as const.
>
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
> drivers/bus/arm-cci.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
> index c49da15..64c75d2 100644
> --- a/drivers/bus/arm-cci.c
> +++ b/drivers/bus/arm-cci.c
> @@ -1445,16 +1445,16 @@ static ssize_t pmu_cpumask_attr_show(struct device *dev,
> NULL,
> };
>
> -static struct attribute_group pmu_attr_group = {
> +static const struct attribute_group pmu_attr_group = {
> .attrs = pmu_attrs,
> };
>
> -static struct attribute_group pmu_format_attr_group = {
> +static const struct attribute_group pmu_format_attr_group = {
> .name = "format",
> .attrs = NULL, /* Filled in cci_pmu_init_attrs */
> };
>
> -static struct attribute_group pmu_event_attr_group = {
> +static const struct attribute_group pmu_event_attr_group = {
> .name = "events",
> .attrs = NULL, /* Filled in cci_pmu_init_attrs */
> };
>
I think we cannot make these const, as the attrs field gets filled in at runtime, indicated
by the comments next to them.
Cheers
Suzuki
[toc] | [next] | [standalone]
| From | Arvind Yadav <arvind.yadav.cs@gmail.com> |
|---|---|
| Date | 2017-07-06 07:00 +0200 |
| Message-ID | <u073r-7Wf-1@gated-at.bofh.it> |
| In reply to | #1681627 |
Hi,
On Wednesday 05 July 2017 09:33 PM, Suzuki K Poulose wrote:
> On 03/07/17 08:46, Arvind Yadav wrote:
>> attribute_groups are not supposed to change at runtime. All functions
>> working with attribute_groups provided by <linux/sysfs.h> work with
>> const
>> attribute_group. So mark the non-const structs as const.
>>
>> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
>> ---
>> drivers/bus/arm-cci.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
>> index c49da15..64c75d2 100644
>> --- a/drivers/bus/arm-cci.c
>> +++ b/drivers/bus/arm-cci.c
>> @@ -1445,16 +1445,16 @@ static ssize_t pmu_cpumask_attr_show(struct
>> device *dev,
>> NULL,
>> };
>>
>> -static struct attribute_group pmu_attr_group = {
>> +static const struct attribute_group pmu_attr_group = {
>> .attrs = pmu_attrs, /*This can be const*/
>> };
>>
>> -static struct attribute_group pmu_format_attr_group = {
>> +static const struct attribute_group pmu_format_attr_group = {
>> .name = "format",
>> .attrs = NULL, /* Filled in cci_pmu_init_attrs */
>> };
>
>
>
>>
>> -static struct attribute_group pmu_event_attr_group = {
>> +static const struct attribute_group pmu_event_attr_group = {
>> .name = "events",
>> .attrs = NULL, /* Filled in cci_pmu_init_attrs */
>> };
>>
>
> I think we cannot make these const, as the attrs field gets filled in
> at runtime, indicated
> by the comments next to them.
>
Yes, Your are right. It's filled at run time.
pmu_event_attr_group.attrs = model->event_attrs;
pmu_format_attr_group.attrs = model->format_attrs;
can we make pmu_attr_group as const.? It's already initialized.
If you are ok with this please let me know. I can push updated patch.
> Cheers
> Suzuki
>
Thanks,
Arvind Yadav
[toc] | [prev] | [next] | [standalone]
| From | Suzuki K Poulose <Suzuki.Poulose@arm.com> |
|---|---|
| Date | 2017-07-06 10:50 +0200 |
| Message-ID | <u0aE2-1W0-9@gated-at.bofh.it> |
| In reply to | #1682042 |
On 06/07/17 05:53, Arvind Yadav wrote:
> Hi,
>
>
> On Wednesday 05 July 2017 09:33 PM, Suzuki K Poulose wrote:
>> On 03/07/17 08:46, Arvind Yadav wrote:
>>> attribute_groups are not supposed to change at runtime. All functions
>>> working with attribute_groups provided by <linux/sysfs.h> work with const
>>> attribute_group. So mark the non-const structs as const.
>>>
>>> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
>>> ---
>>> drivers/bus/arm-cci.c | 6 +++---
>>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
>>> index c49da15..64c75d2 100644
>>> --- a/drivers/bus/arm-cci.c
>>> +++ b/drivers/bus/arm-cci.c
>>> @@ -1445,16 +1445,16 @@ static ssize_t pmu_cpumask_attr_show(struct device *dev,
>>> NULL,
>>> };
>>>
>>> -static struct attribute_group pmu_attr_group = {
>>> +static const struct attribute_group pmu_attr_group = {
>>> .attrs = pmu_attrs, /*This can be const*/
>>> };
>>>
>>> -static struct attribute_group pmu_format_attr_group = {
>>> +static const struct attribute_group pmu_format_attr_group = {
>>> .name = "format",
>>> .attrs = NULL, /* Filled in cci_pmu_init_attrs */
>>> };
>>
>>
>>
>>>
>>> -static struct attribute_group pmu_event_attr_group = {
>>> +static const struct attribute_group pmu_event_attr_group = {
>>> .name = "events",
>>> .attrs = NULL, /* Filled in cci_pmu_init_attrs */
>>> };
>>>
>>
>> I think we cannot make these const, as the attrs field gets filled in at runtime, indicated
>> by the comments next to them.
>>
> Yes, Your are right. It's filled at run time.
> pmu_event_attr_group.attrs = model->event_attrs;
> pmu_format_attr_group.attrs = model->format_attrs;
> can we make pmu_attr_group as const.? It's already initialized.
> If you are ok with this please let me know. I can push updated patch.
>
Yes, you can do that.
Or you could go a step ahead and create per-model pmu_attr_groups[], with shared
pmu_attr_group and per-model event/format groups and tie it to the model description
and make everything const.
i.e,
static const struct attribute_group cci5xx_pmu_attr_groups[] = {
&pmu_attr_group,
&cci5xx_format_attr_group,
&cci5xx_event_attr_group,
NULL,
};
static const struct attribute_group cci400r0_pmu_attr_groups = {
&pmu_attr_group,
&cci400_pmu_format_attr_group,
&cci400_pmu_event_attr_group,
NULL,
};
static const struct attribute_group cci400r1_pmu_attr_groups = {
&pmu_attr_group,
&cci400_pmu_format_attr_group,
&cci400r1_pmu_event_attr_group,
NULL,
};
and then do :
cci_pmu->pmu = (struct pmu) {
....
.attr_groups = model->attr_groups,
};
Suzuki
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web