Commit 1676587b authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'fixes-for-3.13a' of...

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

Jonathan writes:

First round of fixes for IIO in the 3.13 cycle.

The usual mixed bag of fixes.

* 3 cases where kconfig dependencies were missing.  We need to keep a closer
  eye on this in new drivers.

* hid_sensors was abusing the iio_dev->trigger pointer.  We had a round
  of clearing this out some time ago but this driver clearly slipped through.

* A misuse of the IIO_ST macro, in mcp3422, which we should really make a
  concertive effort to finish removing.

* Avoid a double free introduced by recent buffer reference counting in the
  one driver that (quite reasonably!) does things differently (am335x)

* A missing mutex_unlock in kxsd9 that means that driver has been non
  functional for some time and no one noticed (including me who for once
  actually has one of the supported devices).

* An incorrect assumption about the parameters of sign_extend32 in mcp3422.

So nothing controversial.  The only substantial patch is the hid_sensors
one and that is actually just adding a new pointer to the devices private
state then moving the code over to it.
parents 5fa9576a 0ee005c7
...@@ -350,7 +350,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev) ...@@ -350,7 +350,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
error_iio_unreg: error_iio_unreg:
iio_device_unregister(indio_dev); iio_device_unregister(indio_dev);
error_remove_trigger: error_remove_trigger:
hid_sensor_remove_trigger(indio_dev); hid_sensor_remove_trigger(&accel_state->common_attributes);
error_unreg_buffer_funcs: error_unreg_buffer_funcs:
iio_triggered_buffer_cleanup(indio_dev); iio_triggered_buffer_cleanup(indio_dev);
error_free_dev_mem: error_free_dev_mem:
...@@ -363,10 +363,11 @@ static int hid_accel_3d_remove(struct platform_device *pdev) ...@@ -363,10 +363,11 @@ static int hid_accel_3d_remove(struct platform_device *pdev)
{ {
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
struct iio_dev *indio_dev = platform_get_drvdata(pdev); struct iio_dev *indio_dev = platform_get_drvdata(pdev);
struct accel_3d_state *accel_state = iio_priv(indio_dev);
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ACCEL_3D); sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ACCEL_3D);
iio_device_unregister(indio_dev); iio_device_unregister(indio_dev);
hid_sensor_remove_trigger(indio_dev); hid_sensor_remove_trigger(&accel_state->common_attributes);
iio_triggered_buffer_cleanup(indio_dev); iio_triggered_buffer_cleanup(indio_dev);
kfree(indio_dev->channels); kfree(indio_dev->channels);
......
...@@ -112,9 +112,10 @@ static int kxsd9_read(struct iio_dev *indio_dev, u8 address) ...@@ -112,9 +112,10 @@ static int kxsd9_read(struct iio_dev *indio_dev, u8 address)
mutex_lock(&st->buf_lock); mutex_lock(&st->buf_lock);
st->tx[0] = KXSD9_READ(address); st->tx[0] = KXSD9_READ(address);
ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers)); ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
if (ret) if (!ret)
return ret; ret = (((u16)(st->rx[0])) << 8) | (st->rx[1] & 0xF0);
return (((u16)(st->rx[0])) << 8) | (st->rx[1] & 0xF0); mutex_unlock(&st->buf_lock);
return ret;
} }
static IIO_CONST_ATTR(accel_scale_available, static IIO_CONST_ATTR(accel_scale_available,
......
...@@ -1047,6 +1047,7 @@ static int at91_adc_probe(struct platform_device *pdev) ...@@ -1047,6 +1047,7 @@ static int at91_adc_probe(struct platform_device *pdev)
} else { } else {
if (!st->caps->has_tsmr) { if (!st->caps->has_tsmr) {
dev_err(&pdev->dev, "We don't support non-TSMR adc\n"); dev_err(&pdev->dev, "We don't support non-TSMR adc\n");
ret = -ENODEV;
goto error_disable_adc_clk; goto error_disable_adc_clk;
} }
......
...@@ -88,10 +88,10 @@ static const int mcp3422_sample_rates[4] = { ...@@ -88,10 +88,10 @@ static const int mcp3422_sample_rates[4] = {
/* sample rates to sign extension table */ /* sample rates to sign extension table */
static const int mcp3422_sign_extend[4] = { static const int mcp3422_sign_extend[4] = {
[MCP3422_SRATE_240] = 12, [MCP3422_SRATE_240] = 11,
[MCP3422_SRATE_60] = 14, [MCP3422_SRATE_60] = 13,
[MCP3422_SRATE_15] = 16, [MCP3422_SRATE_15] = 15,
[MCP3422_SRATE_3] = 18 }; [MCP3422_SRATE_3] = 17 };
/* Client data (each client gets its own) */ /* Client data (each client gets its own) */
struct mcp3422 { struct mcp3422 {
......
...@@ -229,12 +229,15 @@ static int tiadc_iio_buffered_hardware_setup(struct iio_dev *indio_dev, ...@@ -229,12 +229,15 @@ static int tiadc_iio_buffered_hardware_setup(struct iio_dev *indio_dev,
unsigned long flags, unsigned long flags,
const struct iio_buffer_setup_ops *setup_ops) const struct iio_buffer_setup_ops *setup_ops)
{ {
struct iio_buffer *buffer;
int ret; int ret;
indio_dev->buffer = iio_kfifo_allocate(indio_dev); buffer = iio_kfifo_allocate(indio_dev);
if (!indio_dev->buffer) if (!buffer)
return -ENOMEM; return -ENOMEM;
iio_device_attach_buffer(indio_dev, buffer);
ret = request_threaded_irq(irq, pollfunc_th, pollfunc_bh, ret = request_threaded_irq(irq, pollfunc_th, pollfunc_bh,
flags, indio_dev->name, indio_dev); flags, indio_dev->name, indio_dev);
if (ret) if (ret)
......
...@@ -55,11 +55,10 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, ...@@ -55,11 +55,10 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
return 0; return 0;
} }
void hid_sensor_remove_trigger(struct iio_dev *indio_dev) void hid_sensor_remove_trigger(struct hid_sensor_common *attrb)
{ {
iio_trigger_unregister(indio_dev->trig); iio_trigger_unregister(attrb->trigger);
iio_trigger_free(indio_dev->trig); iio_trigger_free(attrb->trigger);
indio_dev->trig = NULL;
} }
EXPORT_SYMBOL(hid_sensor_remove_trigger); EXPORT_SYMBOL(hid_sensor_remove_trigger);
...@@ -90,7 +89,7 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name, ...@@ -90,7 +89,7 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
dev_err(&indio_dev->dev, "Trigger Register Failed\n"); dev_err(&indio_dev->dev, "Trigger Register Failed\n");
goto error_free_trig; goto error_free_trig;
} }
indio_dev->trig = trig; indio_dev->trig = attrb->trigger = trig;
return ret; return ret;
......
...@@ -21,6 +21,6 @@ ...@@ -21,6 +21,6 @@
int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name, int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
struct hid_sensor_common *attrb); struct hid_sensor_common *attrb);
void hid_sensor_remove_trigger(struct iio_dev *indio_dev); void hid_sensor_remove_trigger(struct hid_sensor_common *attrb);
#endif #endif
...@@ -348,7 +348,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) ...@@ -348,7 +348,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
error_iio_unreg: error_iio_unreg:
iio_device_unregister(indio_dev); iio_device_unregister(indio_dev);
error_remove_trigger: error_remove_trigger:
hid_sensor_remove_trigger(indio_dev); hid_sensor_remove_trigger(&gyro_state->common_attributes);
error_unreg_buffer_funcs: error_unreg_buffer_funcs:
iio_triggered_buffer_cleanup(indio_dev); iio_triggered_buffer_cleanup(indio_dev);
error_free_dev_mem: error_free_dev_mem:
...@@ -361,10 +361,11 @@ static int hid_gyro_3d_remove(struct platform_device *pdev) ...@@ -361,10 +361,11 @@ static int hid_gyro_3d_remove(struct platform_device *pdev)
{ {
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
struct iio_dev *indio_dev = platform_get_drvdata(pdev); struct iio_dev *indio_dev = platform_get_drvdata(pdev);
struct gyro_3d_state *gyro_state = iio_priv(indio_dev);
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_GYRO_3D); sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_GYRO_3D);
iio_device_unregister(indio_dev); iio_device_unregister(indio_dev);
hid_sensor_remove_trigger(indio_dev); hid_sensor_remove_trigger(&gyro_state->common_attributes);
iio_triggered_buffer_cleanup(indio_dev); iio_triggered_buffer_cleanup(indio_dev);
kfree(indio_dev->channels); kfree(indio_dev->channels);
......
...@@ -81,6 +81,8 @@ config SENSORS_LM3533 ...@@ -81,6 +81,8 @@ config SENSORS_LM3533
config TCS3472 config TCS3472
tristate "TAOS TCS3472 color light-to-digital converter" tristate "TAOS TCS3472 color light-to-digital converter"
depends on I2C depends on I2C
select IIO_BUFFER
select IIO_TRIGGERED_BUFFER
help help
If you say yes here you get support for the TAOS TCS3472 If you say yes here you get support for the TAOS TCS3472
family of color light-to-digital converters with IR filter. family of color light-to-digital converters with IR filter.
......
...@@ -314,7 +314,7 @@ static int hid_als_probe(struct platform_device *pdev) ...@@ -314,7 +314,7 @@ static int hid_als_probe(struct platform_device *pdev)
error_iio_unreg: error_iio_unreg:
iio_device_unregister(indio_dev); iio_device_unregister(indio_dev);
error_remove_trigger: error_remove_trigger:
hid_sensor_remove_trigger(indio_dev); hid_sensor_remove_trigger(&als_state->common_attributes);
error_unreg_buffer_funcs: error_unreg_buffer_funcs:
iio_triggered_buffer_cleanup(indio_dev); iio_triggered_buffer_cleanup(indio_dev);
error_free_dev_mem: error_free_dev_mem:
...@@ -327,10 +327,11 @@ static int hid_als_remove(struct platform_device *pdev) ...@@ -327,10 +327,11 @@ static int hid_als_remove(struct platform_device *pdev)
{ {
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
struct iio_dev *indio_dev = platform_get_drvdata(pdev); struct iio_dev *indio_dev = platform_get_drvdata(pdev);
struct als_state *als_state = iio_priv(indio_dev);
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ALS); sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ALS);
iio_device_unregister(indio_dev); iio_device_unregister(indio_dev);
hid_sensor_remove_trigger(indio_dev); hid_sensor_remove_trigger(&als_state->common_attributes);
iio_triggered_buffer_cleanup(indio_dev); iio_triggered_buffer_cleanup(indio_dev);
kfree(indio_dev->channels); kfree(indio_dev->channels);
......
...@@ -19,6 +19,8 @@ config AK8975 ...@@ -19,6 +19,8 @@ config AK8975
config MAG3110 config MAG3110
tristate "Freescale MAG3110 3-Axis Magnetometer" tristate "Freescale MAG3110 3-Axis Magnetometer"
depends on I2C depends on I2C
select IIO_BUFFER
select IIO_TRIGGERED_BUFFER
help help
Say yes here to build support for the Freescale MAG3110 3-Axis Say yes here to build support for the Freescale MAG3110 3-Axis
magnetometer. magnetometer.
......
...@@ -351,7 +351,7 @@ static int hid_magn_3d_probe(struct platform_device *pdev) ...@@ -351,7 +351,7 @@ static int hid_magn_3d_probe(struct platform_device *pdev)
error_iio_unreg: error_iio_unreg:
iio_device_unregister(indio_dev); iio_device_unregister(indio_dev);
error_remove_trigger: error_remove_trigger:
hid_sensor_remove_trigger(indio_dev); hid_sensor_remove_trigger(&magn_state->common_attributes);
error_unreg_buffer_funcs: error_unreg_buffer_funcs:
iio_triggered_buffer_cleanup(indio_dev); iio_triggered_buffer_cleanup(indio_dev);
error_free_dev_mem: error_free_dev_mem:
...@@ -364,10 +364,11 @@ static int hid_magn_3d_remove(struct platform_device *pdev) ...@@ -364,10 +364,11 @@ static int hid_magn_3d_remove(struct platform_device *pdev)
{ {
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
struct iio_dev *indio_dev = platform_get_drvdata(pdev); struct iio_dev *indio_dev = platform_get_drvdata(pdev);
struct magn_3d_state *magn_state = iio_priv(indio_dev);
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_COMPASS_3D); sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_COMPASS_3D);
iio_device_unregister(indio_dev); iio_device_unregister(indio_dev);
hid_sensor_remove_trigger(indio_dev); hid_sensor_remove_trigger(&magn_state->common_attributes);
iio_triggered_buffer_cleanup(indio_dev); iio_triggered_buffer_cleanup(indio_dev);
kfree(indio_dev->channels); kfree(indio_dev->channels);
......
...@@ -250,7 +250,12 @@ static irqreturn_t mag3110_trigger_handler(int irq, void *p) ...@@ -250,7 +250,12 @@ static irqreturn_t mag3110_trigger_handler(int irq, void *p)
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \
BIT(IIO_CHAN_INFO_SCALE), \ BIT(IIO_CHAN_INFO_SCALE), \
.scan_index = idx, \ .scan_index = idx, \
.scan_type = IIO_ST('s', 16, 16, IIO_BE), \ .scan_type = { \
.sign = 's', \
.realbits = 16, \
.storagebits = 16, \
.endianness = IIO_BE, \
}, \
} }
static const struct iio_chan_spec mag3110_channels[] = { static const struct iio_chan_spec mag3110_channels[] = {
......
...@@ -6,6 +6,8 @@ menu "Magnetometer sensors" ...@@ -6,6 +6,8 @@ menu "Magnetometer sensors"
config SENSORS_HMC5843 config SENSORS_HMC5843
tristate "Honeywell HMC5843/5883/5883L 3-Axis Magnetometer" tristate "Honeywell HMC5843/5883/5883L 3-Axis Magnetometer"
depends on I2C depends on I2C
select IIO_BUFFER
select IIO_TRIGGERED_BUFFER
help help
Say Y here to add support for the Honeywell HMC5843, HMC5883 and Say Y here to add support for the Honeywell HMC5843, HMC5883 and
HMC5883L 3-Axis Magnetometer (digital compass). HMC5883L 3-Axis Magnetometer (digital compass).
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include <linux/hid.h> #include <linux/hid.h>
#include <linux/hid-sensor-ids.h> #include <linux/hid-sensor-ids.h>
#include <linux/iio/iio.h>
#include <linux/iio/trigger.h>
/** /**
* struct hid_sensor_hub_attribute_info - Attribute info * struct hid_sensor_hub_attribute_info - Attribute info
...@@ -184,6 +186,7 @@ struct hid_sensor_common { ...@@ -184,6 +186,7 @@ struct hid_sensor_common {
struct platform_device *pdev; struct platform_device *pdev;
unsigned usage_id; unsigned usage_id;
bool data_ready; bool data_ready;
struct iio_trigger *trigger;
struct hid_sensor_hub_attribute_info poll; struct hid_sensor_hub_attribute_info poll;
struct hid_sensor_hub_attribute_info report_state; struct hid_sensor_hub_attribute_info report_state;
struct hid_sensor_hub_attribute_info power_state; struct hid_sensor_hub_attribute_info power_state;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment