Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a491aea authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

Merge tag 'v3.6-rc1-iio-fixes' of...

Merge tag 'v3.6-rc1-iio-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus

IIO fixes for v3.6-rc1

These mostly consist of fixes from Lars-Peter Clausen that were
the first part of a large series reworking the drivers concerned.
Turns out these drivers had quite a wealth of minor bugs.

Also here are some build warning fixes for lm3533-als and
adjd_s111 (both new drives in this cycle).
Final elements are a a div factor overflow and a warning
related fix in a couple of Analog Devices drivers.

All in all nothing major, but a worthwhile bunch of short
fixes.
parents e74f7fc5 95d1c8c7
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ static int adf4350_set_freq(struct adf4350_state *st, unsigned long long freq)
{
	struct adf4350_platform_data *pdata = st->pdata;
	u64 tmp;
	u32 div_gcd, prescaler;
	u32 div_gcd, prescaler, chspc;
	u16 mdiv, r_cnt = 0;
	u8 band_sel_div;

@@ -158,14 +158,20 @@ static int adf4350_set_freq(struct adf4350_state *st, unsigned long long freq)
	if (pdata->ref_div_factor)
		r_cnt = pdata->ref_div_factor - 1;

	do  {
		r_cnt = adf4350_tune_r_cnt(st, r_cnt);
	chspc = st->chspc;

		st->r1_mod = st->fpfd / st->chspc;
		while (st->r1_mod > ADF4350_MAX_MODULUS) {
	do  {
		do {
			do {
				r_cnt = adf4350_tune_r_cnt(st, r_cnt);
			st->r1_mod = st->fpfd / st->chspc;
				st->r1_mod = st->fpfd / chspc;
				if (r_cnt > ADF4350_MAX_R_CNT) {
					/* try higher spacing values */
					chspc++;
					r_cnt = 0;
				}
			} while ((st->r1_mod > ADF4350_MAX_MODULUS) && r_cnt);
		} while (r_cnt == 0);

		tmp = freq * (u64)st->r1_mod + (st->fpfd > 1);
		do_div(tmp, st->fpfd); /* Div round closest (n + d/2)/d */
@@ -194,7 +200,7 @@ static int adf4350_set_freq(struct adf4350_state *st, unsigned long long freq)
	st->regs[ADF4350_REG0] = ADF4350_REG0_INT(st->r0_int) |
				 ADF4350_REG0_FRACT(st->r0_fract);

	st->regs[ADF4350_REG1] = ADF4350_REG1_PHASE(0) |
	st->regs[ADF4350_REG1] = ADF4350_REG1_PHASE(1) |
				 ADF4350_REG1_MOD(st->r1_mod) |
				 prescaler;

+4 −3
Original line number Diff line number Diff line
@@ -271,9 +271,10 @@ static int adjd_s311_update_scan_mode(struct iio_dev *indio_dev,
	const unsigned long *scan_mask)
{
	struct adjd_s311_data *data = iio_priv(indio_dev);
	data->buffer = krealloc(data->buffer, indio_dev->scan_bytes,
				GFP_KERNEL);
	if (!data->buffer)

	kfree(data->buffer);
	data->buffer = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
	if (data->buffer == NULL)
		return -ENOMEM;

	return 0;
+2 −2
Original line number Diff line number Diff line
@@ -404,7 +404,7 @@ static int lm3533_als_get_hysteresis(struct iio_dev *indio_dev, unsigned nr,
	return ret;
}

static int show_thresh_either_en(struct device *dev,
static ssize_t show_thresh_either_en(struct device *dev,
					struct device_attribute *attr,
					char *buf)
{
@@ -424,7 +424,7 @@ static int show_thresh_either_en(struct device *dev,
	return scnprintf(buf, PAGE_SIZE, "%u\n", enable);
}

static int store_thresh_either_en(struct device *dev,
static ssize_t store_thresh_either_en(struct device *dev,
					struct device_attribute *attr,
					const char *buf, size_t len)
{
+26 −22
Original line number Diff line number Diff line
@@ -754,7 +754,7 @@ static ssize_t ad7192_set(struct device *dev,
		else
			st->mode &= ~AD7192_MODE_ACX;

		ad7192_write_reg(st, AD7192_REG_GPOCON, 3, st->mode);
		ad7192_write_reg(st, AD7192_REG_MODE, 3, st->mode);
		break;
	default:
		ret = -EINVAL;
@@ -798,6 +798,11 @@ static const struct attribute_group ad7195_attribute_group = {
	.attrs = ad7195_attributes,
};

static unsigned int ad7192_get_temp_scale(bool unipolar)
{
	return unipolar ? 2815 * 2 : 2815;
}

static int ad7192_read_raw(struct iio_dev *indio_dev,
			   struct iio_chan_spec const *chan,
			   int *val,
@@ -824,19 +829,6 @@ static int ad7192_read_raw(struct iio_dev *indio_dev,
		*val = (smpl >> chan->scan_type.shift) &
			((1 << (chan->scan_type.realbits)) - 1);

		switch (chan->type) {
		case IIO_VOLTAGE:
			if (!unipolar)
				*val -= (1 << (chan->scan_type.realbits - 1));
			break;
		case IIO_TEMP:
			*val -= 0x800000;
			*val /= 2815; /* temp Kelvin */
			*val -= 273; /* temp Celsius */
			break;
		default:
			return -EINVAL;
		}
		return IIO_VAL_INT;

	case IIO_CHAN_INFO_SCALE:
@@ -848,11 +840,21 @@ static int ad7192_read_raw(struct iio_dev *indio_dev,
			mutex_unlock(&indio_dev->mlock);
			return IIO_VAL_INT_PLUS_NANO;
		case IIO_TEMP:
			*val =  1000;
			return IIO_VAL_INT;
			*val = 0;
			*val2 = 1000000000 / ad7192_get_temp_scale(unipolar);
			return IIO_VAL_INT_PLUS_NANO;
		default:
			return -EINVAL;
		}
	case IIO_CHAN_INFO_OFFSET:
		if (!unipolar)
			*val = -(1 << (chan->scan_type.realbits - 1));
		else
			*val = 0;
		/* Kelvin to Celsius */
		if (chan->type == IIO_TEMP)
			*val -= 273 * ad7192_get_temp_scale(unipolar);
		return IIO_VAL_INT;
	}

	return -EINVAL;
@@ -890,7 +892,7 @@ static int ad7192_write_raw(struct iio_dev *indio_dev,
				}
				ret = 0;
			}

		break;
	default:
		ret = -EINVAL;
	}
@@ -942,20 +944,22 @@ static const struct iio_info ad7195_info = {
	  .channel = _chan,						\
	  .channel2 = _chan2,						\
	  .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |			\
	  IIO_CHAN_INFO_SCALE_SHARED_BIT,				\
	  IIO_CHAN_INFO_SCALE_SHARED_BIT |				\
	  IIO_CHAN_INFO_OFFSET_SHARED_BIT,				\
	  .address = _address,						\
	  .scan_index = _si,						\
	  .scan_type =  IIO_ST('s', 24, 32, 0)}
	  .scan_type =  IIO_ST('u', 24, 32, 0)}

#define AD7192_CHAN(_chan, _address, _si)				\
	{ .type = IIO_VOLTAGE,						\
	  .indexed = 1,							\
	  .channel = _chan,						\
	  .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |			\
	  IIO_CHAN_INFO_SCALE_SHARED_BIT,				\
	  IIO_CHAN_INFO_SCALE_SHARED_BIT |				\
	  IIO_CHAN_INFO_OFFSET_SHARED_BIT,				\
	  .address = _address,						\
	  .scan_index = _si,						\
	  .scan_type =  IIO_ST('s', 24, 32, 0)}
	  .scan_type =  IIO_ST('u', 24, 32, 0)}

#define AD7192_CHAN_TEMP(_chan, _address, _si)				\
	{ .type = IIO_TEMP,						\
@@ -965,7 +969,7 @@ static const struct iio_info ad7195_info = {
	  IIO_CHAN_INFO_SCALE_SEPARATE_BIT,				\
	  .address = _address,						\
	  .scan_index = _si,						\
	  .scan_type =  IIO_ST('s', 24, 32, 0)}
	  .scan_type =  IIO_ST('u', 24, 32, 0)}

static struct iio_chan_spec ad7192_channels[] = {
	AD7192_CHAN_DIFF(1, 2, NULL, AD7192_CH_AIN1P_AIN2M, 0),
+1 −1
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p)
	struct iio_dev *indio_dev = pf->indio_dev;
	struct ad7298_state *st = iio_priv(indio_dev);
	struct iio_buffer *ring = indio_dev->buffer;
	s64 time_ns;
	s64 time_ns = 0;
	__u16 buf[16];
	int b_sent, i;

Loading