media: v4l2-core: introduce a helper to unregister a spi subdev
Introduce a new video4linux2 spi helper, to unregister a subdev. This allows to get rid of some more ifdefs. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
Родитель
02283b98b1
Коммит
a9cff393c1
|
@ -11,9 +11,6 @@
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/i2c.h>
|
#include <linux/i2c.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#if defined(CONFIG_SPI)
|
|
||||||
#include <linux/spi/spi.h>
|
|
||||||
#endif
|
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
#include <media/v4l2-device.h>
|
#include <media/v4l2-device.h>
|
||||||
#include <media/v4l2-ctrls.h>
|
#include <media/v4l2-ctrls.h>
|
||||||
|
@ -124,15 +121,8 @@ void v4l2_device_unregister(struct v4l2_device *v4l2_dev)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(CONFIG_SPI)
|
else if (sd->flags & V4L2_SUBDEV_FL_IS_SPI)
|
||||||
if (sd->flags & V4L2_SUBDEV_FL_IS_SPI) {
|
v4l2_spi_subdev_unregister(sd);
|
||||||
struct spi_device *spi = v4l2_get_subdevdata(sd);
|
|
||||||
|
|
||||||
if (spi && !spi->dev.of_node && !spi->dev.fwnode)
|
|
||||||
spi_unregister_device(spi);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
/* Mark as unregistered, thus preventing duplicate unregistrations */
|
/* Mark as unregistered, thus preventing duplicate unregistrations */
|
||||||
v4l2_dev->name[0] = '\0';
|
v4l2_dev->name[0] = '\0';
|
||||||
|
|
|
@ -8,6 +8,14 @@
|
||||||
#include <media/v4l2-common.h>
|
#include <media/v4l2-common.h>
|
||||||
#include <media/v4l2-device.h>
|
#include <media/v4l2-device.h>
|
||||||
|
|
||||||
|
void v4l2_spi_subdev_unregister(struct v4l2_subdev *sd)
|
||||||
|
{
|
||||||
|
struct spi_device *spi = v4l2_get_subdevdata(sd);
|
||||||
|
|
||||||
|
if (spi && !spi->dev.of_node && !spi->dev.fwnode)
|
||||||
|
spi_unregister_device(spi);
|
||||||
|
}
|
||||||
|
|
||||||
void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi,
|
void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi,
|
||||||
const struct v4l2_subdev_ops *ops)
|
const struct v4l2_subdev_ops *ops)
|
||||||
{
|
{
|
||||||
|
|
|
@ -285,6 +285,13 @@ struct v4l2_subdev *v4l2_spi_new_subdev(struct v4l2_device *v4l2_dev,
|
||||||
void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi,
|
void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi,
|
||||||
const struct v4l2_subdev_ops *ops);
|
const struct v4l2_subdev_ops *ops);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* v4l2_spi_subdev_unregister - Unregister a v4l2_subdev
|
||||||
|
*
|
||||||
|
* @sd: pointer to &struct v4l2_subdev
|
||||||
|
*/
|
||||||
|
void v4l2_spi_subdev_unregister(struct v4l2_subdev *sd);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static inline struct v4l2_subdev *
|
static inline struct v4l2_subdev *
|
||||||
|
@ -299,6 +306,8 @@ v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi,
|
||||||
const struct v4l2_subdev_ops *ops)
|
const struct v4l2_subdev_ops *ops)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
static inline void v4l2_spi_subdev_unregister(struct v4l2_subdev *sd)
|
||||||
|
{}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче