Commit 675722b0 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

Merge branch 'upstream-fixes' into patchwork

Merge the media fixes merged upstream for v3.13-rc4

* upstream-fixes: (30 commits)
  [media] videobuf2-dma-sg: fix possible memory leak
  [media] vb2: regression fix: always set length field.
  [media] mt9p031: Include linux/of.h header
  [media] rtl2830: add parent for I2C adapter
  [media] media: marvell-ccic: use devm to release clk
  [media] ths7303: Declare as static a private function
  [media] em28xx-video: Swap release order to avoid lock nesting
  [media] usbtv: Add support for PAL video source
  [media] media_tree: Fix spelling errors
  [media] videobuf2: Add support for file access mode flags for DMABUF exporting
  [media] radio-shark2: Mark shark_resume_leds() inline to kill compiler warning
  [media] radio-shark: Mark shark_resume_leds() inline to kill compiler warning
  [media] af9035: unlock on error in af9035_i2c_master_xfer()
  [media] af9033: fix broken I2C
  [media] v4l: omap3isp: Don't check for missing get_fmt op on remote subdev
  [media] af9035: fix broken I2C and USB I/O
  [media] wm8775: fix broken audio routing
  [media] marvell-ccic: drop resource free in driver remove
  [media] tef6862/radio-tea5764: actually assign clamp result
  [media] cx231xx: use after free on error path in probe
  ...
