Skip to content

Commit

Permalink
[media] v4l2: add const to argument of write-only s_frequency ioctl
Browse files Browse the repository at this point in the history
This ioctl is defined as IOW, so pass the argument as const.

Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Mar 24, 2013
1 parent 69aa6f4 commit b530a44
Show file tree
Hide file tree
Showing 56 changed files with 115 additions and 110 deletions.
2 changes: 1 addition & 1 deletion drivers/media/i2c/cx25840/cx25840-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1835,7 +1835,7 @@ static int cx25840_s_audio_routing(struct v4l2_subdev *sd,
return set_input(client, state->vid_input, input);
}

static int cx25840_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *freq)
static int cx25840_s_frequency(struct v4l2_subdev *sd, const struct v4l2_frequency *freq)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/i2c/msp3400-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ static int msp_s_radio(struct v4l2_subdev *sd)
return 0;
}

static int msp_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *freq)
static int msp_s_frequency(struct v4l2_subdev *sd, const struct v4l2_frequency *freq)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/i2c/tvaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1817,7 +1817,7 @@ static int tvaudio_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
return 0;
}

static int tvaudio_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *freq)
static int tvaudio_s_frequency(struct v4l2_subdev *sd, const struct v4l2_frequency *freq)
{
struct CHIPSTATE *chip = to_state(sd);
struct CHIPDESC *desc = chip->desc;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/i2c/upd64031a.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static void upd64031a_write(struct v4l2_subdev *sd, u8 reg, u8 val)
/* ------------------------------------------------------------------------ */

/* The input changed due to new input or channel changed */
static int upd64031a_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *freq)
static int upd64031a_s_frequency(struct v4l2_subdev *sd, const struct v4l2_frequency *freq)
{
struct upd64031a_state *state = to_state(sd);
u8 reg = state->regs[R00];
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/i2c/wm8775.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static int wm8775_log_status(struct v4l2_subdev *sd)
return 0;
}

static int wm8775_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *freq)
static int wm8775_s_frequency(struct v4l2_subdev *sd, const struct v4l2_frequency *freq)
{
wm8775_set_audio(sd, 0);
return 0;
Expand Down
14 changes: 8 additions & 6 deletions drivers/media/pci/bt8xx/bttv-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1852,24 +1852,26 @@ static int bttv_g_frequency(struct file *file, void *priv,
return 0;
}

static void bttv_set_frequency(struct bttv *btv, struct v4l2_frequency *f)
static void bttv_set_frequency(struct bttv *btv, const struct v4l2_frequency *f)
{
struct v4l2_frequency new_freq = *f;

bttv_call_all(btv, tuner, s_frequency, f);
/* s_frequency may clamp the frequency, so get the actual
frequency before assigning radio/tv_freq. */
bttv_call_all(btv, tuner, g_frequency, f);
if (f->type == V4L2_TUNER_RADIO) {
bttv_call_all(btv, tuner, g_frequency, &new_freq);
if (new_freq.type == V4L2_TUNER_RADIO) {
radio_enable(btv);
btv->radio_freq = f->frequency;
btv->radio_freq = new_freq.frequency;
if (btv->has_matchbox)
tea5757_set_freq(btv, btv->radio_freq);
} else {
btv->tv_freq = f->frequency;
btv->tv_freq = new_freq.frequency;
}
}

static int bttv_s_frequency(struct file *file, void *priv,
struct v4l2_frequency *f)
const struct v4l2_frequency *f)
{
struct bttv_fh *fh = priv;
struct bttv *btv = fh->btv;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/cx18/cx18-av-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ static void input_change(struct cx18 *cx)
}

static int cx18_av_s_frequency(struct v4l2_subdev *sd,
struct v4l2_frequency *freq)
const struct v4l2_frequency *freq)
{
struct cx18 *cx = v4l2_get_subdevdata(sd);
input_change(cx);
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/cx18/cx18-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ static int cx18_g_frequency(struct file *file, void *fh,
return 0;
}

int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf)
int cx18_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *vf)
{
struct cx18_open_id *id = fh2id(fh);
struct cx18 *cx = id->cx;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/cx18/cx18-ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ void cx18_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal);
u16 cx18_get_service_set(struct v4l2_sliced_vbi_format *fmt);
void cx18_set_funcs(struct video_device *vdev);
int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std);
int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf);
int cx18_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *vf);
int cx18_s_input(struct file *file, void *fh, unsigned int inp);
2 changes: 1 addition & 1 deletion drivers/media/pci/cx23885/cx23885-417.c
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ static int vidioc_g_frequency(struct file *file, void *priv,
}

