Re: [PATCH 4/5] media: vimc: use configfs instead of having hardcoded configuration
On 9/19/19 2:32 PM, Dafna Hirschfeld wrote:
Use configfs in order to create a device and set its topology
and remove the hardcoded device.
Signed-off-by: Helen Koike
[refactored for upstream]
What does this mean?
Signed-off-by: Dafna Hirschfeld
---
drivers/media/platform/vimc/vimc-capture.c | 21 +-
drivers/media/platform/vimc/vimc-common.h | 50 +--
drivers/media/platform/vimc/vimc-configfs.c | 6 +-
drivers/media/platform/vimc/vimc-core.c | 319
drivers/media/platform/vimc/vimc-debayer.c | 13 +-
drivers/media/platform/vimc/vimc-scaler.c | 9 +-
drivers/media/platform/vimc/vimc-sensor.c | 12 +-
7 files changed, 170 insertions(+), 260 deletions(-)
diff --git a/drivers/media/platform/vimc/vimc-capture.c
b/drivers/media/platform/vimc/vimc-capture.c
index 5cc419e76ce7..6ccf879c0b75 100644
--- a/drivers/media/platform/vimc/vimc-capture.c
+++ b/drivers/media/platform/vimc/vimc-capture.c
@@ -335,11 +335,12 @@ static void vimc_cap_release(struct video_device *vdev)
kfree(vcap);
}
-void vimc_cap_rm(struct vimc_device *vimc, struct vimc_ent_device *ved)
+void vimc_cap_rm(struct vimc_ent_device *ved)
{
- struct vimc_cap_device *vcap;
+ struct vimc_cap_device *vcap = container_of(ved,
+ struct vimc_cap_device,
+ ved);
- vcap = container_of(ved, struct vimc_cap_device, ved);
vb2_queue_release(&vcap->queue);
media_entity_cleanup(ved->ent);
video_unregister_device(&vcap->vdev);
@@ -397,8 +398,9 @@ struct vimc_ent_device *vimc_cap_add(struct vimc_device
*vimc,
/* Allocate the vimc_cap_device struct */
vcap = kzalloc(sizeof(*vcap), GFP_KERNEL);
if (!vcap)
- return NULL;
+ return ERR_PTR(-ENOMEM);
+ strscpy(vcap->ved.name, vcfg_name, sizeof(vcap->ved.name));
/* Allocate the pads */
vcap->ved.pads =
vimc_pads_init(1, (const unsigned long[1]) {MEDIA_PAD_FL_SINK});
@@ -408,7 +410,7 @@ struct vimc_ent_device *vimc_cap_add(struct vimc_device
*vimc,
}
/* Initialize the media entity */
- vcap->vdev.entity.name = vcfg_name;
+ vcap->vdev.entity.name = vcap->ved.name;
vcap->vdev.entity.function = MEDIA_ENT_F_IO_V4L;
ret = media_entity_pads_init(&vcap->vdev.entity,
1, vcap->ved.pads);
@@ -432,7 +434,7 @@ struct vimc_ent_device *vimc_cap_add(struct vimc_device
*vimc,
ret = vb2_queue_init(q);
if (ret) {
- dev_err(&vimc->pdev.dev, "%s: vb2 queue init failed (err=%d)\n",
+ dev_err(vimc->mdev.dev, "%s: vb2 queue init failed (err=%d)\n",
vcfg_name, ret);
goto err_clean_m_ent;
}
@@ -452,7 +454,8 @@ struct vimc_ent_device *vimc_cap_add(struct vimc_device
*vimc,
vcap->ved.ent = &vcap->vdev.entity;
vcap->ved.process_frame = vimc_cap_process_frame;
vcap->ved.vdev_get_format = vimc_cap_get_format;
- vcap->dev = &vimc->pdev.dev;
+
+ vcap->dev = vimc->mdev.dev;
/* Initialize the video_device struct */
vdev = &vcap->vdev;
@@ -471,7 +474,7 @@ struct vimc_ent_device *vimc_cap_add(struct vimc_device
*vimc,
/* Register the video_device with the v4l2 and the media framework */
ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
if (ret) {
- dev_err(&vimc->pdev.dev, "%s: video register failed (err=%d)\n",
+ dev_err(vimc->mdev.dev, "%s: video register failed (err=%d)\n",
vcap->vdev.name, ret);
goto err_release_queue;
}
@@ -487,7 +490,7 @@ struct vimc_ent_device *vimc_cap_add(struct vimc_device
*vimc,
err_free_vcap:
kfree(vcap);
- return NULL;
+ return ERR_PTR(ret);
}
static void vimc_cap_create_cfs_pads(struct config_group *ent_group)
diff --git a/drivers/media/platform/vimc/vimc-common.h
b/drivers/media/platform/vimc/vimc-common.h
index e0e3b3ab7b19..5c7f451a7bf0 100644
--- a/drivers/media/platform/vimc/vimc-common.h
+++ b/drivers/media/platform/vimc/vimc-common.h
@@ -63,21 +63,6 @@ do {
\
(fmt)->xfer_func = V4L2_XFER_FUNC_DEFAULT; \
} while (0)
-/**
- * struct vimc_platform_data - platform data to components
- *
- * @entity_name: The name of the entity to be created
- *
- * Board setup code will often provide additional information using the
device's
- * platform_data field to hold additional information.
- * When injecting a new platform_device in the component system the core needs
- * to provide to the corresponding submodules the name of the entity that
should
- * be used when registering the subdevice in the Media Controller system.
- */
-struct vimc_platform_data {
- char entity_nam
[PATCH 4/5] media: vimc: use configfs instead of having hardcoded configuration
Use configfs in order to create a device and set its topology
and remove the hardcoded device.
Signed-off-by: Helen Koike
[refactored for upstream]
Signed-off-by: Dafna Hirschfeld
---
drivers/media/platform/vimc/vimc-capture.c | 21 +-
drivers/media/platform/vimc/vimc-common.h | 50 +--
drivers/media/platform/vimc/vimc-configfs.c | 6 +-
drivers/media/platform/vimc/vimc-core.c | 319
drivers/media/platform/vimc/vimc-debayer.c | 13 +-
drivers/media/platform/vimc/vimc-scaler.c | 9 +-
drivers/media/platform/vimc/vimc-sensor.c | 12 +-
7 files changed, 170 insertions(+), 260 deletions(-)
diff --git a/drivers/media/platform/vimc/vimc-capture.c
b/drivers/media/platform/vimc/vimc-capture.c
index 5cc419e76ce7..6ccf879c0b75 100644
--- a/drivers/media/platform/vimc/vimc-capture.c
+++ b/drivers/media/platform/vimc/vimc-capture.c
@@ -335,11 +335,12 @@ static void vimc_cap_release(struct video_device *vdev)
kfree(vcap);
}
-void vimc_cap_rm(struct vimc_device *vimc, struct vimc_ent_device *ved)
+void vimc_cap_rm(struct vimc_ent_device *ved)
{
- struct vimc_cap_device *vcap;
+ struct vimc_cap_device *vcap = container_of(ved,
+ struct vimc_cap_device,
+ ved);
- vcap = container_of(ved, struct vimc_cap_device, ved);
vb2_queue_release(&vcap->queue);
media_entity_cleanup(ved->ent);
video_unregister_device(&vcap->vdev);
@@ -397,8 +398,9 @@ struct vimc_ent_device *vimc_cap_add(struct vimc_device
*vimc,
/* Allocate the vimc_cap_device struct */
vcap = kzalloc(sizeof(*vcap), GFP_KERNEL);
if (!vcap)
- return NULL;
+ return ERR_PTR(-ENOMEM);
+ strscpy(vcap->ved.name, vcfg_name, sizeof(vcap->ved.name));
/* Allocate the pads */
vcap->ved.pads =
vimc_pads_init(1, (const unsigned long[1]) {MEDIA_PAD_FL_SINK});
@@ -408,7 +410,7 @@ struct vimc_ent_device *vimc_cap_add(struct vimc_device
*vimc,
}
/* Initialize the media entity */
- vcap->vdev.entity.name = vcfg_name;
+ vcap->vdev.entity.name = vcap->ved.name;
vcap->vdev.entity.function = MEDIA_ENT_F_IO_V4L;
ret = media_entity_pads_init(&vcap->vdev.entity,
1, vcap->ved.pads);
@@ -432,7 +434,7 @@ struct vimc_ent_device *vimc_cap_add(struct vimc_device
*vimc,
ret = vb2_queue_init(q);
if (ret) {
- dev_err(&vimc->pdev.dev, "%s: vb2 queue init failed (err=%d)\n",
+ dev_err(vimc->mdev.dev, "%s: vb2 queue init failed (err=%d)\n",
vcfg_name, ret);
goto err_clean_m_ent;
}
@@ -452,7 +454,8 @@ struct vimc_ent_device *vimc_cap_add(struct vimc_device
*vimc,
vcap->ved.ent = &vcap->vdev.entity;
vcap->ved.process_frame = vimc_cap_process_frame;
vcap->ved.vdev_get_format = vimc_cap_get_format;
- vcap->dev = &vimc->pdev.dev;
+
+ vcap->dev = vimc->mdev.dev;
/* Initialize the video_device struct */
vdev = &vcap->vdev;
@@ -471,7 +474,7 @@ struct vimc_ent_device *vimc_cap_add(struct vimc_device
*vimc,
/* Register the video_device with the v4l2 and the media framework */
ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
if (ret) {
- dev_err(&vimc->pdev.dev, "%s: video register failed (err=%d)\n",
+ dev_err(vimc->mdev.dev, "%s: video register failed (err=%d)\n",
vcap->vdev.name, ret);
goto err_release_queue;
}
@@ -487,7 +490,7 @@ struct vimc_ent_device *vimc_cap_add(struct vimc_device
*vimc,
err_free_vcap:
kfree(vcap);
- return NULL;
+ return ERR_PTR(ret);
}
static void vimc_cap_create_cfs_pads(struct config_group *ent_group)
diff --git a/drivers/media/platform/vimc/vimc-common.h
b/drivers/media/platform/vimc/vimc-common.h
index e0e3b3ab7b19..5c7f451a7bf0 100644
--- a/drivers/media/platform/vimc/vimc-common.h
+++ b/drivers/media/platform/vimc/vimc-common.h
@@ -63,21 +63,6 @@ do {
\
(fmt)->xfer_func = V4L2_XFER_FUNC_DEFAULT; \
} while (0)
-/**
- * struct vimc_platform_data - platform data to components
- *
- * @entity_name: The name of the entity to be created
- *
- * Board setup code will often provide additional information using the
device's
- * platform_data field to hold additional information.
- * When injecting a new platform_device in the component system the core needs
- * to provide to the corresponding submodules the name of the entity that
should
- * be used when registering the subdevice in the Media Controller system.
- */
-struct vimc_platform_data {
- char entity_name[32];
-};
-
/**
* struct vimc_platform_data_core - platform dat
