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

Merge tag 'iio-for-3.9a' of...

Merge tag 'iio-for-3.9a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan says:

	First round of IIO new stuff and cleanups for 3.9

	Here we have:
	* RTC driver for the hid-sensor hubs.  This is routed through here with
	  agreement of Jiri Kosina and Andrew Morton.
	* Some small patches doing dead code removal and fixing some comments.
	* max1363 - move to the triggered_buffer helpers (basically duplicate code
	  removal).
	* lp8788 - parent device change from the i2c device to the intermediate mfd.

	So the bulk of what we have is actually outside the IIO tree but the RTC
	driver in question is dependent on some patches that directly effect IIO so
	I am routing it through IIO with the agreement of the relevant maintainers
	(Andrew is acting as maintainer of RTC at the moment).  The majority of
	HID-sensor related code is in IIO and it now crosses 3 subsystems so it
	was going to be a bit awkward whatever route it took.
parents d1c3ed66 e07c6d17
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@
#include <linux/iio/buffer.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>
#include "../common/hid-sensors/hid-sensor-attributes.h"
#include "../common/hid-sensors/hid-sensor-trigger.h"

/*Format: HID-SENSOR-usage_id_in_hex*/
@@ -44,7 +43,7 @@ enum accel_3d_channel {

struct accel_3d_state {
	struct hid_sensor_hub_callbacks callbacks;
	struct hid_sensor_iio_common common_attributes;
	struct hid_sensor_common common_attributes;
	struct hid_sensor_hub_attribute_info accel[ACCEL_3D_CHANNEL_MAX];
	u32 accel_val[ACCEL_3D_CHANNEL_MAX];
};
+3 −3
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ static int lp8788_iio_map_register(struct iio_dev *indio_dev,

	ret = iio_map_array_register(indio_dev, map);
	if (ret) {
		dev_err(adc->lp->dev, "iio map err: %d\n", ret);
		dev_err(&indio_dev->dev, "iio map err: %d\n", ret);
		return ret;
	}

@@ -214,7 +214,7 @@ static int __devinit lp8788_adc_probe(struct platform_device *pdev)

	mutex_init(&adc->lock);

	indio_dev->dev.parent = lp->dev;
	indio_dev->dev.parent = &pdev->dev;
	indio_dev->name = pdev->name;
	indio_dev->modes = INDIO_DIRECT_MODE;
	indio_dev->info = &lp8788_adc_info;
@@ -223,7 +223,7 @@ static int __devinit lp8788_adc_probe(struct platform_device *pdev)

	ret = iio_device_register(indio_dev);
	if (ret) {
		dev_err(lp->dev, "iio dev register err: %d\n", ret);
		dev_err(&pdev->dev, "iio dev register err: %d\n", ret);
		goto err_iio_device;
	}

+12 −62
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
#include <linux/iio/driver.h>
#include <linux/iio/kfifo_buf.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>

#define MAX1363_SETUP_BYTE(a) ((a) | 0x80)

@@ -55,7 +56,7 @@
#define MAX1363_SETUP_POWER_UP_INT_REF		0x10
#define MAX1363_SETUP_POWER_DOWN_INT_REF	0x00

/* think about includeing max11600 etc - more settings */
/* think about including max11600 etc - more settings */
#define MAX1363_SETUP_EXT_CLOCK			0x08
#define MAX1363_SETUP_INT_CLOCK			0x00
#define MAX1363_SETUP_UNIPOLAR			0x00
@@ -133,7 +134,7 @@ enum max1363_modes {
 * @mode_list:		array of available scan modes
 * @default_mode:	the scan mode in which the chip starts up
 * @int_vref_mv:	the internal reference voltage
 * @num_channels:	number of channels
 * @num_modes:		number of modes
 * @bits:		accuracy of the adc in bits
 */
struct max1363_chip_info {
@@ -152,7 +153,7 @@ struct max1363_chip_info {
 * @client:		i2c_client
 * @setupbyte:		cache of current device setup byte
 * @configbyte:		cache of current device config byte
 * @chip_info:		chip model specific constants, available modes etc
 * @chip_info:		chip model specific constants, available modes, etc.
 * @current_mode:	the scan mode of this chip
 * @requestedmask:	a valid requested set of channels
 * @reg:		supply regulator
@@ -1423,7 +1424,6 @@ static int __devinit max1363_alloc_scan_masks(struct iio_dev *indio_dev)
	return 0;
}


static irqreturn_t max1363_trigger_handler(int irq, void *p)
{
	struct iio_poll_func *pf = p;
@@ -1483,48 +1483,6 @@ static const struct iio_buffer_setup_ops max1363_buffered_setup_ops = {
	.predisable = &iio_triggered_buffer_predisable,
};

static int max1363_register_buffered_funcs_and_init(struct iio_dev *indio_dev)
{
	struct max1363_state *st = iio_priv(indio_dev);
	int ret = 0;

	indio_dev->buffer = iio_kfifo_allocate(indio_dev);
	if (!indio_dev->buffer) {
		ret = -ENOMEM;
		goto error_ret;
	}
	indio_dev->pollfunc = iio_alloc_pollfunc(NULL,
						 &max1363_trigger_handler,
						 IRQF_ONESHOT,
						 indio_dev,
						 "%s_consumer%d",
						 st->client->name,
						 indio_dev->id);
	if (indio_dev->pollfunc == NULL) {
		ret = -ENOMEM;
		goto error_deallocate_sw_rb;
	}
	/* Buffer functions - here trigger setup related */
	indio_dev->setup_ops = &max1363_buffered_setup_ops;

	/* Flag that polled buffering is possible */
	indio_dev->modes |= INDIO_BUFFER_TRIGGERED;

	return 0;

error_deallocate_sw_rb:
	iio_kfifo_free(indio_dev->buffer);
error_ret:
	return ret;
}

static void max1363_buffer_cleanup(struct iio_dev *indio_dev)
{
	/* ensure that the trigger has been detached */
	iio_dealloc_pollfunc(indio_dev->pollfunc);
	iio_kfifo_free(indio_dev->buffer);
}

static int __devinit max1363_probe(struct i2c_client *client,
				   const struct i2c_device_id *id)
{
@@ -1564,7 +1522,7 @@ static int __devinit max1363_probe(struct i2c_client *client,
	if (ret)
		goto error_disable_reg;

	/* Estabilish that the iio_dev is a child of the i2c device */
	/* Establish that the iio_dev is a child of the i2c device */
	indio_dev->dev.parent = &client->dev;
	indio_dev->name = id->name;
	indio_dev->channels = st->chip_info->channels;
@@ -1577,16 +1535,11 @@ static int __devinit max1363_probe(struct i2c_client *client,
	if (ret < 0)
		goto error_free_available_scan_masks;

	ret = max1363_register_buffered_funcs_and_init(indio_dev);
	ret = iio_triggered_buffer_setup(indio_dev, NULL,
		&max1363_trigger_handler, &max1363_buffered_setup_ops);
	if (ret)
		goto error_free_available_scan_masks;

	ret = iio_buffer_register(indio_dev,
				  st->chip_info->channels,
				  st->chip_info->num_channels);
	if (ret)
		goto error_cleanup_buffer;

	if (client->irq) {
		ret = request_threaded_irq(st->client->irq,
					   NULL,
@@ -1607,9 +1560,7 @@ static int __devinit max1363_probe(struct i2c_client *client,
error_free_irq:
	free_irq(st->client->irq, indio_dev);
error_uninit_buffer:
	iio_buffer_unregister(indio_dev);
error_cleanup_buffer:
	max1363_buffer_cleanup(indio_dev);
	iio_triggered_buffer_cleanup(indio_dev);
error_free_available_scan_masks:
	kfree(indio_dev->available_scan_masks);
error_unregister_map:
@@ -1632,8 +1583,7 @@ static int __devexit max1363_remove(struct i2c_client *client)
	iio_device_unregister(indio_dev);
	if (client->irq)
		free_irq(st->client->irq, indio_dev);
	iio_buffer_unregister(indio_dev);
	max1363_buffer_cleanup(indio_dev);
	iio_triggered_buffer_cleanup(indio_dev);
	kfree(indio_dev->available_scan_masks);
	if (!IS_ERR(st->reg)) {
		regulator_disable(st->reg);
+5 −6
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@
#include <linux/hid-sensor-hub.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include "hid-sensor-attributes.h"

static int pow_10(unsigned power)
{
@@ -114,7 +113,7 @@ static u32 convert_to_vtf_format(int size, int exp, int val1, int val2)
	return value;
}

int hid_sensor_read_samp_freq_value(struct hid_sensor_iio_common *st,
int hid_sensor_read_samp_freq_value(struct hid_sensor_common *st,
				int *val1, int *val2)
{
	s32 value;
@@ -141,7 +140,7 @@ int hid_sensor_read_samp_freq_value(struct hid_sensor_iio_common *st,
}
EXPORT_SYMBOL(hid_sensor_read_samp_freq_value);

int hid_sensor_write_samp_freq_value(struct hid_sensor_iio_common *st,
int hid_sensor_write_samp_freq_value(struct hid_sensor_common *st,
				int val1, int val2)
{
	s32 value;
@@ -169,7 +168,7 @@ int hid_sensor_write_samp_freq_value(struct hid_sensor_iio_common *st,
}
EXPORT_SYMBOL(hid_sensor_write_samp_freq_value);

int hid_sensor_read_raw_hyst_value(struct hid_sensor_iio_common *st,
int hid_sensor_read_raw_hyst_value(struct hid_sensor_common *st,
				int *val1, int *val2)
{
	s32 value;
@@ -191,7 +190,7 @@ int hid_sensor_read_raw_hyst_value(struct hid_sensor_iio_common *st,
}
EXPORT_SYMBOL(hid_sensor_read_raw_hyst_value);

int hid_sensor_write_raw_hyst_value(struct hid_sensor_iio_common *st,
int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st,
					int val1, int val2)
{
	s32 value;
@@ -212,7 +211,7 @@ EXPORT_SYMBOL(hid_sensor_write_raw_hyst_value);

int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
					u32 usage_id,
					struct hid_sensor_iio_common *st)
					struct hid_sensor_common *st)
{

	sensor_hub_input_get_attribute_info(hsdev,
+0 −57
Original line number Diff line number Diff line
/*
 * HID Sensors Driver
 * Copyright (c) 2012, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope 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 St - Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */
#ifndef _HID_SENSORS_ATTRIBUTES_H
#define _HID_SENSORS_ATTRIBUTES_H

/* Common hid sensor iio structure */
struct hid_sensor_iio_common {
	struct hid_sensor_hub_device *hsdev;
	struct platform_device *pdev;
	unsigned usage_id;
	bool data_ready;
	struct hid_sensor_hub_attribute_info poll;
	struct hid_sensor_hub_attribute_info report_state;
	struct hid_sensor_hub_attribute_info power_state;
	struct hid_sensor_hub_attribute_info sensitivity;
};

/*Convert from hid unit expo to regular exponent*/
static inline int hid_sensor_convert_exponent(int unit_expo)
{
	if (unit_expo < 0x08)
		return unit_expo;
	else if (unit_expo <= 0x0f)
		return -(0x0f-unit_expo+1);
	else
		return 0;
}

int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
					u32 usage_id,
					struct hid_sensor_iio_common *st);
int hid_sensor_write_raw_hyst_value(struct hid_sensor_iio_common *st,
					int val1, int val2);
int hid_sensor_read_raw_hyst_value(struct hid_sensor_iio_common *st,
					int *val1, int *val2);
int hid_sensor_write_samp_freq_value(struct hid_sensor_iio_common *st,
					int val1, int val2);
int hid_sensor_read_samp_freq_value(struct hid_sensor_iio_common *st,
					int *val1, int *val2);

#endif
Loading