[1/2] media: v4l2-common: v4l2_spi_subdev_init : generate unique name
diff mbox series

Message ID 1533158457-15831-1-git-send-email-phdm@macqel.be
State New
Headers show
Series
  • [1/2] media: v4l2-common: v4l2_spi_subdev_init : generate unique name
Related show

Commit Message

Philippe De Muyter Aug. 1, 2018, 9:20 p.m. UTC
While v4l2_i2c_subdev_init does give a unique name to the subdev, matching
the one appearing in dmesg for messages generated by dev_info and friends
(e.g. imx185 30-0010), v4l2_spi_subdev_init does a poor job, copying only
the driver name, but not the dev_name(), yielding e.g. "imx185", but
missing the "spi1.1" part, and not generating a unique name.

Fix that.

Signed-off-by: Philippe De Muyter <phdm@macqel.be>
---
 drivers/media/v4l2-core/v4l2-common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Hans Verkuil Sept. 5, 2018, 7:53 a.m. UTC | #1
On 08/01/18 23:20, Philippe De Muyter wrote:
> While v4l2_i2c_subdev_init does give a unique name to the subdev, matching
> the one appearing in dmesg for messages generated by dev_info and friends
> (e.g. imx185 30-0010), v4l2_spi_subdev_init does a poor job, copying only
> the driver name, but not the dev_name(), yielding e.g. "imx185", but
> missing the "spi1.1" part, and not generating a unique name.
> 
> Fix that.
> 
> Signed-off-by: Philippe De Muyter <phdm@macqel.be>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

> ---
>  drivers/media/v4l2-core/v4l2-common.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> index b518b92..5471c6d 100644
> --- a/drivers/media/v4l2-core/v4l2-common.c
> +++ b/drivers/media/v4l2-core/v4l2-common.c
> @@ -255,7 +255,9 @@ void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi,
>  	v4l2_set_subdevdata(sd, spi);
>  	spi_set_drvdata(spi, sd);
>  	/* initialize name */
> -	strlcpy(sd->name, spi->dev.driver->name, sizeof(sd->name));
> +	snprintf(sd->name, sizeof(sd->name), "%s %s",
> +		spi->dev.driver->name, dev_name(&spi->dev));
> +
>  }
>  EXPORT_SYMBOL_GPL(v4l2_spi_subdev_init);
>  
>

Patch
diff mbox series

diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
index b518b92..5471c6d 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -255,7 +255,9 @@  void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi,
 	v4l2_set_subdevdata(sd, spi);
 	spi_set_drvdata(spi, sd);
 	/* initialize name */
-	strlcpy(sd->name, spi->dev.driver->name, sizeof(sd->name));
+	snprintf(sd->name, sizeof(sd->name), "%s %s",
+		spi->dev.driver->name, dev_name(&spi->dev));
+
 }
 EXPORT_SYMBOL_GPL(v4l2_spi_subdev_init);