diff options
Diffstat (limited to 'drivers/media/pci')
89 files changed, 390 insertions, 269 deletions
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c index cf05e11da01b..b2cfcbb0008e 100644 --- a/drivers/media/pci/bt8xx/bttv-driver.c +++ b/drivers/media/pci/bt8xx/bttv-driver.c @@ -2040,7 +2040,6 @@ limit_scaled_size_lock (struct bttv_fh * fh, max_width = max_width & width_mask; /* Max. scale factor is 16:1 for frames, 8:1 for fields. */ - min_height = min_height; /* Min. scale factor is 1:1. */ max_height >>= !V4L2_FIELD_HAS_BOTH(field); @@ -2473,8 +2472,8 @@ static int bttv_querycap(struct file *file, void *priv, if (0 == v4l2) return -EINVAL; - strlcpy(cap->driver, "bttv", sizeof(cap->driver)); - strlcpy(cap->card, btv->video_dev.name, sizeof(cap->card)); + strscpy(cap->driver, "bttv", sizeof(cap->driver)); + strscpy(cap->card, btv->video_dev.name, sizeof(cap->card)); snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", pci_name(btv->c.pci)); cap->capabilities = @@ -2535,7 +2534,7 @@ static int bttv_enum_fmt_cap_ovr(struct v4l2_fmtdesc *f) return -EINVAL; f->pixelformat = formats[i].fourcc; - strlcpy(f->description, formats[i].name, sizeof(f->description)); + strscpy(f->description, formats[i].name, sizeof(f->description)); return i; } @@ -2782,7 +2781,7 @@ static int bttv_g_tuner(struct file *file, void *priv, t->rxsubchans = V4L2_TUNER_SUB_MONO; t->capability = V4L2_TUNER_CAP_NORM; bttv_call_all(btv, tuner, g_tuner, t); - strcpy(t->name, "Television"); + strscpy(t->name, "Television", sizeof(t->name)); t->type = V4L2_TUNER_ANALOG_TV; if (btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC) t->signal = 0xffff; @@ -3257,7 +3256,7 @@ static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t) if (0 != t->index) return -EINVAL; - strcpy(t->name, "Radio"); + strscpy(t->name, "Radio", sizeof(t->name)); t->type = V4L2_TUNER_RADIO; radio_enable(btv); diff --git a/drivers/media/pci/bt8xx/bttv-i2c.c b/drivers/media/pci/bt8xx/bttv-i2c.c index c76823eb399d..15ff7f9d8373 100644 --- a/drivers/media/pci/bt8xx/bttv-i2c.c +++ b/drivers/media/pci/bt8xx/bttv-i2c.c @@ -347,13 +347,13 @@ static void do_i2c_scan(char *name, struct i2c_client *c) /* init + register i2c adapter */ int init_bttv_i2c(struct bttv *btv) { - strlcpy(btv->i2c_client.name, "bttv internal", I2C_NAME_SIZE); + strscpy(btv->i2c_client.name, "bttv internal", I2C_NAME_SIZE); if (i2c_hw) btv->use_i2c_hw = 1; if (btv->use_i2c_hw) { /* bt878 */ - strlcpy(btv->c.i2c_adap.name, "bt878", + strscpy(btv->c.i2c_adap.name, "bt878", sizeof(btv->c.i2c_adap.name)); btv->c.i2c_adap.algo = &bttv_algo; } else { @@ -362,7 +362,7 @@ int init_bttv_i2c(struct bttv *btv) if (i2c_udelay<5) i2c_udelay=5; - strlcpy(btv->c.i2c_adap.name, "bttv", + strscpy(btv->c.i2c_adap.name, "bttv", sizeof(btv->c.i2c_adap.name)); btv->i2c_algo = bttv_i2c_algo_bit_template; btv->i2c_algo.udelay = i2c_udelay; diff --git a/drivers/media/pci/bt8xx/bttv-input.c b/drivers/media/pci/bt8xx/bttv-input.c index 08266b23826e..d34fbaa027c2 100644 --- a/drivers/media/pci/bt8xx/bttv-input.c +++ b/drivers/media/pci/bt8xx/bttv-input.c @@ -370,7 +370,7 @@ static int get_key_pv951(struct IR_i2c *ir, enum rc_proto *protocol, /* Instantiate the I2C IR receiver device, if present */ void init_bttv_i2c_ir(struct bttv *btv) { - const unsigned short addr_list[] = { + static const unsigned short addr_list[] = { 0x1a, 0x18, 0x64, 0x30, 0x71, I2C_CLIENT_END }; @@ -382,7 +382,7 @@ void init_bttv_i2c_ir(struct bttv *btv) memset(&info, 0, sizeof(struct i2c_board_info)); memset(&btv->init_data, 0, sizeof(btv->init_data)); - strlcpy(info.type, "ir_video", I2C_NAME_SIZE); + strscpy(info.type, "ir_video", I2C_NAME_SIZE); switch (btv->c.type) { case BTTV_BOARD_PV951: diff --git a/drivers/media/pci/bt8xx/dvb-bt8xx.c b/drivers/media/pci/bt8xx/dvb-bt8xx.c index 2f810b7130e6..b46fbe557dd9 100644 --- a/drivers/media/pci/bt8xx/dvb-bt8xx.c +++ b/drivers/media/pci/bt8xx/dvb-bt8xx.c @@ -819,7 +819,8 @@ static int dvb_bt8xx_probe(struct bttv_sub_device *sub) mutex_init(&card->lock); card->bttv_nr = sub->core->nr; - strlcpy(card->card_name, sub->core->v4l2_dev.name, sizeof(card->card_name)); + strscpy(card->card_name, sub->core->v4l2_dev.name, + sizeof(card->card_name)); card->i2c_adapter = &sub->core->i2c_adap; switch(sub->core->type) { diff --git a/drivers/media/pci/cobalt/cobalt-alsa-main.c b/drivers/media/pci/cobalt/cobalt-alsa-main.c index e5022b620856..c57f87a68269 100644 --- a/drivers/media/pci/cobalt/cobalt-alsa-main.c +++ b/drivers/media/pci/cobalt/cobalt-alsa-main.c @@ -65,7 +65,7 @@ static int snd_cobalt_card_set_names(struct snd_cobalt_card *cobsc) struct snd_card *sc = cobsc->sc; /* sc->driver is used by alsa-lib's configurator: simple, unique */ - strlcpy(sc->driver, "cobalt", sizeof(sc->driver)); + strscpy(sc->driver, "cobalt", sizeof(sc->driver)); /* sc->shortname is a symlink in /proc/asound: COBALT-M -> cardN */ snprintf(sc->shortname, sizeof(sc->shortname), "cobalt-%d-%d", diff --git a/drivers/media/pci/cobalt/cobalt-alsa-pcm.c b/drivers/media/pci/cobalt/cobalt-alsa-pcm.c index f6a7df13cd04..38d00935a292 100644 --- a/drivers/media/pci/cobalt/cobalt-alsa-pcm.c +++ b/drivers/media/pci/cobalt/cobalt-alsa-pcm.c @@ -557,7 +557,7 @@ int snd_cobalt_pcm_create(struct snd_cobalt_card *cobsc) &snd_cobalt_pcm_capture_ops); sp->info_flags = 0; sp->private_data = cobsc; - strlcpy(sp->name, "cobalt", sizeof(sp->name)); + strscpy(sp->name, "cobalt", sizeof(sp->name)); } else { cobalt_s_bit_sysctrl(cobalt, COBALT_SYS_CTRL_AUDIO_OPP_RESETN_BIT, 0); @@ -581,7 +581,7 @@ int snd_cobalt_pcm_create(struct snd_cobalt_card *cobsc) &snd_cobalt_pcm_playback_ops); sp->info_flags = 0; sp->private_data = cobsc; - strlcpy(sp->name, "cobalt", sizeof(sp->name)); + strscpy(sp->name, "cobalt", sizeof(sp->name)); } return 0; diff --git a/drivers/media/pci/cobalt/cobalt-v4l2.c b/drivers/media/pci/cobalt/cobalt-v4l2.c index e2a4c705d353..0525f5e1565b 100644 --- a/drivers/media/pci/cobalt/cobalt-v4l2.c +++ b/drivers/media/pci/cobalt/cobalt-v4l2.c @@ -479,8 +479,8 @@ static int cobalt_querycap(struct file *file, void *priv_fh, struct cobalt_stream *s = video_drvdata(file); struct cobalt *cobalt = s->cobalt; - strlcpy(vcap->driver, "cobalt", sizeof(vcap->driver)); - strlcpy(vcap->card, "cobalt", sizeof(vcap->card)); + strscpy(vcap->driver, "cobalt", sizeof(vcap->driver)); + strscpy(vcap->card, "cobalt", sizeof(vcap->card)); snprintf(vcap->bus_info, sizeof(vcap->bus_info), "PCIe:%s", pci_name(cobalt->pci_dev)); vcap->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_READWRITE; @@ -693,15 +693,15 @@ static int cobalt_enum_fmt_vid_cap(struct file *file, void *priv_fh, { switch (f->index) { case 0: - strlcpy(f->description, "YUV 4:2:2", sizeof(f->description)); + strscpy(f->description, "YUV 4:2:2", sizeof(f->description)); f->pixelformat = V4L2_PIX_FMT_YUYV; break; case 1: - strlcpy(f->description, "RGB24", sizeof(f->description)); + strscpy(f->description, "RGB24", sizeof(f->description)); f->pixelformat = V4L2_PIX_FMT_RGB24; break; case 2: - strlcpy(f->description, "RGB32", sizeof(f->description)); + strscpy(f->description, "RGB32", sizeof(f->description)); f->pixelformat = V4L2_PIX_FMT_BGR32; break; default: @@ -898,11 +898,11 @@ static int cobalt_enum_fmt_vid_out(struct file *file, void *priv_fh, { switch (f->index) { case 0: - strlcpy(f->description, "YUV 4:2:2", sizeof(f->description)); + strscpy(f->description, "YUV 4:2:2", sizeof(f->description)); f->pixelformat = V4L2_PIX_FMT_YUYV; break; case 1: - strlcpy(f->description, "RGB32", sizeof(f->description)); + strscpy(f->description, "RGB32", sizeof(f->description)); f->pixelformat = V4L2_PIX_FMT_BGR32; break; default: @@ -1064,10 +1064,15 @@ static int cobalt_subscribe_event(struct v4l2_fh *fh, static int cobalt_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a) { + struct cobalt_stream *s = video_drvdata(file); + struct v4l2_fract fps; + if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) return -EINVAL; - a->parm.capture.timeperframe.numerator = 1; - a->parm.capture.timeperframe.denominator = 60; + + fps = v4l2_calc_timeperframe(&s->timings); + a->parm.capture.timeperframe.numerator = fps.numerator; + a->parm.capture.timeperframe.denominator = fps.denominator; a->parm.capture.readbuffers = 3; return 0; } diff --git a/drivers/media/pci/cx18/cx18-alsa-main.c b/drivers/media/pci/cx18/cx18-alsa-main.c index 93443d1457c5..687477748fdd 100644 --- a/drivers/media/pci/cx18/cx18-alsa-main.c +++ b/drivers/media/pci/cx18/cx18-alsa-main.c @@ -112,7 +112,7 @@ static int snd_cx18_card_set_names(struct snd_cx18_card *cxsc) struct snd_card *sc = cxsc->sc; /* sc->driver is used by alsa-lib's configurator: simple, unique */ - strlcpy(sc->driver, "CX23418", sizeof(sc->driver)); + strscpy(sc->driver, "CX23418", sizeof(sc->driver)); /* sc->shortname is a symlink in /proc/asound: CX18-M -> cardN */ snprintf(sc->shortname, sizeof(sc->shortname), "CX18-%d", diff --git a/drivers/media/pci/cx18/cx18-alsa-pcm.c b/drivers/media/pci/cx18/cx18-alsa-pcm.c index 4f31042a442a..3eafc27956c2 100644 --- a/drivers/media/pci/cx18/cx18-alsa-pcm.c +++ b/drivers/media/pci/cx18/cx18-alsa-pcm.c @@ -345,7 +345,7 @@ int snd_cx18_pcm_create(struct snd_cx18_card *cxsc) &snd_cx18_pcm_capture_ops); sp->info_flags = 0; sp->private_data = cxsc; - strlcpy(sp->name, cx->card_name, sizeof(sp->name)); + strscpy(sp->name, cx->card_name, sizeof(sp->name)); return 0; diff --git a/drivers/media/pci/cx18/cx18-cards.c b/drivers/media/pci/cx18/cx18-cards.c index c2cf965d639e..2dcbccfbd60d 100644 --- a/drivers/media/pci/cx18/cx18-cards.c +++ b/drivers/media/pci/cx18/cx18-cards.c @@ -602,8 +602,8 @@ int cx18_get_input(struct cx18 *cx, u16 index, struct v4l2_input *input) if (index >= cx->nof_inputs) return -EINVAL; input->index = index; - strlcpy(input->name, input_strs[card_input->video_type - 1], - sizeof(input->name)); + strscpy(input->name, input_strs[card_input->video_type - 1], + sizeof(input->name)); input->type = (card_input->video_type == CX18_CARD_INPUT_VID_TUNER ? V4L2_INPUT_TYPE_TUNER : V4L2_INPUT_TYPE_CAMERA); input->audioset = (1 << cx->nof_audio_inputs) - 1; @@ -625,8 +625,8 @@ int cx18_get_audio_input(struct cx18 *cx, u16 index, struct v4l2_audio *audio) memset(audio, 0, sizeof(*audio)); if (index >= cx->nof_audio_inputs) return -EINVAL; - strlcpy(audio->name, input_strs[aud_input->audio_type - 1], - sizeof(audio->name)); + strscpy(audio->name, input_strs[aud_input->audio_type - 1], + sizeof(audio->name)); audio->index = index; audio->capability = V4L2_AUDCAP_STEREO; return 0; diff --git a/drivers/media/pci/cx18/cx18-driver.c b/drivers/media/pci/cx18/cx18-driver.c index 0c389a3fb4e5..a6ba4ca5aa91 100644 --- a/drivers/media/pci/cx18/cx18-driver.c +++ b/drivers/media/pci/cx18/cx18-driver.c @@ -328,7 +328,7 @@ void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv) if (!c) return; - strlcpy(c->name, "cx18 tveeprom tmp", sizeof(c->name)); + strscpy(c->name, "cx18 tveeprom tmp", sizeof(c->name)); c->adapter = &cx->i2c_adap[0]; c->addr = 0xa0 >> 1; @@ -1252,7 +1252,7 @@ static void cx18_cancel_out_work_orders(struct cx18 *cx) { int i; for (i = 0; i < CX18_MAX_STREAMS; i++) - if (&cx->streams[i].video_dev) + if (cx->streams[i].video_dev.v4l2_dev) cancel_work_sync(&cx->streams[i].out_work_order); } diff --git a/drivers/media/pci/cx18/cx18-i2c.c b/drivers/media/pci/cx18/cx18-i2c.c index f0eb181f2b94..a89c666953f5 100644 --- a/drivers/media/pci/cx18/cx18-i2c.c +++ b/drivers/media/pci/cx18/cx18-i2c.c @@ -83,7 +83,7 @@ static int cx18_i2c_new_ir(struct cx18 *cx, struct i2c_adapter *adap, u32 hw, unsigned short addr_list[2] = { addr, I2C_CLIENT_END }; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, type, I2C_NAME_SIZE); + strscpy(info.type, type, I2C_NAME_SIZE); /* Our default information for ir-kbd-i2c.c to use */ switch (hw) { diff --git a/drivers/media/pci/cx18/cx18-ioctl.c b/drivers/media/pci/cx18/cx18-ioctl.c index 80b902b12a78..854116375a7c 100644 --- a/drivers/media/pci/cx18/cx18-ioctl.c +++ b/drivers/media/pci/cx18/cx18-ioctl.c @@ -397,8 +397,8 @@ static int cx18_querycap(struct file *file, void *fh, struct cx18_stream *s = video_drvdata(file); struct cx18 *cx = id->cx; - strlcpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver)); - strlcpy(vcap->card, cx->card_name, sizeof(vcap->card)); + strscpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver)); + strscpy(vcap->card, cx->card_name, sizeof(vcap->card)); snprintf(vcap->bus_info, sizeof(vcap->bus_info), "PCI:%s", pci_name(cx->pci_dev)); vcap->capabilities = cx->v4l2_cap; /* capabilities */ @@ -632,9 +632,9 @@ static int cx18_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt) cx18_call_all(cx, tuner, g_tuner, vt); if (vt->type == V4L2_TUNER_RADIO) - strlcpy(vt->name, "cx18 Radio Tuner", sizeof(vt->name)); + strscpy(vt->name, "cx18 Radio Tuner", sizeof(vt->name)); else - strlcpy(vt->name, "cx18 TV Tuner", sizeof(vt->name)); + strscpy(vt->name, "cx18 TV Tuner", sizeof(vt->name)); return 0; } diff --git a/drivers/media/pci/cx23885/altera-ci.c b/drivers/media/pci/cx23885/altera-ci.c index 62bc8049b320..198c05e83f5c 100644 --- a/drivers/media/pci/cx23885/altera-ci.c +++ b/drivers/media/pci/cx23885/altera-ci.c @@ -665,6 +665,10 @@ static int altera_hw_filt_init(struct altera_ci_config *config, int hw_filt_nr) } temp_int = append_internal(inter); + if (!temp_int) { + ret = -ENOMEM; + goto err; + } inter->filts_used = 1; inter->dev = config->dev; inter->fpga_rw = config->fpga_rw; @@ -699,6 +703,7 @@ err: __func__, ret); kfree(pid_filt); + kfree(inter); return ret; } @@ -733,6 +738,10 @@ int altera_ci_init(struct altera_ci_config *config, int ci_nr) } temp_int = append_internal(inter); + if (!temp_int) { + ret = -ENOMEM; + goto err; + } inter->cis_used = 1; inter->dev = config->dev; inter->fpga_rw = config->fpga_rw; @@ -801,6 +810,7 @@ err: ci_dbg_print("%s: Cannot initialize CI: Error %d.\n", __func__, ret); kfree(state); + kfree(inter); return ret; } diff --git a/drivers/media/pci/cx23885/cx23885-417.c b/drivers/media/pci/cx23885/cx23885-417.c index a71f3c7569ce..3083434bb636 100644 --- a/drivers/media/pci/cx23885/cx23885-417.c +++ b/drivers/media/pci/cx23885/cx23885-417.c @@ -1280,7 +1280,7 @@ static int vidioc_g_tuner(struct file *file, void *priv, return -EINVAL; if (0 != t->index) return -EINVAL; - strcpy(t->name, "Television"); + strscpy(t->name, "Television", sizeof(t->name)); call_all(dev, tuner, g_tuner, t); dprintk(1, "VIDIOC_G_TUNER: tuner type %d\n", t->type); @@ -1329,8 +1329,8 @@ static int vidioc_querycap(struct file *file, void *priv, struct cx23885_dev *dev = video_drvdata(file); struct cx23885_tsport *tsport = &dev->ts1; - strlcpy(cap->driver, dev->name, sizeof(cap->driver)); - strlcpy(cap->card, cx23885_boards[tsport->dev->board].name, + strscpy(cap->driver, dev->name, sizeof(cap->driver)); + strscpy(cap->card, cx23885_boards[tsport->dev->board].name, sizeof(cap->card)); sprintf(cap->bus_info, "PCIe:%s", pci_name(dev->pci)); cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | @@ -1349,7 +1349,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, if (f->index != 0) return -EINVAL; - strlcpy(f->description, "MPEG", sizeof(f->description)); + strscpy(f->description, "MPEG", sizeof(f->description)); f->pixelformat = V4L2_PIX_FMT_MPEG; return 0; diff --git a/drivers/media/pci/cx23885/cx23885-alsa.c b/drivers/media/pci/cx23885/cx23885-alsa.c index db1e8ff35474..ee9d329c4038 100644 --- a/drivers/media/pci/cx23885/cx23885-alsa.c +++ b/drivers/media/pci/cx23885/cx23885-alsa.c @@ -526,7 +526,7 @@ static int snd_cx23885_pcm(struct cx23885_audio_dev *chip, int device, if (err < 0) return err; pcm->private_data = chip; - strcpy(pcm->name, name); + strscpy(pcm->name, name, sizeof(pcm->name)); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cx23885_pcm_ops); return 0; @@ -571,7 +571,7 @@ struct cx23885_audio_dev *cx23885_audio_register(struct cx23885_dev *dev) if (err < 0) goto error; - strcpy(card->driver, "CX23885"); + strscpy(card->driver, "CX23885", sizeof(card->driver)); sprintf(card->shortname, "Conexant CX23885"); sprintf(card->longname, "%s at %s", card->shortname, dev->name); diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c index 7d52173073d6..0d0929c54f93 100644 --- a/drivers/media/pci/cx23885/cx23885-dvb.c +++ b/drivers/media/pci/cx23885/cx23885-dvb.c @@ -1165,7 +1165,7 @@ static int dvb_register_ci_mac(struct cx23885_tsport *port) sp2_config.priv = port; sp2_config.ci_control = cx23885_sp2_ci_ctrl; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "sp2", I2C_NAME_SIZE); + strscpy(info.type, "sp2", I2C_NAME_SIZE); info.addr = 0x40; info.platform_data = &sp2_config; request_module(info.type); @@ -1831,7 +1831,7 @@ static int dvb_register(struct cx23885_tsport *port) case 1: /* attach demod + tuner combo */ memset(&info, 0, sizeof(info)); - strlcpy(info.type, "tda10071_cx24118", I2C_NAME_SIZE); + strscpy(info.type, "tda10071_cx24118", I2C_NAME_SIZE); info.addr = 0x05; info.platform_data = &tda10071_pdata; request_module("tda10071"); @@ -1848,7 +1848,7 @@ static int dvb_register(struct cx23885_tsport *port) /* attach SEC */ a8293_pdata.dvb_frontend = fe0->dvb.frontend; memset(&info, 0, sizeof(info)); - strlcpy(info.type, "a8293", I2C_NAME_SIZE); + strscpy(info.type, "a8293", I2C_NAME_SIZE); info.addr = 0x0b; info.platform_data = &a8293_pdata; request_module("a8293"); @@ -1869,7 +1869,7 @@ static int dvb_register(struct cx23885_tsport *port) si2165_pdata.chip_mode = SI2165_MODE_PLL_XTAL; si2165_pdata.ref_freq_hz = 16000000; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2165", I2C_NAME_SIZE); + strscpy(info.type, "si2165", I2C_NAME_SIZE); info.addr = 0x64; info.platform_data = &si2165_pdata; request_module(info.type); @@ -1903,7 +1903,7 @@ static int dvb_register(struct cx23885_tsport *port) /* attach demod + tuner combo */ memset(&info, 0, sizeof(info)); - strlcpy(info.type, "tda10071_cx24118", I2C_NAME_SIZE); + strscpy(info.type, "tda10071_cx24118", I2C_NAME_SIZE); info.addr = 0x05; info.platform_data = &tda10071_pdata; request_module("tda10071"); @@ -1920,7 +1920,7 @@ static int dvb_register(struct cx23885_tsport *port) /* attach SEC */ a8293_pdata.dvb_frontend = fe0->dvb.frontend; memset(&info, 0, sizeof(info)); - strlcpy(info.type, "a8293", I2C_NAME_SIZE); + strscpy(info.type, "a8293", I2C_NAME_SIZE); info.addr = 0x0b; info.platform_data = &a8293_pdata; request_module("a8293"); @@ -1953,7 +1953,7 @@ static int dvb_register(struct cx23885_tsport *port) ts2020_config.fe = fe0->dvb.frontend; ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "ts2020", I2C_NAME_SIZE); + strscpy(info.type, "ts2020", I2C_NAME_SIZE); info.addr = 0x60; info.platform_data = &ts2020_config; request_module(info.type); @@ -1990,7 +1990,7 @@ static int dvb_register(struct cx23885_tsport *port) si2168_config.fe = &fe0->dvb.frontend; si2168_config.ts_mode = SI2168_TS_SERIAL; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2168", I2C_NAME_SIZE); + strscpy(info.type, "si2168", I2C_NAME_SIZE); info.addr = 0x64; info.platform_data = &si2168_config; request_module(info.type); @@ -2009,7 +2009,7 @@ static int dvb_register(struct cx23885_tsport *port) si2157_config.fe = fe0->dvb.frontend; si2157_config.if_port = 1; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2157", I2C_NAME_SIZE); + strscpy(info.type, "si2157", I2C_NAME_SIZE); info.addr = 0x60; info.platform_data = &si2157_config; request_module(info.type); @@ -2037,7 +2037,7 @@ static int dvb_register(struct cx23885_tsport *port) si2168_config.fe = &fe0->dvb.frontend; si2168_config.ts_mode = SI2168_TS_PARALLEL; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2168", I2C_NAME_SIZE); + strscpy(info.type, "si2168", I2C_NAME_SIZE); info.addr = 0x64; info.platform_data = &si2168_config; request_module(info.type); @@ -2055,7 +2055,7 @@ static int dvb_register(struct cx23885_tsport *port) si2157_config.fe = fe0->dvb.frontend; si2157_config.if_port = 1; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2157", I2C_NAME_SIZE); + strscpy(info.type, "si2157", I2C_NAME_SIZE); info.addr = 0x60; info.platform_data = &si2157_config; request_module(info.type); @@ -2085,7 +2085,7 @@ static int dvb_register(struct cx23885_tsport *port) ts2020_config.fe = fe0->dvb.frontend; ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "ts2020", I2C_NAME_SIZE); + strscpy(info.type, "ts2020", I2C_NAME_SIZE); info.addr = 0x60; info.platform_data = &ts2020_config; request_module(info.type); @@ -2134,7 +2134,7 @@ static int dvb_register(struct cx23885_tsport *port) } memset(&info, 0, sizeof(info)); - strlcpy(info.type, "m88ds3103", I2C_NAME_SIZE); + strscpy(info.type, "m88ds3103", I2C_NAME_SIZE); info.addr = 0x68; info.platform_data = &m88ds3103_pdata; request_module(info.type); @@ -2154,7 +2154,7 @@ static int dvb_register(struct cx23885_tsport *port) ts2020_config.fe = fe0->dvb.frontend; ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "ts2020", I2C_NAME_SIZE); + strscpy(info.type, "ts2020", I2C_NAME_SIZE); info.addr = 0x60; info.platform_data = &ts2020_config; request_module(info.type); @@ -2199,7 +2199,7 @@ static int dvb_register(struct cx23885_tsport *port) si2168_config.i2c_adapter = &adapter; si2168_config.fe = &fe0->dvb.frontend; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2168", I2C_NAME_SIZE); + strscpy(info.type, "si2168", I2C_NAME_SIZE); info.addr = 0x64; info.platform_data = &si2168_config; request_module(info.type); @@ -2217,7 +2217,7 @@ static int dvb_register(struct cx23885_tsport *port) si2157_config.fe = fe0->dvb.frontend; si2157_config.if_port = 1; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2157", I2C_NAME_SIZE); + strscpy(info.type, "si2157", I2C_NAME_SIZE); info.addr = 0x60; info.platform_data = &si2157_config; request_module(info.type); @@ -2250,7 +2250,7 @@ static int dvb_register(struct cx23885_tsport *port) /* attach SEC */ a8293_pdata.dvb_frontend = fe0->dvb.frontend; memset(&info, 0, sizeof(info)); - strlcpy(info.type, "a8293", I2C_NAME_SIZE); + strscpy(info.type, "a8293", I2C_NAME_SIZE); info.addr = 0x0b; info.platform_data = &a8293_pdata; request_module("a8293"); @@ -2267,7 +2267,7 @@ static int dvb_register(struct cx23885_tsport *port) memset(&m88rs6000t_config, 0, sizeof(m88rs6000t_config)); m88rs6000t_config.fe = fe0->dvb.frontend; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "m88rs6000t", I2C_NAME_SIZE); + strscpy(info.type, "m88rs6000t", I2C_NAME_SIZE); info.addr = 0x21; info.platform_data = &m88rs6000t_config; request_module("%s", info.type); @@ -2292,7 +2292,7 @@ static int dvb_register(struct cx23885_tsport *port) si2168_config.fe = &fe0->dvb.frontend; si2168_config.ts_mode = SI2168_TS_SERIAL; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2168", I2C_NAME_SIZE); + strscpy(info.type, "si2168", I2C_NAME_SIZE); info.addr = 0x64; info.platform_data = &si2168_config; request_module("%s", info.type); @@ -2310,7 +2310,7 @@ static int dvb_register(struct cx23885_tsport *port) si2157_config.fe = fe0->dvb.frontend; si2157_config.if_port = 1; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2157", I2C_NAME_SIZE); + strscpy(info.type, "si2157", I2C_NAME_SIZE); info.addr = 0x60; info.platform_data = &si2157_config; request_module("%s", info.type); @@ -2345,7 +2345,7 @@ static int dvb_register(struct cx23885_tsport *port) si2168_config.fe = &fe0->dvb.frontend; si2168_config.ts_mode = SI2168_TS_SERIAL; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2168", I2C_NAME_SIZE); + strscpy(info.type, "si2168", I2C_NAME_SIZE); info.addr = 0x64; info.platform_data = &si2168_config; request_module("%s", info.type); @@ -2363,7 +2363,7 @@ static int dvb_register(struct cx23885_tsport *port) si2157_config.fe = fe0->dvb.frontend; si2157_config.if_port = 1; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2157", I2C_NAME_SIZE); + strscpy(info.type, "si2157", I2C_NAME_SIZE); info.addr = 0x60; info.platform_data = &si2157_config; request_module("%s", info.type); @@ -2392,7 +2392,7 @@ static int dvb_register(struct cx23885_tsport *port) si2168_config.fe = &fe0->dvb.frontend; si2168_config.ts_mode = SI2168_TS_SERIAL; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2168", I2C_NAME_SIZE); + strscpy(info.type, "si2168", I2C_NAME_SIZE); info.addr = 0x66; info.platform_data = &si2168_config; request_module("%s", info.type); @@ -2410,7 +2410,7 @@ static int dvb_register(struct cx23885_tsport *port) si2157_config.fe = fe0->dvb.frontend; si2157_config.if_port = 1; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2157", I2C_NAME_SIZE); + strscpy(info.type, "si2157", I2C_NAME_SIZE); info.addr = 0x62; info.platform_data = &si2157_config; request_module("%s", info.type); @@ -2452,7 +2452,7 @@ static int dvb_register(struct cx23885_tsport *port) si2157_config.if_port = 1; si2157_config.inversion = 1; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2157", I2C_NAME_SIZE); + strscpy(info.type, "si2157", I2C_NAME_SIZE); info.addr = 0x60; info.platform_data = &si2157_config; request_module("%s", info.type); @@ -2488,7 +2488,7 @@ static int dvb_register(struct cx23885_tsport *port) si2157_config.if_port = 1; si2157_config.inversion = 1; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2157", I2C_NAME_SIZE); + strscpy(info.type, "si2157", I2C_NAME_SIZE); info.addr = 0x62; info.platform_data = &si2157_config; request_module("%s", info.type); @@ -2528,7 +2528,7 @@ static int dvb_register(struct cx23885_tsport *port) si2157_config.if_port = 1; si2157_config.inversion = 1; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2157", I2C_NAME_SIZE); + strscpy(info.type, "si2157", I2C_NAME_SIZE); info.addr = 0x60; info.platform_data = &si2157_config; request_module("%s", info.type); diff --git a/drivers/media/pci/cx23885/cx23885-i2c.c b/drivers/media/pci/cx23885/cx23885-i2c.c index ef863492c0ac..d0df3dfff694 100644 --- a/drivers/media/pci/cx23885/cx23885-i2c.c +++ b/drivers/media/pci/cx23885/cx23885-i2c.c @@ -317,7 +317,7 @@ int cx23885_i2c_register(struct cx23885_i2c *bus) bus->i2c_client = cx23885_i2c_client_template; bus->i2c_adap.dev.parent = &dev->pci->dev; - strlcpy(bus->i2c_adap.name, bus->dev->name, + strscpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name)); bus->i2c_adap.algo_data = bus; @@ -340,12 +340,12 @@ int cx23885_i2c_register(struct cx23885_i2c *bus) /* Instantiate the IR receiver device, if present */ if (0 == bus->i2c_rc) { struct i2c_board_info info; - const unsigned short addr_list[] = { + static const unsigned short addr_list[] = { 0x6b, I2C_CLIENT_END }; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "ir_video", I2C_NAME_SIZE); + strscpy(info.type, "ir_video", I2C_NAME_SIZE); /* Use quick read command for probe, some IR chips don't * support writes */ i2c_new_probed_device(&bus->i2c_adap, &info, addr_list, diff --git a/drivers/media/pci/cx23885/cx23885-ioctl.c b/drivers/media/pci/cx23885/cx23885-ioctl.c index d2cdd40f79f5..d162bf4b4800 100644 --- a/drivers/media/pci/cx23885/cx23885-ioctl.c +++ b/drivers/media/pci/cx23885/cx23885-ioctl.c @@ -31,9 +31,9 @@ int cx23885_g_chip_info(struct file *file, void *fh, if (chip->match.addr == 1) { if (dev->v4l_device == NULL) return -EINVAL; - strlcpy(chip->name, "cx23417", sizeof(chip->name)); + strscpy(chip->name, "cx23417", sizeof(chip->name)); } else { - strlcpy(chip->name, dev->v4l2_dev.name, sizeof(chip->name)); + strscpy(chip->name, dev->v4l2_dev.name, sizeof(chip->name)); } return 0; } diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c index f8a3deadc77a..92d32a733f1b 100644 --- a/drivers/media/pci/cx23885/cx23885-video.c +++ b/drivers/media/pci/cx23885/cx23885-video.c @@ -639,8 +639,8 @@ static int vidioc_querycap(struct file *file, void *priv, struct cx23885_dev *dev = video_drvdata(file); struct video_device *vdev = video_devdata(file); - strcpy(cap->driver, "cx23885"); - strlcpy(cap->card, cx23885_boards[dev->board].name, + strscpy(cap->driver, "cx23885", sizeof(cap->driver)); + strscpy(cap->card, cx23885_boards[dev->board].name, sizeof(cap->card)); sprintf(cap->bus_info, "PCIe:%s", pci_name(dev->pci)); cap->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | V4L2_CAP_AUDIO; @@ -661,7 +661,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, if (unlikely(f->index >= ARRAY_SIZE(formats))) return -EINVAL; - strlcpy(f->description, formats[f->index].name, + strscpy(f->description, formats[f->index].name, sizeof(f->description)); f->pixelformat = formats[f->index].fourcc; @@ -731,7 +731,7 @@ int cx23885_enum_input(struct cx23885_dev *dev, struct v4l2_input *i) i->index = n; i->type = V4L2_INPUT_TYPE_CAMERA; - strcpy(i->name, iname[INPUT(n)->type]); + strscpy(i->name, iname[INPUT(n)->type], sizeof(i->name)); i->std = CX23885_NORMS; if ((CX23885_VMUX_TELEVISION == INPUT(n)->type) || (CX23885_VMUX_CABLE == INPUT(n)->type)) { @@ -828,7 +828,7 @@ static int cx23885_query_audinput(struct file *file, void *priv, memset(i, 0, sizeof(*i)); i->index = n; - strcpy(i->name, iname[n]); + strscpy(i->name, iname[n], sizeof(i->name)); i->capability = V4L2_AUDCAP_STEREO; return 0; @@ -887,7 +887,7 @@ static int vidioc_g_tuner(struct file *file, void *priv, if (0 != t->index) return -EINVAL; - strcpy(t->name, "Television"); + strscpy(t->name, "Television", sizeof(t->name)); call_all(dev, tuner, g_tuner, t); return 0; @@ -1186,7 +1186,8 @@ int cx23885_video_register(struct cx23885_dev *dev) /* Initialize VBI template */ cx23885_vbi_template = cx23885_video_template; - strcpy(cx23885_vbi_template.name, "cx23885-vbi"); + strscpy(cx23885_vbi_template.name, "cx23885-vbi", + sizeof(cx23885_vbi_template.name)); dev->tvnorm = V4L2_STD_NTSC_M; dev->fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV); diff --git a/drivers/media/pci/cx23885/cx23888-ir.c b/drivers/media/pci/cx23885/cx23888-ir.c index 00329f668b59..1d775c90df51 100644 --- a/drivers/media/pci/cx23885/cx23888-ir.c +++ b/drivers/media/pci/cx23885/cx23888-ir.c @@ -696,10 +696,8 @@ static int cx23888_ir_rx_read(struct v4l2_subdev *sd, u8 *buf, size_t count, if (v > IR_MAX_DURATION) v = IR_MAX_DURATION; - init_ir_raw_event(&p->ir_core_data); - p->ir_core_data.pulse = u; - p->ir_core_data.duration = v; - p->ir_core_data.timeout = w; + p->ir_core_data = (struct ir_raw_event) + { .pulse = u, .duration = v, .timeout = w }; v4l2_dbg(2, ir_888_debug, sd, "rx read: %10u ns %s %s\n", v, u ? "mark" : "space", w ? "(timed out)" : ""); diff --git a/drivers/media/pci/cx25821/cx25821-alsa.c b/drivers/media/pci/cx25821/cx25821-alsa.c index ef6380651c10..0a6c90e92557 100644 --- a/drivers/media/pci/cx25821/cx25821-alsa.c +++ b/drivers/media/pci/cx25821/cx25821-alsa.c @@ -674,7 +674,7 @@ static int snd_cx25821_pcm(struct cx25821_audio_dev *chip, int device, } pcm->private_data = chip; pcm->info_flags = 0; - strcpy(pcm->name, name); + strscpy(pcm->name, name, sizeof(pcm->name)); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cx25821_pcm_ops); return 0; @@ -725,7 +725,7 @@ static int cx25821_audio_initdev(struct cx25821_dev *dev) return err; } - strcpy(card->driver, "cx25821"); + strscpy(card->driver, "cx25821", sizeof(card->driver)); /* Card "creation" */ chip = card->private_data; @@ -754,10 +754,10 @@ static int cx25821_audio_initdev(struct cx25821_dev *dev) goto error; } - strcpy(card->shortname, "cx25821"); + strscpy(card->shortname, "cx25821", sizeof(card->shortname)); sprintf(card->longname, "%s at 0x%lx irq %d", chip->dev->name, chip->iobase, chip->irq); - strcpy(card->mixername, "CX25821"); + strscpy(card->mixername, "CX25821", sizeof(card->mixername)); pr_info("%s/%i: ALSA support for cx25821 boards\n", card->driver, devno); diff --git a/drivers/media/pci/cx25821/cx25821-i2c.c b/drivers/media/pci/cx25821/cx25821-i2c.c index 31479a41f359..67d2f7610011 100644 --- a/drivers/media/pci/cx25821/cx25821-i2c.c +++ b/drivers/media/pci/cx25821/cx25821-i2c.c @@ -306,7 +306,7 @@ int cx25821_i2c_register(struct cx25821_i2c *bus) bus->i2c_client = cx25821_i2c_client_template; bus->i2c_adap.dev.parent = &dev->pci->dev; - strlcpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name)); + strscpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name)); bus->i2c_adap.algo_data = bus; i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev); diff --git a/drivers/media/pci/cx25821/cx25821-video.c b/drivers/media/pci/cx25821/cx25821-video.c index dbaf42ec26cd..3d23c2e64102 100644 --- a/drivers/media/pci/cx25821/cx25821-video.c +++ b/drivers/media/pci/cx25821/cx25821-video.c @@ -322,7 +322,7 @@ static int cx25821_vidioc_enum_fmt_vid_cap(struct file *file, void *priv, if (unlikely(f->index >= ARRAY_SIZE(formats))) return -EINVAL; - strlcpy(f->description, formats[f->index].name, sizeof(f->description)); + strscpy(f->description, formats[f->index].name, sizeof(f->description)); f->pixelformat = formats[f->index].fourcc; return 0; @@ -441,8 +441,8 @@ static int cx25821_vidioc_querycap(struct file *file, void *priv, V4L2_CAP_READWRITE | V4L2_CAP_STREAMING; const u32 cap_output = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_READWRITE; - strcpy(cap->driver, "cx25821"); - strlcpy(cap->card, cx25821_boards[dev->board].name, sizeof(cap->card)); + strscpy(cap->driver, "cx25821", sizeof(cap->driver)); + strscpy(cap->card, cx25821_boards[dev->board].name, sizeof(cap->card)); sprintf(cap->bus_info, "PCIe:%s", pci_name(dev->pci)); if (chan->id >= VID_CHANNEL_NUM) cap->device_caps = cap_output; @@ -486,7 +486,7 @@ static int cx25821_vidioc_enum_input(struct file *file, void *priv, i->type = V4L2_INPUT_TYPE_CAMERA; i->std = CX25821_NORMS; - strcpy(i->name, "Composite"); + strscpy(i->name, "Composite", sizeof(i->name)); return 0; } @@ -534,7 +534,7 @@ static int cx25821_vidioc_enum_output(struct file *file, void *priv, o->type = V4L2_INPUT_TYPE_CAMERA; o->std = CX25821_NORMS; - strcpy(o->name, "Composite"); + strscpy(o->name, "Composite", sizeof(o->name)); return 0; } diff --git a/drivers/media/pci/cx88/cx88-alsa.c b/drivers/media/pci/cx88/cx88-alsa.c index 89a65478ae36..b683cbe13dee 100644 --- a/drivers/media/pci/cx88/cx88-alsa.c +++ b/drivers/media/pci/cx88/cx88-alsa.c @@ -616,7 +616,7 @@ static int snd_cx88_pcm(struct cx88_audio_dev *chip, int device, if (err < 0) return err; pcm->private_data = chip; - strcpy(pcm->name, name); + strscpy(pcm->name, name, sizeof(pcm->name)); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cx88_pcm_ops); return 0; @@ -968,12 +968,12 @@ static int cx88_audio_initdev(struct pci_dev *pci, goto error; } - strcpy(card->driver, "CX88x"); + strscpy(card->driver, "CX88x", sizeof(card->driver)); sprintf(card->shortname, "Conexant CX%x", pci->device); sprintf(card->longname, "%s at %#llx", card->shortname, (unsigned long long)pci_resource_start(pci, 0)); - strcpy(card->mixername, "CX88"); + strscpy(card->mixername, "CX88", sizeof(card->mixername)); dprintk(0, "%s/%i: ALSA support for cx2388x boards\n", card->driver, devno); diff --git a/drivers/media/pci/cx88/cx88-blackbird.c b/drivers/media/pci/cx88/cx88-blackbird.c index 7a4876cf9f08..199756547f03 100644 --- a/drivers/media/pci/cx88/cx88-blackbird.c +++ b/drivers/media/pci/cx88/cx88-blackbird.c @@ -803,7 +803,7 @@ static int vidioc_querycap(struct file *file, void *priv, struct cx8802_dev *dev = video_drvdata(file); struct cx88_core *core = dev->core; - strcpy(cap->driver, "cx88_blackbird"); + strscpy(cap->driver, "cx88_blackbird", sizeof(cap->driver)); sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci)); return cx88_querycap(file, core, cap); } @@ -814,7 +814,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, if (f->index != 0) return -EINVAL; - strlcpy(f->description, "MPEG", sizeof(f->description)); + strscpy(f->description, "MPEG", sizeof(f->description)); f->pixelformat = V4L2_PIX_FMT_MPEG; f->flags = V4L2_FMT_FLAG_COMPRESSED; return 0; @@ -995,7 +995,7 @@ static int vidioc_g_tuner(struct file *file, void *priv, if (t->index != 0) return -EINVAL; - strcpy(t->name, "Television"); + strscpy(t->name, "Television", sizeof(t->name)); t->capability = V4L2_TUNER_CAP_NORM; t->rangehigh = 0xffffffffUL; call_all(core, tuner, g_tuner, t); diff --git a/drivers/media/pci/cx88/cx88-cards.c b/drivers/media/pci/cx88/cx88-cards.c index 07e1483e987d..382af90fd4a9 100644 --- a/drivers/media/pci/cx88/cx88-cards.c +++ b/drivers/media/pci/cx88/cx88-cards.c @@ -3693,7 +3693,7 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) core->height = 240; core->field = V4L2_FIELD_INTERLACED; - strcpy(core->v4l2_dev.name, core->name); + strscpy(core->v4l2_dev.name, core->name, sizeof(core->v4l2_dev.name)); if (v4l2_device_register(NULL, &core->v4l2_dev)) { kfree(core); return NULL; diff --git a/drivers/media/pci/cx88/cx88-i2c.c b/drivers/media/pci/cx88/cx88-i2c.c index 99f88a05a7c9..48be0b0ad680 100644 --- a/drivers/media/pci/cx88/cx88-i2c.c +++ b/drivers/media/pci/cx88/cx88-i2c.c @@ -140,14 +140,14 @@ int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci) core->i2c_algo = cx8800_i2c_algo_template; core->i2c_adap.dev.parent = &pci->dev; - strlcpy(core->i2c_adap.name, core->name, sizeof(core->i2c_adap.name)); + strscpy(core->i2c_adap.name, core->name, sizeof(core->i2c_adap.name)); core->i2c_adap.owner = THIS_MODULE; core->i2c_algo.udelay = i2c_udelay; core->i2c_algo.data = core; i2c_set_adapdata(&core->i2c_adap, &core->v4l2_dev); core->i2c_adap.algo_data = &core->i2c_algo; core->i2c_client.adapter = &core->i2c_adap; - strlcpy(core->i2c_client.name, "cx88xx internal", I2C_NAME_SIZE); + strscpy(core->i2c_client.name, "cx88xx internal", I2C_NAME_SIZE); cx8800_bit_setscl(core, 1); cx8800_bit_setsda(core, 1); diff --git a/drivers/media/pci/cx88/cx88-input.c b/drivers/media/pci/cx88/cx88-input.c index 2f5debce4905..ca76da04b476 100644 --- a/drivers/media/pci/cx88/cx88-input.c +++ b/drivers/media/pci/cx88/cx88-input.c @@ -535,7 +535,7 @@ void cx88_ir_irq(struct cx88_core *core) struct cx88_IR *ir = core->ir; u32 samples; unsigned int todo, bits; - struct ir_raw_event ev; + struct ir_raw_event ev = {}; if (!ir || !ir->sampling) return; @@ -550,7 +550,6 @@ void cx88_ir_irq(struct cx88_core *core) if (samples == 0xff && ir->dev->idle) return; - init_ir_raw_event(&ev); for (todo = 32; todo > 0; todo -= bits) { ev.pulse = samples & 0x80000000 ? false : true; bits = min(todo, 32U - fls(ev.pulse ? samples : ~samples)); @@ -610,7 +609,7 @@ void cx88_i2c_init_ir(struct cx88_core *core) return; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "ir_video", I2C_NAME_SIZE); + strscpy(info.type, "ir_video", I2C_NAME_SIZE); switch (core->boardnr) { case CX88_BOARD_LEADTEK_PVR2000: @@ -635,7 +634,7 @@ void cx88_i2c_init_ir(struct cx88_core *core) if (*addrp == 0x71) { /* Hauppauge Z8F0811 */ - strlcpy(info.type, "ir_z8f0811_haup", I2C_NAME_SIZE); + strscpy(info.type, "ir_z8f0811_haup", I2C_NAME_SIZE); core->init_data.name = core->board.name; core->init_data.ir_codes = RC_MAP_HAUPPAUGE; core->init_data.type = RC_PROTO_BIT_RC5 | diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c index 7b113bad70d2..df4e7a0686e0 100644 --- a/drivers/media/pci/cx88/cx88-video.c +++ b/drivers/media/pci/cx88/cx88-video.c @@ -811,7 +811,7 @@ int cx88_querycap(struct file *file, struct cx88_core *core, { struct video_device *vdev = video_devdata(file); - strlcpy(cap->card, core->board.name, sizeof(cap->card)); + strscpy(cap->card, core->board.name, sizeof(cap->card)); cap->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING; if (core->board.tuner_type != UNSET) cap->device_caps |= V4L2_CAP_TUNER; @@ -842,7 +842,7 @@ static int vidioc_querycap(struct file *file, void *priv, struct cx8800_dev *dev = video_drvdata(file); struct cx88_core *core = dev->core; - strcpy(cap->driver, "cx8800"); + strscpy(cap->driver, "cx8800", sizeof(cap->driver)); sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci)); return cx88_querycap(file, core, cap); } @@ -853,7 +853,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, if (unlikely(f->index >= ARRAY_SIZE(formats))) return -EINVAL; - strlcpy(f->description, formats[f->index].name, sizeof(f->description)); + strscpy(f->description, formats[f->index].name, sizeof(f->description)); f->pixelformat = formats[f->index].fourcc; return 0; @@ -897,7 +897,7 @@ int cx88_enum_input(struct cx88_core *core, struct v4l2_input *i) if (!INPUT(n).type) return -EINVAL; i->type = V4L2_INPUT_TYPE_CAMERA; - strcpy(i->name, iname[INPUT(n).type]); + strscpy(i->name, iname[INPUT(n).type], sizeof(i->name)); if ((INPUT(n).type == CX88_VMUX_TELEVISION) || (INPUT(n).type == CX88_VMUX_CABLE)) i->type = V4L2_INPUT_TYPE_TUNER; @@ -952,7 +952,7 @@ static int vidioc_g_tuner(struct file *file, void *priv, if (t->index != 0) return -EINVAL; - strcpy(t->name, "Television"); + strscpy(t->name, "Television", sizeof(t->name)); t->capability = V4L2_TUNER_CAP_NORM; t->rangehigh = 0xffffffffUL; call_all(core, tuner, g_tuner, t); @@ -1065,7 +1065,7 @@ static int radio_g_tuner(struct file *file, void *priv, if (unlikely(t->index > 0)) return -EINVAL; - strcpy(t->name, "Radio"); + strscpy(t->name, "Radio", sizeof(t->name)); call_all(core, tuner, g_tuner, t); return 0; diff --git a/drivers/media/pci/cx88/cx88-vp3054-i2c.c b/drivers/media/pci/cx88/cx88-vp3054-i2c.c index 92876de3841c..e4db636e9fad 100644 --- a/drivers/media/pci/cx88/cx88-vp3054-i2c.c +++ b/drivers/media/pci/cx88/cx88-vp3054-i2c.c @@ -114,7 +114,7 @@ int vp3054_i2c_probe(struct cx8802_dev *dev) vp3054_i2c->algo = vp3054_i2c_algo_template; vp3054_i2c->adap.dev.parent = &dev->pci->dev; - strlcpy(vp3054_i2c->adap.name, core->name, + strscpy(vp3054_i2c->adap.name, core->name, sizeof(vp3054_i2c->adap.name)); vp3054_i2c->adap.owner = THIS_MODULE; vp3054_i2c->algo.data = dev; diff --git a/drivers/media/pci/ddbridge/ddbridge-ci.c b/drivers/media/pci/ddbridge/ddbridge-ci.c index cfe23d02e561..377991095aba 100644 --- a/drivers/media/pci/ddbridge/ddbridge-ci.c +++ b/drivers/media/pci/ddbridge/ddbridge-ci.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * ddbridge-ci.c: Digital Devices bridge CI (DuoFlex, CI Bridge) support * @@ -13,9 +14,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * To obtain the license, point your browser to - * http://www.gnu.org/copyleft/gpl.html */ #include "ddbridge.h" diff --git a/drivers/media/pci/ddbridge/ddbridge-ci.h b/drivers/media/pci/ddbridge/ddbridge-ci.h index 35a39182dd83..cc98656af349 100644 --- a/drivers/media/pci/ddbridge/ddbridge-ci.h +++ b/drivers/media/pci/ddbridge/ddbridge-ci.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * ddbridge-ci.h: Digital Devices bridge CI (DuoFlex, CI Bridge) support * @@ -13,9 +14,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * To obtain the license, point your browser to - * http://www.gnu.org/copyleft/gpl.html */ #ifndef __DDBRIDGE_CI_H__ diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index c1b982e8e6c9..7a2d19682fe3 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * ddbridge-core.c: Digital Devices bridge core functions * @@ -5,19 +6,14 @@ * Marcus Metzler <mocm@metzlerbros.de> * Ralph Metzler <rjkm@metzlerbros.de> * - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 only, as published by the Free Software Foundation. * - * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * To obtain the license, point your browser to - * http://www.gnu.org/copyleft/gpl.html */ #include <linux/module.h> diff --git a/drivers/media/pci/ddbridge/ddbridge-hw.c b/drivers/media/pci/ddbridge/ddbridge-hw.c index f3cbac07b41f..f9c91bdbd041 100644 --- a/drivers/media/pci/ddbridge/ddbridge-hw.c +++ b/drivers/media/pci/ddbridge/ddbridge-hw.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * ddbridge-hw.c: Digital Devices bridge hardware maps * @@ -13,7 +14,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * */ #include "ddbridge.h" diff --git a/drivers/media/pci/ddbridge/ddbridge-hw.h b/drivers/media/pci/ddbridge/ddbridge-hw.h index 7c142419419c..e34bd94c266b 100644 --- a/drivers/media/pci/ddbridge/ddbridge-hw.h +++ b/drivers/media/pci/ddbridge/ddbridge-hw.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * ddbridge-hw.h: Digital Devices bridge hardware maps * @@ -13,7 +14,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * */ #ifndef _DDBRIDGE_HW_H_ diff --git a/drivers/media/pci/ddbridge/ddbridge-i2c.c b/drivers/media/pci/ddbridge/ddbridge-i2c.c index 5a28d7611713..aafa6030c8cc 100644 --- a/drivers/media/pci/ddbridge/ddbridge-i2c.c +++ b/drivers/media/pci/ddbridge/ddbridge-i2c.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * ddbridge-i2c.c: Digital Devices bridge i2c driver * @@ -13,7 +14,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * */ #include <linux/module.h> diff --git a/drivers/media/pci/ddbridge/ddbridge-i2c.h b/drivers/media/pci/ddbridge/ddbridge-i2c.h index 7ed220506c05..90830f7b1638 100644 --- a/drivers/media/pci/ddbridge/ddbridge-i2c.h +++ b/drivers/media/pci/ddbridge/ddbridge-i2c.h @@ -1,5 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* - * ddbridge-i2c.c: Digital Devices bridge i2c driver + * ddbridge-i2c.h: Digital Devices bridge i2c driver * * Copyright (C) 2010-2017 Digital Devices GmbH * Ralph Metzler <rjkm@metzlerbros.de> @@ -13,7 +14,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * */ #ifndef __DDBRIDGE_I2C_H__ diff --git a/drivers/media/pci/ddbridge/ddbridge-io.h b/drivers/media/pci/ddbridge/ddbridge-io.h index b3646c04f1a7..1a5b31b52494 100644 --- a/drivers/media/pci/ddbridge/ddbridge-io.h +++ b/drivers/media/pci/ddbridge/ddbridge-io.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * ddbridge-io.h: Digital Devices bridge I/O inline functions * @@ -13,7 +14,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * */ #ifndef __DDBRIDGE_IO_H__ diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c b/drivers/media/pci/ddbridge/ddbridge-main.c index f4748cfd904b..03dc9924fa2c 100644 --- a/drivers/media/pci/ddbridge/ddbridge-main.c +++ b/drivers/media/pci/ddbridge/ddbridge-main.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * ddbridge.c: Digital Devices PCIe bridge driver * @@ -13,7 +14,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt @@ -318,5 +318,5 @@ module_exit(module_exit_ddbridge); MODULE_DESCRIPTION("Digital Devices PCIe Bridge"); MODULE_AUTHOR("Ralph and Marcus Metzler, Metzler Brothers Systementwicklung GbR"); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); MODULE_VERSION(DDBRIDGE_VERSION); diff --git a/drivers/media/pci/ddbridge/ddbridge-max.c b/drivers/media/pci/ddbridge/ddbridge-max.c index 8da1c7b91577..576dd2318e4d 100644 --- a/drivers/media/pci/ddbridge/ddbridge-max.c +++ b/drivers/media/pci/ddbridge/ddbridge-max.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * ddbridge-max.c: Digital Devices bridge MAX card support * @@ -13,7 +14,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * */ #include <linux/module.h> diff --git a/drivers/media/pci/ddbridge/ddbridge-max.h b/drivers/media/pci/ddbridge/ddbridge-max.h index 9838c73973b6..6543dfc77138 100644 --- a/drivers/media/pci/ddbridge/ddbridge-max.h +++ b/drivers/media/pci/ddbridge/ddbridge-max.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * ddbridge-max.h: Digital Devices bridge MAX card support * @@ -13,7 +14,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * */ #ifndef _DDBRIDGE_MAX_H_ diff --git a/drivers/media/pci/ddbridge/ddbridge-regs.h b/drivers/media/pci/ddbridge/ddbridge-regs.h index f9e1cbb99b53..2942a7f35099 100644 --- a/drivers/media/pci/ddbridge/ddbridge-regs.h +++ b/drivers/media/pci/ddbridge/ddbridge-regs.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * ddbridge-regs.h: Digital Devices PCIe bridge driver * @@ -7,14 +8,10 @@ * modify it under the terms of the GNU General Public License * version 2 only, as published by the Free Software Foundation. * - * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * To obtain the license, point your browser to - * http://www.gnu.org/copyleft/gpl.html */ #ifndef __DDBRIDGE_REGS_H__ diff --git a/drivers/media/pci/ddbridge/ddbridge-sx8.c b/drivers/media/pci/ddbridge/ddbridge-sx8.c index 64f05f5ee039..374fcee94960 100644 --- a/drivers/media/pci/ddbridge/ddbridge-sx8.c +++ b/drivers/media/pci/ddbridge/ddbridge-sx8.c @@ -398,9 +398,7 @@ static int set_parameters(struct dvb_frontend *fe) } stat = start(fe, 3, mask, ts_config); } else { - u32 flags = (iq_mode == 2) ? 1 : 0; - - stat = start_iq(fe, flags, 4, ts_config); + stat = start_iq(fe, 0, 4, ts_config); } if (!stat) { state->started = 1; diff --git a/drivers/media/pci/ddbridge/ddbridge.h b/drivers/media/pci/ddbridge/ddbridge.h index 8a354dfb6c22..f137155bf79e 100644 --- a/drivers/media/pci/ddbridge/ddbridge.h +++ b/drivers/media/pci/ddbridge/ddbridge.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * ddbridge.h: Digital Devices PCIe bridge driver * @@ -8,14 +9,10 @@ * modify it under the terms of the GNU General Public License * version 2 only, as published by the Free Software Foundation. * - * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * To obtain the license, point your browser to - * http://www.gnu.org/copyleft/gpl.html */ #ifndef _DDBRIDGE_H_ diff --git a/drivers/media/pci/dm1105/dm1105.c b/drivers/media/pci/dm1105/dm1105.c index 1ddb0576fb7b..a84c8270ea13 100644 --- a/drivers/media/pci/dm1105/dm1105.c +++ b/drivers/media/pci/dm1105/dm1105.c @@ -1046,7 +1046,7 @@ static int dm1105_probe(struct pci_dev *pdev, /* i2c */ i2c_set_adapdata(&dev->i2c_adap, dev); - strcpy(dev->i2c_adap.name, DRIVER_NAME); + strscpy(dev->i2c_adap.name, DRIVER_NAME, sizeof(dev->i2c_adap.name)); dev->i2c_adap.owner = THIS_MODULE; dev->i2c_adap.dev.parent = &pdev->dev; dev->i2c_adap.algo = &dm1105_algo; @@ -1057,7 +1057,8 @@ static int dm1105_probe(struct pci_dev *pdev, goto err_dm1105_hw_exit; i2c_set_adapdata(&dev->i2c_bb_adap, dev); - strcpy(dev->i2c_bb_adap.name, DM1105_I2C_GPIO_NAME); + strscpy(dev->i2c_bb_adap.name, DM1105_I2C_GPIO_NAME, + sizeof(dev->i2c_bb_adap.name)); dev->i2c_bb_adap.owner = THIS_MODULE; dev->i2c_bb_adap.dev.parent = &pdev->dev; dev->i2c_bb_adap.algo_data = &dev->i2c_bit; diff --git a/drivers/media/pci/dt3155/dt3155.c b/drivers/media/pci/dt3155/dt3155.c index 1775c36891ae..17d69bd5d7f1 100644 --- a/drivers/media/pci/dt3155/dt3155.c +++ b/drivers/media/pci/dt3155/dt3155.c @@ -307,8 +307,8 @@ static int dt3155_querycap(struct file *filp, void *p, { struct dt3155_priv *pd = video_drvdata(filp); - strcpy(cap->driver, DT3155_NAME); - strcpy(cap->card, DT3155_NAME " frame grabber"); + strscpy(cap->driver, DT3155_NAME, sizeof(cap->driver)); + strscpy(cap->card, DT3155_NAME " frame grabber", sizeof(cap->card)); sprintf(cap->bus_info, "PCI:%s", pci_name(pd->pdev)); cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | V4L2_CAP_READWRITE; @@ -322,7 +322,7 @@ static int dt3155_enum_fmt_vid_cap(struct file *filp, if (f->index) return -EINVAL; f->pixelformat = V4L2_PIX_FMT_GREY; - strcpy(f->description, "8-bit Greyscale"); + strscpy(f->description, "8-bit Greyscale", sizeof(f->description)); return 0; } @@ -378,7 +378,7 @@ static int dt3155_enum_input(struct file *filp, void *p, snprintf(input->name, sizeof(input->name), "VID%d", input->index); else - strlcpy(input->name, "J2/VID0", sizeof(input->name)); + strscpy(input->name, "J2/VID0", sizeof(input->name)); input->type = V4L2_INPUT_TYPE_CAMERA; input->std = V4L2_STD_ALL; input->status = 0; diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c index 29027159eced..452eb9b42140 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c @@ -218,13 +218,11 @@ static int cio2_fbpt_init(struct cio2_device *cio2, struct cio2_queue *q) { struct device *dev = &cio2->pci_dev->dev; - q->fbpt = dma_alloc_coherent(dev, CIO2_FBPT_SIZE, &q->fbpt_bus_addr, - GFP_KERNEL); + q->fbpt = dma_zalloc_coherent(dev, CIO2_FBPT_SIZE, &q->fbpt_bus_addr, + GFP_KERNEL); if (!q->fbpt) return -ENOMEM; - memset(q->fbpt, 0, CIO2_FBPT_SIZE); - return 0; } @@ -1066,8 +1064,8 @@ static int cio2_v4l2_querycap(struct file *file, void *fh, { struct cio2_device *cio2 = video_drvdata(file); - strlcpy(cap->driver, CIO2_NAME, sizeof(cap->driver)); - strlcpy(cap->card, CIO2_DEVICE_NAME, sizeof(cap->card)); + strscpy(cap->driver, CIO2_NAME, sizeof(cap->driver)); + strscpy(cap->card, CIO2_DEVICE_NAME, sizeof(cap->card)); snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", pci_name(cio2->pci_dev)); @@ -1145,7 +1143,7 @@ cio2_video_enum_input(struct file *file, void *fh, struct v4l2_input *input) if (input->index > 0) return -EINVAL; - strlcpy(input->name, "camera", sizeof(input->name)); + strscpy(input->name, "camera", sizeof(input->name)); input->type = V4L2_INPUT_TYPE_CAMERA; return 0; @@ -1435,13 +1433,13 @@ static int cio2_notifier_complete(struct v4l2_async_notifier *notifier) struct cio2_device *cio2 = container_of(notifier, struct cio2_device, notifier); struct sensor_async_subdev *s_asd; + struct v4l2_async_subdev *asd; struct cio2_queue *q; - unsigned int i, pad; + unsigned int pad; int ret; - for (i = 0; i < notifier->num_subdevs; i++) { - s_asd = container_of(cio2->notifier.subdevs[i], - struct sensor_async_subdev, asd); + list_for_each_entry(asd, &cio2->notifier.asd_list, asd_list) { + s_asd = container_of(asd, struct sensor_async_subdev, asd); q = &cio2->queue[s_asd->csi2.port]; for (pad = 0; pad < q->sensor->entity.num_pads; pad++) @@ -1463,7 +1461,7 @@ static int cio2_notifier_complete(struct v4l2_async_notifier *notifier) if (ret) { dev_err(&cio2->pci_dev->dev, "failed to create link for %s\n", - cio2->queue[i].sensor->name); + q->sensor->name); return ret; } } @@ -1484,7 +1482,7 @@ static int cio2_fwnode_parse(struct device *dev, struct sensor_async_subdev *s_asd = container_of(asd, struct sensor_async_subdev, asd); - if (vep->bus_type != V4L2_MBUS_CSI2) { + if (vep->bus_type != V4L2_MBUS_CSI2_DPHY) { dev_err(dev, "Only CSI2 bus type is currently supported\n"); return -EINVAL; } @@ -1499,6 +1497,8 @@ static int cio2_notifier_init(struct cio2_device *cio2) { int ret; + v4l2_async_notifier_init(&cio2->notifier); + ret = v4l2_async_notifier_parse_fwnode_endpoints( &cio2->pci_dev->dev, &cio2->notifier, sizeof(struct sensor_async_subdev), @@ -1506,7 +1506,7 @@ static int cio2_notifier_init(struct cio2_device *cio2) if (ret < 0) return ret; - if (!cio2->notifier.num_subdevs) + if (list_empty(&cio2->notifier.asd_list)) return -ENODEV; /* no endpoint */ cio2->notifier.ops = &cio2_async_ops; @@ -1785,7 +1785,7 @@ static int cio2_pci_probe(struct pci_dev *pci_dev, mutex_init(&cio2->lock); cio2->media_dev.dev = &cio2->pci_dev->dev; - strlcpy(cio2->media_dev.model, CIO2_DEVICE_NAME, + strscpy(cio2->media_dev.model, CIO2_DEVICE_NAME, sizeof(cio2->media_dev.model)); snprintf(cio2->media_dev.bus_info, sizeof(cio2->media_dev.bus_info), "PCI:%s", pci_name(cio2->pci_dev)); diff --git a/drivers/media/pci/ivtv/ivtv-alsa-main.c b/drivers/media/pci/ivtv/ivtv-alsa-main.c index c1856f609d2c..0de8a9f5011a 100644 --- a/drivers/media/pci/ivtv/ivtv-alsa-main.c +++ b/drivers/media/pci/ivtv/ivtv-alsa-main.c @@ -109,7 +109,7 @@ static int snd_ivtv_card_set_names(struct snd_ivtv_card *itvsc) struct snd_card *sc = itvsc->sc; /* sc->driver is used by alsa-lib's configurator: simple, unique */ - strlcpy(sc->driver, "CX2341[56]", sizeof(sc->driver)); + strscpy(sc->driver, "CX2341[56]", sizeof(sc->driver)); /* sc->shortname is a symlink in /proc/asound: IVTV-M -> cardN */ snprintf(sc->shortname, sizeof(sc->shortname), "IVTV-%d", diff --git a/drivers/media/pci/ivtv/ivtv-alsa-pcm.c b/drivers/media/pci/ivtv/ivtv-alsa-pcm.c index 5326d86fa375..737c52de7558 100644 --- a/drivers/media/pci/ivtv/ivtv-alsa-pcm.c +++ b/drivers/media/pci/ivtv/ivtv-alsa-pcm.c @@ -350,7 +350,7 @@ int snd_ivtv_pcm_create(struct snd_ivtv_card *itvsc) &snd_ivtv_pcm_capture_ops); sp->info_flags = 0; sp->private_data = itvsc; - strlcpy(sp->name, itv->card_name, sizeof(sp->name)); + strscpy(sp->name, itv->card_name, sizeof(sp->name)); return 0; diff --git a/drivers/media/pci/ivtv/ivtv-cards.c b/drivers/media/pci/ivtv/ivtv-cards.c index c63792964a03..4ff46a6d0503 100644 --- a/drivers/media/pci/ivtv/ivtv-cards.c +++ b/drivers/media/pci/ivtv/ivtv-cards.c @@ -1317,8 +1317,8 @@ int ivtv_get_input(struct ivtv *itv, u16 index, struct v4l2_input *input) if (index >= itv->nof_inputs) return -EINVAL; input->index = index; - strlcpy(input->name, input_strs[card_input->video_type - 1], - sizeof(input->name)); + strscpy(input->name, input_strs[card_input->video_type - 1], + sizeof(input->name)); input->type = (card_input->video_type == IVTV_CARD_INPUT_VID_TUNER ? V4L2_INPUT_TYPE_TUNER : V4L2_INPUT_TYPE_CAMERA); input->audioset = (1 << itv->nof_audio_inputs) - 1; @@ -1334,7 +1334,7 @@ int ivtv_get_output(struct ivtv *itv, u16 index, struct v4l2_output *output) if (index >= itv->card->nof_outputs) return -EINVAL; output->index = index; - strlcpy(output->name, card_output->name, sizeof(output->name)); + strscpy(output->name, card_output->name, sizeof(output->name)); output->type = V4L2_OUTPUT_TYPE_ANALOG; output->audioset = 1; output->std = V4L2_STD_ALL; @@ -1353,8 +1353,8 @@ int ivtv_get_audio_input(struct ivtv *itv, u16 index, struct v4l2_audio *audio) memset(audio, 0, sizeof(*audio)); if (index >= itv->nof_audio_inputs) return -EINVAL; - strlcpy(audio->name, input_strs[aud_input->audio_type - 1], - sizeof(audio->name)); + strscpy(audio->name, input_strs[aud_input->audio_type - 1], + sizeof(audio->name)); audio->index = index; audio->capability = V4L2_AUDCAP_STEREO; return 0; @@ -1365,6 +1365,6 @@ int ivtv_get_audio_output(struct ivtv *itv, u16 index, struct v4l2_audioout *aud memset(aud_output, 0, sizeof(*aud_output)); if (itv->card->video_outputs == NULL || index != 0) return -EINVAL; - strlcpy(aud_output->name, "A/V Audio Out", sizeof(aud_output->name)); + strscpy(aud_output->name, "A/V Audio Out", sizeof(aud_output->name)); return 0; } diff --git a/drivers/media/pci/ivtv/ivtv-i2c.c b/drivers/media/pci/ivtv/ivtv-i2c.c index e9ce54dd5e01..55ef1385519e 100644 --- a/drivers/media/pci/ivtv/ivtv-i2c.c +++ b/drivers/media/pci/ivtv/ivtv-i2c.c @@ -218,7 +218,7 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr) memset(&info, 0, sizeof(struct i2c_board_info)); info.platform_data = init_data; - strlcpy(info.type, type, I2C_NAME_SIZE); + strscpy(info.type, type, I2C_NAME_SIZE); return i2c_new_probed_device(adap, &info, addr_list, NULL) == NULL ? -1 : 0; @@ -239,14 +239,14 @@ struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv) * allocations, so this function must be called after all other i2c * devices we care about are registered. */ - const unsigned short addr_list[] = { + static const unsigned short addr_list[] = { 0x1a, /* Hauppauge IR external - collides with WM8739 */ 0x18, /* Hauppauge IR internal */ I2C_CLIENT_END }; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "ir_video", I2C_NAME_SIZE); + strscpy(info.type, "ir_video", I2C_NAME_SIZE); return i2c_new_probed_device(&itv->i2c_adap, &info, addr_list, NULL); } diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/ivtv-ioctl.c index 4cdc6d2be85d..a66f8b872520 100644 --- a/drivers/media/pci/ivtv/ivtv-ioctl.c +++ b/drivers/media/pci/ivtv/ivtv-ioctl.c @@ -36,6 +36,7 @@ #include <media/tveeprom.h> #include <media/v4l2-event.h> #ifdef CONFIG_VIDEO_IVTV_DEPRECATED_IOCTLS +#include <linux/compat.h> #include <linux/dvb/audio.h> #include <linux/dvb/video.h> #endif @@ -747,8 +748,8 @@ static int ivtv_querycap(struct file *file, void *fh, struct v4l2_capability *vc struct ivtv *itv = id->itv; struct ivtv_stream *s = &itv->streams[id->type]; - strlcpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver)); - strlcpy(vcap->card, itv->card_name, sizeof(vcap->card)); + strscpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver)); + strscpy(vcap->card, itv->card_name, sizeof(vcap->card)); snprintf(vcap->bus_info, sizeof(vcap->bus_info), "PCI:%s", pci_name(itv->pdev)); vcap->capabilities = itv->v4l2_cap | V4L2_CAP_DEVICE_CAPS; vcap->device_caps = s->caps; @@ -1227,9 +1228,9 @@ static int ivtv_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt) ivtv_call_all(itv, tuner, g_tuner, vt); if (vt->type == V4L2_TUNER_RADIO) - strlcpy(vt->name, "ivtv Radio Tuner", sizeof(vt->name)); + strscpy(vt->name, "ivtv Radio Tuner", sizeof(vt->name)); else - strlcpy(vt->name, "ivtv TV Tuner", sizeof(vt->name)); + strscpy(vt->name, "ivtv TV Tuner", sizeof(vt->name)); return 0; } @@ -1627,6 +1628,21 @@ static __inline__ void warn_deprecated_ioctl(const char *name) pr_warn_once("warning: the %s ioctl is deprecated. Don't use it, as it will be removed soon\n", name); } + +#ifdef CONFIG_COMPAT +struct compat_video_event { + __s32 type; + /* unused, make sure to use atomic time for y2038 if it ever gets used */ + compat_long_t timestamp; + union { + video_size_t size; + unsigned int frame_rate; /* in frames per 1000sec */ + unsigned char vsync_field; /* unknown/odd/even/progressive */ + } u; +}; +#define VIDEO_GET_EVENT32 _IOR('o', 28, struct compat_video_event) +#endif + #endif static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg) @@ -1749,7 +1765,13 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg) return ivtv_video_command(itv, id, dc, try); } +#ifdef CONFIG_COMPAT + case VIDEO_GET_EVENT32: +#endif case VIDEO_GET_EVENT: { +#ifdef CONFIG_COMPAT + struct compat_video_event *ev32 = arg; +#endif struct video_event *ev = arg; DEFINE_WAIT(wait); @@ -1763,14 +1785,22 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg) if (test_and_clear_bit(IVTV_F_I_EV_DEC_STOPPED, &itv->i_flags)) ev->type = VIDEO_EVENT_DECODER_STOPPED; else if (test_and_clear_bit(IVTV_F_I_EV_VSYNC, &itv->i_flags)) { + unsigned char vsync_field; + ev->type = VIDEO_EVENT_VSYNC; - ev->u.vsync_field = test_bit(IVTV_F_I_EV_VSYNC_FIELD, &itv->i_flags) ? + vsync_field = test_bit(IVTV_F_I_EV_VSYNC_FIELD, &itv->i_flags) ? VIDEO_VSYNC_FIELD_ODD : VIDEO_VSYNC_FIELD_EVEN; if (itv->output_mode == OUT_UDMA_YUV && (itv->yuv_info.lace_mode & IVTV_YUV_MODE_MASK) == IVTV_YUV_MODE_PROGRESSIVE) { - ev->u.vsync_field = VIDEO_VSYNC_FIELD_PROGRESSIVE; + vsync_field = VIDEO_VSYNC_FIELD_PROGRESSIVE; } +#ifdef CONFIG_COMPAT + if (cmd == VIDEO_GET_EVENT32) + ev32->u.vsync_field = vsync_field; + else +#endif + ev->u.vsync_field = vsync_field; } if (ev->type) return 0; diff --git a/drivers/media/pci/ivtv/ivtv-streams.c b/drivers/media/pci/ivtv/ivtv-streams.c index d27c6df97566..a641f20e3f86 100644 --- a/drivers/media/pci/ivtv/ivtv-streams.c +++ b/drivers/media/pci/ivtv/ivtv-streams.c @@ -51,6 +51,9 @@ static const struct v4l2_file_operations ivtv_v4l2_enc_fops = { .write = ivtv_v4l2_write, .open = ivtv_v4l2_open, .unlocked_ioctl = video_ioctl2, +#ifdef CONFIG_COMPAT + .compat_ioctl32 = video_ioctl2, /* for ivtv_default() */ +#endif .release = ivtv_v4l2_close, .poll = ivtv_v4l2_enc_poll, }; @@ -61,6 +64,9 @@ static const struct v4l2_file_operations ivtv_v4l2_dec_fops = { .write = ivtv_v4l2_write, .open = ivtv_v4l2_open, .unlocked_ioctl = video_ioctl2, +#ifdef CONFIG_COMPAT + .compat_ioctl32 = video_ioctl2, /* for ivtv_default() */ +#endif .release = ivtv_v4l2_close, .poll = ivtv_v4l2_dec_poll, }; @@ -69,6 +75,9 @@ static const struct v4l2_file_operations ivtv_v4l2_radio_fops = { .owner = THIS_MODULE, .open = ivtv_v4l2_open, .unlocked_ioctl = video_ioctl2, +#ifdef CONFIG_COMPAT + .compat_ioctl32 = video_ioctl2, /* for ivtv_default() */ +#endif .release = ivtv_v4l2_close, .poll = ivtv_v4l2_enc_poll, }; diff --git a/drivers/media/pci/ivtv/ivtv-yuv.c b/drivers/media/pci/ivtv/ivtv-yuv.c index 44936d6d7c39..1380474519f2 100644 --- a/drivers/media/pci/ivtv/ivtv-yuv.c +++ b/drivers/media/pci/ivtv/ivtv-yuv.c @@ -935,7 +935,7 @@ static void ivtv_yuv_init(struct ivtv *itv) } /* We need a buffer for blanking when Y plane is offset - non-fatal if we can't get one */ - yi->blanking_ptr = kzalloc(720 * 16, GFP_KERNEL|__GFP_NOWARN); + yi->blanking_ptr = kzalloc(720 * 16, GFP_ATOMIC|__GFP_NOWARN); if (yi->blanking_ptr) { yi->blanking_dmaptr = pci_map_single(itv->pdev, yi->blanking_ptr, 720*16, PCI_DMA_TODEVICE); } else { diff --git a/drivers/media/pci/ivtv/ivtvfb.c b/drivers/media/pci/ivtv/ivtvfb.c index 5ddaa8ed11a5..3e02de02ffdd 100644 --- a/drivers/media/pci/ivtv/ivtvfb.c +++ b/drivers/media/pci/ivtv/ivtvfb.c @@ -624,7 +624,7 @@ static int ivtvfb_get_fix(struct ivtv *itv, struct fb_fix_screeninfo *fix) IVTVFB_DEBUG_INFO("ivtvfb_get_fix\n"); memset(fix, 0, sizeof(struct fb_fix_screeninfo)); - strlcpy(fix->id, "cx23415 TV out", sizeof(fix->id)); + strscpy(fix->id, "cx23415 TV out", sizeof(fix->id)); fix->smem_start = oi->video_pbase; fix->smem_len = oi->video_buffer_size; fix->type = FB_TYPE_PACKED_PIXELS; diff --git a/drivers/media/pci/meye/meye.c b/drivers/media/pci/meye/meye.c index 8001d3e9134e..bd870e60c32b 100644 --- a/drivers/media/pci/meye/meye.c +++ b/drivers/media/pci/meye/meye.c @@ -1019,8 +1019,8 @@ static int meyeioc_stilljcapt(int *len) static int vidioc_querycap(struct file *file, void *fh, struct v4l2_capability *cap) { - strcpy(cap->driver, "meye"); - strcpy(cap->card, "meye"); + strscpy(cap->driver, "meye", sizeof(cap->driver)); + strscpy(cap->card, "meye", sizeof(cap->card)); sprintf(cap->bus_info, "PCI:%s", pci_name(meye.mchip_dev)); cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | @@ -1035,7 +1035,7 @@ static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i) if (i->index != 0) return -EINVAL; - strcpy(i->name, "Camera"); + strscpy(i->name, "Camera", sizeof(i->name)); i->type = V4L2_INPUT_TYPE_CAMERA; return 0; @@ -1118,12 +1118,12 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *fh, if (f->index == 0) { /* standard YUV 422 capture */ f->flags = 0; - strcpy(f->description, "YUV422"); + strscpy(f->description, "YUV422", sizeof(f->description)); f->pixelformat = V4L2_PIX_FMT_YUYV; } else { /* compressed MJPEG capture */ f->flags = V4L2_FMT_FLAG_COMPRESSED; - strcpy(f->description, "MJPEG"); + strscpy(f->description, "MJPEG", sizeof(f->description)); f->pixelformat = V4L2_PIX_FMT_MJPEG; } @@ -1460,7 +1460,7 @@ static int meye_mmap(struct file *file, struct vm_area_struct *vma) unsigned long page, pos; mutex_lock(&meye.lock); - if (size > gbuffers * gbufsize) { + if (size > gbuffers * gbufsize || offset > gbuffers * gbufsize - size) { mutex_unlock(&meye.lock); return -EINVAL; } diff --git a/drivers/media/pci/ngene/ngene-i2c.c b/drivers/media/pci/ngene/ngene-i2c.c index 092d46c2a3a9..02a06f6c97f8 100644 --- a/drivers/media/pci/ngene/ngene-i2c.c +++ b/drivers/media/pci/ngene/ngene-i2c.c @@ -161,7 +161,7 @@ int ngene_i2c_init(struct ngene *dev, int dev_nr) i2c_set_adapdata(adap, &(dev->channel[dev_nr])); - strcpy(adap->name, "nGene"); + strscpy(adap->name, "nGene", sizeof(adap->name)); adap->algo = &ngene_i2c_algo; adap->algo_data = (void *)&(dev->channel[dev_nr]); diff --git a/drivers/media/pci/pluto2/pluto2.c b/drivers/media/pci/pluto2/pluto2.c index 5e6fe686f420..872c796621d2 100644 --- a/drivers/media/pci/pluto2/pluto2.c +++ b/drivers/media/pci/pluto2/pluto2.c @@ -633,7 +633,7 @@ static int pluto2_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /* i2c */ i2c_set_adapdata(&pluto->i2c_adap, pluto); - strcpy(pluto->i2c_adap.name, DRIVER_NAME); + strscpy(pluto->i2c_adap.name, DRIVER_NAME, sizeof(pluto->i2c_adap.name)); pluto->i2c_adap.owner = THIS_MODULE; pluto->i2c_adap.dev.parent = &pdev->dev; pluto->i2c_adap.algo_data = &pluto->i2c_bit; diff --git a/drivers/media/pci/pt1/pt1.c b/drivers/media/pci/pt1/pt1.c index 7f878fc41b7e..f4b8030e2369 100644 --- a/drivers/media/pci/pt1/pt1.c +++ b/drivers/media/pci/pt1/pt1.c @@ -1354,7 +1354,7 @@ static int pt1_probe(struct pci_dev *pdev, const struct pci_device_id *ent) i2c_adap->algo = &pt1_i2c_algo; i2c_adap->algo_data = NULL; i2c_adap->dev.parent = &pdev->dev; - strcpy(i2c_adap->name, DRIVER_NAME); + strscpy(i2c_adap->name, DRIVER_NAME, sizeof(i2c_adap->name)); i2c_set_adapdata(i2c_adap, pt1); ret = i2c_add_adapter(i2c_adap); if (ret < 0) diff --git a/drivers/media/pci/pt3/pt3.c b/drivers/media/pci/pt3/pt3.c index 90273b4d772f..7a7afae4c84c 100644 --- a/drivers/media/pci/pt3/pt3.c +++ b/drivers/media/pci/pt3/pt3.c @@ -765,7 +765,7 @@ static int pt3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) i2c->algo = &pt3_i2c_algo; i2c->algo_data = NULL; i2c->dev.parent = &pdev->dev; - strlcpy(i2c->name, DRV_NAME, sizeof(i2c->name)); + strscpy(i2c->name, DRV_NAME, sizeof(i2c->name)); i2c_set_adapdata(i2c, pt3); ret = i2c_add_adapter(i2c); if (ret < 0) diff --git a/drivers/media/pci/saa7134/saa7134-alsa.c b/drivers/media/pci/saa7134/saa7134-alsa.c index b90cfde6e301..dc9cdaaee1fb 100644 --- a/drivers/media/pci/saa7134/saa7134-alsa.c +++ b/drivers/media/pci/saa7134/saa7134-alsa.c @@ -901,7 +901,7 @@ static int snd_card_saa7134_pcm(snd_card_saa7134_t *saa7134, int device) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_card_saa7134_capture_ops); pcm->private_data = saa7134; pcm->info_flags = 0; - strcpy(pcm->name, "SAA7134 PCM"); + strscpy(pcm->name, "SAA7134 PCM", sizeof(pcm->name)); return 0; } @@ -1074,7 +1074,7 @@ static int snd_card_saa7134_new_mixer(snd_card_saa7134_t * chip) unsigned int idx; int err, addr; - strcpy(card->mixername, "SAA7134 Mixer"); + strscpy(card->mixername, "SAA7134 Mixer", sizeof(card->mixername)); for (idx = 0; idx < ARRAY_SIZE(snd_saa7134_volume_controls); idx++) { kcontrol = snd_ctl_new1(&snd_saa7134_volume_controls[idx], @@ -1138,7 +1138,7 @@ static int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum) if (err < 0) return err; - strcpy(card->driver, "SAA7134"); + strscpy(card->driver, "SAA7134", sizeof(card->driver)); /* Card "creation" */ @@ -1178,7 +1178,7 @@ static int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum) /* End of "creation" */ - strcpy(card->shortname, "SAA7134"); + strscpy(card->shortname, "SAA7134", sizeof(card->shortname)); sprintf(card->longname, "%s at 0x%lx irq %d", chip->dev->name, chip->iobase, chip->irq); diff --git a/drivers/media/pci/saa7134/saa7134-cards.c b/drivers/media/pci/saa7134/saa7134-cards.c index 9d6688a82b50..40ce033cb884 100644 --- a/drivers/media/pci/saa7134/saa7134-cards.c +++ b/drivers/media/pci/saa7134/saa7134-cards.c @@ -3628,6 +3628,21 @@ struct saa7134_board saa7134_boards[] = { .vmux = 1, .amux = TV, .gpio = 0x0200000, + },{ + .type = SAA7134_INPUT_COMPOSITE1, + .vmux = 3, + .amux = LINE2, + .gpio = 0x0200000, + },{ + .type = SAA7134_INPUT_COMPOSITE2, + .vmux = 0, + .amux = LINE2, + .gpio = 0x0200000, + },{ + .type = SAA7134_INPUT_SVIDEO, + .vmux = 8, + .amux = LINE2, + .gpio = 0x0200000, }}, }, [SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA] = { diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c index 9e76de2411ae..8984b1bf57a5 100644 --- a/drivers/media/pci/saa7134/saa7134-core.c +++ b/drivers/media/pci/saa7134/saa7134-core.c @@ -845,12 +845,13 @@ static void saa7134_create_entities(struct saa7134_dev *dev) */ if (!decoder) { dev->demod.name = "saa713x"; - dev->demod_pad[DEMOD_PAD_IF_INPUT].flags = MEDIA_PAD_FL_SINK; - dev->demod_pad[DEMOD_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE; - dev->demod_pad[DEMOD_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE; + dev->demod_pad[SAA7134_PAD_IF_INPUT].flags = MEDIA_PAD_FL_SINK; + dev->demod_pad[SAA7134_PAD_IF_INPUT].sig_type = PAD_SIGNAL_ANALOG; + dev->demod_pad[SAA7134_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE; + dev->demod_pad[SAA7134_PAD_VID_OUT].sig_type = PAD_SIGNAL_DV; dev->demod.function = MEDIA_ENT_F_ATV_DECODER; - ret = media_entity_pads_init(&dev->demod, DEMOD_NUM_PADS, + ret = media_entity_pads_init(&dev->demod, SAA7134_NUM_PADS, dev->demod_pad); if (ret < 0) pr_err("failed to initialize demod pad!\n"); diff --git a/drivers/media/pci/saa7134/saa7134-empress.c b/drivers/media/pci/saa7134/saa7134-empress.c index 66acfd35ffc6..747a082229dc 100644 --- a/drivers/media/pci/saa7134/saa7134-empress.c +++ b/drivers/media/pci/saa7134/saa7134-empress.c @@ -100,7 +100,7 @@ static int empress_enum_fmt_vid_cap(struct file *file, void *priv, if (f->index != 0) return -EINVAL; - strlcpy(f->description, "MPEG TS", sizeof(f->description)); + strscpy(f->description, "MPEG TS", sizeof(f->description)); f->pixelformat = V4L2_PIX_FMT_MPEG; f->flags = V4L2_FMT_FLAG_COMPRESSED; return 0; diff --git a/drivers/media/pci/saa7134/saa7134-go7007.c b/drivers/media/pci/saa7134/saa7134-go7007.c index 2799538e2d7e..275c5e151818 100644 --- a/drivers/media/pci/saa7134/saa7134-go7007.c +++ b/drivers/media/pci/saa7134/saa7134-go7007.c @@ -435,7 +435,7 @@ static int saa7134_go7007_init(struct saa7134_dev *dev) go->board_id = GO7007_BOARDID_PCI_VOYAGER; snprintf(go->bus_info, sizeof(go->bus_info), "PCI:%s", pci_name(dev->pci)); - strlcpy(go->name, saa7134_boards[dev->board].name, sizeof(go->name)); + strscpy(go->name, saa7134_boards[dev->board].name, sizeof(go->name)); go->hpi_ops = &saa7134_go7007_hpi_ops; go->hpi_context = saa; saa->dev = dev; diff --git a/drivers/media/pci/saa7134/saa7134-i2c.c b/drivers/media/pci/saa7134/saa7134-i2c.c index cf1e526de56a..51af3310654c 100644 --- a/drivers/media/pci/saa7134/saa7134-i2c.c +++ b/drivers/media/pci/saa7134/saa7134-i2c.c @@ -437,7 +437,7 @@ int saa7134_i2c_register(struct saa7134_dev *dev) { dev->i2c_adap = saa7134_adap_template; dev->i2c_adap.dev.parent = &dev->pci->dev; - strcpy(dev->i2c_adap.name,dev->name); + strscpy(dev->i2c_adap.name, dev->name, sizeof(dev->i2c_adap.name)); dev->i2c_adap.algo_data = dev; i2c_set_adapdata(&dev->i2c_adap, &dev->v4l2_dev); i2c_add_adapter(&dev->i2c_adap); diff --git a/drivers/media/pci/saa7134/saa7134-input.c b/drivers/media/pci/saa7134/saa7134-input.c index 0e28c5021ac4..999b2774b220 100644 --- a/drivers/media/pci/saa7134/saa7134-input.c +++ b/drivers/media/pci/saa7134/saa7134-input.c @@ -953,7 +953,7 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev) memset(&info, 0, sizeof(struct i2c_board_info)); memset(&dev->init_data, 0, sizeof(dev->init_data)); - strlcpy(info.type, "ir_video", I2C_NAME_SIZE); + strscpy(info.type, "ir_video", I2C_NAME_SIZE); switch (dev->board) { case SAA7134_BOARD_PINNACLE_PCTV_110i: diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c index 1a50ec9d084f..1a22ae7cbdd9 100644 --- a/drivers/media/pci/saa7134/saa7134-video.c +++ b/drivers/media/pci/saa7134/saa7134-video.c @@ -1445,7 +1445,8 @@ int saa7134_enum_input(struct file *file, void *priv, struct v4l2_input *i) if (card_in(dev, i->index).type == SAA7134_NO_INPUT) return -EINVAL; i->index = n; - strcpy(i->name, saa7134_input_name[card_in(dev, n).type]); + strscpy(i->name, saa7134_input_name[card_in(dev, n).type], + sizeof(i->name)); switch (card_in(dev, n).type) { case SAA7134_INPUT_TV: case SAA7134_INPUT_TV_MONO: @@ -1502,8 +1503,8 @@ int saa7134_querycap(struct file *file, void *priv, unsigned int tuner_type = dev->tuner_type; - strcpy(cap->driver, "saa7134"); - strlcpy(cap->card, saa7134_boards[dev->board].name, + strscpy(cap->driver, "saa7134", sizeof(cap->driver)); + strscpy(cap->card, saa7134_boards[dev->board].name, sizeof(cap->card)); sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci)); @@ -1747,7 +1748,7 @@ int saa7134_g_tuner(struct file *file, void *priv, if (n == SAA7134_INPUT_MAX) return -EINVAL; if (card_in(dev, n).type != SAA7134_NO_INPUT) { - strcpy(t->name, "Television"); + strscpy(t->name, "Television", sizeof(t->name)); t->type = V4L2_TUNER_ANALOG_TV; saa_call_all(dev, tuner, g_tuner, t); t->capability = V4L2_TUNER_CAP_NORM | @@ -1819,7 +1820,7 @@ static int saa7134_enum_fmt_vid_cap(struct file *file, void *priv, if (f->index >= FORMATS) return -EINVAL; - strlcpy(f->description, formats[f->index].name, + strscpy(f->description, formats[f->index].name, sizeof(f->description)); f->pixelformat = formats[f->index].fourcc; @@ -1838,7 +1839,7 @@ static int saa7134_enum_fmt_vid_overlay(struct file *file, void *priv, if ((f->index >= FORMATS) || formats[f->index].planar) return -EINVAL; - strlcpy(f->description, formats[f->index].name, + strscpy(f->description, formats[f->index].name, sizeof(f->description)); f->pixelformat = formats[f->index].fourcc; @@ -1939,7 +1940,7 @@ static int radio_g_tuner(struct file *file, void *priv, if (0 != t->index) return -EINVAL; - strcpy(t->name, "Radio"); + strscpy(t->name, "Radio", sizeof(t->name)); saa_call_all(dev, tuner, g_tuner, t); t->audmode &= V4L2_TUNER_MODE_MONO | V4L2_TUNER_MODE_STEREO; diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h index d99e937a98c1..480228456014 100644 --- a/drivers/media/pci/saa7134/saa7134.h +++ b/drivers/media/pci/saa7134/saa7134.h @@ -547,6 +547,12 @@ struct saa7134_mpeg_ops { unsigned long status); }; +enum saa7134_pads { + SAA7134_PAD_IF_INPUT, + SAA7134_PAD_VID_OUT, + SAA7134_NUM_PADS +}; + /* global device status */ struct saa7134_dev { struct list_head devlist; @@ -674,7 +680,7 @@ struct saa7134_dev { struct media_pad input_pad[SAA7134_INPUT_MAX + 1]; struct media_entity demod; - struct media_pad demod_pad[DEMOD_NUM_PADS]; + struct media_pad demod_pad[SAA7134_NUM_PADS]; struct media_pad video_pad, vbi_pad; struct media_entity *decoder; diff --git a/drivers/media/pci/saa7146/mxb.c b/drivers/media/pci/saa7146/mxb.c index 6b5582b7c595..44440c6208df 100644 --- a/drivers/media/pci/saa7146/mxb.c +++ b/drivers/media/pci/saa7146/mxb.c @@ -553,7 +553,7 @@ static int vidioc_g_tuner(struct file *file, void *fh, struct v4l2_tuner *t) DEB_EE("VIDIOC_G_TUNER: %d\n", t->index); memset(t, 0, sizeof(*t)); - strlcpy(t->name, "TV Tuner", sizeof(t->name)); + strscpy(t->name, "TV Tuner", sizeof(t->name)); t->type = V4L2_TUNER_ANALOG_TV; t->capability = V4L2_TUNER_CAP_NORM | V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2 | V4L2_TUNER_CAP_SAP; diff --git a/drivers/media/pci/saa7164/saa7164-core.c b/drivers/media/pci/saa7164/saa7164-core.c index d697e1ad929c..f33349e16359 100644 --- a/drivers/media/pci/saa7164/saa7164-core.c +++ b/drivers/media/pci/saa7164/saa7164-core.c @@ -179,7 +179,7 @@ static void saa7164_histogram_reset(struct saa7164_histogram *hg, char *name) int i; memset(hg, 0, sizeof(struct saa7164_histogram)); - strcpy(hg->name, name); + strscpy(hg->name, name, sizeof(hg->name)); /* First 30ms x 1ms */ for (i = 0; i < 30; i++) diff --git a/drivers/media/pci/saa7164/saa7164-dvb.c b/drivers/media/pci/saa7164/saa7164-dvb.c index 4f9f03c3b252..dfb118d7d1ec 100644 --- a/drivers/media/pci/saa7164/saa7164-dvb.c +++ b/drivers/media/pci/saa7164/saa7164-dvb.c @@ -120,7 +120,7 @@ static int si2157_attach(struct saa7164_port *port, struct i2c_adapter *adapter, memset(&bi, 0, sizeof(bi)); - strlcpy(bi.type, "si2157", I2C_NAME_SIZE); + strscpy(bi.type, "si2157", I2C_NAME_SIZE); bi.platform_data = cfg; bi.addr = addr8bit >> 1; @@ -643,7 +643,7 @@ int saa7164_dvb_register(struct saa7164_port *port) si2168_config.fe = &port->dvb.frontend; si2168_config.ts_mode = SI2168_TS_SERIAL; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2168", I2C_NAME_SIZE); + strscpy(info.type, "si2168", I2C_NAME_SIZE); info.addr = 0xc8 >> 1; info.platform_data = &si2168_config; request_module(info.type); @@ -663,7 +663,7 @@ int saa7164_dvb_register(struct saa7164_port *port) si2157_config.if_port = 1; si2157_config.fe = port->dvb.frontend; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2157", I2C_NAME_SIZE); + strscpy(info.type, "si2157", I2C_NAME_SIZE); info.addr = 0xc0 >> 1; info.platform_data = &si2157_config; request_module(info.type); @@ -688,7 +688,7 @@ int saa7164_dvb_register(struct saa7164_port *port) si2168_config.fe = &port->dvb.frontend; si2168_config.ts_mode = SI2168_TS_SERIAL; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2168", I2C_NAME_SIZE); + strscpy(info.type, "si2168", I2C_NAME_SIZE); info.addr = 0xcc >> 1; info.platform_data = &si2168_config; request_module(info.type); @@ -708,7 +708,7 @@ int saa7164_dvb_register(struct saa7164_port *port) si2157_config.fe = port->dvb.frontend; si2157_config.if_port = 1; memset(&info, 0, sizeof(struct i2c_board_info)); - strlcpy(info.type, "si2157", I2C_NAME_SIZE); + strscpy(info.type, "si2157", I2C_NAME_SIZE); info.addr = 0xc0 >> 1; info.platform_data = &si2157_config; request_module(info.type); diff --git a/drivers/media/pci/saa7164/saa7164-encoder.c b/drivers/media/pci/saa7164/saa7164-encoder.c index 32136ebe4f61..adec2bab8352 100644 --- a/drivers/media/pci/saa7164/saa7164-encoder.c +++ b/drivers/media/pci/saa7164/saa7164-encoder.c @@ -258,7 +258,7 @@ int saa7164_enum_input(struct file *file, void *priv, struct v4l2_input *i) if (i->index >= 7) return -EINVAL; - strcpy(i->name, inputs[i->index]); + strscpy(i->name, inputs[i->index], sizeof(i->name)); if (i->index == 0) i->type = V4L2_INPUT_TYPE_TUNER; @@ -325,7 +325,7 @@ int saa7164_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t) if (0 != t->index) return -EINVAL; - strcpy(t->name, "tuner"); + strscpy(t->name, "tuner", sizeof(t->name)); t->capability = V4L2_TUNER_CAP_NORM | V4L2_TUNER_CAP_STEREO; t->rangelow = SAA7164_TV_MIN_FREQ; t->rangehigh = SAA7164_TV_MAX_FREQ; @@ -497,8 +497,8 @@ static int vidioc_querycap(struct file *file, void *priv, struct saa7164_port *port = fh->port; struct saa7164_dev *dev = port->dev; - strcpy(cap->driver, dev->name); - strlcpy(cap->card, saa7164_boards[dev->board].name, + strscpy(cap->driver, dev->name, sizeof(cap->driver)); + strscpy(cap->card, saa7164_boards[dev->board].name, sizeof(cap->card)); sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci)); @@ -520,7 +520,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, if (f->index != 0) return -EINVAL; - strlcpy(f->description, "MPEG", sizeof(f->description)); + strscpy(f->description, "MPEG", sizeof(f->description)); f->pixelformat = V4L2_PIX_FMT_MPEG; return 0; diff --git a/drivers/media/pci/saa7164/saa7164-i2c.c b/drivers/media/pci/saa7164/saa7164-i2c.c index 6d13cbb9d010..317f48bc6506 100644 --- a/drivers/media/pci/saa7164/saa7164-i2c.c +++ b/drivers/media/pci/saa7164/saa7164-i2c.c @@ -99,7 +99,7 @@ int saa7164_i2c_register(struct saa7164_i2c *bus) bus->i2c_adap.dev.parent = &dev->pci->dev; - strlcpy(bus->i2c_adap.name, bus->dev->name, + strscpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name)); bus->i2c_adap.algo_data = bus; diff --git a/drivers/media/pci/saa7164/saa7164-vbi.c b/drivers/media/pci/saa7164/saa7164-vbi.c index 221de91a8bae..841c7e94405d 100644 --- a/drivers/media/pci/saa7164/saa7164-vbi.c +++ b/drivers/media/pci/saa7164/saa7164-vbi.c @@ -208,8 +208,8 @@ static int vidioc_querycap(struct file *file, void *priv, struct saa7164_port *port = fh->port; struct saa7164_dev *dev = port->dev; - strcpy(cap->driver, dev->name); - strlcpy(cap->card, saa7164_boards[dev->board].name, + strscpy(cap->driver, dev->name, sizeof(cap->driver)); + strscpy(cap->card, saa7164_boards[dev->board].name, sizeof(cap->card)); sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci)); diff --git a/drivers/media/pci/smipcie/smipcie-main.c b/drivers/media/pci/smipcie/smipcie-main.c index 6dbe3b4d09ce..4d5ddbcb3514 100644 --- a/drivers/media/pci/smipcie/smipcie-main.c +++ b/drivers/media/pci/smipcie/smipcie-main.c @@ -191,7 +191,7 @@ static int smi_i2c_init(struct smi_dev *dev) /* i2c bus 0 */ smi_i2c_cfg(dev, I2C_A_SW_CTL); i2c_set_adapdata(&dev->i2c_bus[0], dev); - strcpy(dev->i2c_bus[0].name, "SMI-I2C0"); + strscpy(dev->i2c_bus[0].name, "SMI-I2C0", sizeof(dev->i2c_bus[0].name)); dev->i2c_bus[0].owner = THIS_MODULE; dev->i2c_bus[0].dev.parent = &dev->pci_dev->dev; dev->i2c_bus[0].algo_data = &dev->i2c_bit[0]; @@ -213,7 +213,7 @@ static int smi_i2c_init(struct smi_dev *dev) /* i2c bus 1 */ smi_i2c_cfg(dev, I2C_B_SW_CTL); i2c_set_adapdata(&dev->i2c_bus[1], dev); - strcpy(dev->i2c_bus[1].name, "SMI-I2C1"); + strscpy(dev->i2c_bus[1].name, "SMI-I2C1", sizeof(dev->i2c_bus[1].name)); dev->i2c_bus[1].owner = THIS_MODULE; dev->i2c_bus[1].dev.parent = &dev->pci_dev->dev; dev->i2c_bus[1].algo_data = &dev->i2c_bit[1]; @@ -549,7 +549,7 @@ static int smi_dvbsky_m88ds3103_fe_attach(struct smi_port *port) } /* attach tuner */ ts2020_config.fe = port->fe; - strlcpy(tuner_info.type, "ts2020", I2C_NAME_SIZE); + strscpy(tuner_info.type, "ts2020", I2C_NAME_SIZE); tuner_info.addr = 0x60; tuner_info.platform_data = &ts2020_config; tuner_client = smi_add_i2c_client(tuner_i2c_adapter, &tuner_info); @@ -605,7 +605,7 @@ static int smi_dvbsky_m88rs6000_fe_attach(struct smi_port *port) } /* attach tuner */ m88rs6000t_config.fe = port->fe; - strlcpy(tuner_info.type, "m88rs6000t", I2C_NAME_SIZE); + strscpy(tuner_info.type, "m88rs6000t", I2C_NAME_SIZE); tuner_info.addr = 0x21; tuner_info.platform_data = &m88rs6000t_config; tuner_client = smi_add_i2c_client(tuner_i2c_adapter, &tuner_info); @@ -647,7 +647,7 @@ static int smi_dvbsky_sit2_fe_attach(struct smi_port *port) si2168_config.ts_mode = SI2168_TS_PARALLEL; memset(&client_info, 0, sizeof(struct i2c_board_info)); - strlcpy(client_info.type, "si2168", I2C_NAME_SIZE); + strscpy(client_info.type, "si2168", I2C_NAME_SIZE); client_info.addr = 0x64; client_info.platform_data = &si2168_config; @@ -664,7 +664,7 @@ static int smi_dvbsky_sit2_fe_attach(struct smi_port *port) si2157_config.if_port = 1; memset(&client_info, 0, sizeof(struct i2c_board_info)); - strlcpy(client_info.type, "si2157", I2C_NAME_SIZE); + strscpy(client_info.type, "si2157", I2C_NAME_SIZE); client_info.addr = 0x60; client_info.platform_data = &si2157_config; diff --git a/drivers/media/pci/solo6x10/solo6x10-g723.c b/drivers/media/pci/solo6x10/solo6x10-g723.c index 2ac33b5cc454..2cc05a9d57ac 100644 --- a/drivers/media/pci/solo6x10/solo6x10-g723.c +++ b/drivers/media/pci/solo6x10/solo6x10-g723.c @@ -354,7 +354,7 @@ static int solo_snd_pcm_init(struct solo_dev *solo_dev) snd_pcm_chip(pcm) = solo_dev; pcm->info_flags = 0; - strcpy(pcm->name, card->shortname); + strscpy(pcm->name, card->shortname, sizeof(pcm->name)); for (i = 0, ss = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; ss; ss = ss->next, i++) @@ -394,8 +394,8 @@ int solo_g723_init(struct solo_dev *solo_dev) card = solo_dev->snd_card; - strcpy(card->driver, SOLO6X10_NAME); - strcpy(card->shortname, "SOLO-6x10 Audio"); + strscpy(card->driver, SOLO6X10_NAME, sizeof(card->driver)); + strscpy(card->shortname, "SOLO-6x10 Audio", sizeof(card->shortname)); sprintf(card->longname, "%s on %s IRQ %d", card->shortname, pci_name(solo_dev->pdev), solo_dev->pdev->irq); @@ -404,7 +404,7 @@ int solo_g723_init(struct solo_dev *solo_dev) goto snd_error; /* Mixer controls */ - strcpy(card->mixername, "SOLO-6x10"); + strscpy(card->mixername, "SOLO-6x10", sizeof(card->mixername)); kctl = snd_solo_capture_volume; kctl.count = solo_dev->nr_chans; diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c index 25f9f2ebff1d..9d27e7463070 100644 --- a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c +++ b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c @@ -775,7 +775,7 @@ static int solo_enc_querycap(struct file *file, void *priv, struct solo_enc_dev *solo_enc = video_drvdata(file); struct solo_dev *solo_dev = solo_enc->solo_dev; - strcpy(cap->driver, SOLO6X10_NAME); + strscpy(cap->driver, SOLO6X10_NAME, sizeof(cap->driver)); snprintf(cap->card, sizeof(cap->card), "Softlogic 6x10 Enc %d", solo_enc->ch); snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", @@ -834,17 +834,18 @@ static int solo_enc_enum_fmt_cap(struct file *file, void *priv, switch (dev_type) { case SOLO_DEV_6010: f->pixelformat = V4L2_PIX_FMT_MPEG4; - strcpy(f->description, "MPEG-4 part 2"); + strscpy(f->description, "MPEG-4 part 2", + sizeof(f->description)); break; case SOLO_DEV_6110: f->pixelformat = V4L2_PIX_FMT_H264; - strcpy(f->description, "H.264"); + strscpy(f->description, "H.264", sizeof(f->description)); break; } break; case 1: f->pixelformat = V4L2_PIX_FMT_MJPEG; - strcpy(f->description, "MJPEG"); + strscpy(f->description, "MJPEG", sizeof(f->description)); break; default: return -EINVAL; @@ -1126,7 +1127,8 @@ static int solo_s_ctrl(struct v4l2_ctrl *ctrl) solo_enc->md_thresholds->p_new.p_u16); break; case V4L2_CID_OSD_TEXT: - strcpy(solo_enc->osd_text, ctrl->p_new.p_char); + strscpy(solo_enc->osd_text, ctrl->p_new.p_char, + sizeof(solo_enc->osd_text)); return solo_osd_print(solo_enc); default: return -EINVAL; diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2.c b/drivers/media/pci/solo6x10/solo6x10-v4l2.c index 99ffd1ed4a73..69fc939fd3d9 100644 --- a/drivers/media/pci/solo6x10/solo6x10-v4l2.c +++ b/drivers/media/pci/solo6x10/solo6x10-v4l2.c @@ -383,8 +383,8 @@ static int solo_querycap(struct file *file, void *priv, { struct solo_dev *solo_dev = video_drvdata(file); - strcpy(cap->driver, SOLO6X10_NAME); - strcpy(cap->card, "Softlogic 6x10"); + strscpy(cap->driver, SOLO6X10_NAME, sizeof(cap->driver)); + strscpy(cap->card, "Softlogic 6x10", sizeof(cap->card)); snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", pci_name(solo_dev->pdev)); cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | @@ -470,7 +470,7 @@ static int solo_enum_fmt_cap(struct file *file, void *priv, return -EINVAL; f->pixelformat = V4L2_PIX_FMT_UYVY; - strlcpy(f->description, "UYUV 4:2:2 Packed", sizeof(f->description)); + strscpy(f->description, "UYUV 4:2:2 Packed", sizeof(f->description)); return 0; } diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c index 1858efedaf1a..411177ec4d72 100644 --- a/drivers/media/pci/sta2x11/sta2x11_vip.c +++ b/drivers/media/pci/sta2x11/sta2x11_vip.c @@ -419,8 +419,8 @@ static int vidioc_querycap(struct file *file, void *priv, { struct sta2x11_vip *vip = video_drvdata(file); - strcpy(cap->driver, KBUILD_MODNAME); - strcpy(cap->card, KBUILD_MODNAME); + strscpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver)); + strscpy(cap->card, KBUILD_MODNAME, sizeof(cap->card)); snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", pci_name(vip->pdev)); cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | @@ -580,7 +580,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, if (f->index != 0) return -EINVAL; - strcpy(f->description, "4:2:2, packed, UYVY"); + strscpy(f->description, "4:2:2, packed, UYVY", sizeof(f->description)); f->pixelformat = V4L2_PIX_FMT_UYVY; f->flags = 0; return 0; diff --git a/drivers/media/pci/ttpci/av7110.c b/drivers/media/pci/ttpci/av7110.c index d6816effb878..409defc75c05 100644 --- a/drivers/media/pci/ttpci/av7110.c +++ b/drivers/media/pci/ttpci/av7110.c @@ -2482,7 +2482,8 @@ static int av7110_attach(struct saa7146_dev* dev, get recognized before the main driver is fully loaded */ saa7146_write(dev, GPIO_CTRL, 0x500000); - strlcpy(av7110->i2c_adap.name, pci_ext->ext_priv, sizeof(av7110->i2c_adap.name)); + strscpy(av7110->i2c_adap.name, pci_ext->ext_priv, + sizeof(av7110->i2c_adap.name)); saa7146_i2c_adapter_prepare(dev, &av7110->i2c_adap, SAA7146_I2C_BUS_BIT_RATE_120); /* 275 kHz */ diff --git a/drivers/media/pci/ttpci/av7110_av.c b/drivers/media/pci/ttpci/av7110_av.c index ef1bc17cdc4d..1073e4671b68 100644 --- a/drivers/media/pci/ttpci/av7110_av.c +++ b/drivers/media/pci/ttpci/av7110_av.c @@ -932,7 +932,6 @@ static int dvb_video_get_event (struct av7110 *av7110, struct video_event *event return 0; } - /****************************************************************************** * DVB device file operations ******************************************************************************/ @@ -1095,6 +1094,42 @@ static int play_iframe(struct av7110 *av7110, char __user *buf, unsigned int len return 0; } +#ifdef CONFIG_COMPAT +struct compat_video_still_picture { + compat_uptr_t iFrame; + int32_t size; +}; +#define VIDEO_STILLPICTURE32 _IOW('o', 30, struct compat_video_still_picture) + +struct compat_video_event { + __s32 type; + /* unused, make sure to use atomic time for y2038 if it ever gets used */ + compat_long_t timestamp; + union { + video_size_t size; + unsigned int frame_rate; /* in frames per 1000sec */ + unsigned char vsync_field; /* unknown/odd/even/progressive */ + } u; +}; +#define VIDEO_GET_EVENT32 _IOR('o', 28, struct compat_video_event) + +static int dvb_compat_video_get_event(struct av7110 *av7110, + struct compat_video_event *event, int flags) +{ + struct video_event ev; + int ret; + + ret = dvb_video_get_event(av7110, &ev, flags); + + *event = (struct compat_video_event) { + .type = ev.type, + .timestamp = ev.timestamp, + .u.size = ev.u.size, + }; + + return ret; +} +#endif static int dvb_video_ioctl(struct file *file, unsigned int cmd, void *parg) @@ -1184,6 +1219,12 @@ static int dvb_video_ioctl(struct file *file, memcpy(parg, &av7110->videostate, sizeof(struct video_status)); break; +#ifdef CONFIG_COMPAT + case VIDEO_GET_EVENT32: + ret = dvb_compat_video_get_event(av7110, parg, file->f_flags); + break; +#endif + case VIDEO_GET_EVENT: ret = dvb_video_get_event(av7110, parg, file->f_flags); break; @@ -1226,6 +1267,19 @@ static int dvb_video_ioctl(struct file *file, 1, (u16) arg); break; +#ifdef CONFIG_COMPAT + case VIDEO_STILLPICTURE32: + { + struct compat_video_still_picture *pic = + (struct compat_video_still_picture *) parg; + av7110->videostate.stream_source = VIDEO_SOURCE_MEMORY; + dvb_ringbuffer_flush_spinlock_wakeup(&av7110->avout); + ret = play_iframe(av7110, compat_ptr(pic->iFrame), + pic->size, file->f_flags & O_NONBLOCK); + break; + } +#endif + case VIDEO_STILLPICTURE: { struct video_still_picture *pic = @@ -1533,6 +1587,7 @@ static const struct file_operations dvb_video_fops = { .owner = THIS_MODULE, .write = dvb_video_write, .unlocked_ioctl = dvb_generic_ioctl, + .compat_ioctl = dvb_generic_ioctl, .open = dvb_video_open, .release = dvb_video_release, .poll = dvb_video_poll, @@ -1552,6 +1607,7 @@ static const struct file_operations dvb_audio_fops = { .owner = THIS_MODULE, .write = dvb_audio_write, .unlocked_ioctl = dvb_generic_ioctl, + .compat_ioctl = dvb_generic_ioctl, .open = dvb_audio_open, .release = dvb_audio_release, .poll = dvb_audio_poll, diff --git a/drivers/media/pci/ttpci/av7110_v4l.c b/drivers/media/pci/ttpci/av7110_v4l.c index e4cf42c32284..d1fe15365f4a 100644 --- a/drivers/media/pci/ttpci/av7110_v4l.c +++ b/drivers/media/pci/ttpci/av7110_v4l.c @@ -332,7 +332,7 @@ static int vidioc_g_tuner(struct file *file, void *fh, struct v4l2_tuner *t) return -EINVAL; memset(t, 0, sizeof(*t)); - strcpy((char *)t->name, "Television"); + strscpy((char *)t->name, "Television", sizeof(t->name)); t->type = V4L2_TUNER_ANALOG_TV; t->capability = V4L2_TUNER_CAP_NORM | V4L2_TUNER_CAP_STEREO | diff --git a/drivers/media/pci/ttpci/budget-core.c b/drivers/media/pci/ttpci/budget-core.c index b3dc45b91101..35b696bdb2df 100644 --- a/drivers/media/pci/ttpci/budget-core.c +++ b/drivers/media/pci/ttpci/budget-core.c @@ -504,10 +504,12 @@ int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev, if (bi->type != BUDGET_FS_ACTIVY) saa7146_write(dev, GPIO_CTRL, 0x500000); /* GPIO 3 = 1 */ - strlcpy(budget->i2c_adap.name, budget->card->name, sizeof(budget->i2c_adap.name)); + strscpy(budget->i2c_adap.name, budget->card->name, + sizeof(budget->i2c_adap.name)); saa7146_i2c_adapter_prepare(dev, &budget->i2c_adap, SAA7146_I2C_BUS_BIT_RATE_120); - strcpy(budget->i2c_adap.name, budget->card->name); + strscpy(budget->i2c_adap.name, budget->card->name, + sizeof(budget->i2c_adap.name)); if (i2c_add_adapter(&budget->i2c_adap) < 0) { ret = -ENOMEM; diff --git a/drivers/media/pci/tw5864/tw5864-video.c b/drivers/media/pci/tw5864/tw5864-video.c index ff2b7da90c08..5a1f3aa4101a 100644 --- a/drivers/media/pci/tw5864/tw5864-video.c +++ b/drivers/media/pci/tw5864/tw5864-video.c @@ -610,7 +610,7 @@ static int tw5864_querycap(struct file *file, void *priv, { struct tw5864_input *input = video_drvdata(file); - strcpy(cap->driver, "tw5864"); + strscpy(cap->driver, "tw5864", sizeof(cap->driver)); snprintf(cap->card, sizeof(cap->card), "TW5864 Encoder %d", input->nr); sprintf(cap->bus_info, "PCI:%s", pci_name(input->root->pci)); diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c index 8c1f4a049764..d3f727045ae8 100644 --- a/drivers/media/pci/tw68/tw68-video.c +++ b/drivers/media/pci/tw68/tw68-video.c @@ -734,8 +734,8 @@ static int tw68_querycap(struct file *file, void *priv, { struct tw68_dev *dev = video_drvdata(file); - strcpy(cap->driver, "tw68"); - strlcpy(cap->card, "Techwell Capture Card", + strscpy(cap->driver, "tw68", sizeof(cap->driver)); + strscpy(cap->card, "Techwell Capture Card", sizeof(cap->card)); sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci)); cap->device_caps = @@ -789,7 +789,7 @@ static int tw68_enum_fmt_vid_cap(struct file *file, void *priv, if (f->index >= FORMATS) return -EINVAL; - strlcpy(f->description, formats[f->index].name, + strscpy(f->description, formats[f->index].name, sizeof(f->description)); f->pixelformat = formats[f->index].fourcc; diff --git a/drivers/media/pci/tw686x/tw686x-audio.c b/drivers/media/pci/tw686x/tw686x-audio.c index 77190768622a..a28329698e20 100644 --- a/drivers/media/pci/tw686x/tw686x-audio.c +++ b/drivers/media/pci/tw686x/tw686x-audio.c @@ -295,7 +295,7 @@ static int tw686x_snd_pcm_init(struct tw686x_dev *dev) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &tw686x_pcm_ops); snd_pcm_chip(pcm) = dev; pcm->info_flags = 0; - strlcpy(pcm->name, "tw686x PCM", sizeof(pcm->name)); + strscpy(pcm->name, "tw686x PCM", sizeof(pcm->name)); for (i = 0, ss = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; ss; ss = ss->next, i++) @@ -390,9 +390,9 @@ int tw686x_audio_init(struct tw686x_dev *dev) return err; dev->snd_card = card; - strlcpy(card->driver, "tw686x", sizeof(card->driver)); - strlcpy(card->shortname, "tw686x", sizeof(card->shortname)); - strlcpy(card->longname, pci_name(pci_dev), sizeof(card->longname)); + strscpy(card->driver, "tw686x", sizeof(card->driver)); + strscpy(card->shortname, "tw686x", sizeof(card->shortname)); + strscpy(card->longname, pci_name(pci_dev), sizeof(card->longname)); snd_card_set_dev(card, &pci_dev->dev); for (ch = 0; ch < max_channels(dev); ch++) { diff --git a/drivers/media/pci/tw686x/tw686x-video.c b/drivers/media/pci/tw686x/tw686x-video.c index 3a06c000f97b..4890b7f1248b 100644 --- a/drivers/media/pci/tw686x/tw686x-video.c +++ b/drivers/media/pci/tw686x/tw686x-video.c @@ -765,8 +765,8 @@ static int tw686x_querycap(struct file *file, void *priv, struct tw686x_video_channel *vc = video_drvdata(file); struct tw686x_dev *dev = vc->dev; - strlcpy(cap->driver, "tw686x", sizeof(cap->driver)); - strlcpy(cap->card, dev->name, sizeof(cap->card)); + strscpy(cap->driver, "tw686x", sizeof(cap->driver)); + strscpy(cap->card, dev->name, sizeof(cap->card)); snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", pci_name(dev->pci_dev)); cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | |