]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
v4l: xilinx: scd: Allocate pads array statically
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Wed, 3 Apr 2019 20:01:50 +0000 (13:01 -0700)
committerMichal Simek <michal.simek@xilinx.com>
Fri, 5 Apr 2019 11:05:29 +0000 (13:05 +0200)
Allocating the pads array dynamically doesn't save much memory, if at
all, due to the extra data needed to track the devm allocation, compared
to embedding an array of two pads in the xscd_device structure. Replace
the dynamic allocation.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hyun Kwon <hyun.kwon@xilinx.com>
drivers/media/platform/xilinx/xilinx-scenechange-channel.c
drivers/media/platform/xilinx/xilinx-scenechange.h

index 6f60a38cfe634d6ca4a9b51b81bcaa8d57fedb2c..25e31373fdc47b643b017010e72e47846c079036 100644 (file)
@@ -368,8 +368,8 @@ int xscd_chan_init(struct xscd_device *xscd, unsigned int chan_id,
 {
        struct xscd_chan *chan;
        struct v4l2_subdev *subdev;
+       unsigned int num_pads;
        int ret;
-       u32 num_pads;
 
        chan = devm_kzalloc(xscd->dev, sizeof(*chan), GFP_KERNEL);
        if (!chan)
@@ -405,17 +405,12 @@ int xscd_chan_init(struct xscd_device *xscd, unsigned int chan_id,
 
        /* Initialize media pads */
        num_pads = xscd->memory_based ? 1 : 2;
-       chan->pad = devm_kzalloc(chan->xscd->dev,
-                                sizeof(struct media_pad) * num_pads,
-                                GFP_KERNEL);
-       if (!chan->pad)
-               return -ENOMEM;
 
-       chan->pad[XVIP_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
+       chan->pads[XVIP_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
        if (!xscd->memory_based)
-               chan->pad[XVIP_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
+               chan->pads[XVIP_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
 
-       ret = media_entity_pads_init(&subdev->entity, num_pads, chan->pad);
+       ret = media_entity_pads_init(&subdev->entity, num_pads, chan->pads);
        if (ret < 0)
                goto error;
 
index 89b51d8622a010aac71c0fc5bed6ecfc91a3dea6..a3881443599d907228cdb3db2414671057b79b23 100644 (file)
@@ -147,7 +147,7 @@ static inline struct xscd_dma_chan *to_xscd_dma_chan(struct dma_chan *chan)
  * @iomem: device I/O register space remapped to kernel virtual memory
  * @xscd: SCD device
  * @subdev: V4L2 subdevice
- * @pad: media pads
+ * @pads: media pads
  * @format: active V4L2 media bus format for the pad
  * @event: scene change event
  * @dmachan: dma channel part of the scenechange stream
@@ -158,7 +158,7 @@ struct xscd_chan {
        void __iomem *iomem;
        struct xscd_device *xscd;
        struct v4l2_subdev subdev;
-       struct media_pad *pad;
+       struct media_pad pads[2];
        struct v4l2_mbus_framefmt format;
        struct v4l2_event event;
        struct xscd_dma_chan dmachan;