Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: gyro: mpu3050: Move iio_device_register() to correct location

iio_device_register() should be at the end of the probe function to
prevent race conditions.

Place iio_device_register() at the end of the probe function and place
iio_device_unregister() accordingly.

Fixes: 3904b28efb2c7 ("iio: gyro: Add driver for the MPU-3050 gyroscope")
Suggested-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Ethan Tidmore and committed by
Jonathan Cameron
4c057994 4216db10

+13 -8
+13 -8
drivers/iio/gyro/mpu3050-core.c
··· 1226 1226 goto err_power_down; 1227 1227 } 1228 1228 1229 - ret = iio_device_register(indio_dev); 1230 - if (ret) { 1231 - dev_err(dev, "device register failed\n"); 1232 - goto err_cleanup_buffer; 1233 - } 1234 - 1235 1229 dev_set_drvdata(dev, indio_dev); 1236 1230 1237 1231 /* Check if we have an assigned IRQ to use as trigger */ ··· 1248 1254 pm_runtime_use_autosuspend(dev); 1249 1255 pm_runtime_put(dev); 1250 1256 1257 + ret = iio_device_register(indio_dev); 1258 + if (ret) { 1259 + dev_err(dev, "device register failed\n"); 1260 + goto err_iio_device_register; 1261 + } 1262 + 1251 1263 return 0; 1252 1264 1253 - err_cleanup_buffer: 1265 + err_iio_device_register: 1266 + pm_runtime_get_sync(dev); 1267 + pm_runtime_put_noidle(dev); 1268 + pm_runtime_disable(dev); 1269 + if (irq) 1270 + free_irq(mpu3050->irq, mpu3050->trig); 1254 1271 iio_triggered_buffer_cleanup(indio_dev); 1255 1272 err_power_down: 1256 1273 mpu3050_power_down(mpu3050); ··· 1274 1269 struct iio_dev *indio_dev = dev_get_drvdata(dev); 1275 1270 struct mpu3050 *mpu3050 = iio_priv(indio_dev); 1276 1271 1272 + iio_device_unregister(indio_dev); 1277 1273 pm_runtime_get_sync(dev); 1278 1274 pm_runtime_put_noidle(dev); 1279 1275 pm_runtime_disable(dev); 1280 1276 iio_triggered_buffer_cleanup(indio_dev); 1281 1277 if (mpu3050->irq) 1282 1278 free_irq(mpu3050->irq, mpu3050->trig); 1283 - iio_device_unregister(indio_dev); 1284 1279 mpu3050_power_down(mpu3050); 1285 1280 } 1286 1281