diff mbox series

[09/11] rcar-vin: Specify media device ops at group creation time

Message ID 20210413180253.2575451-10-niklas.soderlund+renesas@ragnatech.se (mailing list archive)
State Superseded
Delegated to: Kieran Bingham
Headers show
Series rcar-vin: Add r8a779a0 support | expand

Commit Message

Niklas Söderlund April 13, 2021, 6:02 p.m. UTC
The media device operations structure will be different deepening on
what media graph layout is used. Instead of hard-coding the R-Car CSI-2
layout allow the operations to be passed as an argument.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/media/platform/rcar-vin/rcar-core.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Jacopo Mondi July 7, 2021, 10:40 a.m. UTC | #1
Hi Niklas,

On Tue, Apr 13, 2021 at 08:02:51PM +0200, Niklas Söderlund wrote:
> The media device operations structure will be different deepening on

s/deepening/depending

> what media graph layout is used. Instead of hard-coding the R-Car CSI-2
> layout allow the operations to be passed as an argument.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
>  drivers/media/platform/rcar-vin/rcar-core.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
> index d03ecd443b01c2b3..28bf9e8f19a1a27b 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -248,7 +248,8 @@ static void rvin_group_cleanup(struct rvin_group *group)
>  }
>
>  static int rvin_group_init(struct rvin_group *group, struct rvin_dev *vin,
> -			   void (*link_setup)(struct rvin_dev *))
> +			   void (*link_setup)(struct rvin_dev *),
> +			   const struct media_device_ops *ops)
>  {
>  	struct media_device *mdev = &group->mdev;
>  	const struct of_device_id *match;
> @@ -267,7 +268,7 @@ static int rvin_group_init(struct rvin_group *group, struct rvin_dev *vin,
>  	group->link_setup = link_setup;
>
>  	mdev->dev = vin->dev;
> -	mdev->ops = &rvin_media_ops;
> +	mdev->ops = ops;
>
>  	match = of_match_node(vin->dev->driver->of_match_table,
>  			      vin->dev->of_node);
> @@ -299,7 +300,8 @@ static void rvin_group_release(struct kref *kref)
>  }
>
>  static int rvin_group_get(struct rvin_dev *vin,
> -			  void (*link_setup)(struct rvin_dev *))
> +			  void (*link_setup)(struct rvin_dev *),
> +			  const struct media_device_ops *ops)
>  {
>  	struct rvin_group *group;
>  	u32 id;
> @@ -331,7 +333,7 @@ static int rvin_group_get(struct rvin_dev *vin,
>  			goto err_group;
>  		}
>
> -		ret = rvin_group_init(group, vin, link_setup);
> +		ret = rvin_group_init(group, vin, link_setup, ops);
>  		if (ret) {
>  			kfree(group);
>  			vin_err(vin, "Failed to initialize group\n");
> @@ -984,7 +986,7 @@ static int rvin_csi2_init(struct rvin_dev *vin)
>  	if (ret < 0)
>  		return ret;
>
> -	ret = rvin_group_get(vin, rvin_csi2_setup_links);
> +	ret = rvin_group_get(vin, rvin_csi2_setup_links, &rvin_media_ops);

I would continue the effort of using the csi2_ prefix for CSI-2
related fields. Just a nit, the change looks good

Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>

Thanks
  j

>  	if (ret)
>  		goto err_controls;
>
> --
> 2.31.1
>
diff mbox series

Patch

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
index d03ecd443b01c2b3..28bf9e8f19a1a27b 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -248,7 +248,8 @@  static void rvin_group_cleanup(struct rvin_group *group)
 }
 
 static int rvin_group_init(struct rvin_group *group, struct rvin_dev *vin,
-			   void (*link_setup)(struct rvin_dev *))
+			   void (*link_setup)(struct rvin_dev *),
+			   const struct media_device_ops *ops)
 {
 	struct media_device *mdev = &group->mdev;
 	const struct of_device_id *match;
@@ -267,7 +268,7 @@  static int rvin_group_init(struct rvin_group *group, struct rvin_dev *vin,
 	group->link_setup = link_setup;
 
 	mdev->dev = vin->dev;
-	mdev->ops = &rvin_media_ops;
+	mdev->ops = ops;
 
 	match = of_match_node(vin->dev->driver->of_match_table,
 			      vin->dev->of_node);
@@ -299,7 +300,8 @@  static void rvin_group_release(struct kref *kref)
 }
 
 static int rvin_group_get(struct rvin_dev *vin,
-			  void (*link_setup)(struct rvin_dev *))
+			  void (*link_setup)(struct rvin_dev *),
+			  const struct media_device_ops *ops)
 {
 	struct rvin_group *group;
 	u32 id;
@@ -331,7 +333,7 @@  static int rvin_group_get(struct rvin_dev *vin,
 			goto err_group;
 		}
 
-		ret = rvin_group_init(group, vin, link_setup);
+		ret = rvin_group_init(group, vin, link_setup, ops);
 		if (ret) {
 			kfree(group);
 			vin_err(vin, "Failed to initialize group\n");
@@ -984,7 +986,7 @@  static int rvin_csi2_init(struct rvin_dev *vin)
 	if (ret < 0)
 		return ret;
 
-	ret = rvin_group_get(vin, rvin_csi2_setup_links);
+	ret = rvin_group_get(vin, rvin_csi2_setup_links, &rvin_media_ops);
 	if (ret)
 		goto err_controls;