linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org,
	Mauro Carvalho Chehab <mchehab@redhat.com>,
	Scott Jiang <scott.jiang.linux@gmail.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	Andy Walls <awalls@md.metrocast.net>,
	Prabhakar Lad <prabhakar.csengg@gmail.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Tomasz Stanislawski <t.stanislaws@samsung.com>,
	Alexey Klimov <klimov.linux@gmail.com>,
	Hans de Goede <hdegoede@redhat.com>,
	Brian Johnson <brijohn@gmail.com>, Mike Isely <isely@pobox.com>,
	Ezequiel Garcia <elezegarcia@gmail.com>,
	Huang Shijie <shijie8@gmail.com>,
	Ismael Luceno <ismael.luceno@corp.bluecherry.net>,
	Takashi Iwai <tiwai@suse.de>,
	Ondrej Zary <linux@rainbow-software.org>,
	Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [REVIEW PATCH 4/5] v4l2: add const to argument of write-only s_register ioctl.
Date: Fri, 15 Mar 2013 13:22:53 +0100	[thread overview]
Message-ID: <14821475.BMCjNXVHSd@avalon> (raw)
In-Reply-To: <60593e2e438a51d9ba5be2179f56a0858df458db.1363342714.git.hans.verkuil@cisco.com>

Hi Hans,

Thanks for the patch.

On Friday 15 March 2013 11:27:24 Hans Verkuil wrote:
> From: Hans Verkuil <hans.verkuil@cisco.com>
> 
> This ioctl is defined as IOW, so pass the argument as const.
> 
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>

[snip]

> diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c
> b/drivers/media/pci/ivtv/ivtv-ioctl.c index 080f179..15e08aa 100644
> --- a/drivers/media/pci/ivtv/ivtv-ioctl.c
> +++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
> @@ -711,49 +711,50 @@ static int ivtv_g_chip_ident(struct file *file, void
> *fh, struct v4l2_dbg_chip_i }
> 
>  #ifdef CONFIG_VIDEO_ADV_DEBUG
> -static int ivtv_itvc(struct ivtv *itv, unsigned int cmd, void *arg)
> +static volatile u8 __iomem *ivtv_itvc_start(struct ivtv *itv,
> +		const struct v4l2_dbg_register *regs)

As you use the proper __iomem accessors I don't think you need a volatile.

