linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
To: Helen Koike <helen.koike@collabora.com>,
	linux-media@vger.kernel.org, laurent.pinchart@ideasonboard.com
Cc: ezequiel@collabora.com, hverkuil@xs4all.nl, kernel@collabora.com,
	dafna3@gmail.com, sakari.ailus@linux.intel.com,
	linux-rockchip@lists.infradead.org, mchehab@kernel.org,
	tfiga@chromium.org
Subject: Re: [PATCH v2 5/9] media: staging: rkisp1: add a pointer to rkisp1_device from struct rkisp1_isp
Date: Tue, 21 Jul 2020 14:26:01 +0200	[thread overview]
Message-ID: <114a3242-88e9-46a1-c8c8-f5bfd424d05a@collabora.com> (raw)
In-Reply-To: <d8475ade-94a3-48ad-02d7-f03810ddf6dc@collabora.com>

Hi,

On 20.07.20 21:25, Helen Koike wrote:
> 
> 
> On 7/18/20 11:59 AM, Dafna Hirschfeld wrote:
>> The code in rkisp1-isp.c requires access to struct 'rkisp1_device'
>> in several places. It access it using the 'container_of' macro.
>> This patch adds a pointer to 'rkisp1_device' in struct 'rkisp1_isp'
>> to simplify the access.
> 
> What is wrong with container_of?

I remember Laurent suggested it a while ago.
I also feel container_of is a bit cumbersome and other entities already have a pointer to rkisp1_device.

Thanks,
Dafna

