]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: use sizeof() instead of V4L2_SUBDEV_NAME_SIZE
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Sat, 23 Sep 2023 15:20:57 +0000 (17:20 +0200)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 27 Sep 2023 08:47:22 +0000 (10:47 +0200)
Don't rely on a define, let the compiler use the actual
field size.

Remove all uses of the V4L2_SUBDEV_NAME_SIZE define and also
drop the define itself.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Tested-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
drivers/media/i2c/msp3400-driver.c
drivers/media/platform/cadence/cdns-csi2rx.c
drivers/media/platform/cadence/cdns-csi2tx.c
drivers/media/platform/renesas/rcar-isp.c
drivers/media/platform/renesas/rcar-vin/rcar-csi2.c
drivers/media/platform/ti/omap3isp/ispstat.c
drivers/staging/media/tegra-video/csi.c
drivers/staging/media/tegra-video/vip.c
include/media/v4l2-subdev.h

index bec76801487abf563086a3ba19de455381794dbc..0ed8561edfee6bfaa3f3d9b824ddd741edb794f7 100644 (file)
@@ -561,7 +561,7 @@ static int msp_log_status(struct v4l2_subdev *sd)
        struct msp_state *state = to_state(sd);
        struct i2c_client *client = v4l2_get_subdevdata(sd);
        const char *p;
-       char prefix[V4L2_SUBDEV_NAME_SIZE + 20];
+       char prefix[sizeof(sd->name) + 20];
 
        if (state->opmode == OPMODE_AUTOSELECT)
                msp_detect_stereo(client);
index 0d879d71d8185014baa11ec653aef1a11ecc582b..b9d9058e2ce3f9858b6ddb7276ccb9259269813b 100644 (file)
@@ -516,8 +516,8 @@ static int csi2rx_probe(struct platform_device *pdev)
        csi2rx->subdev.dev = &pdev->dev;
        v4l2_subdev_init(&csi2rx->subdev, &csi2rx_subdev_ops);
        v4l2_set_subdevdata(&csi2rx->subdev, &pdev->dev);
-       snprintf(csi2rx->subdev.name, V4L2_SUBDEV_NAME_SIZE, "%s.%s",
-                KBUILD_MODNAME, dev_name(&pdev->dev));
+       snprintf(csi2rx->subdev.name, sizeof(csi2rx->subdev.name),
+                "%s.%s", KBUILD_MODNAME, dev_name(&pdev->dev));
 
        /* Create our media pads */
        csi2rx->subdev.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE;
index cbbb775201126f38f0608ff0fe1dc822d866b0c6..c115742f347ff17d1367cc44d4e27cbd8d5b5f6b 100644 (file)
@@ -592,8 +592,8 @@ static int csi2tx_probe(struct platform_device *pdev)
        csi2tx->subdev.owner = THIS_MODULE;
        csi2tx->subdev.dev = &pdev->dev;
        csi2tx->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-       snprintf(csi2tx->subdev.name, V4L2_SUBDEV_NAME_SIZE, "%s.%s",
-                KBUILD_MODNAME, dev_name(&pdev->dev));
+       snprintf(csi2tx->subdev.name, sizeof(csi2tx->subdev.name),
+                "%s.%s", KBUILD_MODNAME, dev_name(&pdev->dev));
 
        ret = csi2tx_check_lanes(csi2tx);
        if (ret)
index 7360cf3863f2c8d8c507a76bf16b231672c17870..19a005d83733072449ab30559896f8e6b8be9c63 100644 (file)
@@ -467,7 +467,7 @@ static int risp_probe(struct platform_device *pdev)
        isp->subdev.dev = &pdev->dev;
        v4l2_subdev_init(&isp->subdev, &rcar_isp_subdev_ops);
        v4l2_set_subdevdata(&isp->subdev, &pdev->dev);
