Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752355AbdGGOdW (ORCPT ); Fri, 7 Jul 2017 10:33:22 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:48637 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750904AbdGGOdV (ORCPT ); Fri, 7 Jul 2017 10:33:21 -0400 From: Hugues FRUCHET To: "Gustavo A. R. Silva" , Mauro Carvalho Chehab CC: "linux-media@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] st-delta: constify vb2_ops structures Thread-Topic: [PATCH] st-delta: constify vb2_ops structures Thread-Index: AQHS9pR3xFsGG367sEmb3xvYRP8Y8aJITS0A Date: Fri, 7 Jul 2017 14:33:02 +0000 Message-ID: References: <20170706201423.GA7477@embeddedgus> In-Reply-To: <20170706201423.GA7477@embeddedgus> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.75.127.49] Content-Type: text/plain; charset="utf-8" Content-ID: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-07-07_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v67EXRk8029489 Content-Length: 1950 Lines: 64 Acked-by: Hugues Fruchet On 07/06/2017 10:14 PM, Gustavo A. R. Silva wrote: > Check for vb2_ops structures that are only stored in the ops field of a > vb2_queue structure. That field is declared const, so vb2_ops structures > that have this property can be declared as const also. > > This issue was detected using Coccinelle and the following semantic patch: > > @r disable optional_qualifier@ > identifier i; > position p; > @@ > static struct vb2_ops i@p = { ... }; > > @ok@ > identifier r.i; > struct vb2_queue e; > position p; > @@ > e.ops = &i@p; > > @bad@ > position p != {r.p,ok.p}; > identifier r.i; > struct vb2_ops e; > @@ > e@i@p > > @depends on !bad disable optional_qualifier@ > identifier r.i; > @@ > static > +const > struct vb2_ops i = { ... }; > > Signed-off-by: Gustavo A. R. Silva > --- > drivers/media/platform/sti/delta/delta-v4l2.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/platform/sti/delta/delta-v4l2.c b/drivers/media/platform/sti/delta/delta-v4l2.c > index c6f2e24..ff9850e 100644 > --- a/drivers/media/platform/sti/delta/delta-v4l2.c > +++ b/drivers/media/platform/sti/delta/delta-v4l2.c > @@ -1574,7 +1574,7 @@ static void delta_vb2_frame_stop_streaming(struct vb2_queue *q) > } > > /* VB2 queue ops */ > -static struct vb2_ops delta_vb2_au_ops = { > +static const struct vb2_ops delta_vb2_au_ops = { > .queue_setup = delta_vb2_au_queue_setup, > .buf_prepare = delta_vb2_au_prepare, > .buf_queue = delta_vb2_au_queue, > @@ -1584,7 +1584,7 @@ static struct vb2_ops delta_vb2_au_ops = { > .stop_streaming = delta_vb2_au_stop_streaming, > }; > > -static struct vb2_ops delta_vb2_frame_ops = { > +static const struct vb2_ops delta_vb2_frame_ops = { > .queue_setup = delta_vb2_frame_queue_setup, > .buf_prepare = delta_vb2_frame_prepare, > .buf_finish = delta_vb2_frame_finish, >