All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com>
To: Alexey Klimov <klimov.linux@gmail.com>
Cc: linux-media@vger.kernel.org, linux-omap@vger.kernel.org,
	saaguirre@ti.com, tuukka.o.toivonen@nokia.com,
	dongsoo.kim@gmail.com
Subject: Re: [PATCH 9/9] omap34xxcam: Add camera driver
Date: Thu, 05 Mar 2009 16:09:15 +0200	[thread overview]
Message-ID: <49AFDD0B.80804@maxwell.research.nokia.com> (raw)
In-Reply-To: <1236101460.10927.109.camel@tux.localhost>

Alexey Klimov wrote:
>> +static int vidioc_g_fmt_vid_cap(struct file *file, void *fh,
>> +				struct v4l2_format *f)
>> +{
>> +	struct omap34xxcam_fh *ofh = fh;
>> +	struct omap34xxcam_videodev *vdev = ofh->vdev;
>> +
>> +	if (vdev->vdev_sensor == v4l2_int_device_dummy())
>> +		return -EINVAL;
>> +
>> +	mutex_lock(&vdev->mutex);
>> +	f->fmt.pix = vdev->pix;
>> +	mutex_unlock(&vdev->mutex);
> 
> Hmmmm, you are using mutex_lock to lock reading from vdev structure..
> Well, i don't if this is right approach. I am used to that mutex_lock is
> used to prevent _changing_ of members in structure..

The vdev->mutex is acquired since we want to prevent concurrent access 
to vdev->pix. Otherwise it might change while we are reading it, right?

>> +static int vidioc_s_fmt_vid_cap(struct file *file, void *fh,
>> +				struct v4l2_format *f)
>> +{
>> +	struct omap34xxcam_fh *ofh = fh;
>> +	struct omap34xxcam_videodev *vdev = ofh->vdev;
>> +	struct v4l2_pix_format pix_tmp;
>> +	struct v4l2_fract timeperframe;
>> +	int rval;
>> +
>> +	if (vdev->vdev_sensor == v4l2_int_device_dummy())
>> +		return -EINVAL;
>> +
>> +	mutex_lock(&vdev->mutex);
>> +	if (vdev->streaming) {
>> +		rval = -EBUSY;
>> +		goto out;
>> +	}
> 
> Well, why don't remove goto, place return -EBUSY, and move mutex after
> if (vdev->streaming) check ?

The streaming state may change in the meantime. See vidioc_streamon. 
It's not very likely but possible as far as I understand.

>> +static int vidioc_reqbufs(struct file *file, void *fh,
>> +			  struct v4l2_requestbuffers *b)
>> +{
>> +	struct omap34xxcam_fh *ofh = fh;
>> +	struct omap34xxcam_videodev *vdev = ofh->vdev;
>> +	int rval;
>> +
>> +	if (vdev->vdev_sensor == v4l2_int_device_dummy())
>> +		return -EINVAL;
>> +
>> +	mutex_lock(&vdev->mutex);
>> +	if (vdev->streaming) {
>> +		mutex_unlock(&vdev->mutex);
>> +		return -EBUSY;
>> +	}
> 
> If i'm doing this i prefer to place mutex_lock after this
> if(vdev->streaming) check.

Same here.

>> +static int omap34xxcam_device_register(struct v4l2_int_device *s)
>> +{
>> +	struct omap34xxcam_videodev *vdev = s->u.slave->master->priv;
>> +	struct omap34xxcam_hw_config hwc;
>> +	int rval;
>> +
>> +	/* We need to check rval just once. The place is here. */
> 
> I didn't understand this comment. You doing nothin in next few lines
> with int variable rval(which introduced in this function). Is comment
> talking about struct v4l2_int_device *s ?

Yes. If the g_priv() succeeds now it will succeed in future, too. This 
comes from the platform data through the slave device.

>> +	/* Are we the first slave? */
>> +	if (vdev->slaves == 1) {
>> +		/* initialize the video_device struct */
>> +		vdev->vfd = video_device_alloc();
>> +		if (!vdev->vfd) {
>> +			dev_err(&vdev->vfd->dev,
>> +				"could not allocate video device struct\n");
> 
> Do i understand you code in right way ?
> You call video_device_alloc() to get vdev->vfd. Then if vdev->vfd is
> null(empty) you make message dev_err which based on vdev->vfd->dev but
> dev->vfd allocating is failed.. If i'm not wrong you message will
> provide kernel oops.
> One more point here is that you use dev_err(&vdev->vfd->dev before call
> to video_device_alloc() in this function.

Indeed. Others hit this already. Thanks.

>> +static int __init omap34xxcam_init(void)
>> +{
>> +	struct omap34xxcam_device *cam;
>> +	int i;
>> +
>> +	cam = kzalloc(sizeof(*cam), GFP_KERNEL);
>> +	if (!cam) {
>> +		printk(KERN_ERR "%s: could not allocate memory\n", __func__);
>> +		goto err;
> 
> If kzalloc failed you return -ENODEV; but this is ENOMEM error.

Yes. Will fix.

Thanks again for the comments.

-- 
Sakari Ailus
sakari.ailus@maxwell.research.nokia.com

  reply	other threads:[~2009-03-05 14:09 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-03 10:06 [RFC 0/9] OMAP3 ISP and camera drivers Sakari Ailus
2009-03-03 10:06 ` [PATCH 1/9] omap3isp: Add ISP main driver and register definitions Sakari Ailus
2009-03-03 10:06   ` [PATCH 2/9] omap3isp: Add ISP MMU wrapper Sakari Ailus
2009-03-03 10:06     ` [PATCH 3/9] omap3isp: Add userspace header Sakari Ailus
2009-03-03 10:06       ` [PATCH 4/9] omap3isp: Add ISP frontend (CCDC) Sakari Ailus
2009-03-03 10:06         ` [PATCH 5/9] omap3isp: Add ISP backend (PRV and RSZ) Sakari Ailus
2009-03-03 10:06           ` [PATCH 6/9] omap3isp: Add statistics collection modules (H3A and HIST) Sakari Ailus
2009-03-03 10:06             ` [PATCH 7/9] omap3isp: Add CSI2 interface support Sakari Ailus
2009-03-03 10:06               ` [PATCH 8/9] omap3isp: Add ISP tables Sakari Ailus
2009-03-03 10:06                 ` [PATCH 9/9] omap34xxcam: Add camera driver Sakari Ailus
2009-03-03 17:31                   ` Alexey Klimov
2009-03-05 14:09                     ` Sakari Ailus [this message]
2009-03-07 14:38                       ` Alexey Klimov
2009-03-03 12:23           ` [PATCH 5/9] omap3isp: Add ISP backend (PRV and RSZ) Alexey Klimov
2009-03-03 12:07         ` [PATCH 4/9] omap3isp: Add ISP frontend (CCDC) Alexey Klimov
2009-03-06 12:51       ` [PATCH 3/9] omap3isp: Add userspace header Hans Verkuil
2009-03-03 11:56   ` [PATCH 1/9] omap3isp: Add ISP main driver and register definitions Alexey Klimov
2009-03-05 11:34     ` Sakari Ailus
2009-03-07 15:25       ` Alexey Klimov
2009-03-03 13:09 ` [RFC 0/9] OMAP3 ISP and camera drivers Sakari Ailus
2009-03-04 15:28 ` Hiremath, Vaibhav
2009-03-04 15:38   ` Sakari Ailus
2009-03-05  0:10     ` DongSoo(Nathaniel) Kim
2009-03-05  3:53       ` Hiremath, Vaibhav
2009-03-05  4:54         ` DongSoo(Nathaniel) Kim
2009-03-05  4:54           ` DongSoo(Nathaniel) Kim
2009-03-05  7:30         ` Sakari Ailus
2009-03-05 14:26         ` [PATCH] omap34xxcam: Don't use dev_err before we have a video device Sakari Ailus
2009-03-05  5:00 ` [RFC 0/9] OMAP3 ISP and camera drivers DongSoo(Nathaniel) Kim
2009-03-05  5:00   ` DongSoo(Nathaniel) Kim

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=49AFDD0B.80804@maxwell.research.nokia.com \
    --to=sakari.ailus@maxwell.research.nokia.com \
    --cc=dongsoo.kim@gmail.com \
    --cc=klimov.linux@gmail.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=saaguirre@ti.com \
    --cc=tuukka.o.toivonen@nokia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.