Skip to content

Commit

Permalink
V4L/DVB: drivers/media: Make static data tables and strings const
Browse files Browse the repository at this point in the history
Making static data const avoids allocation of additional r/w memory and
reduces initialisation time.  It also provides some additional opportunities
for compiler optimisations.

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
lawrence rust authored and Mauro Carvalho Chehab committed Oct 21, 2010
1 parent f71d768 commit 2e4e98e
Show file tree
Hide file tree
Showing 27 changed files with 139 additions and 139 deletions.
2 changes: 1 addition & 1 deletion drivers/media/common/tuners/xc5000.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ static const struct dvb_tuner_ops xc5000_tuner_ops = {

struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe,
struct i2c_adapter *i2c,
struct xc5000_config *cfg)
const struct xc5000_config *cfg)
{
struct xc5000_priv *priv = NULL;
int instance;
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/common/tuners/xc5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ struct xc5000_config {
(defined(CONFIG_MEDIA_TUNER_XC5000_MODULE) && defined(MODULE))
extern struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe,
struct i2c_adapter *i2c,
struct xc5000_config *cfg);
const struct xc5000_config *cfg);
#else
static inline struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe,
struct i2c_adapter *i2c,
struct xc5000_config *cfg)
const struct xc5000_config *cfg)
{
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/dvb-core/dvb_frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ struct dvb_frontend_ops {
int (*init)(struct dvb_frontend* fe);
int (*sleep)(struct dvb_frontend* fe);

int (*write)(struct dvb_frontend* fe, u8* buf, int len);
int (*write)(struct dvb_frontend* fe, const u8 buf[], int len);

/* if this is set, it overrides the default swzigzag */
int (*tune)(struct dvb_frontend* fe,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/dvb-usb/friio-fe.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static int jdvbt90502_single_reg_write(struct jdvbt90502_state *state,
return 0;
}

static int _jdvbt90502_write(struct dvb_frontend *fe, u8 *buf, int len)
static int _jdvbt90502_write(struct dvb_frontend *fe, const u8 buf[], int len)
{
struct jdvbt90502_state *state = fe->demodulator_priv;
int err, i;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/frontends/cx24110.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ static int cx24110_set_symbolrate (struct cx24110_state* state, u32 srate)

}

static int _cx24110_pll_write (struct dvb_frontend* fe, u8 *buf, int len)
static int _cx24110_pll_write (struct dvb_frontend* fe, const u8 buf[], int len)
{
struct cx24110_state *state = fe->demodulator_priv;

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/frontends/lgs8gxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ static void lgs8gxx_release(struct dvb_frontend *fe)
}


static int lgs8gxx_write(struct dvb_frontend *fe, u8 *buf, int len)
static int lgs8gxx_write(struct dvb_frontend *fe, const u8 buf[], int len)
{
struct lgs8gxx_state *priv = fe->demodulator_priv;

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/frontends/mt352.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static int mt352_single_write(struct dvb_frontend *fe, u8 reg, u8 val)
return 0;
}

static int _mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen)
static int _mt352_write(struct dvb_frontend* fe, const u8 ibuf[], int ilen)
{
int err,i;
for (i=0; i < ilen-1; i++)
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/frontends/mt352.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static inline struct dvb_frontend* mt352_attach(const struct mt352_config* confi
}
#endif // CONFIG_DVB_MT352

static inline int mt352_write(struct dvb_frontend *fe, u8 *buf, int len) {
static inline int mt352_write(struct dvb_frontend *fe, const u8 buf[], int len) {
int r = 0;
if (fe->ops.write)
r = fe->ops.write(fe, buf, len);
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/frontends/si21xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ static int si21_writereg(struct si21xx_state *state, u8 reg, u8 data)
return (ret != 1) ? -EREMOTEIO : 0;
}

static int si21_write(struct dvb_frontend *fe, u8 *buf, int len)
static int si21_write(struct dvb_frontend *fe, const u8 buf[], int len)
{
struct si21xx_state *state = fe->demodulator_priv;

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/frontends/stb6100.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ static struct dvb_tuner_ops stb6100_ops = {
};

struct dvb_frontend *stb6100_attach(struct dvb_frontend *fe,
struct stb6100_config *config,
const struct stb6100_config *config,
struct i2c_adapter *i2c)
{
struct stb6100_state *state = NULL;
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb/frontends/stb6100.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ struct stb6100_state {
#if defined(CONFIG_DVB_STB6100) || (defined(CONFIG_DVB_STB6100_MODULE) && defined(MODULE))

extern struct dvb_frontend *stb6100_attach(struct dvb_frontend *fe,
struct stb6100_config *config,
const struct stb6100_config *config,
struct i2c_adapter *i2c);

#else

static inline struct dvb_frontend *stb6100_attach(struct dvb_frontend *fe,
struct stb6100_config *config,
const struct stb6100_config *config,
struct i2c_adapter *i2c)
{
printk(KERN_WARNING "%s: Driver disabled by Kconfig\n", __func__);
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/frontends/stv0288.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static int stv0288_writeregI(struct stv0288_state *state, u8 reg, u8 data)
return (ret != 1) ? -EREMOTEIO : 0;
}

static int stv0288_write(struct dvb_frontend *fe, u8 *buf, int len)
static int stv0288_write(struct dvb_frontend *fe, const u8 buf[], int len)
{
struct stv0288_state *state = fe->demodulator_priv;

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/frontends/stv0299.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static int stv0299_writeregI (struct stv0299_state* state, u8 reg, u8 data)
return (ret != 1) ? -EREMOTEIO : 0;
}

static int stv0299_write(struct dvb_frontend* fe, u8 *buf, int len)
static int stv0299_write(struct dvb_frontend* fe, const u8 buf[], int len)
{
struct stv0299_state* state = fe->demodulator_priv;

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/frontends/stv0299.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct stv0299_config
* First of each pair is the register, second is the value.
* List should be terminated with an 0xff, 0xff pair.
*/
u8* inittab;
const u8* inittab;

/* master clock to use */
u32 mclk;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/frontends/tda1004x.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ static int tda1004x_decode_fec(int tdafec)
return -1;
}

static int tda1004x_write(struct dvb_frontend* fe, u8 *buf, int len)
static int tda1004x_write(struct dvb_frontend* fe, const u8 buf[], int len)
{
struct tda1004x_state* state = fe->demodulator_priv;

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/dvb/frontends/zl10353.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static int zl10353_single_write(struct dvb_frontend *fe, u8 reg, u8 val)
return 0;
}

static int zl10353_write(struct dvb_frontend *fe, u8 *ibuf, int ilen)
static int zl10353_write(struct dvb_frontend *fe, const u8 ibuf[], int ilen)
{
int err, i;
for (i = 0; i < ilen - 1; i++)
Expand Down
18 changes: 9 additions & 9 deletions drivers/media/video/cx88/cx88-alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ typedef struct cx88_audio_dev snd_cx88_card_t;
****************************************************************************/

static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
static const char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 1};

module_param_array(enable, bool, NULL, 0444);
Expand Down Expand Up @@ -131,7 +131,7 @@ static int _cx88_start_audio_dma(snd_cx88_card_t *chip)
{
struct cx88_audio_buffer *buf = chip->buf;
struct cx88_core *core=chip->core;
struct sram_channel *audio_ch = &cx88_sram_channels[SRAM_CH25];
const struct sram_channel *audio_ch = &cx88_sram_channels[SRAM_CH25];

/* Make sure RISC/FIFO are off before changing FIFO/RISC settings */
cx_clear(MO_AUD_DMACNTRL, 0x11);
Expand Down Expand Up @@ -197,7 +197,7 @@ static int _cx88_stop_audio_dma(snd_cx88_card_t *chip)
/*
* BOARD Specific: IRQ dma bits
*/
static char *cx88_aud_irqs[32] = {
static const char *cx88_aud_irqs[32] = {
"dn_risci1", "up_risci1", "rds_dn_risc1", /* 0-2 */
NULL, /* reserved */
"dn_risci2", "up_risci2", "rds_dn_risc2", /* 4-6 */
Expand Down Expand Up @@ -308,7 +308,7 @@ static int dsp_buffer_free(snd_cx88_card_t *chip)
* Digital hardware definition
*/
#define DEFAULT_FIFO_SIZE 4096
static struct snd_pcm_hardware snd_cx88_digital_hw = {
static const struct snd_pcm_hardware snd_cx88_digital_hw = {
.info = SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_INTERLEAVED |
SNDRV_PCM_INFO_BLOCK_TRANSFER |
Expand Down Expand Up @@ -533,7 +533,7 @@ static struct snd_pcm_ops snd_cx88_pcm_ops = {
/*
* create a PCM device
*/
static int __devinit snd_cx88_pcm(snd_cx88_card_t *chip, int device, char *name)
static int __devinit snd_cx88_pcm(snd_cx88_card_t *chip, int device, const char *name)
{
int err;
struct snd_pcm *pcm;
Expand Down Expand Up @@ -614,7 +614,7 @@ static int snd_cx88_volume_put(struct snd_kcontrol *kcontrol,

static const DECLARE_TLV_DB_SCALE(snd_cx88_db_scale, -6300, 100, 0);

static struct snd_kcontrol_new snd_cx88_volume = {
static const struct snd_kcontrol_new snd_cx88_volume = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
SNDRV_CTL_ELEM_ACCESS_TLV_READ,
Expand Down Expand Up @@ -656,7 +656,7 @@ static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol,
return ret;
}

static struct snd_kcontrol_new snd_cx88_dac_switch = {
static const struct snd_kcontrol_new snd_cx88_dac_switch = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Playback Switch",
.info = snd_ctl_boolean_mono_info,
Expand All @@ -665,7 +665,7 @@ static struct snd_kcontrol_new snd_cx88_dac_switch = {
.private_value = (1<<8),
};

static struct snd_kcontrol_new snd_cx88_source_switch = {
static const struct snd_kcontrol_new snd_cx88_source_switch = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Capture Switch",
.info = snd_ctl_boolean_mono_info,
Expand All @@ -683,7 +683,7 @@ static struct snd_kcontrol_new snd_cx88_source_switch = {
* Only boards with eeprom and byte 1 at eeprom=1 have it
*/

static struct pci_device_id cx88_audio_pci_tbl[] __devinitdata = {
static const struct pci_device_id const cx88_audio_pci_tbl[] __devinitdata = {
{0x14f1,0x8801,PCI_ANY_ID,PCI_ANY_ID,0,0,0},
{0x14f1,0x8811,PCI_ANY_ID,PCI_ANY_ID,0,0,0},
{0, }
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/video/cx88/cx88-cards.c
Original file line number Diff line number Diff line change
Expand Up @@ -2673,10 +2673,10 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
/* ----------------------------------------------------------------------- */
/* some GDI (was: Modular Technology) specific stuff */

static struct {
static const struct {
int id;
int fm;
char *name;
const char *name;
} gdi_tuner[] = {
[ 0x01 ] = { .id = TUNER_ABSENT,
.name = "NTSC_M" },
Expand Down Expand Up @@ -2710,7 +2710,7 @@ static struct {

static void gdi_eeprom(struct cx88_core *core, u8 *eeprom_data)
{
char *name = (eeprom_data[0x0d] < ARRAY_SIZE(gdi_tuner))
const char *name = (eeprom_data[0x0d] < ARRAY_SIZE(gdi_tuner))
? gdi_tuner[eeprom_data[0x0d]].name : NULL;

info_printk(core, "GDI: tuner=%s\n", name ? name : "unknown");
Expand Down
26 changes: 13 additions & 13 deletions drivers/media/video/cx88/cx88-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf)
* 0x0c00 - FIFOs
*/

struct sram_channel cx88_sram_channels[] = {
const struct sram_channel const cx88_sram_channels[] = {
[SRAM_CH21] = {
.name = "video y / packed",
.cmds_start = 0x180040,
Expand Down Expand Up @@ -353,7 +353,7 @@ struct sram_channel cx88_sram_channels[] = {
};

int cx88_sram_channel_setup(struct cx88_core *core,
struct sram_channel *ch,
const struct sram_channel *ch,
unsigned int bpl, u32 risc)
{
unsigned int i,lines;
Expand Down Expand Up @@ -394,7 +394,7 @@ int cx88_sram_channel_setup(struct cx88_core *core,

static int cx88_risc_decode(u32 risc)
{
static char *instr[16] = {
static const char * const instr[16] = {
[ RISC_SYNC >> 28 ] = "sync",
[ RISC_WRITE >> 28 ] = "write",
[ RISC_WRITEC >> 28 ] = "writec",
Expand All @@ -406,14 +406,14 @@ static int cx88_risc_decode(u32 risc)
[ RISC_WRITECM >> 28 ] = "writecm",
[ RISC_WRITECR >> 28 ] = "writecr",
};
static int incr[16] = {
static int const incr[16] = {
[ RISC_WRITE >> 28 ] = 2,
[ RISC_JUMP >> 28 ] = 2,
[ RISC_WRITERM >> 28 ] = 3,
[ RISC_WRITECM >> 28 ] = 3,
[ RISC_WRITECR >> 28 ] = 4,
};
static char *bits[] = {
static const char * const bits[] = {
"12", "13", "14", "resync",
"cnt0", "cnt1", "18", "19",
"20", "21", "22", "23",
Expand All @@ -432,9 +432,9 @@ static int cx88_risc_decode(u32 risc)


void cx88_sram_channel_dump(struct cx88_core *core,
struct sram_channel *ch)
const struct sram_channel *ch)
{
static char *name[] = {
static const char * const name[] = {
"initial risc",
"cdt base",
"cdt size",
Expand Down Expand Up @@ -489,14 +489,14 @@ void cx88_sram_channel_dump(struct cx88_core *core,
core->name,cx_read(ch->cnt2_reg));
}

static char *cx88_pci_irqs[32] = {
static const char *cx88_pci_irqs[32] = {
"vid", "aud", "ts", "vip", "hst", "5", "6", "tm1",
"src_dma", "dst_dma", "risc_rd_err", "risc_wr_err",
"brdg_err", "src_dma_err", "dst_dma_err", "ipb_dma_err",
"i2c", "i2c_rack", "ir_smp", "gpio0", "gpio1"
};

void cx88_print_irqbits(char *name, char *tag, char **strings,
void cx88_print_irqbits(const char *name, const char *tag, const char *strings[],
int len, u32 bits, u32 mask)
{
unsigned int i;
Expand Down Expand Up @@ -770,7 +770,7 @@ static const u32 xtal = 28636363;

static int set_pll(struct cx88_core *core, int prescale, u32 ofreq)
{
static u32 pre[] = { 0, 0, 0, 3, 2, 1 };
static const u32 pre[] = { 0, 0, 0, 3, 2, 1 };
u64 pll;
u32 reg;
int i;
Expand Down Expand Up @@ -1020,15 +1020,15 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm)

struct video_device *cx88_vdev_init(struct cx88_core *core,
struct pci_dev *pci,
struct video_device *template,
char *type)
const struct video_device *template_,
const char *type)
{
struct video_device *vfd;

vfd = video_device_alloc();
if (NULL == vfd)
return NULL;
*vfd = *template;
*vfd = *template_;
vfd->v4l2_dev = &core->v4l2_dev;
vfd->parent = &pci->dev;
vfd->release = video_device_release;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/cx88/cx88-dsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ static s32 detect_btsc(struct cx88_core *core, s16 x[], u32 N)

static s16 *read_rds_samples(struct cx88_core *core, u32 *N)
{
struct sram_channel *srch = &cx88_sram_channels[SRAM_CH27];
const struct sram_channel *srch = &cx88_sram_channels[SRAM_CH27];
s16 *samples;

unsigned int i;
Expand Down
Loading

0 comments on commit 2e4e98e

Please sign in to comment.