> 
> I usually prefer moving to container_of then the other way around, since this avoid a new field
> in the struct, and also avoid the requirements of keeping the pointer in sync.
> 
> Thanks
> Helen
> 
>>
>> Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
>> ---
>>   drivers/staging/media/rkisp1/rkisp1-common.h |  1 +
>>   drivers/staging/media/rkisp1/rkisp1-isp.c    | 12 +++++-------
>>   2 files changed, 6 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/staging/media/rkisp1/rkisp1-common.h b/drivers/staging/media/rkisp1/rkisp1-common.h
>> index e54793d13c3d..893caa9df891 100644
>> --- a/drivers/staging/media/rkisp1/rkisp1-common.h
>> +++ b/drivers/staging/media/rkisp1/rkisp1-common.h
>> @@ -106,6 +106,7 @@ struct rkisp1_sensor_async {
>>    */
>>   struct rkisp1_isp {
>>   	struct v4l2_subdev sd;
>> +	struct rkisp1_device *rkisp1;
>>   	struct media_pad pads[RKISP1_ISP_PAD_MAX];
>>   	struct v4l2_subdev_pad_config pad_cfg[RKISP1_ISP_PAD_MAX];
>>   	const struct rkisp1_isp_mbus_info *sink_fmt;
>> diff --git a/drivers/staging/media/rkisp1/rkisp1-isp.c b/drivers/staging/media/rkisp1/rkisp1-isp.c
>> index 6ec1e9816e9f..b2131aea5488 100644
>> --- a/drivers/staging/media/rkisp1/rkisp1-isp.c
>> +++ b/drivers/staging/media/rkisp1/rkisp1-isp.c
>> @@ -836,9 +836,8 @@ static int rkisp1_isp_set_selection(struct v4l2_subdev *sd,
>>   				    struct v4l2_subdev_pad_config *cfg,
>>   				    struct v4l2_subdev_selection *sel)
>>   {
>> -	struct rkisp1_device *rkisp1 =
>> -		container_of(sd->v4l2_dev, struct rkisp1_device, v4l2_dev);
>>   	struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd);
>> +	struct rkisp1_device *rkisp1 = isp->rkisp1;
>>   	int ret = 0;
>>   
>>   	if (sel->target != V4L2_SEL_TGT_CROP)
>> @@ -883,8 +882,7 @@ static const struct v4l2_subdev_pad_ops rkisp1_isp_pad_ops = {
>>   static int rkisp1_mipi_csi2_start(struct rkisp1_isp *isp,
>>   				  struct rkisp1_sensor_async *sensor)
>>   {
>> -	struct rkisp1_device *rkisp1 =
>> -		container_of(isp->sd.v4l2_dev, struct rkisp1_device, v4l2_dev);
>> +	struct rkisp1_device *rkisp1 = isp->rkisp1;
>>   	union phy_configure_opts opts;
>>   	struct phy_configure_opts_mipi_dphy *cfg = &opts.mipi_dphy;
>>   	s64 pixel_clock;
>> @@ -916,9 +914,8 @@ static void rkisp1_mipi_csi2_stop(struct rkisp1_sensor_async *sensor)
>>   
>>   static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable)
>>   {
>> -	struct rkisp1_device *rkisp1 =
>> -		container_of(sd->v4l2_dev, struct rkisp1_device, v4l2_dev);
>> -	struct rkisp1_isp *isp = &rkisp1->isp;
>> +	struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd);
>> +	struct rkisp1_device *rkisp1 = isp->rkisp1;
>>   	struct v4l2_subdev *sensor_sd;
>>   	int ret = 0;
>>   
>> @@ -997,6 +994,7 @@ int rkisp1_isp_register(struct rkisp1_device *rkisp1,
>>   	struct v4l2_subdev *sd = &isp->sd;
>>   	int ret;
>>   
>> +	isp->rkisp1 = rkisp1;
>>   	v4l2_subdev_init(sd, &rkisp1_isp_ops);
>>   	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
>>   	sd->entity.ops = &rkisp1_isp_media_ops;
>>

  reply	other threads:[~2020-07-21 12:26 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-18 14:59 [PATCH v2 0/9] media: staging: rkisp1: document rkisp1-common.h Dafna Hirschfeld
2020-07-18 14:59 ` [PATCH v2 1/9] media: staging: rkisp1: remove unused field ctrl_handler from struct rkisp1_device Dafna Hirschfeld
2020-07-18 14:59 ` [PATCH v2 2/9] media: staging: rkisp1: remove unused field alloc_ctx " Dafna Hirschfeld
2020-07-18 14:59 ` [PATCH v2 3/9] media: staging: rkisp1: set pads array of the resizer to size 2 Dafna Hirschfeld
2020-07-18 14:59 ` [PATCH v2 4/9] media: staging: rkisp1: don't define vaddr field in rkisp1_buffer as an array Dafna Hirschfeld
2020-07-20 19:22   ` Helen Koike
2020-07-18 14:59 ` [PATCH v2 5/9] media: staging: rkisp1: add a pointer to rkisp1_device from struct rkisp1_isp Dafna Hirschfeld
2020-07-20 19:25   ` Helen Koike
2020-07-21 12:26     ` Dafna Hirschfeld [this message]
2020-07-21 12:36       ` Tomasz Figa
2020-07-21 15:30         ` Dafna Hirschfeld
2020-07-21 15:32           ` Tomasz Figa
2020-08-01 16:08             ` Dafna Hirschfeld
2020-08-05 13:59               ` Tomasz Figa
2020-07-18 14:59 ` [PATCH v2 6/9] media: staging: rkisp1: unify (un)register functions to have the same parameters Dafna Hirschfeld
2020-07-20 19:26   ` Helen Koike
2020-07-18 14:59 ` [PATCH v2 7/9] media: staging: rkisp1: remove declaration of unimplemented function 'rkisp1_params_isr_handler' Dafna Hirschfeld
2020-07-20 19:26   ` Helen Koike
2020-07-18 14:59 ` [PATCH v2 8/9] media: staging: rkisp1: group declaration of similar functions together Dafna Hirschfeld
2020-07-20 19:29   ` Helen Koike
2020-07-18 14:59 ` [PATCH v2 9/9] media: staging: rkisp1: improve documentation of rkisp1-common.h Dafna Hirschfeld
2020-07-20 19:36   ` Helen Koike

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=114a3242-88e9-46a1-c8c8-f5bfd424d05a@collabora.com \
    --to=dafna.hirschfeld@collabora.com \
    --cc=dafna3@gmail.com \
    --cc=ezequiel@collabora.com \
    --cc=helen.koike@collabora.com \
    --cc=hverkuil@xs4all.nl \
    --cc=kernel@collabora.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tfiga@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).