parents 989af883 64c832a4
...@@ -1032,8 +1032,13 @@ static int dmx_section_feed_release_filter(struct dmx_section_feed *feed, ...@@ -1032,8 +1032,13 @@ static int dmx_section_feed_release_filter(struct dmx_section_feed *feed,
return -EINVAL; return -EINVAL;
} }
if (feed->is_filtering) if (feed->is_filtering) {
/* release dvbdmx->mutex as far as it is
acquired by stop_filtering() itself */
mutex_unlock(&dvbdmx->mutex);
feed->stop_filtering(feed); feed->stop_filtering(feed);
mutex_lock(&dvbdmx->mutex);
}
spin_lock_irq(&dvbdmx->lock); spin_lock_irq(&dvbdmx->lock);
f = dvbdmxfeed->filter; f = dvbdmxfeed->filter;
......
...@@ -170,18 +170,18 @@ static int af9033_rd_reg_mask(struct af9033_state *state, u32 reg, u8 *val, ...@@ -170,18 +170,18 @@ static int af9033_rd_reg_mask(struct af9033_state *state, u32 reg, u8 *val,
static int af9033_wr_reg_val_tab(struct af9033_state *state, static int af9033_wr_reg_val_tab(struct af9033_state *state,
const struct reg_val *tab, int tab_len) const struct reg_val *tab, int tab_len)
{ {
#define MAX_TAB_LEN 212
int ret, i, j; int ret, i, j;
u8 buf[MAX_XFER_SIZE]; u8 buf[1 + MAX_TAB_LEN];
dev_dbg(&state->i2c->dev, "%s: tab_len=%d\n", __func__, tab_len);
if (tab_len > sizeof(buf)) { if (tab_len > sizeof(buf)) {
dev_warn(&state->i2c->dev, dev_warn(&state->i2c->dev, "%s: tab len %d is too big\n",
"%s: i2c wr len=%d is too big!\n", KBUILD_MODNAME, tab_len);
KBUILD_MODNAME, tab_len);
return -EINVAL; return -EINVAL;
} }
dev_dbg(&state->i2c->dev, "%s: tab_len=%d\n", __func__, tab_len);
for (i = 0, j = 0; i < tab_len; i++) { for (i = 0, j = 0; i < tab_len; i++) {
buf[j] = tab[i].val; buf[j] = tab[i].val;
......
...@@ -78,7 +78,7 @@ int cxd2820r_set_frontend_c(struct dvb_frontend *fe) ...@@ -78,7 +78,7 @@ int cxd2820r_set_frontend_c(struct dvb_frontend *fe)
num = if_freq / 1000; /* Hz => kHz */ num = if_freq / 1000; /* Hz => kHz */
num *= 0x4000; num *= 0x4000;
if_ctl = cxd2820r_div_u64_round_closest(num, 41000); if_ctl = 0x4000 - cxd2820r_div_u64_round_closest(num, 41000);
buf[0] = (if_ctl >> 8) & 0x3f; buf[0] = (if_ctl >> 8) & 0x3f;
buf[1] = (if_ctl >> 0) & 0xff; buf[1] = (if_ctl >> 0) & 0xff;
......
...@@ -130,12 +130,10 @@ static int wm8775_s_routing(struct v4l2_subdev *sd, ...@@ -130,12 +130,10 @@ static int wm8775_s_routing(struct v4l2_subdev *sd,
return -EINVAL; return -EINVAL;
} }
state->input = input; state->input = input;
if (!v4l2_ctrl_g_ctrl(state->mute)) if (v4l2_ctrl_g_ctrl(state->mute))
return 0; return 0;
if (!v4l2_ctrl_g_ctrl(state->vol)) if (!v4l2_ctrl_g_ctrl(state->vol))
return 0; return 0;
if (!v4l2_ctrl_g_ctrl(state->bal))
return 0;
wm8775_set_audio(sd, 1); wm8775_set_audio(sd, 1);
return 0; return 0;
} }
......
...@@ -4182,7 +4182,8 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id) ...@@ -4182,7 +4182,8 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
} }
btv->std = V4L2_STD_PAL; btv->std = V4L2_STD_PAL;
init_irqreg(btv); init_irqreg(btv);
v4l2_ctrl_handler_setup(hdl); if (!bttv_tvcards[btv->c.type].no_video)
v4l2_ctrl_handler_setup(hdl);
if (hdl->error) { if (hdl->error) {
result = hdl->error; result = hdl->error;
goto fail2; goto fail2;
......
...@@ -1354,9 +1354,11 @@ static int saa7164_initdev(struct pci_dev *pci_dev, ...@@ -1354,9 +1354,11 @@ static int saa7164_initdev(struct pci_dev *pci_dev,
if (fw_debug) { if (fw_debug) {
dev->kthread = kthread_run(saa7164_thread_function, dev, dev->kthread = kthread_run(saa7164_thread_function, dev,
"saa7164 debug"); "saa7164 debug");
if (!dev->kthread) if (IS_ERR(dev->kthread)) {
dev->kthread = NULL;
printk(KERN_ERR "%s() Failed to create " printk(KERN_ERR "%s() Failed to create "
"debug kernel thread\n", __func__); "debug kernel thread\n", __func__);
}
} }
} /* != BOARD_UNKNOWN */ } /* != BOARD_UNKNOWN */
......
...@@ -290,14 +290,11 @@ __isp_video_get_format(struct isp_video *video, struct v4l2_format *format) ...@@ -290,14 +290,11 @@ __isp_video_get_format(struct isp_video *video, struct v4l2_format *format)
if (subdev == NULL) if (subdev == NULL)
return -EINVAL; return -EINVAL;
mutex_lock(&video->mutex);
fmt.pad = pad; fmt.pad = pad;
fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt);
if (ret == -ENOIOCTLCMD)
ret = -EINVAL;
mutex_lock(&video->mutex);
ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt);
mutex_unlock(&video->mutex); mutex_unlock(&video->mutex);
if (ret) if (ret)
......
...@@ -1039,8 +1039,10 @@ int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf) ...@@ -1039,8 +1039,10 @@ int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf)
/* ... and the buffers queue... */ /* ... and the buffers queue... */
video->alloc_ctx = vb2_dma_contig_init_ctx(video->vsp1->dev); video->alloc_ctx = vb2_dma_contig_init_ctx(video->vsp1->dev);
if (IS_ERR(video->alloc_ctx)) if (IS_ERR(video->alloc_ctx)) {
ret = PTR_ERR(video->alloc_ctx);
goto error; goto error;
}
video->queue.type = video->type; video->queue.type = video->type;
video->queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; video->queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
......
...@@ -356,7 +356,7 @@ static int vidioc_s_frequency(struct file *file, void *priv, ...@@ -356,7 +356,7 @@ static int vidioc_s_frequency(struct file *file, void *priv,
So we keep it as-is. */ So we keep it as-is. */
return -EINVAL; return -EINVAL;
} }
clamp(freq, FREQ_MIN * FREQ_MUL, FREQ_MAX * FREQ_MUL); freq = clamp(freq, FREQ_MIN * FREQ_MUL, FREQ_MAX * FREQ_MUL);
tea5764_power_up(radio); tea5764_power_up(radio);
tea5764_tune(radio, (freq * 125) / 2); tea5764_tune(radio, (freq * 125) / 2);
return 0; return 0;
......
...@@ -112,7 +112,7 @@ static int tef6862_s_frequency(struct v4l2_subdev *sd, const struct v4l2_frequen ...@@ -112,7 +112,7 @@ static int tef6862_s_frequency(struct v4l2_subdev *sd, const struct v4l2_frequen
if (f->tuner != 0) if (f->tuner != 0)
return -EINVAL; return -EINVAL;
clamp(freq, TEF6862_LO_FREQ, TEF6862_HI_FREQ); freq = clamp(freq, TEF6862_LO_FREQ, TEF6862_HI_FREQ);
pll = 1964 + ((freq - TEF6862_LO_FREQ) * 20) / FREQ_MUL; pll = 1964 + ((freq - TEF6862_LO_FREQ) * 20) / FREQ_MUL;
i2cmsg[0] = (MSA_MODE_PRESET << MSA_MODE_SHIFT) | WM_SUB_PLLM; i2cmsg[0] = (MSA_MODE_PRESET << MSA_MODE_SHIFT) | WM_SUB_PLLM;
i2cmsg[1] = (pll >> 8) & 0xff; i2cmsg[1] = (pll >> 8) & 0xff;
......
...@@ -1412,8 +1412,8 @@ static int cx231xx_usb_probe(struct usb_interface *interface, ...@@ -1412,8 +1412,8 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
usb_set_intfdata(interface, NULL); usb_set_intfdata(interface, NULL);
err_if: err_if:
usb_put_dev(udev); usb_put_dev(udev);
kfree(dev);
clear_bit(dev->devno, &cx231xx_devused); clear_bit(dev->devno, &cx231xx_devused);
kfree(dev);
return retval; return retval;
} }
......
...@@ -131,7 +131,7 @@ static int af9035_wr_regs(struct dvb_usb_device *d, u32 reg, u8 *val, int len) ...@@ -131,7 +131,7 @@ static int af9035_wr_regs(struct dvb_usb_device *d, u32 reg, u8 *val, int len)
{ {
u8 wbuf[MAX_XFER_SIZE]; u8 wbuf[MAX_XFER_SIZE];
u8 mbox = (reg >> 16) & 0xff; u8 mbox = (reg >> 16) & 0xff;
struct usb_req req = { CMD_MEM_WR, mbox, sizeof(wbuf), wbuf, 0, NULL }; struct usb_req req = { CMD_MEM_WR, mbox, 6 + len, wbuf, 0, NULL };
if (6 + len > sizeof(wbuf)) { if (6 + len > sizeof(wbuf)) {
dev_warn(&d->udev->dev, "%s: i2c wr: len=%d is too big!\n", dev_warn(&d->udev->dev, "%s: i2c wr: len=%d is too big!\n",
...@@ -238,14 +238,15 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap, ...@@ -238,14 +238,15 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
} else { } else {
/* I2C */ /* I2C */
u8 buf[MAX_XFER_SIZE]; u8 buf[MAX_XFER_SIZE];
struct usb_req req = { CMD_I2C_RD, 0, sizeof(buf), struct usb_req req = { CMD_I2C_RD, 0, 5 + msg[0].len,
buf, msg[1].len, msg[1].buf }; buf, msg[1].len, msg[1].buf };
if (5 + msg[0].len > sizeof(buf)) { if (5 + msg[0].len > sizeof(buf)) {
dev_warn(&d->udev->dev, dev_warn(&d->udev->dev,
"%s: i2c xfer: len=%d is too big!\n", "%s: i2c xfer: len=%d is too big!\n",
KBUILD_MODNAME, msg[0].len); KBUILD_MODNAME, msg[0].len);
return -EOPNOTSUPP; ret = -EOPNOTSUPP;
goto unlock;
} }
req.mbox |= ((msg[0].addr & 0x80) >> 3); req.mbox |= ((msg[0].addr & 0x80) >> 3);
buf[0] = msg[1].len; buf[0] = msg[1].len;
...@@ -274,14 +275,15 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap, ...@@ -274,14 +275,15 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
} else { } else {
/* I2C */ /* I2C */
u8 buf[MAX_XFER_SIZE]; u8 buf[MAX_XFER_SIZE];
struct usb_req req = { CMD_I2C_WR, 0, sizeof(buf), buf, struct usb_req req = { CMD_I2C_WR, 0, 5 + msg[0].len,
0, NULL }; buf, 0, NULL };
if (5 + msg[0].len > sizeof(buf)) { if (5 + msg[0].len > sizeof(buf)) {
dev_warn(&d->udev->dev, dev_warn(&d->udev->dev,
"%s: i2c xfer: len=%d is too big!\n", "%s: i2c xfer: len=%d is too big!\n",
KBUILD_MODNAME, msg[0].len); KBUILD_MODNAME, msg[0].len);
return -EOPNOTSUPP; ret = -EOPNOTSUPP;
goto unlock;
} }
req.mbox |= ((msg[0].addr & 0x80) >> 3); req.mbox |= ((msg[0].addr & 0x80) >> 3);
buf[0] = msg[0].len; buf[0] = msg[0].len;
...@@ -319,6 +321,7 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap, ...@@ -319,6 +321,7 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
} }
unlock:
mutex_unlock(&d->i2c_mutex); mutex_unlock(&d->i2c_mutex);
if (ret < 0) if (ret < 0)
......
...@@ -102,7 +102,7 @@ static int technisat_usb2_i2c_access(struct usb_device *udev, ...@@ -102,7 +102,7 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
if (rxlen > 62) { if (rxlen > 62) {
err("i2c RX buffer can't exceed 62 bytes (dev 0x%02x)", err("i2c RX buffer can't exceed 62 bytes (dev 0x%02x)",
device_addr); device_addr);
txlen = 62; rxlen = 62;
} }
b[0] = I2C_SPEED_100KHZ_BIT; b[0] = I2C_SPEED_100KHZ_BIT;
......
...@@ -361,6 +361,9 @@ static void stk1135_configure_clock(struct gspca_dev *gspca_dev) ...@@ -361,6 +361,9 @@ static void stk1135_configure_clock(struct gspca_dev *gspca_dev)
/* set serial interface clock divider (30MHz/0x1f*16+2) = 60240 kHz) */ /* set serial interface clock divider (30MHz/0x1f*16+2) = 60240 kHz) */
reg_w(gspca_dev, STK1135_REG_SICTL + 2, 0x1f); reg_w(gspca_dev, STK1135_REG_SICTL + 2, 0x1f);
/* wait a while for sensor to catch up */
udelay(1000);
} }
static void stk1135_camera_disable(struct gspca_dev *gspca_dev) static void stk1135_camera_disable(struct gspca_dev *gspca_dev)
......
...@@ -1027,6 +1027,7 @@ static const struct usb_device_id device_table[] = { ...@@ -1027,6 +1027,7 @@ static const struct usb_device_id device_table[] = {
{USB_DEVICE(0x055f, 0xc650), BS(SPCA533, 0)}, {USB_DEVICE(0x055f, 0xc650), BS(SPCA533, 0)},
{USB_DEVICE(0x05da, 0x1018), BS(SPCA504B, 0)}, {USB_DEVICE(0x05da, 0x1018), BS(SPCA504B, 0)},
{USB_DEVICE(0x06d6, 0x0031), BS(SPCA533, 0)}, {USB_DEVICE(0x06d6, 0x0031), BS(SPCA533, 0)},
{USB_DEVICE(0x06d6, 0x0041), BS(SPCA504B, 0)},
{USB_DEVICE(0x0733, 0x1311), BS(SPCA533, 0)}, {USB_DEVICE(0x0733, 0x1311), BS(SPCA533, 0)},
{USB_DEVICE(0x0733, 0x1314), BS(SPCA533, 0)}, {USB_DEVICE(0x0733, 0x1314), BS(SPCA533, 0)},
{USB_DEVICE(0x0733, 0x2211), BS(SPCA533, 0)}, {USB_DEVICE(0x0733, 0x2211), BS(SPCA533, 0)},
......
...@@ -144,6 +144,25 @@ static void __vb2_buf_dmabuf_put(struct vb2_buffer *vb) ...@@ -144,6 +144,25 @@ static void __vb2_buf_dmabuf_put(struct vb2_buffer *vb)
__vb2_plane_dmabuf_put(q, &vb->planes[plane]); __vb2_plane_dmabuf_put(q, &vb->planes[plane]);
} }
/**
* __setup_lengths() - setup initial lengths for every plane in
* every buffer on the queue
*/
static void __setup_lengths(struct vb2_queue *q, unsigned int n)
{
unsigned int buffer, plane;
struct vb2_buffer *vb;
for (buffer = q->num_buffers; buffer < q->num_buffers + n; ++buffer) {
vb = q->bufs[buffer];
if (!vb)
continue;
for (plane = 0; plane < vb->num_planes; ++plane)
vb->v4l2_planes[plane].length = q->plane_sizes[plane];
}
}
/** /**
* __setup_offsets() - setup unique offsets ("cookies") for every plane in * __setup_offsets() - setup unique offsets ("cookies") for every plane in
* every buffer on the queue * every buffer on the queue
...@@ -169,7 +188,6 @@ static void __setup_offsets(struct vb2_queue *q, unsigned int n) ...@@ -169,7 +188,6 @@ static void __setup_offsets(struct vb2_queue *q, unsigned int n)
continue; continue;
for (plane = 0; plane < vb->num_planes; ++plane) { for (plane = 0; plane < vb->num_planes; ++plane) {
vb->v4l2_planes[plane].length = q->plane_sizes[plane];
vb->v4l2_planes[plane].m.mem_offset = off; vb->v4l2_planes[plane].m.mem_offset = off;
dprintk(3, "Buffer %d, plane %d offset 0x%08lx\n", dprintk(3, "Buffer %d, plane %d offset 0x%08lx\n",
...@@ -241,6 +259,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum v4l2_memory memory, ...@@ -241,6 +259,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum v4l2_memory memory,
q->bufs[q->num_buffers + buffer] = vb; q->bufs[q->num_buffers + buffer] = vb;
} }
__setup_lengths(q, buffer);
if (memory == V4L2_MEMORY_MMAP) if (memory == V4L2_MEMORY_MMAP)
__setup_offsets(q, buffer); __setup_offsets(q, buffer);
......
...@@ -185,7 +185,7 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr, ...@@ -185,7 +185,7 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr,
buf->pages = kzalloc(buf->num_pages * sizeof(struct page *), buf->pages = kzalloc(buf->num_pages * sizeof(struct page *),
GFP_KERNEL); GFP_KERNEL);
if (!buf->pages) if (!buf->pages)
return NULL; goto userptr_fail_alloc_pages;
vma = find_vma(current->mm, vaddr); vma = find_vma(current->mm, vaddr);
if (!vma) { if (!vma) {
...@@ -245,6 +245,7 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr, ...@@ -245,6 +245,7 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr,
vb2_put_vma(buf->vma); vb2_put_vma(buf->vma);
userptr_fail_find_vma: userptr_fail_find_vma:
kfree(buf->pages); kfree(buf->pages);
userptr_fail_alloc_pages:
kfree(buf); kfree(buf);
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment