8210a2004d
As these are very late in the 5.15 cycle and non are particularly urgent, they can wait for the merge window. Key element in this set is Yang Yingliang has identified a number of issues in error paths introduced recently when we added multiple buffer support. Other fixes: * adi,ad5662 - Fix handling of i2c_master_send() return value. * adi,ad5766 - Fix a wrong dt-property name that indicated wrong units and did not mach the bindings. - Associated 'fix' of the bindings example to have a possible scale. * st,pressure-spi - Add some missing entries to the spi_device_id table to ensure auto-loading works. * ti,tsc2046 - Fix a backwards comparison leading to a false dev_warn -----BEGIN PGP SIGNATURE----- iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmFxs7kRHGppYzIzQGtl cm5lbC5vcmcACgkQVIU0mcT0FojEXhAAn8OoUwEaViRbrVuPJmWCLuhZR8/ke1HE 9WFXYjVvr6+FIyxgOxTVhoVd0LmcqzgeMg0si8CvnXvmx0mYqRyGxSgZ0oSWOfNR /RhfbL3RKyWmbp5ey3JuJxGS9Py1LXSFycsC7igjrgySqGo05kLrMpGkMr2g3d6a OKBOaoiBQPEvYmkNlFLOhtWGHNA4mICmi7UWwcfeN667SWKT3VFpBllSQwRpRXtz h/h0XhJg72x7JdJJsiBAWX9IsbBm9bXjaeXWZldDNnrZRS3VKTXzAkMTI0Wu0Rrq voEXvh74ys280aXoh5eHzN4OLdGBTJLVRjNaEAUaSMry4oWPpnkkda9pYY8dCcaR b8kPxn68PnrjbBG5et3PBo+/XAh7C0Ny2ETEqI8qlNk9adqUEl0wixuUUEljEqVE 2rB35SEJYJzl0V0Up2uZMzYhPsfw+kbZoLUPyLfL9uNW3r1l9xgQURTM74UZcSdI cV2kcGWZdIX6IKVrChhPpeXcsS9ZWljWzUGu4IFBw1h9X6jwhbWJvACj889Rf4EI +ndjCylpE4aJfoZI7JSg5i41KvEGbwE3SkrKZTMNWe6aPajhcylzeG9+jxsAYaPn +hnKbPTE99oaopu1Od/s2EUtmIontZQy74aDfbQM3HU8fHmauk8/+L9kDNlkV2b3 ZWbSw6Z2g4g= =jYCH -----END PGP SIGNATURE----- Merge tag 'iio-fixes-for-5.16a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next Jonathan writes: First set of IIO fixes for the 5.16 cycle As these are very late in the 5.15 cycle and non are particularly urgent, they can wait for the merge window. Key element in this set is Yang Yingliang has identified a number of issues in error paths introduced recently when we added multiple buffer support. Other fixes: * adi,ad5662 - Fix handling of i2c_master_send() return value. * adi,ad5766 - Fix a wrong dt-property name that indicated wrong units and did not mach the bindings. - Associated 'fix' of the bindings example to have a possible scale. * st,pressure-spi - Add some missing entries to the spi_device_id table to ensure auto-loading works. * ti,tsc2046 - Fix a backwards comparison leading to a false dev_warn * tag 'iio-fixes-for-5.16a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: buffer: Fix memory leak in iio_buffers_alloc_sysfs_and_mask() iio: adc: tsc2046: fix scan interval warning iio: core: fix double free in iio_device_unregister_sysfs() iio: core: check return value when calling dev_set_name() iio: buffer: Fix memory leak in iio_buffer_register_legacy_sysfs_groups() iio: buffer: Fix double-free in iio_buffers_alloc_sysfs_and_mask() iio: buffer: Fix memory leak in __iio_buffer_alloc_sysfs_and_mask() iio: buffer: check return value of kstrdup_const() iio: dac: ad5446: Fix ad5622_write() return value Documentation:devicetree:bindings:iio:dac: Fix val drivers: iio: dac: ad5766: Fix dt property name iio: st_pressure_spi: Add missing entries SPI to device ID table
121 lines
2.8 KiB
C
121 lines
2.8 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* STMicroelectronics pressures driver
|
|
*
|
|
* Copyright 2013 STMicroelectronics Inc.
|
|
*
|
|
* Denis Ciocca <denis.ciocca@st.com>
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/mod_devicetable.h>
|
|
#include <linux/spi/spi.h>
|
|
#include <linux/iio/iio.h>
|
|
|
|
#include <linux/iio/common/st_sensors.h>
|
|
#include <linux/iio/common/st_sensors_spi.h>
|
|
#include "st_pressure.h"
|
|
|
|
/*
|
|
* For new single-chip sensors use <device_name> as compatible string.
|
|
* For old single-chip devices keep <device_name>-press to maintain
|
|
* compatibility
|
|
*/
|
|
static const struct of_device_id st_press_of_match[] = {
|
|
{
|
|
.compatible = "st,lps001wp-press",
|
|
.data = LPS001WP_PRESS_DEV_NAME,
|
|
},
|
|
{
|
|
.compatible = "st,lps25h-press",
|
|
.data = LPS25H_PRESS_DEV_NAME,
|
|
},
|
|
{
|
|
.compatible = "st,lps331ap-press",
|
|
.data = LPS331AP_PRESS_DEV_NAME,
|
|
},
|
|
{
|
|
.compatible = "st,lps22hb-press",
|
|
.data = LPS22HB_PRESS_DEV_NAME,
|
|
},
|
|
{
|
|
.compatible = "st,lps33hw",
|
|
.data = LPS33HW_PRESS_DEV_NAME,
|
|
},
|
|
{
|
|
.compatible = "st,lps35hw",
|
|
.data = LPS35HW_PRESS_DEV_NAME,
|
|
},
|
|
{
|
|
.compatible = "st,lps22hh",
|
|
.data = LPS22HH_PRESS_DEV_NAME,
|
|
},
|
|
{},
|
|
};
|
|
MODULE_DEVICE_TABLE(of, st_press_of_match);
|
|
|
|
static int st_press_spi_probe(struct spi_device *spi)
|
|
{
|
|
const struct st_sensor_settings *settings;
|
|
struct st_sensor_data *press_data;
|
|
struct iio_dev *indio_dev;
|
|
int err;
|
|
|
|
st_sensors_dev_name_probe(&spi->dev, spi->modalias, sizeof(spi->modalias));
|
|
|
|
settings = st_press_get_settings(spi->modalias);
|
|
if (!settings) {
|
|
dev_err(&spi->dev, "device name %s not recognized.\n",
|
|
spi->modalias);
|
|
return -ENODEV;
|
|
}
|
|
|
|
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*press_data));
|
|
if (!indio_dev)
|
|
return -ENOMEM;
|
|
|
|
press_data = iio_priv(indio_dev);
|
|
press_data->sensor_settings = (struct st_sensor_settings *)settings;
|
|
|
|
err = st_sensors_spi_configure(indio_dev, spi);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
err = st_sensors_power_enable(indio_dev);
|
|
if (err)
|
|
return err;
|
|
|
|
return st_press_common_probe(indio_dev);
|
|
}
|
|
|
|
static const struct spi_device_id st_press_id_table[] = {
|
|
{ LPS001WP_PRESS_DEV_NAME },
|
|
{ LPS25H_PRESS_DEV_NAME },
|
|
{ LPS331AP_PRESS_DEV_NAME },
|
|
{ LPS22HB_PRESS_DEV_NAME },
|
|
{ LPS33HW_PRESS_DEV_NAME },
|
|
{ LPS35HW_PRESS_DEV_NAME },
|
|
{ LPS22HH_PRESS_DEV_NAME },
|
|
{ "lps001wp-press" },
|
|
{ "lps25h-press", },
|
|
{ "lps331ap-press" },
|
|
{ "lps22hb-press" },
|
|
{},
|
|
};
|
|
MODULE_DEVICE_TABLE(spi, st_press_id_table);
|
|
|
|
static struct spi_driver st_press_driver = {
|
|
.driver = {
|
|
.name = "st-press-spi",
|
|
.of_match_table = st_press_of_match,
|
|
},
|
|
.probe = st_press_spi_probe,
|
|
.id_table = st_press_id_table,
|
|
};
|
|
module_spi_driver(st_press_driver);
|
|
|
|
MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
|
|
MODULE_DESCRIPTION("STMicroelectronics pressures spi driver");
|
|
MODULE_LICENSE("GPL v2");
|