From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Dafna Hirschfeld <dafna@fastmail.com>
Cc: linux-media@vger.kernel.org, Heiko Stuebner <heiko@sntech.de>,
Paul Elder <paul.elder@ideasonboard.com>,
Tomasz Figa <tfiga@google.com>,
linux-rockchip@lists.infradead.org
Subject: Re: [PATCH 02/16] media: rkisp1: capture: Fix and simplify (un)registration
Date: Fri, 4 Mar 2022 14:21:31 +0200 [thread overview]
Message-ID: <YiIES2Q6G4FPTQQ8@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20220302171040.bem4jeinzowppzx6@guri>
Hi Dafna,
On Wed, Mar 02, 2022 at 07:10:40PM +0200, Dafna Hirschfeld wrote:
> On 27.02.2022 18:01, Laurent Pinchart wrote:
> > The rkisp1_register_capture() and rkisp1_unregister_capture() functions
> > don't destroy the mutex (in the error path for the former). Fix this and
> > make rkisp1_unregister_capture() and rkisp1_capture_devs_unregister()
> > safe to be called on an unregistered capture node to prepare for
> > simplification of error handling at probe time.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > .../platform/rockchip/rkisp1/rkisp1-capture.c | 26 ++++++++++---------
> > 1 file changed, 14 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c
> > index 9c11f2b8e5f5..18be7c982db7 100644
> > --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c
> > +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c
> > @@ -1312,8 +1312,12 @@ static const struct v4l2_file_operations rkisp1_fops = {
> >
> > static void rkisp1_unregister_capture(struct rkisp1_capture *cap)
> > {
> > + if (!cap->rkisp1)
> > + return;
> > +
> > media_entity_cleanup(&cap->vnode.vdev.entity);
> > vb2_video_unregister_device(&cap->vnode.vdev);
> > + mutex_destroy(&cap->vnode.vlock);
> > }
> >
> > void rkisp1_capture_devs_unregister(struct rkisp1_device *rkisp1)
> > @@ -1390,6 +1394,8 @@ static int rkisp1_register_capture(struct rkisp1_capture *cap)
> >
> > error:
> > media_entity_cleanup(&vdev->entity);
> > + mutex_destroy(&node->vlock);
> > + cap->rkisp1 = NULL;
> > return ret;
> > }
> >
> > @@ -1425,26 +1431,22 @@ rkisp1_capture_init(struct rkisp1_device *rkisp1, enum rkisp1_stream_id id)
> >
> > int rkisp1_capture_devs_register(struct rkisp1_device *rkisp1)
> > {
> > - struct rkisp1_capture *cap;
> > - unsigned int i, j;
> > + unsigned int i;
> > int ret;
> >
> > for (i = 0; i < ARRAY_SIZE(rkisp1->capture_devs); i++) {
> > + struct rkisp1_capture *cap = &rkisp1->capture_devs[i];
> > +
> > rkisp1_capture_init(rkisp1, i);
> > - cap = &rkisp1->capture_devs[i];
> > cap->rkisp1 = rkisp1;
> > +
> > ret = rkisp1_register_capture(cap);
> > - if (ret)
> > - goto err_unreg_capture_devs;
> > + if (ret) {
>
> I would set 'cap->rkisp1 = NULL' here instead of in rkisp1_register_capture
> so that 'rkisp1l' field is set and unset in the same function
I'll fix that, and in the resizer patch too.
> > + rkisp1_capture_devs_unregister(rkisp1);
> > + return ret;
> > + }
> > }
> >
> > return 0;
> >
> > -err_unreg_capture_devs:
> > - for (j = 0; j < i; j++) {
> > - cap = &rkisp1->capture_devs[j];
> > - rkisp1_unregister_capture(cap);
> > - }
> > -
> > - return ret;
> > }
--
Regards,
Laurent Pinchart
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
next prev parent reply other threads:[~2022-03-04 12:21 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-27 16:01 [PATCH 00/16] media: rkisp1: Misc bug fixes and cleanups Laurent Pinchart
2022-02-27 16:01 ` [PATCH 01/16] media: rkisp1: capture: Initialize entity before video device Laurent Pinchart
2022-03-02 14:25 ` Dafna Hirschfeld
2022-02-27 16:01 ` [PATCH 02/16] media: rkisp1: capture: Fix and simplify (un)registration Laurent Pinchart
2022-03-02 17:10 ` Dafna Hirschfeld
2022-03-04 12:21 ` Laurent Pinchart [this message]
2022-02-27 16:01 ` [PATCH 03/16] media: rkisp1: isp: " Laurent Pinchart
2022-02-27 16:01 ` [PATCH 04/16] media: rkisp1: resizer: " Laurent Pinchart
2022-03-02 19:12 ` Dafna Hirschfeld
2022-02-27 16:01 ` [PATCH 05/16] media: rkisp1: params: " Laurent Pinchart
2022-02-27 16:01 ` [PATCH 06/16] media: rkisp1: stats: Simplify (un)registration Laurent Pinchart
2022-02-27 16:01 ` [PATCH 07/16] media: rkisp1: Simplify rkisp1_entities_register() error path Laurent Pinchart
2022-03-02 19:16 ` Dafna Hirschfeld
2022-02-27 16:01 ` [PATCH 08/16] media: rkisp1: regs: Don't use BIT() macro for multi-bit register fields Laurent Pinchart
2022-02-27 16:01 ` [PATCH 09/16] media: rkisp1: regs: Rename CCL, ICCL and IRCL registers with VI_ prefix Laurent Pinchart
2022-02-27 16:01 ` [PATCH 10/16] media: rkisp1: resizer: Simplify register access Laurent Pinchart
2022-02-27 16:10 ` [PATCH v1.1 " Laurent Pinchart
2022-03-03 6:32 ` Dafna Hirschfeld
2022-03-03 8:21 ` Laurent Pinchart
2022-03-02 19:34 ` [PATCH " Dafna Hirschfeld
2022-02-27 16:01 ` [PATCH 11/16] media: rkisp1: Move debugfs code to a separate file Laurent Pinchart
2022-02-27 16:01 ` [PATCH 12/16] media: rkisp1: Compile debugfs support conditionally Laurent Pinchart
2022-02-28 3:27 ` kernel test robot
2022-02-27 16:01 ` [PATCH 13/16] media: rkisp1: debug: Collect input status by sampling ISP_FLAGS_SHD Laurent Pinchart
2022-02-27 16:01 ` [PATCH 14/16] media: rkisp1: debug: Add debugfs files to dump core and ISP registers Laurent Pinchart
2022-02-27 16:01 ` [PATCH 15/16] media: rkisp1: debug: Move resizer register dump to debugfs Laurent Pinchart
2022-02-27 16:01 ` [PATCH 16/16] media: rkisp1: capture: Bypass the main device for handling querycap Laurent Pinchart
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=YiIES2Q6G4FPTQQ8@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=dafna@fastmail.com \
--cc=heiko@sntech.de \
--cc=linux-media@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=paul.elder@ideasonboard.com \
--cc=tfiga@google.com \
/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