static int vidioc_s_frequency(struct file *file, void *priv,
struct v4l2_frequency *f)
const struct v4l2_frequency *f)
{
return cx23885_set_frequency(file, priv, f);
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/pci/cx23885/cx23885-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,7 @@ static int vidioc_g_frequency(struct file *file, void *priv,
return 0;
}

static int cx23885_set_freq(struct cx23885_dev *dev, struct v4l2_frequency *f)
static int cx23885_set_freq(struct cx23885_dev *dev, const struct v4l2_frequency *f)
{
struct v4l2_control ctrl;

Expand Down Expand Up @@ -1550,7 +1550,7 @@ static int cx23885_set_freq(struct cx23885_dev *dev, struct v4l2_frequency *f)
}

static int cx23885_set_freq_via_ops(struct cx23885_dev *dev,
struct v4l2_frequency *f)
const struct v4l2_frequency *f)
{
struct v4l2_control ctrl;
struct videobuf_dvb_frontend *vfe;
Expand Down Expand Up @@ -1608,7 +1608,7 @@ static int cx23885_set_freq_via_ops(struct cx23885_dev *dev,
}

int cx23885_set_frequency(struct file *file, void *priv,
struct v4l2_frequency *f)
const struct v4l2_frequency *f)
{
struct cx23885_fh *fh = priv;
struct cx23885_dev *dev = fh->dev;
Expand All @@ -1628,7 +1628,7 @@ int cx23885_set_frequency(struct file *file, void *priv,
}

static int vidioc_s_frequency(struct file *file, void *priv,
struct v4l2_frequency *f)
const struct v4l2_frequency *f)
{
return cx23885_set_frequency(file, priv, f);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/cx23885/cx23885.h
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ extern void cx23885_video_wakeup(struct cx23885_dev *dev,
int cx23885_enum_input(struct cx23885_dev *dev, struct v4l2_input *i);
int cx23885_set_input(struct file *file, void *priv, unsigned int i);
int cx23885_get_input(struct file *file, void *priv, unsigned int *i);
int cx23885_set_frequency(struct file *file, void *priv, struct v4l2_frequency *f);
int cx23885_set_frequency(struct file *file, void *priv, const struct v4l2_frequency *f);
int cx23885_set_control(struct cx23885_dev *dev, struct v4l2_control *ctl);
int cx23885_get_control(struct cx23885_dev *dev, struct v4l2_control *ctl);
int cx23885_set_tvnorm(struct cx23885_dev *dev, v4l2_std_id norm);
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/pci/cx25821/cx25821-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ int cx25821_vidioc_g_frequency(struct file *file, void *priv,
return 0;
}

int cx25821_set_freq(struct cx25821_dev *dev, struct v4l2_frequency *f)
int cx25821_set_freq(struct cx25821_dev *dev, const struct v4l2_frequency *f)
{
mutex_lock(&dev->lock);
dev->freq = f->frequency;
Expand All @@ -1328,7 +1328,7 @@ int cx25821_set_freq(struct cx25821_dev *dev, struct v4l2_frequency *f)
}

int cx25821_vidioc_s_frequency(struct file *file, void *priv,
struct v4l2_frequency *f)
const struct v4l2_frequency *f)
{
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev;
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/pci/cx25821/cx25821-video.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ extern int cx25821_vidioc_g_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f);
extern int cx25821_vidioc_g_frequency(struct file *file, void *priv,
struct v4l2_frequency *f);
extern int cx25821_set_freq(struct cx25821_dev *dev, struct v4l2_frequency *f);
extern int cx25821_set_freq(struct cx25821_dev *dev, const struct v4l2_frequency *f);
extern int cx25821_vidioc_s_frequency(struct file *file, void *priv,
struct v4l2_frequency *f);
const struct v4l2_frequency *f);
extern int cx25821_vidioc_g_register(struct file *file, void *fh,
struct v4l2_dbg_register *reg);
extern int cx25821_vidioc_s_register(struct file *file, void *fh,
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/cx88/cx88-blackbird.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
}

