lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20151019143050.GB18952@hard-bop>
Date:	Mon, 19 Oct 2015 17:30:50 +0300
From:	Teodora Baluta <teodora.baluta@...el.com>
To:	Lars-Peter Clausen <lars@...afoo.de>
Cc:	jic23@...nel.org, knaack.h@....de, pmeerw@...erw.net,
	daniel.baluta@...el.com, dan.carpenter@...cle.com,
	linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iio: accel: add support for Memsic MXC6255XC sensor

On Mon, Oct 19, 2015 at 12:52:50PM +0200, Lars-Peter Clausen wrote:
> On 10/16/2015 12:29 PM, Teodora Baluta wrote:
> > This patch adds a minimal implementation for the Memsic MXC6255XC
> > orientation sensing accelerometer. The supported operations are reading
> > raw acceleration values for X/Y axis that can be scaled using the
> > exposed scale.
> > 
> > Signed-off-by: Teodora Baluta <teodora.baluta@...el.com>
> 
> Looks quite good in general, a few minor things inline.

Thanks for the review. I'll send a v2 as soon as possible.

> 
> [...]
> > +/* scale value for +/- 2G measurement range */
> > +static const int mxc6255_scale = 153829;
> > +
> > +static IIO_CONST_ATTR(in_accel_scale_available, MXC6255_SCALE_AVAIL);
> 
> If there is only one scale available it does not make too much sense to have
> a scale_available attribute.
> 
> [..]
> > +static int mxc6255_read_raw(struct iio_dev *indio_dev,
> > +			    struct iio_chan_spec const *chan,
> > +			    int *val, int *val2, long mask)
> > +{
> > +	struct mxc6255_data *data = iio_priv(indio_dev);
> > +	unsigned int reg;
> > +	int axis = chan->channel2 - 1;
> 
> 1 is a bit of a magic constant here. Use IIO_MOD_X instead. Or even better
> use chan->address.
> 
> > +	int ret;
> > +
> > +	switch (mask) {
> > +	case IIO_CHAN_INFO_RAW:
> > +		ret = regmap_read(data->regmap,
> > +				  MXC6255_AXIS_TO_REG(axis), &reg);
> > +		if (ret < 0) {
> > +			dev_err(&data->client->dev,
> > +				"Error reading axis %d\n", axis);
> > +			return ret;
> > +		}
> > +
> > +		*val = sign_extend32(reg, 7);
> > +		return IIO_VAL_INT;
> > +	case IIO_CHAN_INFO_SCALE:
> > +		*val = 0;
> > +		*val2 = mxc6255_scale;
> > +		return IIO_VAL_INT_PLUS_MICRO;
> > +	default:
> > +		return -EINVAL;
> > +	}
> > +}
> [...]
> > +static int mxc6255_probe(struct i2c_client *client,
> > +			 const struct i2c_device_id *id)
> > +{
> [...]
> > +	ret = regmap_read(data->regmap, MXC6255_REG_CHIP_ID, &chip_id);
> > +	if (ret < 0) {
> > +		dev_err(&client->dev, "Error reading chip id %d\n", ret);
> > +		return ret;
> > +	}
> 
> Does it make sense to check whether chip ID matches the expected value, to
> catch mistakes where the I2C address is incorrect?
> 
> > +
> > +	dev_dbg(&client->dev, "Chip id %x\n", chip_id);
> > +
> > +	ret = devm_iio_device_register(&client->dev, indio_dev);
> > +	if (ret < 0) {
> > +		dev_err(&client->dev, "Could not register IIO device\n");
> > +		return ret;
> > +	}
> > +
> > +	return 0;
> > +}
> [...]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