-       snprintf(isp->subdev.name, V4L2_SUBDEV_NAME_SIZE, "%s %s",
+       snprintf(isp->subdev.name, sizeof(isp->subdev.name), "%s %s",
                 KBUILD_MODNAME, dev_name(&pdev->dev));
        isp->subdev.flags = V4L2_SUBDEV_FL_HAS_DEVNODE;
 
index f6326df0b09bef904ded0e03c80f3399b9009dd0..66fe553a00e757418dc8611599ea0677eecd9c85 100644 (file)
@@ -1889,7 +1889,7 @@ static int rcsi2_probe(struct platform_device *pdev)
        priv->subdev.dev = &pdev->dev;
        v4l2_subdev_init(&priv->subdev, &rcar_csi2_subdev_ops);
        v4l2_set_subdevdata(&priv->subdev, &pdev->dev);
-       snprintf(priv->subdev.name, V4L2_SUBDEV_NAME_SIZE, "%s %s",
+       snprintf(priv->subdev.name, sizeof(priv->subdev.name), "%s %s",
                 KBUILD_MODNAME, dev_name(&pdev->dev));
        priv->subdev.flags = V4L2_SUBDEV_FL_HAS_DEVNODE;
 
index 68cf68dbcace281090e81f44ee9ec100a2c6187d..359a846205b0ffe9e736c7ed37c22677991cc9f2 100644 (file)
@@ -1039,7 +1039,7 @@ static int isp_stat_init_entities(struct ispstat *stat, const char *name,
        struct media_entity *me = &subdev->entity;
 
        v4l2_subdev_init(subdev, sd_ops);
-       snprintf(subdev->name, V4L2_SUBDEV_NAME_SIZE, "OMAP3 ISP %s", name);
+       snprintf(subdev->name, sizeof(subdev->name), "OMAP3 ISP %s", name);
        subdev->grp_id = BIT(16);       /* group ID for isp subdevs */
        subdev->flags |= V4L2_SUBDEV_FL_HAS_EVENTS | V4L2_SUBDEV_FL_HAS_DEVNODE;
        v4l2_set_subdevdata(subdev, stat);
index e79657920dc8ab338fe75c30ceaa6a32fc741057..9aa72863c213e3bcfdd440ccf211ae3639bfbad7 100644 (file)
@@ -607,10 +607,10 @@ static int tegra_csi_channel_init(struct tegra_csi_channel *chan)
        v4l2_subdev_init(subdev, &tegra_csi_ops);
        subdev->dev = csi->dev;
        if (IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG))
-               snprintf(subdev->name, V4L2_SUBDEV_NAME_SIZE, "%s-%d", "tpg",
+               snprintf(subdev->name, sizeof(subdev->name), "%s-%d", "tpg",
                         chan->csi_port_nums[0]);
        else
-               snprintf(subdev->name, V4L2_SUBDEV_NAME_SIZE, "%s",
+               snprintf(subdev->name, sizeof(subdev->name), "%s",
                         kbasename(chan->of_node->full_name));
 
        v4l2_set_subdevdata(subdev, chan);
index 191ecd19a6a7c78b20fbc3f35b35bb1cfda5654c..e95cc7bb190e1f76987584308a007bd59050134b 100644 (file)
@@ -163,7 +163,7 @@ static int tegra_vip_channel_init(struct tegra_vip *vip)
        subdev = &vip->chan.subdev;
        v4l2_subdev_init(subdev, &tegra_vip_ops);
        subdev->dev = vip->dev;
-       snprintf(subdev->name, V4L2_SUBDEV_NAME_SIZE, "%s",
+       snprintf(subdev->name, sizeof(subdev->name), "%s",
                 kbasename(vip->chan.of_node->full_name));
 
        v4l2_set_subdevdata(subdev, &vip->chan);
index 5711354056b97cb09fe10c25c94d5057ed2a7a51..c1f90c1223a749ec8fa8959cd64d105b4566e129 100644 (file)
@@ -951,8 +951,6 @@ struct v4l2_subdev_internal_ops {
        void (*release)(struct v4l2_subdev *sd);
 };
 
-#define V4L2_SUBDEV_NAME_SIZE 52
-
 /* Set this flag if this subdev is a i2c device. */
 #define V4L2_SUBDEV_FL_IS_I2C                  (1U << 0)
 /* Set this flag if this subdev is a spi device. */
@@ -1062,7 +1060,7 @@ struct v4l2_subdev {
        const struct v4l2_subdev_ops *ops;
        const struct v4l2_subdev_internal_ops *internal_ops;
        struct v4l2_ctrl_handler *ctrl_handler;
-       char name[V4L2_SUBDEV_NAME_SIZE];
+       char name[52];
        u32 grp_id;
        void *dev_priv;
        void *host_priv;