[next] media: bt8xx: make read-only arrays static

Message ID 20230627134851.728487-1-colin.i.king@gmail.com (mailing list archive)
State Superseded
Headers
Series [next] media: bt8xx: make read-only arrays static |

Commit Message

Colin Ian King June 27, 2023, 1:48 p.m. UTC
  Don't populate the arrays on the stack, instead make them static const.
Also add spaces between values to clean up checkpatch style warnings.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 drivers/media/pci/bt8xx/dvb-bt8xx.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
  

Comments

Tommaso Merciai June 27, 2023, 2:38 p.m. UTC | #1
Hi Colin,

On Tue, Jun 27, 2023 at 02:48:51PM +0100, Colin Ian King wrote:
> Don't populate the arrays on the stack, instead make them static const.
> Also add spaces between values to clean up checkpatch style warnings.
> 
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>  drivers/media/pci/bt8xx/dvb-bt8xx.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/pci/bt8xx/dvb-bt8xx.c b/drivers/media/pci/bt8xx/dvb-bt8xx.c
> index 4cb890b949c3..df83b59a618d 100644
> --- a/drivers/media/pci/bt8xx/dvb-bt8xx.c
> +++ b/drivers/media/pci/bt8xx/dvb-bt8xx.c
> @@ -190,11 +190,15 @@ static int cx24108_tuner_set_params(struct dvb_frontend *fe)
>  	u32 freq = c->frequency;
>  	int i, a, n, pump;
>  	u32 band, pll;
> -	u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000,
> -		1576000,1718000,1856000,2036000,2150000};
> -	u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000,
> +	static const u32 osci[] = {
> +		950000, 1019000, 1075000, 1178000, 1296000, 1432000,
> +		1576000, 1718000, 1856000, 2036000, 2150000
> +	};
> +	static const u32 bandsel[] = {
> +		0, 0x00020000, 0x00040000, 0x00100800, 0x00101000,
>  		0x00102000,0x00104000,0x00108000,0x00110000,

Are you not missing space also here?

> -		0x00120000,0x00140000};
> +		0x00120000, 0x00140000
> +	};
>  
>  	#define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */
>  	dprintk("cx24108 debug: entering SetTunerFreq, freq=%d\n", freq);
> -- 
> 2.39.2
> 

Regards,
Tommaso
  
Colin Ian King June 27, 2023, 3:04 p.m. UTC | #2
On 27/06/2023 15:38, Tommaso Merciai wrote:
> Hi Colin,
> 
> On Tue, Jun 27, 2023 at 02:48:51PM +0100, Colin Ian King wrote:
>> Don't populate the arrays on the stack, instead make them static const.
>> Also add spaces between values to clean up checkpatch style warnings.
>>
>> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
>> ---
>>   drivers/media/pci/bt8xx/dvb-bt8xx.c | 12 ++++++++----
>>   1 file changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/media/pci/bt8xx/dvb-bt8xx.c b/drivers/media/pci/bt8xx/dvb-bt8xx.c
>> index 4cb890b949c3..df83b59a618d 100644
>> --- a/drivers/media/pci/bt8xx/dvb-bt8xx.c
>> +++ b/drivers/media/pci/bt8xx/dvb-bt8xx.c
>> @@ -190,11 +190,15 @@ static int cx24108_tuner_set_params(struct dvb_frontend *fe)
>>   	u32 freq = c->frequency;
>>   	int i, a, n, pump;
>>   	u32 band, pll;
>> -	u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000,
>> -		1576000,1718000,1856000,2036000,2150000};
>> -	u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000,
>> +	static const u32 osci[] = {
>> +		950000, 1019000, 1075000, 1178000, 1296000, 1432000,
>> +		1576000, 1718000, 1856000, 2036000, 2150000
>> +	};
>> +	static const u32 bandsel[] = {
>> +		0, 0x00020000, 0x00040000, 0x00100800, 0x00101000,
>>   		0x00102000,0x00104000,0x00108000,0x00110000,
> 
> Are you not missing space also here?

I can't see the space you are referring to.

> 
>> -		0x00120000,0x00140000};
>> +		0x00120000, 0x00140000
>> +	};
>>   
>>   	#define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */
>>   	dprintk("cx24108 debug: entering SetTunerFreq, freq=%d\n", freq);
>> -- 
>> 2.39.2
>>
> 
> Regards,
> Tommaso
  
Tommaso Merciai June 27, 2023, 3:14 p.m. UTC | #3
Hi Coli,