static int vidioc_s_frequency (struct file *file, void *priv,
struct v4l2_frequency *f)
const struct v4l2_frequency *f)
{
struct cx8802_fh *fh = priv;
struct cx8802_dev *dev = fh->dev;
Expand Down
10 changes: 6 additions & 4 deletions drivers/media/pci/cx88/cx88-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1321,8 +1321,10 @@ static int vidioc_g_frequency (struct file *file, void *priv,
}

int cx88_set_freq (struct cx88_core *core,
struct v4l2_frequency *f)
const struct v4l2_frequency *f)
{
struct v4l2_frequency new_freq = *f;

if (unlikely(UNSET == core->board.tuner_type))
return -EINVAL;
if (unlikely(f->tuner != 0))
Expand All @@ -1331,8 +1333,8 @@ int cx88_set_freq (struct cx88_core *core,
mutex_lock(&core->lock);
cx88_newstation(core);
call_all(core, tuner, s_frequency, f);
call_all(core, tuner, g_frequency, f);
core->freq = f->frequency;
call_all(core, tuner, g_frequency, &new_freq);
core->freq = new_freq.frequency;

/* When changing channels it is required to reset TVAUDIO */
msleep (10);
Expand All @@ -1345,7 +1347,7 @@ int cx88_set_freq (struct cx88_core *core,
EXPORT_SYMBOL(cx88_set_freq);

static int vidioc_s_frequency (struct file *file, void *priv,
struct v4l2_frequency *f)
const struct v4l2_frequency *f)
{
struct cx8800_fh *fh = priv;
struct cx88_core *core = fh->dev->core;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/cx88/cx88.h
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ void cx8802_cancel_buffers(struct cx8802_dev *dev);
/* ----------------------------------------------------------- */
/* cx88-video.c*/
int cx88_enum_input (struct cx88_core *core,struct v4l2_input *i);
int cx88_set_freq (struct cx88_core *core,struct v4l2_frequency *f);
int cx88_set_freq(struct cx88_core *core, const struct v4l2_frequency *f);
int cx88_video_mux(struct cx88_core *core, unsigned int input);
void cx88_querycap(struct file *file, struct cx88_core *core,
struct v4l2_capability *cap);
2 changes: 1 addition & 1 deletion drivers/media/pci/ivtv/ivtv-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ static int ivtv_g_frequency(struct file *file, void *fh, struct v4l2_frequency *
return 0;
}

int ivtv_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf)
int ivtv_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *vf)
{
struct ivtv *itv = fh2id(fh)->itv;
struct ivtv_stream *s = &itv->streams[fh2id(fh)->type];
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/ivtv/ivtv-ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int ivtv_set_speed(struct ivtv *itv, int speed);
void ivtv_set_funcs(struct video_device *vdev);
void ivtv_s_std_enc(struct ivtv *itv, v4l2_std_id *std);
void ivtv_s_std_dec(struct ivtv *itv, v4l2_std_id *std);
int ivtv_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf);
int ivtv_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *vf);
int ivtv_s_input(struct file *file, void *fh, unsigned int inp);

#endif
2 changes: 1 addition & 1 deletion drivers/media/pci/saa7134/saa7134-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -2057,7 +2057,7 @@ static int saa7134_g_frequency(struct file *file, void *priv,
}

