mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-23 16:53:58 -05:00
Char/Misc driver fixes for 6.7-rc7
Here are a small number of various driver fixes for 6.7-rc7 that normally come through the char-misc tree, and one debugfs fix as well. Included in here are: - iio and hid sensor driver fixes for a number of small things - interconnect driver fixes - brcm_nvmem driver fixes - debugfs fix for previous fix - guard() definition in device.h so that many subsystems can start using it for 6.8-rc1 (requested by Dan Williams to make future merges easier.) All of these have been in linux-next for a while with no reported issues. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> -----BEGIN PGP SIGNATURE----- iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCZYapuQ8cZ3JlZ0Brcm9h aC5jb20ACgkQMUfUDdst+yljzgCbBkgtY/CpJJLz2VWcibJ5QiYougsAoK7vQKcX 7gJbm3CB3gWjHqx1eKAu =Wf96 -----END PGP SIGNATURE----- Merge tag 'char-misc-6.7-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc Pull char / misc driver fixes from Greg KH: "Here are a small number of various driver fixes for 6.7-rc7 that normally come through the char-misc tree, and one debugfs fix as well. Included in here are: - iio and hid sensor driver fixes for a number of small things - interconnect driver fixes - brcm_nvmem driver fixes - debugfs fix for previous fix - guard() definition in device.h so that many subsystems can start using it for 6.8-rc1 (requested by Dan Williams to make future merges easier) All of these have been in linux-next for a while with no reported issues" * tag 'char-misc-6.7-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (21 commits) debugfs: initialize cancellations earlier Revert "iio: hid-sensor-als: Add light color temperature support" Revert "iio: hid-sensor-als: Add light chromaticity support" nvmem: brcm_nvram: store a copy of NVRAM content dt-bindings: nvmem: mxs-ocotp: Document fsl,ocotp driver core: Add a guard() definition for the device_lock() interconnect: qcom: icc-rpm: Fix peak rate calculation iio: adc: MCP3564: fix hardware identification logic iio: adc: MCP3564: fix calib_bias and calib_scale range checks iio: adc: meson: add separate config for axg SoC family iio: adc: imx93: add four channels for imx93 adc iio: adc: ti_am335x_adc: Fix return value check of tiadc_request_dma() interconnect: qcom: sm8250: Enable sync_state iio: triggered-buffer: prevent possible freeing of wrong buffer iio: imu: inv_mpu6050: fix an error code problem in inv_mpu6050_read_raw iio: imu: adis16475: use bit numbers in assign_bit() iio: imu: adis16475: add spi_device_id table iio: tmag5273: fix temperature offset interconnect: Treat xlate() returning NULL node as an error iio: common: ms_sensors: ms_sensors_i2c: fix humidity conversion time table ...
This commit is contained in:
commit
a0652eb205
19 changed files with 260 additions and 224 deletions
|
@ -15,9 +15,11 @@ allOf:
|
|||
|
||||
properties:
|
||||
compatible:
|
||||
enum:
|
||||
- fsl,imx23-ocotp
|
||||
- fsl,imx28-ocotp
|
||||
items:
|
||||
- enum:
|
||||
- fsl,imx23-ocotp
|
||||
- fsl,imx28-ocotp
|
||||
- const: fsl,ocotp
|
||||
|
||||
reg:
|
||||
maxItems: 1
|
||||
|
@ -35,7 +37,7 @@ unevaluatedProperties: false
|
|||
examples:
|
||||
- |
|
||||
ocotp: efuse@8002c000 {
|
||||
compatible = "fsl,imx28-ocotp";
|
||||
compatible = "fsl,imx28-ocotp", "fsl,ocotp";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
reg = <0x8002c000 0x2000>;
|
||||
|
|
|
@ -393,17 +393,17 @@ static const unsigned int kx022a_odrs[] = {
|
|||
* (range / 2^bits) * g = (range / 2^bits) * 9.80665 m/s^2
|
||||
* => KX022A uses 16 bit (HiRes mode - assume the low 8 bits are zeroed
|
||||
* in low-power mode(?) )
|
||||
* => +/-2G => 4 / 2^16 * 9,80665 * 10^6 (to scale to micro)
|
||||
* => +/-2G - 598.550415
|
||||
* +/-4G - 1197.10083
|
||||
* +/-8G - 2394.20166
|
||||
* +/-16G - 4788.40332
|
||||
* => +/-2G => 4 / 2^16 * 9,80665
|
||||
* => +/-2G - 0.000598550415
|
||||
* +/-4G - 0.00119710083
|
||||
* +/-8G - 0.00239420166
|
||||
* +/-16G - 0.00478840332
|
||||
*/
|
||||
static const int kx022a_scale_table[][2] = {
|
||||
{ 598, 550415 },
|
||||
{ 1197, 100830 },
|
||||
{ 2394, 201660 },
|
||||
{ 4788, 403320 },
|
||||
{ 0, 598550 },
|
||||
{ 0, 1197101 },
|
||||
{ 0, 2394202 },
|
||||
{ 0, 4788403 },
|
||||
};
|
||||
|
||||
static int kx022a_read_avail(struct iio_dev *indio_dev,
|
||||
|
@ -422,7 +422,7 @@ static int kx022a_read_avail(struct iio_dev *indio_dev,
|
|||
*vals = (const int *)kx022a_scale_table;
|
||||
*length = ARRAY_SIZE(kx022a_scale_table) *
|
||||
ARRAY_SIZE(kx022a_scale_table[0]);
|
||||
*type = IIO_VAL_INT_PLUS_MICRO;
|
||||
*type = IIO_VAL_INT_PLUS_NANO;
|
||||
return IIO_AVAIL_LIST;
|
||||
default:
|
||||
return -EINVAL;
|
||||
|
@ -485,6 +485,20 @@ static int kx022a_turn_on_unlock(struct kx022a_data *data)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int kx022a_write_raw_get_fmt(struct iio_dev *idev,
|
||||
struct iio_chan_spec const *chan,
|
||||
long mask)
|
||||
{
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
return IIO_VAL_INT_PLUS_NANO;
|
||||
case IIO_CHAN_INFO_SAMP_FREQ:
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
static int kx022a_write_raw(struct iio_dev *idev,
|
||||
struct iio_chan_spec const *chan,
|
||||
int val, int val2, long mask)
|
||||
|
@ -629,7 +643,7 @@ static int kx022a_read_raw(struct iio_dev *idev,
|
|||
|
||||
kx022a_reg2scale(regval, val, val2);
|
||||
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
return IIO_VAL_INT_PLUS_NANO;
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
|
@ -856,6 +870,7 @@ static int kx022a_fifo_flush(struct iio_dev *idev, unsigned int samples)
|
|||
static const struct iio_info kx022a_info = {
|
||||
.read_raw = &kx022a_read_raw,
|
||||
.write_raw = &kx022a_write_raw,
|
||||
.write_raw_get_fmt = &kx022a_write_raw_get_fmt,
|
||||
.read_avail = &kx022a_read_avail,
|
||||
|
||||
.validate_trigger = iio_validate_own_trigger,
|
||||
|
|
|
@ -93,6 +93,10 @@ static const struct iio_chan_spec imx93_adc_iio_channels[] = {
|
|||
IMX93_ADC_CHAN(1),
|
||||
IMX93_ADC_CHAN(2),
|
||||
IMX93_ADC_CHAN(3),
|
||||
IMX93_ADC_CHAN(4),
|
||||
IMX93_ADC_CHAN(5),
|
||||
IMX93_ADC_CHAN(6),
|
||||
IMX93_ADC_CHAN(7),
|
||||
};
|
||||
|
||||
static void imx93_adc_power_down(struct imx93_adc *adc)
|
||||
|
|
|
@ -918,7 +918,7 @@ static int mcp3564_write_raw(struct iio_dev *indio_dev,
|
|||
mutex_unlock(&adc->lock);
|
||||
return ret;
|
||||
case IIO_CHAN_INFO_CALIBBIAS:
|
||||
if (val < mcp3564_calib_bias[0] && val > mcp3564_calib_bias[2])
|
||||
if (val < mcp3564_calib_bias[0] || val > mcp3564_calib_bias[2])
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&adc->lock);
|
||||
|
@ -928,7 +928,7 @@ static int mcp3564_write_raw(struct iio_dev *indio_dev,
|
|||
mutex_unlock(&adc->lock);
|
||||
return ret;
|
||||
case IIO_CHAN_INFO_CALIBSCALE:
|
||||
if (val < mcp3564_calib_scale[0] && val > mcp3564_calib_scale[2])
|
||||
if (val < mcp3564_calib_scale[0] || val > mcp3564_calib_scale[2])
|
||||
return -EINVAL;
|
||||
|
||||
if (adc->calib_scale == val)
|
||||
|
@ -1122,7 +1122,7 @@ static int mcp3564_config(struct iio_dev *indio_dev)
|
|||
enum mcp3564_ids ids;
|
||||
int ret = 0;
|
||||
unsigned int tmp = 0x01;
|
||||
bool err = true;
|
||||
bool err = false;
|
||||
|
||||
/*
|
||||
* The address is set on a per-device basis by fuses in the factory,
|
||||
|
@ -1509,5 +1509,5 @@ static struct spi_driver mcp3564_driver = {
|
|||
module_spi_driver(mcp3564_driver);
|
||||
|
||||
MODULE_AUTHOR("Marius Cristea <marius.cristea@microchip.com>");
|
||||
MODULE_DESCRIPTION("Microchip MCP346x/MCP346xR and MCP356x/MCP346xR ADCs");
|
||||
MODULE_DESCRIPTION("Microchip MCP346x/MCP346xR and MCP356x/MCP356xR ADCs");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
|
|
@ -1241,6 +1241,20 @@ static const struct meson_sar_adc_param meson_sar_adc_gxl_param = {
|
|||
.cmv_select = 1,
|
||||
};
|
||||
|
||||
static const struct meson_sar_adc_param meson_sar_adc_axg_param = {
|
||||
.has_bl30_integration = true,
|
||||
.clock_rate = 1200000,
|
||||
.bandgap_reg = MESON_SAR_ADC_REG11,
|
||||
.regmap_config = &meson_sar_adc_regmap_config_gxbb,
|
||||
.resolution = 12,
|
||||
.disable_ring_counter = 1,
|
||||
.has_reg11 = true,
|
||||
.vref_volatge = 1,
|
||||
.has_vref_select = true,
|
||||
.vref_select = VREF_VDDA,
|
||||
.cmv_select = 1,
|
||||
};
|
||||
|
||||
static const struct meson_sar_adc_param meson_sar_adc_g12a_param = {
|
||||
.has_bl30_integration = false,
|
||||
.clock_rate = 1200000,
|
||||
|
@ -1285,7 +1299,7 @@ static const struct meson_sar_adc_data meson_sar_adc_gxm_data = {
|
|||
};
|
||||
|
||||
static const struct meson_sar_adc_data meson_sar_adc_axg_data = {
|
||||
.param = &meson_sar_adc_gxl_param,
|
||||
.param = &meson_sar_adc_axg_param,
|
||||
.name = "meson-axg-saradc",
|
||||
};
|
||||
|
||||
|
|
|
@ -670,8 +670,10 @@ static int tiadc_probe(struct platform_device *pdev)
|
|||
platform_set_drvdata(pdev, indio_dev);
|
||||
|
||||
err = tiadc_request_dma(pdev, adc_dev);
|
||||
if (err && err == -EPROBE_DEFER)
|
||||
if (err && err != -ENODEV) {
|
||||
dev_err_probe(&pdev->dev, err, "DMA request failed\n");
|
||||
goto err_dma;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -46,6 +46,16 @@ int iio_triggered_buffer_setup_ext(struct iio_dev *indio_dev,
|
|||
struct iio_buffer *buffer;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* iio_triggered_buffer_cleanup() assumes that the buffer allocated here
|
||||
* is assigned to indio_dev->buffer but this is only the case if this
|
||||
* function is the first caller to iio_device_attach_buffer(). If
|
||||
* indio_dev->buffer is already set then we can't proceed otherwise the
|
||||
* cleanup function will try to free a buffer that was not allocated here.
|
||||
*/
|
||||
if (indio_dev->buffer)
|
||||
return -EADDRINUSE;
|
||||
|
||||
buffer = iio_kfifo_allocate();
|
||||
if (!buffer) {
|
||||
ret = -ENOMEM;
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
/* Conversion times in us */
|
||||
static const u16 ms_sensors_ht_t_conversion_time[] = { 50000, 25000,
|
||||
13000, 7000 };
|
||||
static const u16 ms_sensors_ht_h_conversion_time[] = { 16000, 3000,
|
||||
5000, 8000 };
|
||||
static const u16 ms_sensors_ht_h_conversion_time[] = { 16000, 5000,
|
||||
3000, 8000 };
|
||||
static const u16 ms_sensors_tp_conversion_time[] = { 500, 1100, 2100,
|
||||
4100, 8220, 16440 };
|
||||
|
||||
|
|
|
@ -70,8 +70,8 @@
|
|||
#define ADIS16475_MAX_SCAN_DATA 20
|
||||
/* spi max speed in brust mode */
|
||||
#define ADIS16475_BURST_MAX_SPEED 1000000
|
||||
#define ADIS16475_LSB_DEC_MASK BIT(0)
|
||||
#define ADIS16475_LSB_FIR_MASK BIT(1)
|
||||
#define ADIS16475_LSB_DEC_MASK 0
|
||||
#define ADIS16475_LSB_FIR_MASK 1
|
||||
#define ADIS16500_BURST_DATA_SEL_0_CHN_MASK GENMASK(5, 0)
|
||||
#define ADIS16500_BURST_DATA_SEL_1_CHN_MASK GENMASK(12, 7)
|
||||
|
||||
|
@ -1406,6 +1406,59 @@ static int adis16475_config_irq_pin(struct adis16475 *st)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int adis16475_probe(struct spi_device *spi)
|
||||
{
|
||||
struct iio_dev *indio_dev;
|
||||
struct adis16475 *st;
|
||||
int ret;
|
||||
|
||||
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
|
||||
if (!indio_dev)
|
||||
return -ENOMEM;
|
||||
|
||||
st = iio_priv(indio_dev);
|
||||
|
||||
st->info = spi_get_device_match_data(spi);
|
||||
if (!st->info)
|
||||
return -EINVAL;
|
||||
|
||||
ret = adis_init(&st->adis, indio_dev, spi, &st->info->adis_data);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
indio_dev->name = st->info->name;
|
||||
indio_dev->channels = st->info->channels;
|
||||
indio_dev->num_channels = st->info->num_channels;
|
||||
indio_dev->info = &adis16475_info;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
|
||||
ret = __adis_initial_startup(&st->adis);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = adis16475_config_irq_pin(st);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = adis16475_config_sync_mode(st);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = devm_adis_setup_buffer_and_trigger(&st->adis, indio_dev,
|
||||
adis16475_trigger_handler);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = devm_iio_device_register(&spi->dev, indio_dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
adis16475_debugfs_init(indio_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id adis16475_of_match[] = {
|
||||
{ .compatible = "adi,adis16470",
|
||||
.data = &adis16475_chip_info[ADIS16470] },
|
||||
|
@ -1451,57 +1504,30 @@ static const struct of_device_id adis16475_of_match[] = {
|
|||
};
|
||||
MODULE_DEVICE_TABLE(of, adis16475_of_match);
|
||||
|
||||
static int adis16475_probe(struct spi_device *spi)
|
||||
{
|
||||
struct iio_dev *indio_dev;
|
||||
struct adis16475 *st;
|
||||
int ret;
|
||||
|
||||
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
|
||||
if (!indio_dev)
|
||||
return -ENOMEM;
|
||||
|
||||
st = iio_priv(indio_dev);
|
||||
|
||||
st->info = device_get_match_data(&spi->dev);
|
||||
if (!st->info)
|
||||
return -EINVAL;
|
||||
|
||||
ret = adis_init(&st->adis, indio_dev, spi, &st->info->adis_data);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
indio_dev->name = st->info->name;
|
||||
indio_dev->channels = st->info->channels;
|
||||
indio_dev->num_channels = st->info->num_channels;
|
||||
indio_dev->info = &adis16475_info;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
|
||||
ret = __adis_initial_startup(&st->adis);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = adis16475_config_irq_pin(st);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = adis16475_config_sync_mode(st);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = devm_adis_setup_buffer_and_trigger(&st->adis, indio_dev,
|
||||
adis16475_trigger_handler);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = devm_iio_device_register(&spi->dev, indio_dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
adis16475_debugfs_init(indio_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
static const struct spi_device_id adis16475_ids[] = {
|
||||
{ "adis16470", (kernel_ulong_t)&adis16475_chip_info[ADIS16470] },
|
||||
{ "adis16475-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16475_1] },
|
||||
{ "adis16475-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16475_2] },
|
||||
{ "adis16475-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16475_3] },
|
||||
{ "adis16477-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16477_1] },
|
||||
{ "adis16477-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16477_2] },
|
||||
{ "adis16477-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16477_3] },
|
||||
{ "adis16465-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16465_1] },
|
||||
{ "adis16465-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16465_2] },
|
||||
{ "adis16465-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16465_3] },
|
||||
{ "adis16467-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16467_1] },
|
||||
{ "adis16467-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16467_2] },
|
||||
{ "adis16467-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16467_3] },
|
||||
{ "adis16500", (kernel_ulong_t)&adis16475_chip_info[ADIS16500] },
|
||||
{ "adis16505-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16505_1] },
|
||||
{ "adis16505-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16505_2] },
|
||||
{ "adis16505-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16505_3] },
|
||||
{ "adis16507-1", (kernel_ulong_t)&adis16475_chip_info[ADIS16507_1] },
|
||||
{ "adis16507-2", (kernel_ulong_t)&adis16475_chip_info[ADIS16507_2] },
|
||||
{ "adis16507-3", (kernel_ulong_t)&adis16475_chip_info[ADIS16507_3] },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(spi, adis16475_ids);
|
||||
|
||||
static struct spi_driver adis16475_driver = {
|
||||
.driver = {
|
||||
|
@ -1509,6 +1535,7 @@ static struct spi_driver adis16475_driver = {
|
|||
.of_match_table = adis16475_of_match,
|
||||
},
|
||||
.probe = adis16475_probe,
|
||||
.id_table = adis16475_ids,
|
||||
};
|
||||
module_spi_driver(adis16475_driver);
|
||||
|
||||
|
|
|
@ -750,13 +750,13 @@ inv_mpu6050_read_raw(struct iio_dev *indio_dev,
|
|||
ret = inv_mpu6050_sensor_show(st, st->reg->gyro_offset,
|
||||
chan->channel2, val);
|
||||
mutex_unlock(&st->lock);
|
||||
return IIO_VAL_INT;
|
||||
return ret;
|
||||
case IIO_ACCEL:
|
||||
mutex_lock(&st->lock);
|
||||
ret = inv_mpu6050_sensor_show(st, st->reg->accl_offset,
|
||||
chan->channel2, val);
|
||||
mutex_unlock(&st->lock);
|
||||
return IIO_VAL_INT;
|
||||
return ret;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
|
|
|
@ -14,11 +14,8 @@
|
|||
#include "../common/hid-sensors/hid-sensor-trigger.h"
|
||||
|
||||
enum {
|
||||
CHANNEL_SCAN_INDEX_INTENSITY,
|
||||
CHANNEL_SCAN_INDEX_ILLUM,
|
||||
CHANNEL_SCAN_INDEX_COLOR_TEMP,
|
||||
CHANNEL_SCAN_INDEX_CHROMATICITY_X,
|
||||
CHANNEL_SCAN_INDEX_CHROMATICITY_Y,
|
||||
CHANNEL_SCAN_INDEX_INTENSITY = 0,
|
||||
CHANNEL_SCAN_INDEX_ILLUM = 1,
|
||||
CHANNEL_SCAN_INDEX_MAX
|
||||
};
|
||||
|
||||
|
@ -68,40 +65,6 @@ static const struct iio_chan_spec als_channels[] = {
|
|||
BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
|
||||
.scan_index = CHANNEL_SCAN_INDEX_ILLUM,
|
||||
},
|
||||
{
|
||||
.type = IIO_COLORTEMP,
|
||||
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
|
||||
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
|
||||
BIT(IIO_CHAN_INFO_SCALE) |
|
||||
BIT(IIO_CHAN_INFO_SAMP_FREQ) |
|
||||
BIT(IIO_CHAN_INFO_HYSTERESIS) |
|
||||
BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
|
||||
.scan_index = CHANNEL_SCAN_INDEX_COLOR_TEMP,
|
||||
},
|
||||
{
|
||||
.type = IIO_CHROMATICITY,
|
||||
.modified = 1,
|
||||
.channel2 = IIO_MOD_X,
|
||||
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
|
||||
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
|
||||
BIT(IIO_CHAN_INFO_SCALE) |
|
||||
BIT(IIO_CHAN_INFO_SAMP_FREQ) |
|
||||
BIT(IIO_CHAN_INFO_HYSTERESIS) |
|
||||
BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
|
||||
.scan_index = CHANNEL_SCAN_INDEX_CHROMATICITY_X,
|
||||
},
|
||||
{
|
||||
.type = IIO_CHROMATICITY,
|
||||
.modified = 1,
|
||||
.channel2 = IIO_MOD_Y,
|
||||
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
|
||||
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
|
||||
BIT(IIO_CHAN_INFO_SCALE) |
|
||||
BIT(IIO_CHAN_INFO_SAMP_FREQ) |
|
||||
BIT(IIO_CHAN_INFO_HYSTERESIS) |
|
||||
BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
|
||||
.scan_index = CHANNEL_SCAN_INDEX_CHROMATICITY_Y,
|
||||
},
|
||||
IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP)
|
||||
};
|
||||
|
||||
|
@ -140,21 +103,6 @@ static int als_read_raw(struct iio_dev *indio_dev,
|
|||
min = als_state->als[chan->scan_index].logical_minimum;
|
||||
address = HID_USAGE_SENSOR_LIGHT_ILLUM;
|
||||
break;
|
||||
case CHANNEL_SCAN_INDEX_COLOR_TEMP:
|
||||
report_id = als_state->als[chan->scan_index].report_id;
|
||||
min = als_state->als[chan->scan_index].logical_minimum;
|
||||
address = HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE;
|
||||
break;
|
||||
case CHANNEL_SCAN_INDEX_CHROMATICITY_X:
|
||||
report_id = als_state->als[chan->scan_index].report_id;
|
||||
min = als_state->als[chan->scan_index].logical_minimum;
|
||||
address = HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X;
|
||||
break;
|
||||
case CHANNEL_SCAN_INDEX_CHROMATICITY_Y:
|
||||
report_id = als_state->als[chan->scan_index].report_id;
|
||||
min = als_state->als[chan->scan_index].logical_minimum;
|
||||
address = HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y;
|
||||
break;
|
||||
default:
|
||||
report_id = -1;
|
||||
break;
|
||||
|
@ -275,18 +223,6 @@ static int als_capture_sample(struct hid_sensor_hub_device *hsdev,
|
|||
als_state->scan.illum[CHANNEL_SCAN_INDEX_ILLUM] = sample_data;
|
||||
ret = 0;
|
||||
break;
|
||||
case HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE:
|
||||
als_state->scan.illum[CHANNEL_SCAN_INDEX_COLOR_TEMP] = sample_data;
|
||||
ret = 0;
|
||||
break;
|
||||
case HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X:
|
||||
als_state->scan.illum[CHANNEL_SCAN_INDEX_CHROMATICITY_X] = sample_data;
|
||||
ret = 0;
|
||||
break;
|
||||
case HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y:
|
||||
als_state->scan.illum[CHANNEL_SCAN_INDEX_CHROMATICITY_Y] = sample_data;
|
||||
ret = 0;
|
||||
break;
|
||||
case HID_USAGE_SENSOR_TIME_TIMESTAMP:
|
||||
als_state->timestamp = hid_sensor_convert_timestamp(&als_state->common_attributes,
|
||||
*(s64 *)raw_data);
|
||||
|
@ -322,38 +258,6 @@ static int als_parse_report(struct platform_device *pdev,
|
|||
st->als[i].report_id);
|
||||
}
|
||||
|
||||
ret = sensor_hub_input_get_attribute_info(hsdev, HID_INPUT_REPORT,
|
||||
usage_id,
|
||||
HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE,
|
||||
&st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP]);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
als_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_COLOR_TEMP,
|
||||
st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].size);
|
||||
|
||||
dev_dbg(&pdev->dev, "als %x:%x\n",
|
||||
st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].index,
|
||||
st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].report_id);
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
int next_scan_index = CHANNEL_SCAN_INDEX_CHROMATICITY_X + i;
|
||||
|
||||
ret = sensor_hub_input_get_attribute_info(hsdev,
|
||||
HID_INPUT_REPORT, usage_id,
|
||||
HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X + i,
|
||||
&st->als[next_scan_index]);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
als_adjust_channel_bit_mask(channels,
|
||||
CHANNEL_SCAN_INDEX_CHROMATICITY_X + i,
|
||||
st->als[next_scan_index].size);
|
||||
|
||||
dev_dbg(&pdev->dev, "als %x:%x\n",
|
||||
st->als[next_scan_index].index,
|
||||
st->als[next_scan_index].report_id);
|
||||
}
|
||||
|
||||
st->scale_precision = hid_sensor_format_scale(usage_id,
|
||||
&st->als[CHANNEL_SCAN_INDEX_INTENSITY],
|
||||
&st->scale_pre_decml, &st->scale_post_decml);
|
||||
|
|
|
@ -356,7 +356,7 @@ static int tmag5273_read_raw(struct iio_dev *indio_dev,
|
|||
case IIO_CHAN_INFO_OFFSET:
|
||||
switch (chan->type) {
|
||||
case IIO_TEMP:
|
||||
*val = -266314;
|
||||
*val = -16005;
|
||||
return IIO_VAL_INT;
|
||||
default:
|
||||
return -EINVAL;
|
||||
|
|
|
@ -395,6 +395,9 @@ struct icc_node_data *of_icc_get_from_provider(struct of_phandle_args *spec)
|
|||
}
|
||||
mutex_unlock(&icc_lock);
|
||||
|
||||
if (!node)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
if (IS_ERR(node))
|
||||
return ERR_CAST(node);
|
||||
|
||||
|
|
|
@ -307,7 +307,7 @@ static u64 qcom_icc_calc_rate(struct qcom_icc_provider *qp, struct qcom_icc_node
|
|||
|
||||
if (qn->ib_coeff) {
|
||||
agg_peak_rate = qn->max_peak[ctx] * 100;
|
||||
agg_peak_rate = div_u64(qn->max_peak[ctx], qn->ib_coeff);
|
||||
agg_peak_rate = div_u64(agg_peak_rate, qn->ib_coeff);
|
||||
} else {
|
||||
agg_peak_rate = qn->max_peak[ctx];
|
||||
}
|
||||
|
|
|
@ -1995,6 +1995,7 @@ static struct platform_driver qnoc_driver = {
|
|||
.driver = {
|
||||
.name = "qnoc-sm8250",
|
||||
.of_match_table = qnoc_of_match,
|
||||
.sync_state = icc_sync_state,
|
||||
},
|
||||
};
|
||||
module_platform_driver(qnoc_driver);
|
||||
|
|
|
@ -17,9 +17,23 @@
|
|||
|
||||
#define NVRAM_MAGIC "FLSH"
|
||||
|
||||
/**
|
||||
* struct brcm_nvram - driver state internal struct
|
||||
*
|
||||
* @dev: NVMEM device pointer
|
||||
* @nvmem_size: Size of the whole space available for NVRAM
|
||||
* @data: NVRAM data copy stored to avoid poking underlaying flash controller
|
||||
* @data_len: NVRAM data size
|
||||
* @padding_byte: Padding value used to fill remaining space
|
||||
* @cells: Array of discovered NVMEM cells
|
||||
* @ncells: Number of elements in cells
|
||||
*/
|
||||
struct brcm_nvram {
|
||||
struct device *dev;
|
||||
void __iomem *base;
|
||||
size_t nvmem_size;
|
||||
uint8_t *data;
|
||||
size_t data_len;
|
||||
uint8_t padding_byte;
|
||||
struct nvmem_cell_info *cells;
|
||||
int ncells;
|
||||
};
|
||||
|
@ -36,10 +50,47 @@ static int brcm_nvram_read(void *context, unsigned int offset, void *val,
|
|||
size_t bytes)
|
||||
{
|
||||
struct brcm_nvram *priv = context;
|
||||
u8 *dst = val;
|
||||
size_t to_copy;
|
||||
|
||||
while (bytes--)
|
||||
*dst++ = readb(priv->base + offset++);
|
||||
if (offset + bytes > priv->data_len)
|
||||
to_copy = max_t(ssize_t, (ssize_t)priv->data_len - offset, 0);
|
||||
else
|
||||
to_copy = bytes;
|
||||
|
||||
memcpy(val, priv->data + offset, to_copy);
|
||||
|
||||
memset((uint8_t *)val + to_copy, priv->padding_byte, bytes - to_copy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int brcm_nvram_copy_data(struct brcm_nvram *priv, struct platform_device *pdev)
|
||||
{
|
||||
struct resource *res;
|
||||
void __iomem *base;
|
||||
|
||||
base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
|
||||
if (IS_ERR(base))
|
||||
return PTR_ERR(base);
|
||||
|
||||
priv->nvmem_size = resource_size(res);
|
||||
|
||||
priv->padding_byte = readb(base + priv->nvmem_size - 1);
|
||||
for (priv->data_len = priv->nvmem_size;
|
||||
priv->data_len;
|
||||
priv->data_len--) {
|
||||
if (readb(base + priv->data_len - 1) != priv->padding_byte)
|
||||
break;
|
||||
}
|
||||
WARN(priv->data_len > SZ_128K, "Unexpected (big) NVRAM size: %zu B\n", priv->data_len);
|
||||
|
||||
priv->data = devm_kzalloc(priv->dev, priv->data_len, GFP_KERNEL);
|
||||
if (!priv->data)
|
||||
return -ENOMEM;
|
||||
|
||||
memcpy_fromio(priv->data, base, priv->data_len);
|
||||
|
||||
bcm47xx_nvram_init_from_iomem(base, priv->data_len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -67,8 +118,13 @@ static int brcm_nvram_add_cells(struct brcm_nvram *priv, uint8_t *data,
|
|||
size_t len)
|
||||
{
|
||||
struct device *dev = priv->dev;
|
||||
char *var, *value, *eq;
|
||||
char *var, *value;
|
||||
uint8_t tmp;
|
||||
int idx;
|
||||
int err = 0;
|
||||
|
||||
tmp = priv->data[len - 1];
|
||||
priv->data[len - 1] = '\0';
|
||||
|
||||
priv->ncells = 0;
|
||||
for (var = data + sizeof(struct brcm_nvram_header);
|
||||
|
@ -78,67 +134,68 @@ static int brcm_nvram_add_cells(struct brcm_nvram *priv, uint8_t *data,
|
|||
}
|
||||
|
||||
priv->cells = devm_kcalloc(dev, priv->ncells, sizeof(*priv->cells), GFP_KERNEL);
|
||||
if (!priv->cells)
|
||||
return -ENOMEM;
|
||||
if (!priv->cells) {
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (var = data + sizeof(struct brcm_nvram_header), idx = 0;
|
||||
var < (char *)data + len && *var;
|
||||
var = value + strlen(value) + 1, idx++) {
|
||||
char *eq, *name;
|
||||
|
||||
eq = strchr(var, '=');
|
||||
if (!eq)
|
||||
break;
|
||||
*eq = '\0';
|
||||
name = devm_kstrdup(dev, var, GFP_KERNEL);
|
||||
*eq = '=';
|
||||
if (!name) {
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
value = eq + 1;
|
||||
|
||||
priv->cells[idx].name = devm_kstrdup(dev, var, GFP_KERNEL);
|
||||
if (!priv->cells[idx].name)
|
||||
return -ENOMEM;
|
||||
priv->cells[idx].name = name;
|
||||
priv->cells[idx].offset = value - (char *)data;
|
||||
priv->cells[idx].bytes = strlen(value);
|
||||
priv->cells[idx].np = of_get_child_by_name(dev->of_node, priv->cells[idx].name);
|
||||
if (!strcmp(var, "et0macaddr") ||
|
||||
!strcmp(var, "et1macaddr") ||
|
||||
!strcmp(var, "et2macaddr")) {
|
||||
if (!strcmp(name, "et0macaddr") ||
|
||||
!strcmp(name, "et1macaddr") ||
|
||||
!strcmp(name, "et2macaddr")) {
|
||||
priv->cells[idx].raw_len = strlen(value);
|
||||
priv->cells[idx].bytes = ETH_ALEN;
|
||||
priv->cells[idx].read_post_process = brcm_nvram_read_post_process_macaddr;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
out:
|
||||
priv->data[len - 1] = tmp;
|
||||
return err;
|
||||
}
|
||||
|
||||
static int brcm_nvram_parse(struct brcm_nvram *priv)
|
||||
{
|
||||
struct brcm_nvram_header *header = (struct brcm_nvram_header *)priv->data;
|
||||
struct device *dev = priv->dev;
|
||||
struct brcm_nvram_header header;
|
||||
uint8_t *data;
|
||||
size_t len;
|
||||
int err;
|
||||
|
||||
memcpy_fromio(&header, priv->base, sizeof(header));
|
||||
|
||||
if (memcmp(header.magic, NVRAM_MAGIC, 4)) {
|
||||
if (memcmp(header->magic, NVRAM_MAGIC, 4)) {
|
||||
dev_err(dev, "Invalid NVRAM magic\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
len = le32_to_cpu(header.len);
|
||||
|
||||
data = kzalloc(len, GFP_KERNEL);
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
||||
memcpy_fromio(data, priv->base, len);
|
||||
data[len - 1] = '\0';
|
||||
|
||||
err = brcm_nvram_add_cells(priv, data, len);
|
||||
if (err) {
|
||||
dev_err(dev, "Failed to add cells: %d\n", err);
|
||||
return err;
|
||||
len = le32_to_cpu(header->len);
|
||||
if (len > priv->nvmem_size) {
|
||||
dev_err(dev, "NVRAM length (%zd) exceeds mapped size (%zd)\n", len,
|
||||
priv->nvmem_size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
kfree(data);
|
||||
err = brcm_nvram_add_cells(priv, priv->data, len);
|
||||
if (err)
|
||||
dev_err(dev, "Failed to add cells: %d\n", err);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -150,7 +207,6 @@ static int brcm_nvram_probe(struct platform_device *pdev)
|
|||
.reg_read = brcm_nvram_read,
|
||||
};
|
||||
struct device *dev = &pdev->dev;
|
||||
struct resource *res;
|
||||
struct brcm_nvram *priv;
|
||||
int err;
|
||||
|
||||
|
@ -159,21 +215,19 @@ static int brcm_nvram_probe(struct platform_device *pdev)
|
|||
return -ENOMEM;
|
||||
priv->dev = dev;
|
||||
|
||||
priv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
|
||||
if (IS_ERR(priv->base))
|
||||
return PTR_ERR(priv->base);
|
||||
err = brcm_nvram_copy_data(priv, pdev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = brcm_nvram_parse(priv);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
bcm47xx_nvram_init_from_iomem(priv->base, resource_size(res));
|
||||
|
||||
config.dev = dev;
|
||||
config.cells = priv->cells;
|
||||
config.ncells = priv->ncells;
|
||||
config.priv = priv;
|
||||
config.size = resource_size(res);
|
||||
config.size = priv->nvmem_size;
|
||||
|
||||
return PTR_ERR_OR_ZERO(devm_nvmem_register(dev, &config));
|
||||
}
|
||||
|
|
|
@ -104,12 +104,14 @@ int debugfs_file_get(struct dentry *dentry)
|
|||
~DEBUGFS_FSDATA_IS_REAL_FOPS_BIT);
|
||||
refcount_set(&fsd->active_users, 1);
|
||||
init_completion(&fsd->active_users_drained);
|
||||
INIT_LIST_HEAD(&fsd->cancellations);
|
||||
mutex_init(&fsd->cancellations_mtx);
|
||||
|
||||
if (cmpxchg(&dentry->d_fsdata, d_fsd, fsd) != d_fsd) {
|
||||
mutex_destroy(&fsd->cancellations_mtx);
|
||||
kfree(fsd);
|
||||
fsd = READ_ONCE(dentry->d_fsdata);
|
||||
}
|
||||
INIT_LIST_HEAD(&fsd->cancellations);
|
||||
mutex_init(&fsd->cancellations_mtx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1007,6 +1007,8 @@ static inline void device_unlock(struct device *dev)
|
|||
mutex_unlock(&dev->mutex);
|
||||
}
|
||||
|
||||
DEFINE_GUARD(device, struct device *, device_lock(_T), device_unlock(_T))
|
||||
|
||||
static inline void device_lock_assert(struct device *dev)
|
||||
{
|
||||
lockdep_assert_held(&dev->mutex);
|
||||
|
|
|
@ -21,10 +21,6 @@
|
|||
#define HID_USAGE_SENSOR_ALS 0x200041
|
||||
#define HID_USAGE_SENSOR_DATA_LIGHT 0x2004d0
|
||||
#define HID_USAGE_SENSOR_LIGHT_ILLUM 0x2004d1
|
||||
#define HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE 0x2004d2
|
||||
#define HID_USAGE_SENSOR_LIGHT_CHROMATICITY 0x2004d3
|
||||
#define HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X 0x2004d4
|
||||
#define HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y 0x2004d5
|
||||
|
||||
/* PROX (200011) */
|
||||
#define HID_USAGE_SENSOR_PROX 0x200011
|
||||
|
|
Loading…
Add table
Reference in a new issue