On Tue, Jun 27, 2023 at 04:04:38PM +0100, Colin King (gmail) wrote:
> On 27/06/2023 15:38, Tommaso Merciai wrote:
> > Hi Colin,
> > 
> > On Tue, Jun 27, 2023 at 02:48:51PM +0100, Colin Ian King wrote:
> > > Don't populate the arrays on the stack, instead make them static const.
> > > Also add spaces between values to clean up checkpatch style warnings.
> > > 
> > > Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> > > ---
> > >   drivers/media/pci/bt8xx/dvb-bt8xx.c | 12 ++++++++----
> > >   1 file changed, 8 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/media/pci/bt8xx/dvb-bt8xx.c b/drivers/media/pci/bt8xx/dvb-bt8xx.c
> > > index 4cb890b949c3..df83b59a618d 100644
> > > --- a/drivers/media/pci/bt8xx/dvb-bt8xx.c
> > > +++ b/drivers/media/pci/bt8xx/dvb-bt8xx.c
> > > @@ -190,11 +190,15 @@ static int cx24108_tuner_set_params(struct dvb_frontend *fe)
> > >   	u32 freq = c->frequency;
> > >   	int i, a, n, pump;
> > >   	u32 band, pll;
> > > -	u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000,
> > > -		1576000,1718000,1856000,2036000,2150000};
> > > -	u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000,
> > > +	static const u32 osci[] = {
> > > +		950000, 1019000, 1075000, 1178000, 1296000, 1432000,
> > > +		1576000, 1718000, 1856000, 2036000, 2150000
> > > +	};
> > > +	static const u32 bandsel[] = {
> > > +		0, 0x00020000, 0x00040000, 0x00100800, 0x00101000,
> > >   		0x00102000,0x00104000,0x00108000,0x00110000,
+			0x00102000, 0x00104000, 0x00108000, 0x00110000,

ERROR: space required after that ',' (ctx:VxV)
#199: FILE: drivers/media/pci/bt8xx/dvb-bt8xx.c:199:
+		0x00102000,0x00104000,0x00108000,0x00110000,

I'm wrong?

Regards,
Tommaso

> > 
> > Are you not missing space also here?
> 
> I can't see the space you are referring to.
> 
> > 
> > > -		0x00120000,0x00140000};
> > > +		0x00120000, 0x00140000
> > > +	};
> > >   	#define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */
> > >   	dprintk("cx24108 debug: entering SetTunerFreq, freq=%d\n", freq);
> > > -- 
> > > 2.39.2
> > > 
> > 
> > Regards,
> > Tommaso
>
  
Colin Ian King June 27, 2023, 3:22 p.m. UTC | #4
On 27/06/2023 16:14, Tommaso Merciai wrote:
> Hi Coli,
> 
> On Tue, Jun 27, 2023 at 04:04:38PM +0100, Colin King (gmail) wrote:
>> On 27/06/2023 15:38, Tommaso Merciai wrote:
>>> Hi Colin,
>>>
>>> On Tue, Jun 27, 2023 at 02:48:51PM +0100, Colin Ian King wrote:
>>>> Don't populate the arrays on the stack, instead make them static const.
>>>> Also add spaces between values to clean up checkpatch style warnings.
>>>>
>>>> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
>>>> ---
>>>>    drivers/media/pci/bt8xx/dvb-bt8xx.c | 12 ++++++++----
>>>>    1 file changed, 8 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/drivers/media/pci/bt8xx/dvb-bt8xx.c b/drivers/media/pci/bt8xx/dvb-bt8xx.c
>>>> index 4cb890b949c3..df83b59a618d 100644
>>>> --- a/drivers/media/pci/bt8xx/dvb-bt8xx.c
>>>> +++ b/drivers/media/pci/bt8xx/dvb-bt8xx.c
>>>> @@ -190,11 +190,15 @@ static int cx24108_tuner_set_params(struct dvb_frontend *fe)
>>>>    	u32 freq = c->frequency;
>>>>    	int i, a, n, pump;
>>>>    	u32 band, pll;
>>>> -	u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000,
>>>> -		1576000,1718000,1856000,2036000,2150000};
>>>> -	u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000,
>>>> +	static const u32 osci[] = {
>>>> +		950000, 1019000, 1075000, 1178000, 1296000, 1432000,
>>>> +		1576000, 1718000, 1856000, 2036000, 2150000
>>>> +	};
>>>> +	static const u32 bandsel[] = {
>>>> +		0, 0x00020000, 0x00040000, 0x00100800, 0x00101000,
>>>>    		0x00102000,0x00104000,0x00108000,0x00110000,
> +			0x00102000, 0x00104000, 0x00108000, 0x00110000,
> 
> ERROR: space required after that ',' (ctx:VxV)
> #199: FILE: drivers/media/pci/bt8xx/dvb-bt8xx.c:199:
> +		0x00102000,0x00104000,0x00108000,0x00110000,

Yep, I can see it now, I'll send a V2. :-/

> 
> I'm wrong?
> 
> Regards,
> Tommaso
> 
>>>
>>> Are you not missing space also here?
>>
>> I can't see the space you are referring to.
>>
>>>
>>>> -		0x00120000,0x00140000};
>>>> +		0x00120000, 0x00140000
>>>> +	};
>>>>    	#define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */
>>>>    	dprintk("cx24108 debug: entering SetTunerFreq, freq=%d\n", freq);
>>>> -- 
>>>> 2.39.2
>>>>
>>>
>>> Regards,
>>> Tommaso
>>
  

Patch

diff --git a/drivers/media/pci/bt8xx/dvb-bt8xx.c b/drivers/media/pci/bt8xx/dvb-bt8xx.c
index 4cb890b949c3..df83b59a618d 100644
--- a/drivers/media/pci/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/pci/bt8xx/dvb-bt8xx.c
@@ -190,11 +190,15 @@  static int cx24108_tuner_set_params(struct dvb_frontend *fe)
 	u32 freq = c->frequency;
 	int i, a, n, pump;
 	u32 band, pll;
-	u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000,
-		1576000,1718000,1856000,2036000,2150000};
-	u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000,
+	static const u32 osci[] = {
+		950000, 1019000, 1075000, 1178000, 1296000, 1432000,
+		1576000, 1718000, 1856000, 2036000, 2150000
+	};
+	static const u32 bandsel[] = {
+		0, 0x00020000, 0x00040000, 0x00100800, 0x00101000,
 		0x00102000,0x00104000,0x00108000,0x00110000,
-		0x00120000,0x00140000};
+		0x00120000, 0x00140000
+	};
 
 	#define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */
 	dprintk("cx24108 debug: entering SetTunerFreq, freq=%d\n", freq);