Skip to contentSkip to conversation

staging: media: omap4iss: Use list_entry instead of container_of

PATCH In review Himadri Pandya 3 participants 9 messages Mar 24, 2019 – Apr 1, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: media: omap4iss: Use list_entry instead of container_of

Use list_entry instead of container_of for lists iss_buffer and iss_video.

---
 drivers/staging/media/omap4iss/iss_video.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/omap4iss/iss_video.h +2 -2
index f22489edb562..e8d27b7ac329 100644
@@ -118,7 +118,7 @@ struct iss_buffer {
 	dma_addr_t iss_addr;
 };
 
-#define to_iss_buffer(buf)	container_of(buf, struct iss_buffer, vb)
+#define to_iss_buffer(buf)	list_entry(buf, struct iss_buffer, vb)
 
 enum iss_video_dmaqueue_flags {
 	/* Set if DMA queue becomes empty when ISS_PIPELINE_STREAM_CONTINUOUS */
@@ -170,7 +170,7 @@ struct iss_video {
 	const struct iss_video_operations *ops;
 };
 
-#define to_iss_video(vdev)	container_of(vdev, struct iss_video, video)
+#define to_iss_video(vdev)	list_entry(vdev, struct iss_video, video)
 
 struct iss_video_fh {
 	struct v4l2_fh vfh;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 13 lines · Himadri Pandya

Use list_entry instead of container_of for lists iss_buffer and iss_video.

---
 drivers/staging/media/omap4iss/iss_video.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/omap4iss/iss_video.h +0 -0
index f22489edb562..e8d27b7ac329 100644

drivers/staging/media/omap4iss/iss_video.h struct iss_buffer { · line 121

Quoted 5 lines
drivers/staging/media/omap4iss/iss_video.h +1 -1
@@ -118,7 +118,7 @@ struct iss_buffer {
 	dma_addr_t iss_addr;
 };
 
-#define to_iss_buffer(buf)	container_of(buf, struct iss_buffer, vb)
+#define to_iss_buffer(buf)	list_entry(buf, struct iss_buffer, vb)

Actually, this macro is no longer used. Perhaps someone else converted the uses to use the proper list operations and forgot to drop the macro definition.

drivers/staging/media/omap4iss/iss_video.h struct iss_video { · line 173

Quoted 9 lines
drivers/staging/media/omap4iss/iss_video.h +1 -1
 enum iss_video_dmaqueue_flags {
 	/* Set if DMA queue becomes empty when ISS_PIPELINE_STREAM_CONTINUOUS */
@@ -170,7 +170,7 @@ struct iss_video {
 	const struct iss_video_operations *ops;
 };
 
-#define to_iss_video(vdev)	container_of(vdev, struct iss_video, video)
+#define to_iss_video(vdev)	list_entry(vdev, struct iss_video, video)

This doesn't involve a list. Nor does the previous one. To use list_entry, the third argument should be the name of a field that has type list_head.

julia

Quoted 12 lines
drivers/staging/media/omap4iss/iss_video.h +0 -1
 struct iss_video_fh {
 	struct v4l2_fh vfh;
--

2.17.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190324165433.95833-1-himadri18.07%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 21 lines · Julia Lawall

Review

Quoted 9 lines · Himadri Pandya

Use list_entry instead of container_of for lists iss_buffer and iss_video.

---
 drivers/staging/media/omap4iss/iss_video.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/media/omap4iss/iss_video.h

Quoted 7 lines

index f22489edb562..e8d27b7ac329 100644

drivers/staging/media/omap4iss/iss_video.h +0 -0
@@ -118,7 +118,7 @@ struct iss_buffer {
      dma_addr_t iss_addr;
 };
 
Quoted 7 lines

drivers/staging/media/omap4iss/iss_video.h struct iss_buffer { · line 121

Quoted 2 lines
drivers/staging/media/omap4iss/iss_video.h +1 -1
-#define to_iss_buffer(buf)   container_of(buf, struct iss_buffer, vb)
+#define to_iss_buffer(buf)   list_entry(buf, struct iss_buffer, vb)

Actually, this macro is no longer used. Perhaps someone else converted the uses to use the proper list operations and forgot to drop the macro definition.

Then should I send a patch to drop these macros?

Quoted 9 lines

drivers/staging/media/omap4iss/iss_video.h struct iss_buffer { · line 123

Quoted 4 lines
drivers/staging/media/omap4iss/iss_video.h +0 -0
 enum iss_video_dmaqueue_flags {
      /* Set if DMA queue becomes empty when

ISS_PIPELINE_STREAM_CONTINUOUS */

Quoted 4 lines
drivers/staging/media/omap4iss/iss_video.h +0 -0
@@ -170,7 +170,7 @@ struct iss_video {
      const struct iss_video_operations *ops;
 };
 
Quoted 7 lines

drivers/staging/media/omap4iss/iss_video.h struct iss_video { · line 173

Quoted 2 lines
drivers/staging/media/omap4iss/iss_video.h +1 -1
-#define to_iss_video(vdev)   container_of(vdev, struct iss_video, video)
+#define to_iss_video(vdev)   list_entry(vdev, struct iss_video, video)

This doesn't involve a list. Nor does the previous one. To use list_entry, the third argument should be the name of a field that has type list_head.

Understood. Thank you.

- Himadri

Quoted 31 lines

julia

Quoted 7 lines
drivers/staging/media/omap4iss/iss_video.h +0 -1
 struct iss_video_fh {
      struct v4l2_fh vfh;
--

2.17.1

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected].

Quoted 2 lines

To post to this group, send email to [email protected]. To view this discussion on the web visit

https://groups.google.com/d/msgid/outreachy-kernel/20190324165433.95833-1-himadri18.07%40gmail.com
.

Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected]. To view this discussion on the web visit
https://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.21.1903241812520.2526%40hadrien
.
For more options, visit https://groups.google.com/d/optout.

#3 lore raw
Quoted 30 lines · Himadri Pandya

On Sun, Mar 24, 2019 at 10:48 PM Julia Lawall <[email protected]> wrote:

On Sun, 24 Mar 2019, Himadri Pandya wrote:

> Use list_entry instead of container_of for lists iss_buffer and
> iss_video.
>
> Signed-off-by: Himadri Pandya <[email protected]> > ---
>  drivers/staging/media/omap4iss/iss_video.h | 4 ++-- >  1 file changed, 2 insertions(+), 2 deletions(-) >
> diff --git a/drivers/staging/media/omap4iss/iss_video.h b/drivers/staging/media/omap4iss/iss_video.h
> index f22489edb562..e8d27b7ac329 100644
> --- a/drivers/staging/media/omap4iss/iss_video.h > +++ b/drivers/staging/media/omap4iss/iss_video.h > @@ -118,7 +118,7 @@ struct iss_buffer {
>       dma_addr_t iss_addr;
>  };
>
> -#define to_iss_buffer(buf)   container_of(buf, struct iss_buffer, vb)
> +#define to_iss_buffer(buf)   list_entry(buf, struct iss_buffer, vb)

Quoted 8 lines

Actually, this macro is no longer used.  Perhaps someone else converted
the uses to use the proper list operations and forgot to drop the macro
definition.

Then should I send a patch to drop these macros?

One of the macros is used and one is not. You can send a patch to drop the one that is not used. The other one is used only once. Still it looks more readable than a call to container_of.

julia

Quoted 69 lines

>
>  enum iss_video_dmaqueue_flags {
>       /* Set if DMA queue becomes empty when ISS_PIPELINE_STREAM_CONTINUOUS */
> @@ -170,7 +170,7 @@ struct iss_video {
>       const struct iss_video_operations *ops; >  };
>
> -#define to_iss_video(vdev)   container_of(vdev, struct iss_video, video)
> +#define to_iss_video(vdev)   list_entry(vdev, struct iss_video, video)

This doesn't involve a list.  Nor does the previous one.  To use list_entry, the third argument should be the name of a field that has type
list_head.

Understood. Thank you.

- Himadri

julia

>  struct iss_video_fh {
>       struct v4l2_fh vfh;
> --
> 2.17.1
>
> --
> You received this message because you are subscribed to the
Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from
it, send an email to
[email protected].
> To post to this group, send email to
[email protected].
> To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/20190324165433.95833-1-h imadri18.07%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

--
You received this message because you are subscribed to the
Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from
it, send an email to
[email protected].
To post to this group, send email to
[email protected].
To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.21.19032418 12520.2526%40hadrien.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups
"outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/CAPnhUpYSAaY0J6dRsQf2hMv MfUhvaSXqu%2BVgt3aQ7g_mjGX8Hw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

#4 lore raw
In reply to Himadri Pandya

Hello Himadri,

Quoted 18 lines · Himadri Pandya
Quoted 17 lines · Julia Lawall
Quoted 16 lines · Himadri Pandya

Use list_entry instead of container_of for lists iss_buffer and iss_video.

---
  drivers/staging/media/omap4iss/iss_video.h | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/omap4iss/iss_video.h +0 -0
index f22489edb562..e8d27b7ac329 100644
@@ -118,7 +118,7 @@ struct iss_buffer {
        dma_addr_t iss_addr;
   };
 
Quoted 8 lines
Quoted 6 lines

drivers/staging/media/omap4iss/iss_video.h struct iss_buffer { · line 121

Quoted 2 lines
drivers/staging/media/omap4iss/iss_video.h +1 -1
-#define to_iss_buffer(buf)   container_of(buf, struct iss_buffer, vb)
+#define to_iss_buffer(buf)   list_entry(buf, struct iss_buffer, vb)

Actually, this macro is no longer used.  Perhaps someone else converted the uses to use the proper list operations and forgot to drop the macro definition.

Then should I send a patch to drop these macros?

It would be better to modify the to_iss_buffer macro to convert from a vb2_buffer to a iss_buffer, and use it where the driver currently uses container_of directly.

Quoted 17 lines
Quoted 6 lines
Quoted 6 lines
drivers/staging/media/omap4iss/iss_video.h +0 -0
   enum iss_video_dmaqueue_flags {
        /* Set if DMA queue becomes empty when ISS_PIPELINE_STREAM_CONTINUOUS */
@@ -170,7 +170,7 @@ struct iss_video {
        const struct iss_video_operations *ops;
   };
 
Quoted 6 lines

drivers/staging/media/omap4iss/iss_video.h struct iss_video { · line 173

Quoted 2 lines
drivers/staging/media/omap4iss/iss_video.h +1 -1
-#define to_iss_video(vdev)   container_of(vdev, struct iss_video, video)
+#define to_iss_video(vdev)   list_entry(vdev, struct iss_video, video)

This doesn't involve a list.  Nor does the previous one.  To use list_entry, the third argument should be the name of a field that has type list_head.

Understood. Thank you.

Quoted 2 lines
Quoted 2 lines
drivers/staging/media/omap4iss/iss_video.h +0 -0
   struct iss_video_fh {
        struct v4l2_fh vfh;
Signature · 3 lines
Regards,

Laurent Pinchart
#5 lore raw
Quoted 30 lines · Laurent Pinchart

Hello Himadri,

Quoted 1 line · Himadri Pandya

On Sun, Mar 24, 2019 at 10:48 PM Julia Lawall <[email protected]>

Quoted 10 lines · wrote:
Quoted 10 lines · Himadri Pandya

Review

Quoted 9 lines

Use list_entry instead of container_of for lists iss_buffer and iss_video.

---
 drivers/staging/media/omap4iss/iss_video.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/media/omap4iss/iss_video.h

Quoted 14 lines
Quoted 13 lines

drivers/staging/media/omap4iss/iss_video.h struct iss_buffer { · line 121

Quoted 9 lines

index f22489edb562..e8d27b7ac329 100644

drivers/staging/media/omap4iss/iss_video.h +1 -1
@@ -118,7 +118,7 @@ struct iss_buffer {
      dma_addr_t iss_addr;
 };
 
-#define to_iss_buffer(buf)   container_of(buf, struct iss_buffer, vb)
+#define to_iss_buffer(buf)   list_entry(buf, struct iss_buffer, vb)

Actually, this macro is no longer used. Perhaps someone else converted the uses to use the proper list operations and forgot to drop the macro definition.

Quoted 7 lines
Quoted 1 line

Then should I send a patch to drop these macros?

It would be better to modify the to_iss_buffer macro to convert from a vb2_buffer to a iss_buffer, and use it where the driver currently uses container_of directly.

I am sorry but I am not sure if I understand what you are suggesting correctly.

to_iss_buffer is defined as:
#define to_iss_buffer(buf) container_of(buf, struct iss_buffer, vb)

And it is not used. Instead, container_of is used directly static void iss_video_buf_cleanup(struct vb2_buffer *vb) {
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);

struct iss_buffer *buffer = container_of(vbuf, struct iss_buffer, vb);
        ...
}

static int iss_video_buf_prepare(struct vb2_buffer *vb) {
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct iss_video_fh *vfh = vb2_get_drv_priv(vb->vb2_queue);

struct iss_buffer *buffer = container_of(vbuf, struct iss_buffer, vb);
        ...
}

static void iss_video_buf_queue(struct vb2_buffer *vb) {
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct iss_video_fh *vfh = vb2_get_drv_priv(vb->vb2_queue); struct iss_video *video = vfh->video;

struct iss_buffer *buffer = container_of(vbuf, struct iss_buffer, vb);
        ...
}

If I understand it correctly, these usages are converting vb2_buffer to iss_buffer. Which could be done by using the to_iss_buffer(vbuf) as well. Why is this macro no longer used? I also don't understand what modification you are suggesting. Can you please elaborate?

Thank you.

- Himadri

Quoted 27 lines
Quoted 2 lines
Quoted 2 lines

drivers/staging/media/omap4iss/iss_video.h struct iss_buffer { · line 123

Quoted 2 lines
drivers/staging/media/omap4iss/iss_video.h +0 -0
 enum iss_video_dmaqueue_flags {
      /* Set if DMA queue becomes empty when

ISS_PIPELINE_STREAM_CONTINUOUS */

Quoted 5 lines
Quoted 5 lines

drivers/staging/media/omap4iss/iss_video.h struct iss_video { · line 173

Quoted 5 lines
drivers/staging/media/omap4iss/iss_video.h +0 -1
@@ -170,7 +170,7 @@ struct iss_video {
      const struct iss_video_operations *ops;
 };
 
-#define to_iss_video(vdev)   container_of(vdev, struct iss_video,

video)

Quoted 1 line
Quoted 1 line

drivers/staging/media/omap4iss/iss_video.h struct iss_video { · line 173

Quoted 1 line
drivers/staging/media/omap4iss/iss_video.h +1 -0
+#define to_iss_video(vdev)   list_entry(vdev, struct iss_video,

video)

Quoted 3 lines
Quoted 3 lines

This doesn't involve a list. Nor does the previous one. To use list_entry, the third argument should be the name of a field that has

type

Quoted 6 lines
Quoted 1 line

list_head.

Understood. Thank you.

Quoted 2 lines
Quoted 2 lines
drivers/staging/media/omap4iss/iss_video.h +0 -0
 struct iss_video_fh {
      struct v4l2_fh vfh;

--
Regards,

Laurent Pinchart

#6 lore raw
Quoted 77 lines · Himadri Pandya
Quoted 30 lines · Laurent Pinchart

Hello Himadri,

Quoted 1 line · Himadri Pandya

On Sun, Mar 24, 2019 at 10:48 PM Julia Lawall <[email protected]>

Quoted 10 lines · wrote:
Quoted 10 lines · Himadri Pandya

Review

Quoted 9 lines

Use list_entry instead of container_of for lists iss_buffer and iss_video.

---
 drivers/staging/media/omap4iss/iss_video.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/media/omap4iss/iss_video.h

Quoted 8 lines
Quoted 8 lines

drivers/staging/media/omap4iss/iss_video.h struct iss_buffer { · line 121

Quoted 8 lines

index f22489edb562..e8d27b7ac329 100644

drivers/staging/media/omap4iss/iss_video.h +0 -1
@@ -118,7 +118,7 @@ struct iss_buffer {
      dma_addr_t iss_addr;
 };
 
-#define to_iss_buffer(buf)   container_of(buf, struct iss_buffer,

vb)

Quoted 3 lines
Quoted 3 lines

drivers/staging/media/omap4iss/iss_video.h struct iss_buffer { · line 121

Quoted 1 line
drivers/staging/media/omap4iss/iss_video.h +1 -0
+#define to_iss_buffer(buf)   list_entry(buf, struct iss_buffer, vb)

Actually, this macro is no longer used. Perhaps someone else

converted

Quoted 1 line
Quoted 1 line

the uses to use the proper list operations and forgot to drop the

Quoted 10 lines

macro

Quoted 3 lines
Quoted 1 line

definition.

Then should I send a patch to drop these macros?

It would be better to modify the to_iss_buffer macro to convert from a vb2_buffer to a iss_buffer, and use it where the driver currently uses container_of directly.

I am sorry but I am not sure if I understand what you are suggesting correctly.

to_iss_buffer is defined as:
#define to_iss_buffer(buf) container_of(buf, struct iss_buffer, vb)

And it is not used. Instead, container_of is used directly static void iss_video_buf_cleanup(struct vb2_buffer *vb) {
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);

struct iss_buffer *buffer = container_of(vbuf, struct iss_buffer, vb);
        ...
}

static int iss_video_buf_prepare(struct vb2_buffer *vb) {
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct iss_video_fh *vfh = vb2_get_drv_priv(vb->vb2_queue);

struct iss_buffer *buffer = container_of(vbuf, struct iss_buffer, vb);
        ...
}

static void iss_video_buf_queue(struct vb2_buffer *vb) {
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct iss_video_fh *vfh = vb2_get_drv_priv(vb->vb2_queue); struct iss_video *video = vfh->video;

struct iss_buffer *buffer = container_of(vbuf, struct iss_buffer, vb);
        ...
}
Quoted 39 lines

If I understand it correctly, these usages are converting vb2_buffer to iss_buffer. Which could be done by using the to_iss_buffer(vbuf) as well. Why is this macro no longer used? I also don't understand what modification you are suggesting. Can you please elaborate?

Thank you.

- Himadri

Quoted 27 lines
Quoted 2 lines
Quoted 2 lines

drivers/staging/media/omap4iss/iss_video.h struct iss_buffer { · line 123

Quoted 2 lines
drivers/staging/media/omap4iss/iss_video.h +0 -0
 enum iss_video_dmaqueue_flags {
      /* Set if DMA queue becomes empty when

ISS_PIPELINE_STREAM_CONTINUOUS */

Quoted 5 lines
Quoted 5 lines

drivers/staging/media/omap4iss/iss_video.h struct iss_video { · line 173

Quoted 5 lines
drivers/staging/media/omap4iss/iss_video.h +0 -1
@@ -170,7 +170,7 @@ struct iss_video {
      const struct iss_video_operations *ops;
 };
 
-#define to_iss_video(vdev)   container_of(vdev, struct iss_video,

video)

Quoted 1 line
Quoted 1 line

drivers/staging/media/omap4iss/iss_video.h struct iss_video { · line 173

Quoted 1 line
drivers/staging/media/omap4iss/iss_video.h +1 -0
+#define to_iss_video(vdev)   list_entry(vdev, struct iss_video,

video)

Quoted 3 lines
Quoted 3 lines

This doesn't involve a list. Nor does the previous one. To use list_entry, the third argument should be the name of a field that has

type

Quoted 6 lines
Quoted 1 line

list_head.

Understood. Thank you.

Quoted 2 lines
Quoted 2 lines
drivers/staging/media/omap4iss/iss_video.h +0 -0
 struct iss_video_fh {
      struct v4l2_fh vfh;

--
Regards,

Laurent Pinchart

I have been suggested to modify the macro to_iss_bufer(). But I do not understand how should it be changed. Can anybody please explain it? I need to understand this in order to send the next version of the patch.

Thank you.

- Himadri

#7 lore raw
In reply to Himadri Pandya

Hello Himadri,

Quoted 33 lines · Himadri Pandya
Quoted 26 lines · Laurent Pinchart
Quoted 25 lines · Himadri Pandya
Quoted 23 lines · Julia Lawall
Quoted 13 lines · Himadri Pandya

Use list_entry instead of container_of for lists iss_buffer and iss_video.

---
  drivers/staging/media/omap4iss/iss_video.h | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/omap4iss/iss_video.h +0 -0
index f22489edb562..e8d27b7ac329 100644

drivers/staging/media/omap4iss/iss_video.h struct iss_buffer { · line 121

Quoted 5 lines
drivers/staging/media/omap4iss/iss_video.h +1 -1
@@ -118,7 +118,7 @@ struct iss_buffer {
        dma_addr_t iss_addr;
   };
 
-#define to_iss_buffer(buf)   container_of(buf, struct iss_buffer, vb)
+#define to_iss_buffer(buf)   list_entry(buf, struct iss_buffer, vb)

Actually, this macro is no longer used.  Perhaps someone else converted the uses to use the proper list operations and forgot to drop the macro definition.

Quoted 5 lines
Quoted 1 line

Then should I send a patch to drop these macros?

It would be better to modify the to_iss_buffer macro to convert from a vb2_buffer to a iss_buffer, and use it where the driver currently uses container_of directly.

Quoted 5 lines

I am sorry but I am not sure if I understand what you are suggesting correctly.

to_iss_buffer is defined as:
#define to_iss_buffer(buf)   container_of(buf, struct iss_buffer, vb)

to_iss_buffer() casts a vb2_v4l2_buffer pointer to a iss_buffer pointer.

Quoted 16 lines

And it is not used. Instead, container_of is used directly static void iss_video_buf_cleanup(struct vb2_buffer *vb)
{
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct iss_buffer *buffer = container_of(vbuf, struct iss_buffer, vb);
        ...
}

static int iss_video_buf_prepare(struct vb2_buffer *vb)
{
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct iss_video_fh *vfh = vb2_get_drv_priv(vb->vb2_queue); struct iss_buffer *buffer = container_of(vbuf, struct iss_buffer, vb);
        ...
}

Quoted 8 lines

static void iss_video_buf_queue(struct vb2_buffer *vb)
{
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct iss_video_fh *vfh = vb2_get_drv_priv(vb->vb2_queue); struct iss_video *video = vfh->video;
struct iss_buffer *buffer = container_of(vbuf, struct iss_buffer, vb);
        ...
}

These three functions need to cast a vb2_buffer pointer to a iss_buffer pointer. They do so by first casting to vb2_v4l2_buffer, and then to iss_buffer with a direct use of container_of. It would be best to combine the two casts in a single to_iss_buffer macro and use it through the code.

Quoted 22 lines

If I understand it correctly, these usages are converting vb2_buffer to iss_buffer. Which could be done by using the to_iss_buffer(vbuf) as well. Why is this macro no longer used? I also don't understand what modification you are suggesting. Can you please elaborate?

Quoted 17 lines
Quoted 17 lines
Quoted 6 lines
Quoted 6 lines
drivers/staging/media/omap4iss/iss_video.h +0 -0
   enum iss_video_dmaqueue_flags {
        /* Set if DMA queue becomes empty when ISS_PIPELINE_STREAM_CONTINUOUS */
@@ -170,7 +170,7 @@ struct iss_video {
        const struct iss_video_operations *ops;
   };
 
Quoted 6 lines

drivers/staging/media/omap4iss/iss_video.h struct iss_video { · line 173

Quoted 2 lines
drivers/staging/media/omap4iss/iss_video.h +1 -1
-#define to_iss_video(vdev)   container_of(vdev, struct iss_video, video)
+#define to_iss_video(vdev)   list_entry(vdev, struct iss_video, video)

This doesn't involve a list.  Nor does the previous one.  To use list_entry, the third argument should be the name of a field that has type list_head.

Understood. Thank you.

Quoted 2 lines
Quoted 2 lines
drivers/staging/media/omap4iss/iss_video.h +0 -0
   struct iss_video_fh {
        struct v4l2_fh vfh;
Signature · 3 lines
Regards,

Laurent Pinchart
#8 lore raw
Quoted 73 lines · Laurent Pinchart

Hello Himadri,

Quoted 7 lines · Himadri Pandya
Quoted 6 lines · Laurent Pinchart
Quoted 5 lines · Himadri Pandya
Quoted 4 lines · Julia Lawall
Quoted 3 lines · Himadri Pandya

Use list_entry instead of container_of for lists iss_buffer and iss_video.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Review

Quoted 6 lines
---
 drivers/staging/media/omap4iss/iss_video.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/media/omap4iss/iss_video.h

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/staging/media/omap4iss/iss_video.h struct iss_buffer { · line 121

Quoted 8 lines

index f22489edb562..e8d27b7ac329 100644

drivers/staging/media/omap4iss/iss_video.h +0 -1
@@ -118,7 +118,7 @@ struct iss_buffer {
      dma_addr_t iss_addr;
 };
 
-#define to_iss_buffer(buf)   container_of(buf, struct iss_buffer,

vb)

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/staging/media/omap4iss/iss_video.h struct iss_buffer { · line 121

Quoted 1 line
drivers/staging/media/omap4iss/iss_video.h +1 -0
+#define to_iss_buffer(buf)   list_entry(buf, struct iss_buffer, vb)

Actually, this macro is no longer used. Perhaps someone else

converted

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the uses to use the proper list operations and forgot to drop the

macro

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

definition.

Then should I send a patch to drop these macros?

It would be better to modify the to_iss_buffer macro to convert from a vb2_buffer to a iss_buffer, and use it where the driver currently uses container_of directly.

Quoted 5 lines

I am sorry but I am not sure if I understand what you are suggesting correctly.

to_iss_buffer is defined as:
#define to_iss_buffer(buf) container_of(buf, struct iss_buffer, vb)

to_iss_buffer() casts a vb2_v4l2_buffer pointer to a iss_buffer pointer.

Quoted 16 lines

And it is not used. Instead, container_of is used directly static void iss_video_buf_cleanup(struct vb2_buffer *vb) {
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);

struct iss_buffer *buffer = container_of(vbuf, struct iss_buffer, vb);
        ...
}

static int iss_video_buf_prepare(struct vb2_buffer *vb) {
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct iss_video_fh *vfh = vb2_get_drv_priv(vb->vb2_queue);

struct iss_buffer *buffer = container_of(vbuf, struct iss_buffer, vb);
        ...
}
Quoted 8 lines

static void iss_video_buf_queue(struct vb2_buffer *vb) {
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct iss_video_fh *vfh = vb2_get_drv_priv(vb->vb2_queue); struct iss_video *video = vfh->video;

struct iss_buffer *buffer = container_of(vbuf, struct iss_buffer, vb);
        ...
}
Quoted 6 lines

These three functions need to cast a vb2_buffer pointer to a iss_buffer pointer. They do so by first casting to vb2_v4l2_buffer, and then to iss_buffer with a direct use of container_of. It would be best to combine the two casts in a single to_iss_buffer macro and use it through the code.

Got it. Thank you.

- Himadri

Quoted 33 lines
Quoted 2 lines

If I understand it correctly, these usages are converting vb2_buffer to iss_buffer. Which could be done by using the to_iss_buffer(vbuf) as

well. Why

Quoted 1 line

is this macro no longer used? I also don't understand what modification

you are

Quoted 4 lines

suggesting. Can you please elaborate?

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/staging/media/omap4iss/iss_video.h +0 -0
 enum iss_video_dmaqueue_flags {
      /* Set if DMA queue becomes empty when

ISS_PIPELINE_STREAM_CONTINUOUS */

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/staging/media/omap4iss/iss_video.h struct iss_video { · line 173

Quoted 5 lines
drivers/staging/media/omap4iss/iss_video.h +0 -1
@@ -170,7 +170,7 @@ struct iss_video {
      const struct iss_video_operations *ops;
 };
 
-#define to_iss_video(vdev)   container_of(vdev, struct iss_video,

video)

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/staging/media/omap4iss/iss_video.h struct iss_video { · line 173

Quoted 1 line
drivers/staging/media/omap4iss/iss_video.h +1 -0
+#define to_iss_video(vdev)   list_entry(vdev, struct iss_video,

video)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines

This doesn't involve a list. Nor does the previous one. To use list_entry, the third argument should be the name of a field that has type list_head.

Understood. Thank you.

Quoted 2 lines
Quoted 2 lines
drivers/staging/media/omap4iss/iss_video.h +0 -0
 struct iss_video_fh {
      struct v4l2_fh vfh;

--
Regards,

Laurent Pinchart