diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-07 13:50:48 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-07 13:50:48 -0400 |
commit | 630aac5ab6d6708c2cf715ddb5a77928e0aacb04 (patch) | |
tree | 164731f7e91aedfb0eb46d56ba9497a6e109067a | |
parent | 3f8f0cf2eddb558e5ccf9b155e758f4b950d8697 (diff) | |
parent | 2b86c4a84377b74a6ec0ec9463feb0803bcb1066 (diff) |
Merge tag 'staging-4.6-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull IIO driver fixes from Grek KH:
"It's really just IIO drivers here, some small fixes that resolve some
'crash on boot' errors that have shown up in the -rc series, and other
bugfixes that are required.
All have been in linux-next with no reported problems"
* tag 'staging-4.6-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
iio: imu: mpu6050: Fix name/chip_id when using ACPI
iio: imu: mpu6050: fix possible NULL dereferences
iio:adc:at91-sama5d2: Repair crash on module removal
iio: ak8975: fix maybe-uninitialized warning
iio: ak8975: Fix NULL pointer exception on early interrupt
-rw-r--r-- | drivers/iio/adc/at91-sama5d2_adc.c | 2 | ||||
-rw-r--r-- | drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 30 | ||||
-rw-r--r-- | drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 3 | ||||
-rw-r--r-- | drivers/iio/magnetometer/ak8975.c | 6 |
4 files changed, 34 insertions, 7 deletions
diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index dbee13ad33a3..2e154cb51685 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c | |||
@@ -451,6 +451,8 @@ static int at91_adc_probe(struct platform_device *pdev) | |||
451 | if (ret) | 451 | if (ret) |
452 | goto vref_disable; | 452 | goto vref_disable; |
453 | 453 | ||
454 | platform_set_drvdata(pdev, indio_dev); | ||
455 | |||
454 | ret = iio_device_register(indio_dev); | 456 | ret = iio_device_register(indio_dev); |
455 | if (ret < 0) | 457 | if (ret < 0) |
456 | goto per_clk_disable_unprepare; | 458 | goto per_clk_disable_unprepare; |
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c index f581256d9d4c..5ee4e0dc093e 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | |||
@@ -104,6 +104,19 @@ static int inv_mpu6050_deselect_bypass(struct i2c_adapter *adap, | |||
104 | return 0; | 104 | return 0; |
105 | } | 105 | } |
106 | 106 | ||
107 | static const char *inv_mpu_match_acpi_device(struct device *dev, int *chip_id) | ||
108 | { | ||
109 | const struct acpi_device_id *id; | ||
110 | |||
111 | id = acpi_match_device(dev->driver->acpi_match_table, dev); | ||
112 | if (!id) | ||
113 | return NULL; | ||
114 | |||
115 | *chip_id = (int)id->driver_data; | ||
116 | |||
117 | return dev_name(dev); | ||
118 | } | ||
119 | |||
107 | /** | 120 | /** |
108 | * inv_mpu_probe() - probe function. | 121 | * inv_mpu_probe() - probe function. |
109 | * @client: i2c client. | 122 | * @client: i2c client. |
@@ -115,14 +128,25 @@ static int inv_mpu_probe(struct i2c_client *client, | |||
115 | const struct i2c_device_id *id) | 128 | const struct i2c_device_id *id) |
116 | { | 129 | { |
117 | struct inv_mpu6050_state *st; | 130 | struct inv_mpu6050_state *st; |
118 | int result; | 131 | int result, chip_type; |
119 | const char *name = id ? id->name : NULL; | ||
120 | struct regmap *regmap; | 132 | struct regmap *regmap; |
133 | const char *name; | ||
121 | 134 | ||
122 | if (!i2c_check_functionality(client->adapter, | 135 | if (!i2c_check_functionality(client->adapter, |
123 | I2C_FUNC_SMBUS_I2C_BLOCK)) | 136 | I2C_FUNC_SMBUS_I2C_BLOCK)) |
124 | return -EOPNOTSUPP; | 137 | return -EOPNOTSUPP; |
125 | 138 | ||
139 | if (id) { | ||
140 | chip_type = (int)id->driver_data; | ||
141 | name = id->name; | ||
142 | } else if (ACPI_HANDLE(&client->dev)) { | ||
143 | name = inv_mpu_match_acpi_device(&client->dev, &chip_type); | ||
144 | if (!name) | ||
145 | return -ENODEV; | ||
146 | } else { | ||
147 | return -ENOSYS; | ||
148 | } | ||
149 | |||
126 | regmap = devm_regmap_init_i2c(client, &inv_mpu_regmap_config); | 150 | regmap = devm_regmap_init_i2c(client, &inv_mpu_regmap_config); |
127 | if (IS_ERR(regmap)) { | 151 | if (IS_ERR(regmap)) { |
128 | dev_err(&client->dev, "Failed to register i2c regmap %d\n", | 152 | dev_err(&client->dev, "Failed to register i2c regmap %d\n", |
@@ -131,7 +155,7 @@ static int inv_mpu_probe(struct i2c_client *client, | |||
131 | } | 155 | } |
132 | 156 | ||
133 | result = inv_mpu_core_probe(regmap, client->irq, name, | 157 | result = inv_mpu_core_probe(regmap, client->irq, name, |
134 | NULL, id->driver_data); | 158 | NULL, chip_type); |
135 | if (result < 0) | 159 | if (result < 0) |
136 | return result; | 160 | return result; |
137 | 161 | ||
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c index dea6c4361de0..7bcb8d839f05 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | |||
@@ -46,6 +46,7 @@ static int inv_mpu_probe(struct spi_device *spi) | |||
46 | struct regmap *regmap; | 46 | struct regmap *regmap; |
47 | const struct spi_device_id *id = spi_get_device_id(spi); | 47 | const struct spi_device_id *id = spi_get_device_id(spi); |
48 | const char *name = id ? id->name : NULL; | 48 | const char *name = id ? id->name : NULL; |
49 | const int chip_type = id ? id->driver_data : 0; | ||
49 | 50 | ||
50 | regmap = devm_regmap_init_spi(spi, &inv_mpu_regmap_config); | 51 | regmap = devm_regmap_init_spi(spi, &inv_mpu_regmap_config); |
51 | if (IS_ERR(regmap)) { | 52 | if (IS_ERR(regmap)) { |
@@ -55,7 +56,7 @@ static int inv_mpu_probe(struct spi_device *spi) | |||
55 | } | 56 | } |
56 | 57 | ||
57 | return inv_mpu_core_probe(regmap, spi->irq, name, | 58 | return inv_mpu_core_probe(regmap, spi->irq, name, |
58 | inv_mpu_i2c_disable, id->driver_data); | 59 | inv_mpu_i2c_disable, chip_type); |
59 | } | 60 | } |
60 | 61 | ||
61 | static int inv_mpu_remove(struct spi_device *spi) | 62 | static int inv_mpu_remove(struct spi_device *spi) |
diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index 9c5c9ef3f1da..0e931a9a1669 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c | |||
@@ -462,6 +462,8 @@ static int ak8975_setup_irq(struct ak8975_data *data) | |||
462 | int rc; | 462 | int rc; |
463 | int irq; | 463 | int irq; |
464 | 464 | ||
465 | init_waitqueue_head(&data->data_ready_queue); | ||
466 | clear_bit(0, &data->flags); | ||
465 | if (client->irq) | 467 | if (client->irq) |
466 | irq = client->irq; | 468 | irq = client->irq; |
467 | else | 469 | else |
@@ -477,8 +479,6 @@ static int ak8975_setup_irq(struct ak8975_data *data) | |||
477 | return rc; | 479 | return rc; |
478 | } | 480 | } |
479 | 481 | ||
480 | init_waitqueue_head(&data->data_ready_queue); | ||
481 | clear_bit(0, &data->flags); | ||
482 | data->eoc_irq = irq; | 482 | data->eoc_irq = irq; |
483 | 483 | ||
484 | return rc; | 484 | return rc; |
@@ -732,7 +732,7 @@ static int ak8975_probe(struct i2c_client *client, | |||
732 | int eoc_gpio; | 732 | int eoc_gpio; |
733 | int err; | 733 | int err; |
734 | const char *name = NULL; | 734 | const char *name = NULL; |
735 | enum asahi_compass_chipset chipset; | 735 | enum asahi_compass_chipset chipset = AK_MAX_TYPE; |
736 | 736 | ||
737 | /* Grab and set up the supplied GPIO. */ | 737 | /* Grab and set up the supplied GPIO. */ |
738 | if (client->dev.platform_data) | 738 | if (client->dev.platform_data) |