static int saa7134_s_frequency(struct file *file, void *priv,
struct v4l2_frequency *f)
const struct v4l2_frequency *f)
{
struct saa7134_fh *fh = priv;
struct saa7134_dev *dev = fh->dev;
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/pci/saa7146/mxb.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ static int vidioc_g_frequency(struct file *file, void *fh, struct v4l2_frequency
return 0;
}

static int vidioc_s_frequency(struct file *file, void *fh, struct v4l2_frequency *f)
static int vidioc_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *f)
{
struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
struct mxb *mxb = (struct mxb *)dev->ext_priv;
Expand All @@ -612,8 +612,8 @@ static int vidioc_s_frequency(struct file *file, void *fh, struct v4l2_frequency
/* tune in desired frequency */
tuner_call(mxb, tuner, s_frequency, f);
/* let the tuner subdev clamp the frequency to the tuner range */
tuner_call(mxb, tuner, g_frequency, f);
mxb->cur_freq = *f;
tuner_call(mxb, tuner, g_frequency, &mxb->cur_freq);
if (mxb->cur_audinput == 0)
mxb_update_audmode(mxb);

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/saa7164/saa7164-encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ static int vidioc_g_frequency(struct file *file, void *priv,
}

static int vidioc_s_frequency(struct file *file, void *priv,
struct v4l2_frequency *f)
const struct v4l2_frequency *f)
{
struct saa7164_encoder_fh *fh = file->private_data;
struct saa7164_port *port = fh->port;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/saa7164/saa7164-vbi.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ static int vidioc_g_frequency(struct file *file, void *priv,
}

static int vidioc_s_frequency(struct file *file, void *priv,
struct v4l2_frequency *f)
const struct v4l2_frequency *f)
{
struct saa7164_vbi_fh *fh = file->private_data;
struct saa7164_port *port = fh->port;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/pci/ttpci/av7110_v4l.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ static int vidioc_g_frequency(struct file *file, void *fh, struct v4l2_frequency
return 0;
}

static int vidioc_s_frequency(struct file *file, void *fh, struct v4l2_frequency *f)
static int vidioc_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *f)
{
struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
struct av7110 *av7110 = (struct av7110 *)dev->ext_priv;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/dsbr100.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static int vidioc_s_tuner(struct file *file, void *priv,
}

static int vidioc_s_frequency(struct file *file, void *priv,
struct v4l2_frequency *f)
const struct v4l2_frequency *f)
{
struct dsbr100_device *radio = video_drvdata(file);

Expand Down
46 changes: 23 additions & 23 deletions drivers/media/radio/radio-cadet.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,26 @@ static u16 sigtable[2][4] = {
{ 2185, 4369, 13107, 65535 },
};

static const struct v4l2_frequency_band bands[] = {
{
.index = 0,
.type = V4L2_TUNER_RADIO,
.capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_FREQ_BANDS,
.rangelow = 8320, /* 520 kHz */
.rangehigh = 26400, /* 1650 kHz */
.modulation = V4L2_BAND_MODULATION_AM,
}, {
.index = 1,
.type = V4L2_TUNER_RADIO,
.capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_RDS |
V4L2_TUNER_CAP_RDS_BLOCK_IO | V4L2_TUNER_CAP_LOW |
V4L2_TUNER_CAP_FREQ_BANDS,
.rangelow = 1400000, /* 87.5 MHz */
.rangehigh = 1728000, /* 108.0 MHz */
.modulation = V4L2_BAND_MODULATION_FM,
},
};


static int cadet_getstereo(struct cadet *dev)
{
Expand Down Expand Up @@ -196,6 +216,8 @@ static void cadet_setfreq(struct cadet *dev, unsigned freq)
int i, j, test;
int curvol;

freq = clamp(freq, bands[dev->is_fm_band].rangelow,
bands[dev->is_fm_band].rangehigh);
dev->curfreq = freq;
/*
* Formulate a fifo command
Expand Down Expand Up @@ -337,26 +359,6 @@ static int vidioc_querycap(struct file *file, void *priv,
return 0;
}

static const struct v4l2_frequency_band bands[] = {
{
.index = 0,
.type = V4L2_TUNER_RADIO,
.capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_FREQ_BANDS,
.rangelow = 8320, /* 520 kHz */
.rangehigh = 26400, /* 1650 kHz */
.modulation = V4L2_BAND_MODULATION_AM,
}, {
.index = 1,
.type = V4L2_TUNER_RADIO,
.capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_RDS |
V4L2_TUNER_CAP_RDS_BLOCK_IO | V4L2_TUNER_CAP_LOW |
V4L2_TUNER_CAP_FREQ_BANDS,
.rangelow = 1400000, /* 87.5 MHz */
.rangehigh = 1728000, /* 108.0 MHz */
.modulation = V4L2_BAND_MODULATION_FM,
},
};

static int vidioc_g_tuner(struct file *file, void *priv,
struct v4l2_tuner *v)
{
Expand Down Expand Up @@ -418,16 +420,14 @@ static int vidioc_g_frequency(struct file *file, void *priv,


static int vidioc_s_frequency(struct file *file, void *priv,
struct v4l2_frequency *f)
const struct v4l2_frequency *f)
{
struct cadet *dev = video_drvdata(file);

if (f->tuner)
return -EINVAL;
dev->is_fm_band =
f->frequency >= (bands[0].rangehigh + bands[1].rangelow) / 2;
clamp(f->frequency, bands[dev->is_fm_band].rangelow,
bands[dev->is_fm_band].rangehigh);
cadet_setfreq(dev, f->frequency);
return 0;
}
Expand Down
Loading

0 comments on commit b530a44

Please sign in to comment.