Commit eff505fa authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Mauro Carvalho Chehab

V4L/DVB (11609): soc-camera: remove an extra device generation from struct soc_camera_host

Make camera devices direct children of host platform devices, move the
inheritance management into the soc_camera.c core driver.
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent eb6c8558
...@@ -106,7 +106,6 @@ struct mx1_camera_dev { ...@@ -106,7 +106,6 @@ struct mx1_camera_dev {
struct soc_camera_device *icd; struct soc_camera_device *icd;
struct mx1_camera_pdata *pdata; struct mx1_camera_pdata *pdata;
struct mx1_buffer *active; struct mx1_buffer *active;
struct device *dev;
struct resource *res; struct resource *res;
struct clk *clk; struct clk *clk;
struct list_head capture; struct list_head capture;
...@@ -220,7 +219,7 @@ static int mx1_camera_setup_dma(struct mx1_camera_dev *pcdev) ...@@ -220,7 +219,7 @@ static int mx1_camera_setup_dma(struct mx1_camera_dev *pcdev)
int ret; int ret;
if (unlikely(!pcdev->active)) { if (unlikely(!pcdev->active)) {
dev_err(pcdev->dev, "DMA End IRQ with no active buffer\n"); dev_err(pcdev->soc_host.dev, "DMA End IRQ with no active buffer\n");
return -EFAULT; return -EFAULT;
} }
...@@ -230,7 +229,7 @@ static int mx1_camera_setup_dma(struct mx1_camera_dev *pcdev) ...@@ -230,7 +229,7 @@ static int mx1_camera_setup_dma(struct mx1_camera_dev *pcdev)
vbuf->size, pcdev->res->start + vbuf->size, pcdev->res->start +
CSIRXR, DMA_MODE_READ); CSIRXR, DMA_MODE_READ);
if (unlikely(ret)) if (unlikely(ret))
dev_err(pcdev->dev, "Failed to setup DMA sg list\n"); dev_err(pcdev->soc_host.dev, "Failed to setup DMA sg list\n");
return ret; return ret;
} }
...@@ -339,14 +338,14 @@ static void mx1_camera_dma_irq(int channel, void *data) ...@@ -339,14 +338,14 @@ static void mx1_camera_dma_irq(int channel, void *data)
imx_dma_disable(channel); imx_dma_disable(channel);
if (unlikely(!pcdev->active)) { if (unlikely(!pcdev->active)) {
dev_err(pcdev->dev, "DMA End IRQ with no active buffer\n"); dev_err(pcdev->soc_host.dev, "DMA End IRQ with no active buffer\n");
goto out; goto out;
} }
vb = &pcdev->active->vb; vb = &pcdev->active->vb;
buf = container_of(vb, struct mx1_buffer, vb); buf = container_of(vb, struct mx1_buffer, vb);
WARN_ON(buf->inwork || list_empty(&vb->queue)); WARN_ON(buf->inwork || list_empty(&vb->queue));
dev_dbg(pcdev->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, dev_dbg(pcdev->soc_host.dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
vb, vb->baddr, vb->bsize); vb, vb->baddr, vb->bsize);
mx1_camera_wakeup(pcdev, vb, buf); mx1_camera_wakeup(pcdev, vb, buf);
...@@ -367,7 +366,7 @@ static void mx1_camera_init_videobuf(struct videobuf_queue *q, ...@@ -367,7 +366,7 @@ static void mx1_camera_init_videobuf(struct videobuf_queue *q,
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
struct mx1_camera_dev *pcdev = ici->priv; struct mx1_camera_dev *pcdev = ici->priv;
videobuf_queue_dma_contig_init(q, &mx1_videobuf_ops, pcdev->dev, videobuf_queue_dma_contig_init(q, &mx1_videobuf_ops, ici->dev,
&pcdev->lock, &pcdev->lock,
V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_NONE, V4L2_FIELD_NONE,
...@@ -386,7 +385,7 @@ static int mclk_get_divisor(struct mx1_camera_dev *pcdev) ...@@ -386,7 +385,7 @@ static int mclk_get_divisor(struct mx1_camera_dev *pcdev)
* they get a nice Oops */ * they get a nice Oops */
div = (lcdclk + 2 * mclk - 1) / (2 * mclk) - 1; div = (lcdclk + 2 * mclk - 1) / (2 * mclk) - 1;
dev_dbg(pcdev->dev, "System clock %lukHz, target freq %dkHz, " dev_dbg(pcdev->soc_host.dev, "System clock %lukHz, target freq %dkHz, "
"divisor %lu\n", lcdclk / 1000, mclk / 1000, div); "divisor %lu\n", lcdclk / 1000, mclk / 1000, div);
return div; return div;
...@@ -396,7 +395,7 @@ static void mx1_camera_activate(struct mx1_camera_dev *pcdev) ...@@ -396,7 +395,7 @@ static void mx1_camera_activate(struct mx1_camera_dev *pcdev)
{ {
unsigned int csicr1 = CSICR1_EN; unsigned int csicr1 = CSICR1_EN;
dev_dbg(pcdev->dev, "Activate device\n"); dev_dbg(pcdev->soc_host.dev, "Activate device\n");
clk_enable(pcdev->clk); clk_enable(pcdev->clk);
...@@ -412,7 +411,7 @@ static void mx1_camera_activate(struct mx1_camera_dev *pcdev) ...@@ -412,7 +411,7 @@ static void mx1_camera_activate(struct mx1_camera_dev *pcdev)
static void mx1_camera_deactivate(struct mx1_camera_dev *pcdev) static void mx1_camera_deactivate(struct mx1_camera_dev *pcdev)
{ {
dev_dbg(pcdev->dev, "Deactivate device\n"); dev_dbg(pcdev->soc_host.dev, "Deactivate device\n");
/* Disable all CSI interface */ /* Disable all CSI interface */
__raw_writel(0x00, pcdev->base + CSICR1); __raw_writel(0x00, pcdev->base + CSICR1);
...@@ -551,7 +550,7 @@ static int mx1_camera_set_fmt(struct soc_camera_device *icd, ...@@ -551,7 +550,7 @@ static int mx1_camera_set_fmt(struct soc_camera_device *icd,
xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat); xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
if (!xlate) { if (!xlate) {
dev_warn(&ici->dev, "Format %x not found\n", pix->pixelformat); dev_warn(ici->dev, "Format %x not found\n", pix->pixelformat);
return -EINVAL; return -EINVAL;
} }
...@@ -668,7 +667,6 @@ static int __init mx1_camera_probe(struct platform_device *pdev) ...@@ -668,7 +667,6 @@ static int __init mx1_camera_probe(struct platform_device *pdev)
goto exit_put_clk; goto exit_put_clk;
} }
platform_set_drvdata(pdev, pcdev);
pcdev->res = res; pcdev->res = res;
pcdev->clk = clk; pcdev->clk = clk;
...@@ -702,16 +700,15 @@ static int __init mx1_camera_probe(struct platform_device *pdev) ...@@ -702,16 +700,15 @@ static int __init mx1_camera_probe(struct platform_device *pdev)
} }
pcdev->irq = irq; pcdev->irq = irq;
pcdev->base = base; pcdev->base = base;
pcdev->dev = &pdev->dev;
/* request dma */ /* request dma */
pcdev->dma_chan = imx_dma_request_by_prio(DRIVER_NAME, DMA_PRIO_HIGH); pcdev->dma_chan = imx_dma_request_by_prio(DRIVER_NAME, DMA_PRIO_HIGH);
if (pcdev->dma_chan < 0) { if (pcdev->dma_chan < 0) {
dev_err(pcdev->dev, "Can't request DMA for MX1 CSI\n"); dev_err(&pdev->dev, "Can't request DMA for MX1 CSI\n");
err = -EBUSY; err = -EBUSY;
goto exit_iounmap; goto exit_iounmap;
} }
dev_dbg(pcdev->dev, "got DMA channel %d\n", pcdev->dma_chan); dev_dbg(&pdev->dev, "got DMA channel %d\n", pcdev->dma_chan);
imx_dma_setup_handlers(pcdev->dma_chan, mx1_camera_dma_irq, NULL, imx_dma_setup_handlers(pcdev->dma_chan, mx1_camera_dma_irq, NULL,
pcdev); pcdev);
...@@ -724,7 +721,7 @@ static int __init mx1_camera_probe(struct platform_device *pdev) ...@@ -724,7 +721,7 @@ static int __init mx1_camera_probe(struct platform_device *pdev)
/* request irq */ /* request irq */
err = claim_fiq(&fh); err = claim_fiq(&fh);
if (err) { if (err) {
dev_err(pcdev->dev, "Camera interrupt register failed \n"); dev_err(&pdev->dev, "Camera interrupt register failed \n");
goto exit_free_dma; goto exit_free_dma;
} }
...@@ -744,7 +741,7 @@ static int __init mx1_camera_probe(struct platform_device *pdev) ...@@ -744,7 +741,7 @@ static int __init mx1_camera_probe(struct platform_device *pdev)
pcdev->soc_host.drv_name = DRIVER_NAME; pcdev->soc_host.drv_name = DRIVER_NAME;
pcdev->soc_host.ops = &mx1_soc_camera_host_ops; pcdev->soc_host.ops = &mx1_soc_camera_host_ops;
pcdev->soc_host.priv = pcdev; pcdev->soc_host.priv = pcdev;
pcdev->soc_host.dev.parent = &pdev->dev; pcdev->soc_host.dev = &pdev->dev;
pcdev->soc_host.nr = pdev->id; pcdev->soc_host.nr = pdev->id;
err = soc_camera_host_register(&pcdev->soc_host); err = soc_camera_host_register(&pcdev->soc_host);
if (err) if (err)
...@@ -774,7 +771,9 @@ static int __init mx1_camera_probe(struct platform_device *pdev) ...@@ -774,7 +771,9 @@ static int __init mx1_camera_probe(struct platform_device *pdev)
static int __exit mx1_camera_remove(struct platform_device *pdev) static int __exit mx1_camera_remove(struct platform_device *pdev)
{ {
struct mx1_camera_dev *pcdev = platform_get_drvdata(pdev); struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev);
struct mx1_camera_dev *pcdev = container_of(soc_host,
struct mx1_camera_dev, soc_host);
struct resource *res; struct resource *res;
imx_dma_free(pcdev->dma_chan); imx_dma_free(pcdev->dma_chan);
...@@ -784,7 +783,7 @@ static int __exit mx1_camera_remove(struct platform_device *pdev) ...@@ -784,7 +783,7 @@ static int __exit mx1_camera_remove(struct platform_device *pdev)
clk_put(pcdev->clk); clk_put(pcdev->clk);
soc_camera_host_unregister(&pcdev->soc_host); soc_camera_host_unregister(soc_host);
iounmap(pcdev->base); iounmap(pcdev->base);
......
...@@ -87,7 +87,6 @@ struct mx3_camera_buffer { ...@@ -87,7 +87,6 @@ struct mx3_camera_buffer {
* @soc_host: embedded soc_host object * @soc_host: embedded soc_host object
*/ */
struct mx3_camera_dev { struct mx3_camera_dev {
struct device *dev;
/* /*
* i.MX3x is only supposed to handle one camera on its Camera Sensor * i.MX3x is only supposed to handle one camera on its Camera Sensor
* Interface. If anyone ever builds hardware to enable more than one * Interface. If anyone ever builds hardware to enable more than one
...@@ -431,7 +430,7 @@ static void mx3_camera_init_videobuf(struct videobuf_queue *q, ...@@ -431,7 +430,7 @@ static void mx3_camera_init_videobuf(struct videobuf_queue *q,
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
struct mx3_camera_dev *mx3_cam = ici->priv; struct mx3_camera_dev *mx3_cam = ici->priv;
videobuf_queue_dma_contig_init(q, &mx3_videobuf_ops, mx3_cam->dev, videobuf_queue_dma_contig_init(q, &mx3_videobuf_ops, ici->dev,
&mx3_cam->lock, &mx3_cam->lock,
V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_NONE, V4L2_FIELD_NONE,
...@@ -599,7 +598,8 @@ static int test_platform_param(struct mx3_camera_dev *mx3_cam, ...@@ -599,7 +598,8 @@ static int test_platform_param(struct mx3_camera_dev *mx3_cam,
*flags |= SOCAM_DATAWIDTH_4; *flags |= SOCAM_DATAWIDTH_4;
break; break;
default: default:
dev_info(mx3_cam->dev, "Unsupported bus width %d\n", buswidth); dev_info(mx3_cam->soc_host.dev, "Unsupported bus width %d\n",
buswidth);
return -EINVAL; return -EINVAL;
} }
...@@ -614,7 +614,7 @@ static int mx3_camera_try_bus_param(struct soc_camera_device *icd, ...@@ -614,7 +614,7 @@ static int mx3_camera_try_bus_param(struct soc_camera_device *icd,
unsigned long bus_flags, camera_flags; unsigned long bus_flags, camera_flags;
int ret = test_platform_param(mx3_cam, depth, &bus_flags); int ret = test_platform_param(mx3_cam, depth, &bus_flags);
dev_dbg(&ici->dev, "requested bus width %d bit: %d\n", depth, ret); dev_dbg(ici->dev, "requested bus width %d bit: %d\n", depth, ret);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -637,7 +637,7 @@ static bool chan_filter(struct dma_chan *chan, void *arg) ...@@ -637,7 +637,7 @@ static bool chan_filter(struct dma_chan *chan, void *arg)
if (!rq) if (!rq)
return false; return false;
pdata = rq->mx3_cam->dev->platform_data; pdata = rq->mx3_cam->soc_host.dev->platform_data;
return rq->id == chan->chan_id && return rq->id == chan->chan_id &&
pdata->dma_dev == chan->device->dev; pdata->dma_dev == chan->device->dev;
...@@ -697,7 +697,7 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, int idx, ...@@ -697,7 +697,7 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, int idx,
xlate->cam_fmt = icd->formats + idx; xlate->cam_fmt = icd->formats + idx;
xlate->buswidth = buswidth; xlate->buswidth = buswidth;
xlate++; xlate++;
dev_dbg(&ici->dev, "Providing format %s using %s\n", dev_dbg(ici->dev, "Providing format %s using %s\n",
mx3_camera_formats[0].name, mx3_camera_formats[0].name,
icd->formats[idx].name); icd->formats[idx].name);
} }
...@@ -709,7 +709,7 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, int idx, ...@@ -709,7 +709,7 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, int idx,
xlate->cam_fmt = icd->formats + idx; xlate->cam_fmt = icd->formats + idx;
xlate->buswidth = buswidth; xlate->buswidth = buswidth;
xlate++; xlate++;
dev_dbg(&ici->dev, "Providing format %s using %s\n", dev_dbg(ici->dev, "Providing format %s using %s\n",
mx3_camera_formats[0].name, mx3_camera_formats[0].name,
icd->formats[idx].name); icd->formats[idx].name);
} }
...@@ -722,7 +722,7 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, int idx, ...@@ -722,7 +722,7 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, int idx,
xlate->cam_fmt = icd->formats + idx; xlate->cam_fmt = icd->formats + idx;
xlate->buswidth = buswidth; xlate->buswidth = buswidth;
xlate++; xlate++;
dev_dbg(&ici->dev, dev_dbg(ici->dev,
"Providing format %s in pass-through mode\n", "Providing format %s in pass-through mode\n",
icd->formats[idx].name); icd->formats[idx].name);
} }
...@@ -829,7 +829,7 @@ static int mx3_camera_set_fmt(struct soc_camera_device *icd, ...@@ -829,7 +829,7 @@ static int mx3_camera_set_fmt(struct soc_camera_device *icd,
xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat); xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
if (!xlate) { if (!xlate) {
dev_warn(&ici->dev, "Format %x not found\n", pix->pixelformat); dev_warn(ici->dev, "Format %x not found\n", pix->pixelformat);
return -EINVAL; return -EINVAL;
} }
...@@ -866,7 +866,7 @@ static int mx3_camera_try_fmt(struct soc_camera_device *icd, ...@@ -866,7 +866,7 @@ static int mx3_camera_try_fmt(struct soc_camera_device *icd,
xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
if (pixfmt && !xlate) { if (pixfmt && !xlate) {
dev_warn(&ici->dev, "Format %x not found\n", pixfmt); dev_warn(ici->dev, "Format %x not found\n", pixfmt);
return -EINVAL; return -EINVAL;
} }
...@@ -933,11 +933,11 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt) ...@@ -933,11 +933,11 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
if (!xlate) { if (!xlate) {
dev_warn(&ici->dev, "Format %x not found\n", pixfmt); dev_warn(ici->dev, "Format %x not found\n", pixfmt);
return -EINVAL; return -EINVAL;
} }
dev_dbg(&ici->dev, "requested bus width %d bit: %d\n", dev_dbg(ici->dev, "requested bus width %d bit: %d\n",
icd->buswidth, ret); icd->buswidth, ret);
if (ret < 0) if (ret < 0)
...@@ -947,7 +947,7 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt) ...@@ -947,7 +947,7 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
common_flags = soc_camera_bus_param_compatible(camera_flags, bus_flags); common_flags = soc_camera_bus_param_compatible(camera_flags, bus_flags);
if (!common_flags) { if (!common_flags) {
dev_dbg(&ici->dev, "no common flags: camera %lx, host %lx\n", dev_dbg(ici->dev, "no common flags: camera %lx, host %lx\n",
camera_flags, bus_flags); camera_flags, bus_flags);
return -EINVAL; return -EINVAL;
} }
...@@ -1054,7 +1054,7 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt) ...@@ -1054,7 +1054,7 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
csi_reg_write(mx3_cam, sens_conf | dw, CSI_SENS_CONF); csi_reg_write(mx3_cam, sens_conf | dw, CSI_SENS_CONF);
dev_dbg(&ici->dev, "Set SENS_CONF to %x\n", sens_conf | dw); dev_dbg(ici->dev, "Set SENS_CONF to %x\n", sens_conf | dw);
return 0; return 0;
} }
...@@ -1102,8 +1102,6 @@ static int mx3_camera_probe(struct platform_device *pdev) ...@@ -1102,8 +1102,6 @@ static int mx3_camera_probe(struct platform_device *pdev)
goto eclkget; goto eclkget;
} }
platform_set_drvdata(pdev, mx3_cam);
mx3_cam->pdata = pdev->dev.platform_data; mx3_cam->pdata = pdev->dev.platform_data;
mx3_cam->platform_flags = mx3_cam->pdata->flags; mx3_cam->platform_flags = mx3_cam->pdata->flags;
if (!(mx3_cam->platform_flags & (MX3_CAMERA_DATAWIDTH_4 | if (!(mx3_cam->platform_flags & (MX3_CAMERA_DATAWIDTH_4 |
...@@ -1135,14 +1133,14 @@ static int mx3_camera_probe(struct platform_device *pdev) ...@@ -1135,14 +1133,14 @@ static int mx3_camera_probe(struct platform_device *pdev)
} }
mx3_cam->base = base; mx3_cam->base = base;
mx3_cam->dev = &pdev->dev;
soc_host = &mx3_cam->soc_host; soc_host = &mx3_cam->soc_host;
soc_host->drv_name = MX3_CAM_DRV_NAME; soc_host->drv_name = MX3_CAM_DRV_NAME;
soc_host->ops = &mx3_soc_camera_host_ops; soc_host->ops = &mx3_soc_camera_host_ops;
soc_host->priv = mx3_cam; soc_host->priv = mx3_cam;
soc_host->dev.parent = &pdev->dev; soc_host->dev = &pdev->dev;
soc_host->nr = pdev->id; soc_host->nr = pdev->id;
err = soc_camera_host_register(soc_host); err = soc_camera_host_register(soc_host);
if (err) if (err)
goto ecamhostreg; goto ecamhostreg;
...@@ -1165,11 +1163,13 @@ static int mx3_camera_probe(struct platform_device *pdev) ...@@ -1165,11 +1163,13 @@ static int mx3_camera_probe(struct platform_device *pdev)
static int __devexit mx3_camera_remove(struct platform_device *pdev) static int __devexit mx3_camera_remove(struct platform_device *pdev)
{ {
struct mx3_camera_dev *mx3_cam = platform_get_drvdata(pdev); struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev);
struct mx3_camera_dev *mx3_cam = container_of(soc_host,
struct mx3_camera_dev, soc_host);
clk_put(mx3_cam->clk); clk_put(mx3_cam->clk);
soc_camera_host_unregister(&mx3_cam->soc_host); soc_camera_host_unregister(soc_host);
iounmap(mx3_cam->base); iounmap(mx3_cam->base);
......
This diff is collapsed.
...@@ -81,7 +81,6 @@ struct sh_mobile_ceu_buffer { ...@@ -81,7 +81,6 @@ struct sh_mobile_ceu_buffer {
}; };
struct sh_mobile_ceu_dev { struct sh_mobile_ceu_dev {
struct device *dev;
struct soc_camera_host ici; struct soc_camera_host ici;
struct soc_camera_device *icd; struct soc_camera_device *icd;
...@@ -617,7 +616,7 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, int idx, ...@@ -617,7 +616,7 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, int idx,
xlate->cam_fmt = icd->formats + idx; xlate->cam_fmt = icd->formats + idx;
xlate->buswidth = icd->formats[idx].depth; xlate->buswidth = icd->formats[idx].depth;
xlate++; xlate++;
dev_dbg(&ici->dev, "Providing format %s using %s\n", dev_dbg(ici->dev, "Providing format %s using %s\n",
sh_mobile_ceu_formats[k].name, sh_mobile_ceu_formats[k].name,
icd->formats[idx].name); icd->formats[idx].name);
} }
...@@ -630,7 +629,7 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, int idx, ...@@ -630,7 +629,7 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, int idx,
xlate->cam_fmt = icd->formats + idx; xlate->cam_fmt = icd->formats + idx;
xlate->buswidth = icd->formats[idx].depth; xlate->buswidth = icd->formats[idx].depth;
xlate++; xlate++;
dev_dbg(&ici->dev, dev_dbg(ici->dev,
"Providing format %s in pass-through mode\n", "Providing format %s in pass-through mode\n",
icd->formats[idx].name); icd->formats[idx].name);
} }
...@@ -657,7 +656,7 @@ static int sh_mobile_ceu_set_fmt(struct soc_camera_device *icd, ...@@ -657,7 +656,7 @@ static int sh_mobile_ceu_set_fmt(struct soc_camera_device *icd,
xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
if (!xlate) { if (!xlate) {
dev_warn(&ici->dev, "Format %x not found\n", pixfmt); dev_warn(ici->dev, "Format %x not found\n", pixfmt);
return -EINVAL; return -EINVAL;
} }
...@@ -684,7 +683,7 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd, ...@@ -684,7 +683,7 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd,
xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
if (!xlate) { if (!xlate) {
dev_warn(&ici->dev, "Format %x not found\n", pixfmt); dev_warn(ici->dev, "Format %x not found\n", pixfmt);
return -EINVAL; return -EINVAL;
} }
...@@ -782,7 +781,7 @@ static void sh_mobile_ceu_init_videobuf(struct videobuf_queue *q, ...@@ -782,7 +781,7 @@ static void sh_mobile_ceu_init_videobuf(struct videobuf_queue *q,
videobuf_queue_dma_contig_init(q, videobuf_queue_dma_contig_init(q,
&sh_mobile_ceu_videobuf_ops, &sh_mobile_ceu_videobuf_ops,
&ici->dev, &pcdev->lock, ici->dev, &pcdev->lock,
V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
pcdev->is_interlaced ? pcdev->is_interlaced ?
V4L2_FIELD_INTERLACED : V4L2_FIELD_NONE, V4L2_FIELD_INTERLACED : V4L2_FIELD_NONE,
...@@ -829,7 +828,6 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev) ...@@ -829,7 +828,6 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev)
goto exit; goto exit;
} }
platform_set_drvdata(pdev, pcdev);
INIT_LIST_HEAD(&pcdev->capture); INIT_LIST_HEAD(&pcdev->capture);
spin_lock_init(&pcdev->lock); spin_lock_init(&pcdev->lock);
...@@ -850,7 +848,6 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev) ...@@ -850,7 +848,6 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev)
pcdev->irq = irq; pcdev->irq = irq;
pcdev->base = base; pcdev->base = base;
pcdev->video_limit = 0; /* only enabled if second resource exists */ pcdev->video_limit = 0; /* only enabled if second resource exists */
pcdev->dev = &pdev->dev;
res = platform_get_resource(pdev, IORESOURCE_MEM, 1); res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (res) { if (res) {
...@@ -885,7 +882,7 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev) ...@@ -885,7 +882,7 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev)
} }
pcdev->ici.priv = pcdev; pcdev->ici.priv = pcdev;
pcdev->ici.dev.parent = &pdev->dev; pcdev->ici.dev = &pdev->dev;
pcdev->ici.nr = pdev->id; pcdev->ici.nr = pdev->id;
pcdev->ici.drv_name = dev_name(&pdev->dev); pcdev->ici.drv_name = dev_name(&pdev->dev);
pcdev->ici.ops = &sh_mobile_ceu_host_ops; pcdev->ici.ops = &sh_mobile_ceu_host_ops;
...@@ -913,9 +910,11 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev) ...@@ -913,9 +910,11 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev)
static int sh_mobile_ceu_remove(struct platform_device *pdev) static int sh_mobile_ceu_remove(struct platform_device *pdev)
{ {
struct sh_mobile_ceu_dev *pcdev = platform_get_drvdata(pdev); struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev);
struct sh_mobile_ceu_dev *pcdev = container_of(soc_host,
struct sh_mobile_ceu_dev, ici);
soc_camera_host_unregister(&pcdev->ici); soc_camera_host_unregister(soc_host);
clk_put(pcdev->clk); clk_put(pcdev->clk);
free_irq(pcdev->irq, pcdev); free_irq(pcdev->irq, pcdev);
if (platform_get_resource(pdev, IORESOURCE_MEM, 1)) if (platform_get_resource(pdev, IORESOURCE_MEM, 1))
......
...@@ -279,7 +279,7 @@ static int soc_camera_set_fmt(struct soc_camera_file *icf, ...@@ -279,7 +279,7 @@ static int soc_camera_set_fmt(struct soc_camera_file *icf,
return ret; return ret;
} else if (!icd->current_fmt || } else if (!icd->current_fmt ||
icd->current_fmt->fourcc != pix->pixelformat) { icd->current_fmt->fourcc != pix->pixelformat) {
dev_err(&ici->dev, dev_err(ici->dev,
"Host driver hasn't set up current format correctly!\n"); "Host driver hasn't set up current format correctly!\n");
return -EINVAL; return -EINVAL;
} }
...@@ -794,7 +794,7 @@ static void scan_add_host(struct soc_camera_host *ici) ...@@ -794,7 +794,7 @@ static void scan_add_host(struct soc_camera_host *ici)
list_for_each_entry(icd, &devices, list) { list_for_each_entry(icd, &devices, list) {
if (icd->iface == ici->nr) { if (icd->iface == ici->nr) {
icd->dev.parent = &ici->dev; icd->dev.parent = ici->dev;
device_register_link(icd); device_register_link(icd);
} }
} }
...@@ -818,7 +818,7 @@ static int scan_add_device(struct soc_camera_device *icd) ...@@ -818,7 +818,7 @@ static int scan_add_device(struct soc_camera_device *icd)
list_for_each_entry(ici, &hosts, list) { list_for_each_entry(ici, &hosts, list) {
if (icd->iface == ici->nr) { if (icd->iface == ici->nr) {
ret = 1; ret = 1;
icd->dev.parent = &ici->dev; icd->dev.parent = ici->dev;
break; break;
} }
} }
...@@ -952,7 +952,6 @@ static void dummy_release(struct device *dev) ...@@ -952,7 +952,6 @@ static void dummy_release(struct device *dev)
int soc_camera_host_register(struct soc_camera_host *ici) int soc_camera_host_register(struct soc_camera_host *ici)
{ {
int ret;
struct soc_camera_host *ix; struct soc_camera_host *ix;
if (!ici || !ici->ops || if (!ici || !ici->ops ||
...@@ -965,12 +964,10 @@ int soc_camera_host_register(struct soc_camera_host *ici) ...@@ -965,12 +964,10 @@ int soc_camera_host_register(struct soc_camera_host *ici)
!ici->ops->reqbufs || !ici->ops->reqbufs ||
!ici->ops->add || !ici->ops->add ||
!ici->ops->remove || !ici->ops->remove ||
!ici->ops->poll) !ici->ops->poll ||
!ici->dev)
return -EINVAL; return -EINVAL;
/* Number might be equal to the platform device ID */
dev_set_name(&ici->dev, "camera_host%d", ici->nr);
mutex_lock(&list_lock); mutex_lock(&list_lock);
list_for_each_entry(ix, &hosts, list) { list_for_each_entry(ix, &hosts, list) {
if (ix->nr == ici->nr) { if (ix->nr == ici->nr) {
...@@ -979,26 +976,14 @@ int soc_camera_host_register(struct soc_camera_host *ici) ...@@ -979,26 +976,14 @@ int soc_camera_host_register(struct soc_camera_host *ici)
} }
} }
dev_set_drvdata(ici->dev, ici);
list_add_tail(&ici->list, &hosts); list_add_tail(&ici->list, &hosts);
mutex_unlock(&list_lock); mutex_unlock(&list_lock);
ici->dev.release = dummy_release;
ret = device_register(&ici->dev);
if (ret)
goto edevr;
scan_add_host(ici); scan_add_host(ici);
return 0; return 0;
edevr:
mutex_lock(&list_lock);
list_del(&ici->list);
mutex_unlock(&list_lock);
return ret;
} }
EXPORT_SYMBOL(soc_camera_host_register); EXPORT_SYMBOL(soc_camera_host_register);
...@@ -1012,7 +997,7 @@ void soc_camera_host_unregister(struct soc_camera_host *ici) ...@@ -1012,7 +997,7 @@ void soc_camera_host_unregister(struct soc_camera_host *ici)
list_del(&ici->list); list_del(&ici->list);
list_for_each_entry(icd, &devices, list) { list_for_each_entry(icd, &devices, list) {
if (icd->dev.parent == &ici->dev) { if (icd->dev.parent == ici->dev) {
device_unregister(&icd->dev); device_unregister(&icd->dev);
/* Not before device_unregister(), .remove /* Not before device_unregister(), .remove
* needs parent to call ici->ops->remove() */ * needs parent to call ici->ops->remove() */
...@@ -1023,7 +1008,7 @@ void soc_camera_host_unregister(struct soc_camera_host *ici) ...@@ -1023,7 +1008,7 @@ void soc_camera_host_unregister(struct soc_camera_host *ici)
mutex_unlock(&list_lock); mutex_unlock(&list_lock);
device_unregister(&ici->dev); dev_set_drvdata(ici->dev, NULL);
} }
EXPORT_SYMBOL(soc_camera_host_unregister); EXPORT_SYMBOL(soc_camera_host_unregister);
...@@ -1130,7 +1115,7 @@ int soc_camera_video_start(struct soc_camera_device *icd) ...@@ -1130,7 +1115,7 @@ int soc_camera_video_start(struct soc_camera_device *icd)
vdev = video_device_alloc(); vdev = video_device_alloc();
if (!vdev) if (!vdev)
goto evidallocd; goto evidallocd;
dev_dbg(&ici->dev, "Allocated video_device %p\n", vdev); dev_dbg(ici->dev, "Allocated video_device %p\n", vdev);
strlcpy(vdev->name, ici->drv_name, sizeof(vdev->name)); strlcpy(vdev->name, ici->drv_name, sizeof(vdev->name));
......
...@@ -60,7 +60,7 @@ struct soc_camera_file { ...@@ -60,7 +60,7 @@ struct soc_camera_file {
struct soc_camera_host { struct soc_camera_host {
struct list_head list; struct list_head list;
struct device dev; struct device *dev;
unsigned char nr; /* Host number */ unsigned char nr; /* Host number */
void *priv; void *priv;
const char *drv_name; const char *drv_name;
...@@ -117,7 +117,7 @@ static inline struct soc_camera_device *to_soc_camera_dev(struct device *dev) ...@@ -117,7 +117,7 @@ static inline struct soc_camera_device *to_soc_camera_dev(struct device *dev)
static inline struct soc_camera_host *to_soc_camera_host(struct device *dev) static inline struct soc_camera_host *to_soc_camera_host(struct device *dev)
{ {
return container_of(dev, struct soc_camera_host, dev); return dev_get_drvdata(dev);
} }
extern int soc_camera_host_register(struct soc_camera_host *ici); extern int soc_camera_host_register(struct soc_camera_host *ici);
......
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