Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752785AbdGFExx (ORCPT ); Thu, 6 Jul 2017 00:53:53 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:33186 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750970AbdGFExw (ORCPT ); Thu, 6 Jul 2017 00:53:52 -0400 Subject: Re: [PATCH] bus: arm-cci: constify attribute_group structures. To: Suzuki K Poulose , nico@linaro.org, mark.rutland@arm.com, mingo@kernel.org, lorenzo.pieralisi@arm.com References: <9b105274-212e-1ec1-8b9e-6dd3d6c16484@arm.com> Cc: linux-kernel@vger.kernel.org From: Arvind Yadav Message-ID: <44004c2c-b843-1f4c-efc4-2ca759e49182@gmail.com> Date: Thu, 6 Jul 2017 10:23:36 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <9b105274-212e-1ec1-8b9e-6dd3d6c16484@arm.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1870 Lines: 61 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 work with >> const >> attribute_group. So mark the non-const structs as const. >> >> Signed-off-by: Arvind Yadav >> --- >> 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