public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthias Schwarzott <zzam@gentoo.org>
To: Antti Palosaari <crope@iki.fi>, linux-media@vger.kernel.org
Subject: Re: [PATCH REVIEW 03/18] Montage M88DS3103 DVB-S/S2 demodulator driver
Date: Mon, 09 Dec 2013 06:58:18 +0100	[thread overview]
Message-ID: <52A55BFA.2060402@gentoo.org> (raw)
In-Reply-To: <1386541895-8634-4-git-send-email-crope@iki.fi>

Hi Antti,
I have a small suggestion, see below.

On 08.12.2013 23:31, Antti Palosaari wrote:
> diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c
> new file mode 100644
> index 0000000..91b3729
> --- /dev/null
> +++ b/drivers/media/dvb-frontends/m88ds3103.c
> @@ -0,0 +1,1293 @@
> +/*
> + * Montage M88DS3103 demodulator driver
> + *
> + * Copyright (C) 2013 Antti Palosaari <crope@iki.fi>
> + *
> + *    This program is free software; you can redistribute it and/or modify
> + *    it under the terms of the GNU General Public License as published by
> + *    the Free Software Foundation; either version 2 of the License, or
> + *    (at your option) any later version.
> + *
> + *    This program is distributed in the hope that it will be useful,
> + *    but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *    GNU General Public License for more details.
> + *
> + *    You should have received a copy of the GNU General Public License along
> + *    with this program; if not, write to the Free Software Foundation, Inc.,
> + *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> + */
> +
> +#include "m88ds3103_priv.h"
> +
> +static struct dvb_frontend_ops m88ds3103_ops;
> +
> +/* write multiple registers */
> +static int m88ds3103_wr_regs(struct m88ds3103_priv *priv,
> +		u8 reg, const u8 *val, int len)
> +{
> +	int ret;
> +	u8 buf[1 + len];

Looking at the recent patches for variable length arrays, I think this
should be converted to fixed size.

> +	struct i2c_msg msg[1] = {
> +		{
> +			.addr = priv->cfg->i2c_addr,
> +			.flags = 0,
> +			.len = sizeof(buf),
> +			.buf = buf,
> +		}
> +	};
> +
> +	buf[0] = reg;
> +	memcpy(&buf[1], val, len);
> +
> +	mutex_lock(&priv->i2c_mutex);
> +	ret = i2c_transfer(priv->i2c, msg, 1);
> +	mutex_unlock(&priv->i2c_mutex);
> +	if (ret == 1) {
> +		ret = 0;
> +	} else {
> +		dev_warn(&priv->i2c->dev,
> +				"%s: i2c wr failed=%d reg=%02x len=%d\n",
> +				KBUILD_MODNAME, ret, reg, len);
> +		ret = -EREMOTEIO;
> +	}
> +
> +	return ret;
> +}
> +
> +/* read multiple registers */
> +static int m88ds3103_rd_regs(struct m88ds3103_priv *priv,
> +		u8 reg, u8 *val, int len)
> +{
> +	int ret;
> +	u8 buf[len];

Same as above.

> +	struct i2c_msg msg[2] = {
> +		{
> +			.addr = priv->cfg->i2c_addr,
> +			.flags = 0,
> +			.len = 1,
> +			.buf = &reg,
> +		}, {
> +			.addr = priv->cfg->i2c_addr,
> +			.flags = I2C_M_RD,
> +			.len = sizeof(buf),
> +			.buf = buf,
> +		}
> +	};
> +
> +	mutex_lock(&priv->i2c_mutex);
> +	ret = i2c_transfer(priv->i2c, msg, 2);
> +	mutex_unlock(&priv->i2c_mutex);
> +	if (ret == 2) {
> +		memcpy(val, buf, len);
> +		ret = 0;
> +	} else {
> +		dev_warn(&priv->i2c->dev,
> +				"%s: i2c rd failed=%d reg=%02x len=%d\n",
> +				KBUILD_MODNAME, ret, reg, len);
> +		ret = -EREMOTEIO;
> +	}
> +
> +	return ret;
> +}
> +

Regards
Matthias



  reply	other threads:[~2013-12-09  5:58 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-08 22:31 [PATCH REVIEW 00/18] M88DS3103 / M88TS2022 / PCTV 461e Antti Palosaari
2013-12-08 22:31 ` [PATCH REVIEW 01/18] em28xx: add support for Empia EM28178 Antti Palosaari
2013-12-08 22:31 ` [PATCH REVIEW 02/18] a8293: add small sleep in order to settle LNB voltage Antti Palosaari
2013-12-08 22:31 ` [PATCH REVIEW 03/18] Montage M88DS3103 DVB-S/S2 demodulator driver Antti Palosaari
2013-12-09  5:58   ` Matthias Schwarzott [this message]
2013-12-18 12:35   ` Mauro Carvalho Chehab
2013-12-18 14:40     ` Antti Palosaari
2013-12-08 22:31 ` [PATCH REVIEW 04/18] Montage M88TS2022 silicon tuner driver Antti Palosaari
2013-12-08 22:31 ` [PATCH REVIEW 05/18] em28xx: add support for PCTV DVB-S2 Stick (461e) [2013:0258] Antti Palosaari
2013-12-08 22:31 ` [PATCH REVIEW 06/18] MAINTAINERS: add M88DS3103 Antti Palosaari
2013-12-08 22:31 ` [PATCH REVIEW 07/18] MAINTAINERS: add M88TS2022 Antti Palosaari
2013-12-08 22:31 ` [PATCH REVIEW 08/18] m88ts2022: do not use dynamic stack allocation Antti Palosaari
2013-12-08 22:31 ` [PATCH REVIEW 09/18] m88ds3103: " Antti Palosaari
2013-12-08 22:31 ` [PATCH REVIEW 10/18] m88ds3103: use I2C mux for tuner I2C adapter Antti Palosaari
2013-12-08 22:31 ` [PATCH REVIEW 11/18] m88ds3103: use kernel macro to round division Antti Palosaari
2013-12-08 22:31 ` [PATCH REVIEW 12/18] m88ds3103: fix TS mode config Antti Palosaari
2013-12-08 22:31 ` [PATCH REVIEW 13/18] m88ts2022: reimplement synthesizer calculations Antti Palosaari
2013-12-08 22:31 ` [PATCH REVIEW 14/18] m88ds3103: remove unneeded AGC from inittab Antti Palosaari
2013-12-08 22:31 ` [PATCH REVIEW 15/18] m88ds3103: add default value for reg 56 Antti Palosaari
2013-12-08 22:31 ` [PATCH REVIEW 16/18] m88ds3103: I/O optimize inittab write Antti Palosaari
2013-12-08 22:31 ` [PATCH REVIEW 17/18] m88ts2022: convert to Kernel I2C driver model Antti Palosaari
2013-12-08 22:31 ` [PATCH REVIEW 18/18] m88ds3103: fix possible i2c deadlock Antti Palosaari

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=52A55BFA.2060402@gentoo.org \
    --to=zzam@gentoo.org \
    --cc=crope@iki.fi \
    --cc=linux-media@vger.kernel.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