>  {
> -	struct v4l2_dbg_register *regs = arg;
> -	volatile u8 __iomem *reg_start;
> -
> -	if (!capable(CAP_SYS_ADMIN))
> -		return -EPERM;
>  	if (regs->reg >= IVTV_REG_OFFSET && regs->reg < IVTV_REG_OFFSET +
> IVTV_REG_SIZE) -		reg_start = itv->reg_mem - IVTV_REG_OFFSET;
> -	else if (itv->has_cx23415 && regs->reg >= IVTV_DECODER_OFFSET &&
> +		return itv->reg_mem - IVTV_REG_OFFSET;
> +	if (itv->has_cx23415 && regs->reg >= IVTV_DECODER_OFFSET &&
>  			regs->reg < IVTV_DECODER_OFFSET + IVTV_DECODER_SIZE)
> -		reg_start = itv->dec_mem - IVTV_DECODER_OFFSET;
> -	else if (regs->reg < IVTV_ENCODER_SIZE)
> -		reg_start = itv->enc_mem;
> -	else
> -		return -EINVAL;
> -
> -	regs->size = 4;
> -	if (cmd == VIDIOC_DBG_G_REGISTER)
> -		regs->val = readl(regs->reg + reg_start);
> -	else
> -		writel(regs->val, regs->reg + reg_start);
> -	return 0;
> +		return itv->dec_mem - IVTV_DECODER_OFFSET;
> +	if (regs->reg < IVTV_ENCODER_SIZE)
> +		return itv->enc_mem;
> +	return NULL;
>  }
> 
>  static int ivtv_g_register(struct file *file, void *fh, struct
> v4l2_dbg_register *reg) {
>  	struct ivtv *itv = fh2id(fh)->itv;
> 
> -	if (v4l2_chip_match_host(&reg->match))
> -		return ivtv_itvc(itv, VIDIOC_DBG_G_REGISTER, reg);
> +	if (v4l2_chip_match_host(&reg->match)) {
> +		volatile u8 __iomem *reg_start = ivtv_itvc_start(itv, reg);
> +
> +		if (reg_start == NULL)
> +			return -EINVAL;
> +		reg->size = 4;
> +		reg->val = readl(reg->reg + reg_start);
> +		return 0;
> +	}
>  	/* TODO: subdev errors should not be ignored, this should become a
>  	   subdev helper function. */
>  	ivtv_call_all(itv, core, g_register, reg);
>  	return 0;
>  }
> 
> -static int ivtv_s_register(struct file *file, void *fh, struct
> v4l2_dbg_register *reg) +static int ivtv_s_register(struct file *file, void
> *fh, const struct v4l2_dbg_register *reg) {
>  	struct ivtv *itv = fh2id(fh)->itv;
> 
> -	if (v4l2_chip_match_host(&reg->match))
> -		return ivtv_itvc(itv, VIDIOC_DBG_S_REGISTER, reg);
> +	if (v4l2_chip_match_host(&reg->match)) {
> +		volatile u8 __iomem *reg_start = ivtv_itvc_start(itv, reg);
> +
> +		if (reg_start == NULL)
> +			return -EINVAL;
> +		writel(reg->val, reg->reg + reg_start);
> +		return 0;
> +	}
>  	/* TODO: subdev errors should not be ignored, this should become a
>  	   subdev helper function. */
>  	ivtv_call_all(itv, core, s_register, reg);

-- 
Regards,

Laurent Pinchart


  reply	other threads:[~2013-03-15 12:22 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-15 10:27 [REVIEW PATCH 0/5] v4l2: constify _IOW ioctls Hans Verkuil
2013-03-15 10:27 ` [REVIEW PATCH 1/5] v4l2: add const to argument of write-only s_frequency ioctl Hans Verkuil
2013-03-15 10:27   ` [REVIEW PATCH 2/5] v4l2: add const to argument of write-only s_tuner ioctl Hans Verkuil
2013-03-15 12:12     ` Laurent Pinchart
2013-03-16 12:18     ` Alexey Klimov
2013-03-15 10:27   ` [REVIEW PATCH 3/5] v4l2: pass std by value to the write-only s_std ioctl Hans Verkuil
2013-03-15 12:17     ` Laurent Pinchart
2013-03-15 13:38     ` Jonathan Corbet
2013-03-15 13:58     ` Mauro Carvalho Chehab
2013-03-15 14:14       ` Hans Verkuil
2013-03-16  6:46     ` Guennadi Liakhovetski
2013-03-16  7:26     ` Prabhakar Lad
2013-03-15 10:27   ` [REVIEW PATCH 4/5] v4l2: add const to argument of write-only s_register ioctl Hans Verkuil
2013-03-15 12:22     ` Laurent Pinchart [this message]
2013-03-16  6:50     ` Guennadi Liakhovetski
2013-03-16  7:43     ` Prabhakar Lad
2013-03-15 10:27   ` [REVIEW PATCH 5/5] v4l2-ioctl: simplify debug code Hans Verkuil
2013-03-15 12:25     ` Laurent Pinchart
2013-03-18 13:52       ` Hans Verkuil
2013-03-15 12:08   ` [REVIEW PATCH 1/5] v4l2: add const to argument of write-only s_frequency ioctl Laurent Pinchart
2013-03-15 12:18     ` Hans Verkuil

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=14821475.BMCjNXVHSd@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=awalls@md.metrocast.net \
    --cc=brijohn@gmail.com \
    --cc=corbet@lwn.net \
    --cc=elezegarcia@gmail.com \
    --cc=g.liakhovetski@gmx.de \
    --cc=hans.verkuil@cisco.com \
    --cc=hdegoede@redhat.com \
    --cc=hverkuil@xs4all.nl \
    --cc=isely@pobox.com \
    --cc=ismael.luceno@corp.bluecherry.net \
    --cc=klimov.linux@gmail.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux@rainbow-software.org \
    --cc=mchehab@redhat.com \
    --cc=prabhakar.csengg@gmail.com \
    --cc=scott.jiang.linux@gmail.com \
    --cc=shijie8@gmail.com \
    --cc=t.stanislaws@samsung.com \
    --cc=tiwai@suse.de \
    /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).