Skip to contentSkip to conversation

media: bt8xx: make read-only arrays static

PATCH Superseded Colin Ian King 2 participants 5 messages Jun 27, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: bt8xx: make read-only arrays static

Don't populate the arrays on the stack, instead make them static const. Also add spaces between values to clean up checkpatch style warnings.

---
 drivers/media/pci/bt8xx/dvb-bt8xx.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/media/pci/bt8xx/dvb-bt8xx.c +8 -4
index 4cb890b949c3..df83b59a618d 100644
@@ -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);
Signature · 1 line
2.39.2
#1 lore raw

Hi Colin,

Quoted 16 lines · Colin Ian King

Don't populate the arrays on the stack, instead make them static const. Also add spaces between values to clean up checkpatch style warnings.

---
 drivers/media/pci/bt8xx/dvb-bt8xx.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/media/pci/bt8xx/dvb-bt8xx.c +0 -0
index 4cb890b949c3..df83b59a618d 100644
@@ -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;

drivers/media/pci/bt8xx/dvb-bt8xx.c static int cx24108_tuner_set_params(struct dvb_frontend *fe) · line 199

Quoted 10 lines
drivers/media/pci/bt8xx/dvb-bt8xx.c +6 -3
-	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?

Quoted 9 lines
drivers/media/pci/bt8xx/dvb-bt8xx.c +2 -1
-		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);
Signature · 1 line
2.39.2

Regards,
Tommaso

#2 lore raw
Quoted 23 lines · Tommaso Merciai

Hi Colin,

Quoted 20 lines · Colin Ian King

Don't populate the arrays on the stack, instead make them static const. Also add spaces between values to clean up checkpatch style warnings.

---
  drivers/media/pci/bt8xx/dvb-bt8xx.c | 12 ++++++++----
  1 file changed, 8 insertions(+), 4 deletions(-)
drivers/media/pci/bt8xx/dvb-bt8xx.c +1 -3
index 4cb890b949c3..df83b59a618d 100644
@@ -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[] = {
Quoted 8 lines

drivers/media/pci/bt8xx/dvb-bt8xx.c static int cx24108_tuner_set_params(struct dvb_frontend *fe) · line 199

Quoted 6 lines
drivers/media/pci/bt8xx/dvb-bt8xx.c +5 -0
+		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.

Quoted 13 lines
Quoted 10 lines
drivers/media/pci/bt8xx/dvb-bt8xx.c +2 -1
-		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);
Signature · 1 line
2.39.2

Regards,
Tommaso

#3 lore raw

Hi Coli,

Quoted 22 lines · Colin King (gmail)
Quoted 21 lines · Tommaso Merciai

Hi Colin,

Quoted 18 lines · Colin Ian King

Don't populate the arrays on the stack, instead make them static const. Also add spaces between values to clean up checkpatch style warnings.

---
  drivers/media/pci/bt8xx/dvb-bt8xx.c | 12 ++++++++----
  1 file changed, 8 insertions(+), 4 deletions(-)
drivers/media/pci/bt8xx/dvb-bt8xx.c +0 -2
index 4cb890b949c3..df83b59a618d 100644
@@ -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};
Quoted 8 lines
Quoted 8 lines

drivers/media/pci/bt8xx/dvb-bt8xx.c static int cx24108_tuner_set_params(struct dvb_frontend *fe) · line 199

Quoted 8 lines
drivers/media/pci/bt8xx/dvb-bt8xx.c +6 -1
-	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

Quoted 18 lines
Quoted 2 lines

Are you not missing space also here?

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

Quoted 12 lines
Quoted 9 lines
drivers/media/pci/bt8xx/dvb-bt8xx.c +2 -1
-		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);
Signature · 1 line
2.39.2

Regards,
Tommaso

#4 lore raw
Quoted 37 lines · Tommaso Merciai

Hi Coli,

Quoted 30 lines · Colin King (gmail)
Quoted 29 lines · Tommaso Merciai

Hi Colin,

Quoted 26 lines · Colin Ian King

Don't populate the arrays on the stack, instead make them static const. Also add spaces between values to clean up checkpatch style warnings.

---
   drivers/media/pci/bt8xx/dvb-bt8xx.c | 12 ++++++++----
   1 file changed, 8 insertions(+), 4 deletions(-)
drivers/media/pci/bt8xx/dvb-bt8xx.c +6 -3
index 4cb890b949c3..df83b59a618d 100644
@@ -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,
(quoted diff) +1 -0
+			0x00102000, 0x00104000, 0x00108000, 0x00110000,

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

Review

Quoted 1 line
(quoted diff) +1 -0
+		0x00102000,0x00104000,0x00108000,0x00110000,

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

Quoted 24 lines

I'm wrong?

Regards,
Tommaso

Quoted 18 lines
Quoted 2 lines

Are you not missing space also here?

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

Quoted 12 lines
Quoted 9 lines
drivers/media/pci/bt8xx/dvb-bt8xx.c +2 -1
-		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);
Signature · 1 line
2.39.2

Regards,
Tommaso