mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
Merge tag 'char-misc-7.4-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc/iio driver fixes from Greg KH: "Here are a bunch of char, misc, and iio driver fixes for reported problems for 7.4-rc4. Included in here are: - usual collection of lots of IIO driver fixes for issues - binder driver fix - iio, w1, and comedi driver fixes found and fixed by Josef - comedi driver fix for a reported problem - other misc driver fixes All of these have been in linux-next for a while with no reported issues" * tag 'char-misc-7.4-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (68 commits) iio: hid-sensors: fix fractional part for unit exponents -7 and -8 iio: trigger: free the trigger ID after device_del() iio: hid-sensors: fix a division by zero iio: humidity: hid-sensor-humidity: Use per-instance callbacks iio: temperature: hid-sensor-temperature: Use per-instance callbacks comedi: comedi_bond: Fix leak of opened device references mei: me: add ice lake point LP iTouch DID mei: lb: read the MTU once rust_binder: push BR_TRANSACTION_COMPLETE before BR_FAILED_REPLY misc: ibmvmc: initialize HMC state before device registration w1: w1_therm: leave the slaves of other families alone w1: w1_therm: lock the list of slaves for the bulk read w1: don't hold list_mutex while a slave is torn down w1: netlink: drop the slave after the bus is unlocked w1: ds2805: use the bus mutex to talk on the bus w1: ds28e04: use the bus mutex to talk on the bus w1: ds2482: set the strong pull-up with its byte w1: remove the master's files before taking its locks w1: use the bus mutex for the "rw" file misc: bcm-vk: fix DMA allocation memory leak ...
This commit is contained in:
@@ -67,6 +67,11 @@ properties:
|
||||
description:
|
||||
Inform the driver that last channel will be used to sensor battery.
|
||||
|
||||
aspeed,trim-syscon:
|
||||
$ref: /schemas/types.yaml#/definitions/phandle
|
||||
description:
|
||||
Phandle to the SCU holding the ADC's reference-voltage trimming data.
|
||||
|
||||
required:
|
||||
- compatible
|
||||
- reg
|
||||
@@ -74,6 +79,18 @@ required:
|
||||
- resets
|
||||
- "#io-channel-cells"
|
||||
|
||||
allOf:
|
||||
- if:
|
||||
properties:
|
||||
compatible:
|
||||
contains:
|
||||
enum:
|
||||
- aspeed,ast2700-adc0
|
||||
- aspeed,ast2700-adc1
|
||||
then:
|
||||
required:
|
||||
- aspeed,trim-syscon
|
||||
|
||||
additionalProperties: false
|
||||
|
||||
examples:
|
||||
|
||||
@@ -66,8 +66,8 @@ properties:
|
||||
- const: 0
|
||||
- enum: [20000, 24000]
|
||||
- items:
|
||||
- const: 4
|
||||
- const: 24000
|
||||
- const: 4000
|
||||
- const: 20000
|
||||
- items:
|
||||
- const: -20000
|
||||
- const: 20000
|
||||
|
||||
@@ -114,7 +114,6 @@ impl fmt::Debug for BinderError {
|
||||
BR_DEAD_REPLY => f.pad("BR_DEAD_REPLY"),
|
||||
BR_FROZEN_REPLY => f.pad("BR_FROZEN_REPLY"),
|
||||
BR_TRANSACTION_PENDING_FROZEN => f.pad("BR_TRANSACTION_PENDING_FROZEN"),
|
||||
BR_TRANSACTION_COMPLETE => f.pad("BR_TRANSACTION_COMPLETE"),
|
||||
_ => match self.source.as_ref() {
|
||||
Some(source) => source.fmt(f),
|
||||
None => self.reply.fmt(f),
|
||||
|
||||
@@ -1332,20 +1332,16 @@ impl Thread {
|
||||
self.transaction_inner(&mut info)
|
||||
};
|
||||
|
||||
// This runs when return work is passed to the caller. This is not
|
||||
// always the same as the transaction failing, as reply errors are
|
||||
// delivered to the remote process.
|
||||
// This runs when a transaction fails with an error returned to the caller.
|
||||
if let Err(err) = ret {
|
||||
self.push_return_work(err.reply);
|
||||
if err.reply != BR_TRANSACTION_COMPLETE {
|
||||
info.reply = err.reply;
|
||||
info.error_line = Some(err.line);
|
||||
if let Some(source) = err.source {
|
||||
info.errno = Some(source);
|
||||
info.reply = err.reply;
|
||||
info.error_line = Some(err.line);
|
||||
if let Some(source) = err.source {
|
||||
info.errno = Some(source);
|
||||
|
||||
self.inner.lock().extended_error =
|
||||
ExtendedError::new(info.debug_id as u32, err.reply, source.to_errno());
|
||||
}
|
||||
self.inner.lock().extended_error =
|
||||
ExtendedError::new(info.debug_id as u32, err.reply, source.to_errno());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1450,7 +1446,7 @@ impl Thread {
|
||||
info.to_pid = orig.from.process.task.pid();
|
||||
|
||||
// We need to complete the transaction even if we cannot complete building the reply.
|
||||
let out = (|| -> BinderResult<_> {
|
||||
if let Err(err) = (|| -> BinderResult<_> {
|
||||
let completion = DTRWrap::arc_try_new(DeliverCode::new(
|
||||
BR_TRANSACTION_COMPLETE,
|
||||
self.process.task.pid(),
|
||||
@@ -1471,11 +1467,10 @@ impl Thread {
|
||||
}
|
||||
orig.from.deliver_reply(Ok(reply), &orig, None);
|
||||
Ok(())
|
||||
})()
|
||||
.map_err(|mut err| {
|
||||
})() {
|
||||
// At this point we only return `BR_TRANSACTION_COMPLETE` to the caller, and we must let
|
||||
// the sender know that the transaction has completed (with an error in this case).
|
||||
|
||||
self.push_return_work(BR_TRANSACTION_COMPLETE);
|
||||
let param = err.source.as_ref().map_or(0, |e| e.to_errno());
|
||||
let ee = ExtendedError::new(info.debug_id as u32, err.reply, param);
|
||||
orig.from
|
||||
@@ -1483,11 +1478,9 @@ impl Thread {
|
||||
info.reply = BR_FAILED_REPLY;
|
||||
info.errno = err.source;
|
||||
info.error_line = Some(err.line);
|
||||
err.reply = BR_TRANSACTION_COMPLETE;
|
||||
err
|
||||
});
|
||||
}
|
||||
|
||||
out
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn oneway_transaction_inner(self: &Arc<Self>, info: &mut TransactionInfo) -> BinderResult {
|
||||
|
||||
@@ -3494,7 +3494,7 @@ void _comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
|
||||
void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
|
||||
{
|
||||
if (comedi_get_is_subdevice_running(s)) {
|
||||
comedi_event(dev, s);
|
||||
_comedi_event(dev, s);
|
||||
comedi_put_is_subdevice_running(s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,7 +696,7 @@ static int apci1500_timer_insn_config(struct comedi_device *dev,
|
||||
return -EINVAL;
|
||||
|
||||
val = z8536_read(dev, Z8536_CT_MODE_REG(chan));
|
||||
val &= Z8536_CT_MODE_EGE;
|
||||
val &= ~Z8536_CT_MODE_EGE;
|
||||
if (data[1] == 1)
|
||||
val |= Z8536_CT_MODE_EGE;
|
||||
else if (data[1] > 1)
|
||||
|
||||
@@ -184,7 +184,9 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||
char file[sizeof("/dev/comediXXXXXX")];
|
||||
int minor = it->options[i];
|
||||
struct comedi_device *d;
|
||||
int sdev = -1, nchans;
|
||||
int sdev = -1;
|
||||
int nchans;
|
||||
int nope = 1;
|
||||
struct bonded_device *bdev;
|
||||
struct bonded_device **devs;
|
||||
|
||||
@@ -223,11 +225,14 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||
dev_err(dev->class_dev,
|
||||
"comedi_get_n_channels() returned %d on minor %u subdev %d!\n",
|
||||
nchans, minor, sdev);
|
||||
return -EINVAL;
|
||||
nope = -EINVAL;
|
||||
break;
|
||||
}
|
||||
bdev = kmalloc_obj(*bdev);
|
||||
if (!bdev)
|
||||
return -ENOMEM;
|
||||
if (!bdev) {
|
||||
nope = -ENOMEM;
|
||||
break;
|
||||
}
|
||||
|
||||
bdev->dev = d;
|
||||
bdev->minor = minor;
|
||||
@@ -248,14 +253,23 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||
dev_err(dev->class_dev,
|
||||
"Could not allocate memory. Out of memory?\n");
|
||||
kfree(bdev);
|
||||
return -ENOMEM;
|
||||
nope = -ENOMEM;
|
||||
break;
|
||||
}
|
||||
devpriv->devs = devs;
|
||||
devpriv->devs[devpriv->ndevs++] = bdev;
|
||||
nope = 0; /* keeps the device open */
|
||||
|
||||
/* Append dev:subdev to devpriv->name */
|
||||
seq_buf_printf(&s, "%u:%u ", bdev->minor, bdev->subdev);
|
||||
}
|
||||
|
||||
if (nope) {
|
||||
/* Opened device cannot be used, so close it. */
|
||||
comedi_close_from(d, dev->minor);
|
||||
if (nope < 0)
|
||||
return nope;
|
||||
}
|
||||
}
|
||||
|
||||
if (!devpriv->nchans) {
|
||||
|
||||
@@ -459,7 +459,8 @@ static int ni_660x_input_poll(struct comedi_device *dev,
|
||||
|
||||
/* lock to avoid race with comedi_poll */
|
||||
spin_lock_irqsave(&devpriv->interrupt_lock, flags);
|
||||
mite_sync_dma(counter->mite_chan, s);
|
||||
if (counter->mite_chan)
|
||||
mite_sync_dma(counter->mite_chan, s);
|
||||
spin_unlock_irqrestore(&devpriv->interrupt_lock, flags);
|
||||
return comedi_buf_read_n_available(s);
|
||||
}
|
||||
|
||||
@@ -800,7 +800,7 @@ static int ni_tio_set_clock_src(struct ni_gpct *counter,
|
||||
GI_PRESCALE_X2(counter_dev->variant) |
|
||||
GI_PRESCALE_X8(counter_dev->variant), bits);
|
||||
}
|
||||
counter->clock_period_ps = period_ns * 1000;
|
||||
counter->clock_period_ps = (u64)period_ns * 1000;
|
||||
ni_tio_set_sync_mode(counter);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ struct vmk80xx_private {
|
||||
enum vmk80xx_model model;
|
||||
};
|
||||
|
||||
static void vmk80xx_do_bulk_msg(struct comedi_device *dev)
|
||||
static int vmk80xx_do_bulk_msg(struct comedi_device *dev)
|
||||
{
|
||||
struct vmk80xx_private *devpriv = dev->private;
|
||||
struct usb_device *usb = comedi_to_usb_dev(dev);
|
||||
@@ -161,6 +161,7 @@ static void vmk80xx_do_bulk_msg(struct comedi_device *dev)
|
||||
unsigned int rx_pipe;
|
||||
size_t tx_size;
|
||||
size_t rx_size;
|
||||
int ret;
|
||||
|
||||
tx_addr = devpriv->ep_tx->bEndpointAddress;
|
||||
rx_addr = devpriv->ep_rx->bEndpointAddress;
|
||||
@@ -169,11 +170,13 @@ static void vmk80xx_do_bulk_msg(struct comedi_device *dev)
|
||||
tx_size = usb_endpoint_maxp(devpriv->ep_tx);
|
||||
rx_size = usb_endpoint_maxp(devpriv->ep_rx);
|
||||
|
||||
usb_bulk_msg(usb, tx_pipe, devpriv->usb_tx_buf, tx_size, NULL,
|
||||
PACKET_TIMEOUT);
|
||||
ret = usb_bulk_msg(usb, tx_pipe, devpriv->usb_tx_buf, tx_size, NULL,
|
||||
PACKET_TIMEOUT);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
usb_bulk_msg(usb, rx_pipe, devpriv->usb_rx_buf, rx_size, NULL,
|
||||
PACKET_TIMEOUT);
|
||||
return usb_bulk_msg(usb, rx_pipe, devpriv->usb_rx_buf, rx_size, NULL,
|
||||
PACKET_TIMEOUT);
|
||||
}
|
||||
|
||||
static int vmk80xx_read_packet(struct comedi_device *dev)
|
||||
@@ -183,10 +186,8 @@ static int vmk80xx_read_packet(struct comedi_device *dev)
|
||||
struct usb_endpoint_descriptor *ep;
|
||||
unsigned int pipe;
|
||||
|
||||
if (devpriv->model == VMK8061_MODEL) {
|
||||
vmk80xx_do_bulk_msg(dev);
|
||||
return 0;
|
||||
}
|
||||
if (devpriv->model == VMK8061_MODEL)
|
||||
return vmk80xx_do_bulk_msg(dev);
|
||||
|
||||
ep = devpriv->ep_rx;
|
||||
pipe = usb_rcvintpipe(usb, ep->bEndpointAddress);
|
||||
@@ -204,10 +205,8 @@ static int vmk80xx_write_packet(struct comedi_device *dev, int cmd)
|
||||
|
||||
devpriv->usb_tx_buf[0] = cmd;
|
||||
|
||||
if (devpriv->model == VMK8061_MODEL) {
|
||||
vmk80xx_do_bulk_msg(dev);
|
||||
return 0;
|
||||
}
|
||||
if (devpriv->model == VMK8061_MODEL)
|
||||
return vmk80xx_do_bulk_msg(dev);
|
||||
|
||||
ep = devpriv->ep_tx;
|
||||
pipe = usb_sndintpipe(usb, ep->bEndpointAddress);
|
||||
|
||||
@@ -33,6 +33,8 @@ config ADIS16209
|
||||
|
||||
config ADXL313
|
||||
tristate
|
||||
select IIO_BUFFER
|
||||
select IIO_KFIFO_BUF
|
||||
|
||||
config ADXL313_I2C
|
||||
tristate "Analog Devices ADXL313 3-Axis Digital Accelerometer I2C Driver"
|
||||
@@ -62,6 +64,8 @@ config ADXL313_SPI
|
||||
|
||||
config ADXL345
|
||||
tristate
|
||||
select IIO_BUFFER
|
||||
select IIO_KFIFO_BUF
|
||||
|
||||
config ADXL345_I2C
|
||||
tristate "Analog Devices ADXL345 3-Axis Digital Accelerometer I2C Driver"
|
||||
|
||||
@@ -334,8 +334,11 @@ static int adxl380_set_act_inact_threshold(struct iio_dev *indio_dev,
|
||||
return ret;
|
||||
|
||||
ret = adxl380_write_act_inact_threshold(st, act, th);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
/* Leave standby also if the value was refused */
|
||||
adxl380_set_measure_en(st, true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return adxl380_set_measure_en(st, true);
|
||||
}
|
||||
@@ -698,6 +701,12 @@ static int adxl380_set_range(struct adxl380_state *st, u8 range)
|
||||
|
||||
guard(mutex)(&st->lock);
|
||||
|
||||
/* The thresholds are rescaled: see that they fit before any change */
|
||||
if (mult_frac(max(st->act_threshold, st->inact_threshold),
|
||||
adxl380_range_scale_factor_tbl[st->range],
|
||||
adxl380_range_scale_factor_tbl[range]) > ADXL380_THRESH_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
ret = adxl380_set_measure_en(st, false);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@@ -478,8 +478,8 @@ void kxsd9_common_remove(struct device *dev)
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct kxsd9_state *st = iio_priv(indio_dev);
|
||||
|
||||
iio_triggered_buffer_cleanup(indio_dev);
|
||||
iio_device_unregister(indio_dev);
|
||||
iio_triggered_buffer_cleanup(indio_dev);
|
||||
pm_runtime_get_sync(dev);
|
||||
pm_runtime_put_noidle(dev);
|
||||
pm_runtime_disable(dev);
|
||||
|
||||
@@ -311,7 +311,9 @@ static int ad7780_probe(struct spi_device *spi)
|
||||
st = iio_priv(indio_dev);
|
||||
st->gain = 1;
|
||||
|
||||
ad_sd_init(&st->sd, indio_dev, spi, &ad7780_sigma_delta_info);
|
||||
ret = ad_sd_init(&st->sd, indio_dev, spi, &ad7780_sigma_delta_info);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
st->chip_info =
|
||||
&ad7780_chip_info_tbl[spi_get_device_id(spi)->driver_data];
|
||||
|
||||
@@ -435,7 +435,9 @@ static int ad7791_probe(struct spi_device *spi)
|
||||
return ret;
|
||||
|
||||
st->info = &ad7791_chip_infos[spi_get_device_id(spi)->driver_data];
|
||||
ad_sd_init(&st->sd, indio_dev, spi, &ad7791_sigma_delta_info);
|
||||
ret = ad_sd_init(&st->sd, indio_dev, spi, &ad7791_sigma_delta_info);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
indio_dev->name = spi_get_device_id(spi)->name;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
|
||||
@@ -796,7 +796,9 @@ static int ad7793_probe(struct spi_device *spi)
|
||||
|
||||
st = iio_priv(indio_dev);
|
||||
|
||||
ad_sd_init(&st->sd, indio_dev, spi, &ad7793_sigma_delta_info);
|
||||
ret = ad_sd_init(&st->sd, indio_dev, spi, &ad7793_sigma_delta_info);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (pdata->refsel != AD7793_REFSEL_INTERNAL) {
|
||||
ret = devm_regulator_get_enable_read_voltage(dev, "refin");
|
||||
|
||||
@@ -366,6 +366,7 @@ static const struct spi_device_id ad7923_id[] = {
|
||||
{ .name = "ad7924", .driver_data = AD7924 },
|
||||
{ .name = "ad7908", .driver_data = AD7908 },
|
||||
{ .name = "ad7918", .driver_data = AD7918 },
|
||||
{ .name = "ad7927", .driver_data = AD7928 },
|
||||
{ .name = "ad7928", .driver_data = AD7928 },
|
||||
{ }
|
||||
};
|
||||
|
||||
@@ -201,18 +201,29 @@ static const struct iio_chan_spec aspeed_adc_iio_bat_channels[] = {
|
||||
|
||||
static int aspeed_adc_set_trim_data(struct iio_dev *indio_dev)
|
||||
{
|
||||
struct device_node *syscon;
|
||||
struct device_node *np, *syscon;
|
||||
struct regmap *scu;
|
||||
u32 scu_otp, trimming_val;
|
||||
struct aspeed_adc_data *data = iio_priv(indio_dev);
|
||||
const char *propname = "aspeed,trim-syscon";
|
||||
|
||||
syscon = of_find_node_by_name(NULL, "syscon");
|
||||
if (syscon == NULL) {
|
||||
dev_warn(data->dev, "Couldn't find syscon node\n");
|
||||
return -EOPNOTSUPP;
|
||||
np = dev_of_node(data->dev);
|
||||
if (of_property_present(np, propname)) {
|
||||
scu = syscon_regmap_lookup_by_phandle(np, propname);
|
||||
} else {
|
||||
/*
|
||||
* No "aspeed,trim-syscon" phandle: either a single-SCU SoC,
|
||||
* or a DTB predating the property. Fall back to the old
|
||||
* global by-name lookup for backward compatibility.
|
||||
*/
|
||||
syscon = of_find_node_by_name(NULL, "syscon");
|
||||
if (!syscon) {
|
||||
dev_warn(data->dev, "Couldn't find syscon node\n");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
scu = syscon_node_to_regmap(syscon);
|
||||
of_node_put(syscon);
|
||||
}
|
||||
scu = syscon_node_to_regmap(syscon);
|
||||
of_node_put(syscon);
|
||||
if (IS_ERR(scu)) {
|
||||
dev_warn(data->dev, "Failed to get syscon regmap\n");
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
@@ -114,7 +114,9 @@ static int max11205_probe(struct spi_device *spi)
|
||||
|
||||
st = iio_priv(indio_dev);
|
||||
|
||||
ad_sd_init(&st->sd, indio_dev, spi, &max11205_sigma_delta_info);
|
||||
ret = ad_sd_init(&st->sd, indio_dev, spi, &max11205_sigma_delta_info);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
st->chip_info = spi_get_device_match_data(spi);
|
||||
if (!st->chip_info)
|
||||
|
||||
@@ -1204,6 +1204,9 @@ static int mcp3564_config(struct iio_dev *indio_dev, bool *use_internal_vref_att
|
||||
* try using fallback compatible in device tree to deal with some newer part number.
|
||||
*/
|
||||
adc->chip_info = spi_get_device_match_data(adc->spi);
|
||||
if (!adc->chip_info)
|
||||
return -ENODATA;
|
||||
|
||||
adc->have_vref = adc->chip_info->have_vref;
|
||||
} else {
|
||||
adc->chip_info = &mcp3564_chip_infos_tbl[ids];
|
||||
|
||||
@@ -609,7 +609,7 @@ static void adc5_gen3_delete_aux(void *data)
|
||||
|
||||
static void adc5_gen3_aux_device_release(struct device *dev) {}
|
||||
|
||||
static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc)
|
||||
static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc, int id)
|
||||
{
|
||||
struct tm5_aux_dev_wrapper *aux_device;
|
||||
int i, ret, i_tm = 0;
|
||||
@@ -619,6 +619,7 @@ static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc)
|
||||
return -ENOMEM;
|
||||
|
||||
aux_device->aux_dev.name = "adc5_tm_gen3";
|
||||
aux_device->aux_dev.id = id;
|
||||
aux_device->aux_dev.dev.parent = adc->dev;
|
||||
aux_device->aux_dev.dev.release = adc5_gen3_aux_device_release;
|
||||
|
||||
@@ -796,7 +797,7 @@ static int adc5_gen3_probe(struct platform_device *pdev)
|
||||
return ret;
|
||||
|
||||
if (adc->n_tm_channels > 0) {
|
||||
ret = adc5_gen3_add_aux_tm_device(adc);
|
||||
ret = adc5_gen3_add_aux_tm_device(adc, iio_device_id(indio_dev));
|
||||
if (ret)
|
||||
dev_err_probe(dev, ret,
|
||||
"Failed to add auxiliary TM device\n");
|
||||
|
||||
@@ -312,7 +312,7 @@ static int ad74413r_gpio_set_multiple(struct gpio_chip *chip,
|
||||
return ret;
|
||||
|
||||
real_mask |= BIT(real_offset);
|
||||
if (*bits & offset)
|
||||
if (test_bit(offset, bits))
|
||||
real_bits |= BIT(real_offset);
|
||||
}
|
||||
|
||||
|
||||
@@ -303,7 +303,8 @@ static int rescale_configure_channel(struct device *dev,
|
||||
chan->info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
|
||||
BIT(IIO_CHAN_INFO_SCALE);
|
||||
|
||||
if (rescale->offset)
|
||||
if (rescale->offset ||
|
||||
iio_channel_has_info(schan, IIO_CHAN_INFO_OFFSET))
|
||||
chan->info_mask_separate |= BIT(IIO_CHAN_INFO_OFFSET);
|
||||
|
||||
/*
|
||||
|
||||
@@ -116,9 +116,6 @@ static int atlas_ezo_read_raw(struct iio_dev *indio_dev,
|
||||
struct atlas_ezo_data *data = iio_priv(indio_dev);
|
||||
struct i2c_client *client = data->client;
|
||||
|
||||
if (chan->type != IIO_CONCENTRATION)
|
||||
return -EINVAL;
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW: {
|
||||
int ret;
|
||||
|
||||
@@ -70,7 +70,7 @@ static int cros_ec_sensors_read(struct iio_dev *indio_dev,
|
||||
break;
|
||||
case IIO_CHAN_INFO_CALIBSCALE:
|
||||
st->core.param.cmd = MOTIONSENSE_CMD_SENSOR_SCALE;
|
||||
st->core.param.sensor_offset.flags = 0;
|
||||
st->core.param.sensor_scale.flags = 0;
|
||||
|
||||
ret = cros_ec_motion_send_host_cmd(&st->core, 0);
|
||||
if (ret == -EPROTO || ret == -EOPNOTSUPP) {
|
||||
@@ -178,8 +178,7 @@ static int cros_ec_sensors_write(struct iio_dev *indio_dev,
|
||||
/* Send to EC for each axis, even if not complete */
|
||||
|
||||
st->core.param.cmd = MOTIONSENSE_CMD_SENSOR_SCALE;
|
||||
st->core.param.sensor_offset.flags =
|
||||
MOTION_SENSE_SET_OFFSET;
|
||||
st->core.param.sensor_scale.flags = MOTION_SENSE_SET_OFFSET;
|
||||
for (i = CROS_EC_SENSOR_X; i < CROS_EC_SENSOR_MAX_AXIS; i++)
|
||||
st->core.param.sensor_scale.scale[i] =
|
||||
st->core.calib[i].scale;
|
||||
|
||||
@@ -38,6 +38,8 @@ static const struct {
|
||||
{HID_USAGE_SENSOR_COMPASS_3D, 0, 0, 1000000},
|
||||
{HID_USAGE_SENSOR_COMPASS_3D, HID_USAGE_SENSOR_UNITS_GAUSS, 1, 0},
|
||||
|
||||
{HID_USAGE_SENSOR_ORIENT_COMP_MAGN_NORTH, 0, 1, 0},
|
||||
|
||||
{HID_USAGE_SENSOR_INCLINOMETER_3D, 0, 0, 17453293},
|
||||
{HID_USAGE_SENSOR_INCLINOMETER_3D,
|
||||
HID_USAGE_SENSOR_UNITS_DEGREES, 0, 17453293},
|
||||
@@ -96,9 +98,14 @@ static void simple_div(int dividend, int divisor, int *whole, int *micro_frac)
|
||||
static void split_micro_fraction(unsigned int no, int exp, int *val1, int *val2)
|
||||
{
|
||||
int divisor = int_pow(10, exp);
|
||||
unsigned int rem;
|
||||
|
||||
*val1 = no / divisor;
|
||||
*val2 = no % divisor * int_pow(10, 6 - exp);
|
||||
rem = no % divisor;
|
||||
if (exp > 6)
|
||||
*val2 = rem / (unsigned int)int_pow(10, exp - 6);
|
||||
else
|
||||
*val2 = rem * int_pow(10, 6 - exp);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -140,7 +147,10 @@ static u32 convert_to_vtf_format(int size, int exp, int val1, int val2)
|
||||
if (val1 < 0 || val2 < 0)
|
||||
sign = -1;
|
||||
exp = hid_sensor_convert_exponent(exp);
|
||||
if (exp < 0) {
|
||||
if (exp < -6) {
|
||||
value = abs(val1) * int_pow(10, -exp);
|
||||
value += abs(val2) * int_pow(10, -exp - 6);
|
||||
} else if (exp < 0) {
|
||||
divisor = int_pow(10, 6 + exp);
|
||||
value = abs(val1) * int_pow(10, -exp);
|
||||
value += abs(val2) / divisor;
|
||||
|
||||
@@ -133,15 +133,26 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
|
||||
return;
|
||||
|
||||
/* no previous data, compute theoretical value from interrupt */
|
||||
if (ts->timestamp == 0) {
|
||||
if (!ts->init) {
|
||||
/* elapsed time: sensor period * sensor samples number */
|
||||
interval = (s64)ts->period * (s64)sample_nb;
|
||||
ts->timestamp = timestamp - interval;
|
||||
delta = timestamp - interval;
|
||||
/* prevent next timestamp to be lower than the last one */
|
||||
if ((delta + ts->period) > ts->timestamp)
|
||||
ts->timestamp = delta;
|
||||
ts->init = true;
|
||||
|
||||
}
|
||||
|
||||
/* update delta timestamps and estimated period */
|
||||
it = &ts->delta;
|
||||
ts->delta_counter += sample_nb;
|
||||
/* reset in case of odr change */
|
||||
if (ts->new_mult) {
|
||||
it->lo = 0;
|
||||
it->up = 0;
|
||||
ts->delta_counter = 0;
|
||||
}
|
||||
delta = timestamp - it->up;
|
||||
delta_threshold = INV_SENSORS_TIMESTAMP_MIN(INV_SENSORS_MIN_IT_DELTA, ts->chip.jitter);
|
||||
if (delta >= delta_threshold) {
|
||||
@@ -161,7 +172,7 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
|
||||
it->lo = it->up;
|
||||
it->up = timestamp;
|
||||
delta = it->up - it->lo;
|
||||
if (it->lo != 0) {
|
||||
if (it->lo != 0 && !ts->new_mult) {
|
||||
/* compute period and check validity */
|
||||
period = div_s64(delta, sample_nb);
|
||||
valid = inv_validate_period(ts, period);
|
||||
@@ -184,7 +195,7 @@ void inv_sensors_timestamp_apply_odr(struct inv_sensors_timestamp *ts,
|
||||
u32 fifo_period, size_t fifo_nb,
|
||||
unsigned int fifo_no)
|
||||
{
|
||||
s64 interval;
|
||||
s64 interval, timestamp;
|
||||
u32 fifo_mult;
|
||||
|
||||
if (ts->new_mult == 0)
|
||||
@@ -207,7 +218,10 @@ void inv_sensors_timestamp_apply_odr(struct inv_sensors_timestamp *ts,
|
||||
fifo_period = fifo_mult * ts->chip_period.val;
|
||||
/* computes time interval between interrupt and this sample */
|
||||
interval = (s64)(fifo_nb - fifo_no) * (s64)fifo_period;
|
||||
ts->timestamp = ts->it.up - interval;
|
||||
timestamp = ts->it.up - interval;
|
||||
/* prevent next timestamp to be lower than current one */
|
||||
if ((timestamp + ts->period) > ts->timestamp)
|
||||
ts->timestamp = timestamp;
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(inv_sensors_timestamp_apply_odr, "IIO_INV_SENSORS_TIMESTAMP");
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/math64.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/scmi_protocol.h>
|
||||
@@ -70,8 +71,7 @@ static int scmi_iio_sensor_update_cb(struct notifier_block *nb,
|
||||
*/
|
||||
tstamp_scale = sensor->sensor_info->tstamp_scale + 9;
|
||||
if (tstamp_scale < 0) {
|
||||
do_div(time, int_pow(10, abs(tstamp_scale)));
|
||||
time_ns = time;
|
||||
time_ns = div64_u64(time, int_pow(10, abs(tstamp_scale)));
|
||||
} else {
|
||||
time_ns = time * int_pow(10, tstamp_scale);
|
||||
}
|
||||
@@ -162,7 +162,7 @@ static int scmi_iio_set_odr_val(struct iio_dev *iio_dev, int val, int val2)
|
||||
mult = scnprintf(buf, sizeof(buf), "%llu", sf) - 1;
|
||||
|
||||
sec = int_pow(10, mult) * MICROHZ_PER_HZ;
|
||||
do_div(sec, uHz);
|
||||
sec = div64_u64(sec, uHz);
|
||||
if (sec == 0) {
|
||||
dev_err(&iio_dev->dev,
|
||||
"Trying to set invalid sensor update value for sensor %s",
|
||||
@@ -237,13 +237,10 @@ static int scmi_iio_read_avail(struct iio_dev *iio_dev,
|
||||
|
||||
static void convert_ns_to_freq(u64 interval_ns, u64 *hz, u64 *uhz)
|
||||
{
|
||||
u64 rem, freq;
|
||||
u64 rem;
|
||||
|
||||
freq = NSEC_PER_SEC;
|
||||
rem = do_div(freq, interval_ns);
|
||||
*hz = freq;
|
||||
*uhz = rem * 1000000UL;
|
||||
do_div(*uhz, interval_ns);
|
||||
*hz = div64_u64_rem(HZ_PER_GHZ, interval_ns, &rem);
|
||||
*uhz = div64_u64(rem * MICROHZ_PER_HZ, interval_ns);
|
||||
}
|
||||
|
||||
static int scmi_iio_get_odr_val(struct iio_dev *iio_dev, int *val, int *val2)
|
||||
@@ -269,7 +266,8 @@ static int scmi_iio_get_odr_val(struct iio_dev *iio_dev, int *val, int *val2)
|
||||
mult = SCMI_SENS_CFG_GET_UPDATE_EXP(sensor_config);
|
||||
if (mult < 0) {
|
||||
sensor_interval_mult = int_pow(10, abs(mult));
|
||||
do_div(sensor_update_interval, sensor_interval_mult);
|
||||
sensor_update_interval = div64_u64(sensor_update_interval,
|
||||
sensor_interval_mult);
|
||||
} else {
|
||||
sensor_interval_mult = int_pow(10, mult);
|
||||
sensor_update_interval =
|
||||
@@ -395,9 +393,9 @@ static ssize_t scmi_iio_get_raw_available(struct iio_dev *iio_dev,
|
||||
*/
|
||||
exponent = exponent - scale;
|
||||
if (exponent < 0) {
|
||||
rem = do_div(resolution,
|
||||
int_pow(10, abs(exponent))
|
||||
);
|
||||
resolution = div64_u64_rem(resolution,
|
||||
int_pow(10, abs(exponent)),
|
||||
&rem);
|
||||
len = sysfs_emit(buf,
|
||||
"[%lld %llu.%llu %lld]\n", min_range,
|
||||
resolution, rem, max_range);
|
||||
@@ -491,7 +489,8 @@ static u64 scmi_iio_convert_interval_to_ns(u32 val)
|
||||
mult = SCMI_SENS_INTVL_GET_EXP(val);
|
||||
if (mult < 0) {
|
||||
sensor_interval_mult = int_pow(10, abs(mult));
|
||||
do_div(sensor_update_interval, sensor_interval_mult);
|
||||
sensor_update_interval = div64_u64(sensor_update_interval,
|
||||
sensor_interval_mult);
|
||||
} else {
|
||||
sensor_interval_mult = int_pow(10, mult);
|
||||
sensor_update_interval =
|
||||
|
||||
@@ -141,7 +141,7 @@ enum ad5758_output_range {
|
||||
AD5758_RANGE_PLUSMINUS_10V,
|
||||
AD5758_RANGE_0mA_20mA = 8,
|
||||
AD5758_RANGE_0mA_24mA,
|
||||
AD5758_RANGE_4mA_24mA,
|
||||
AD5758_RANGE_4mA_20mA,
|
||||
AD5758_RANGE_PLUSMINUS_20mA,
|
||||
AD5758_RANGE_PLUSMINUS_24mA,
|
||||
AD5758_RANGE_MINUS_1mA_PLUS_22mA,
|
||||
@@ -164,7 +164,7 @@ static const struct ad5758_range ad5758_voltage_range[] = {
|
||||
static const struct ad5758_range ad5758_current_range[] = {
|
||||
{ AD5758_RANGE_0mA_20mA, 0, 20000},
|
||||
{ AD5758_RANGE_0mA_24mA, 0, 24000 },
|
||||
{ AD5758_RANGE_4mA_24mA, 4, 24000 },
|
||||
{ AD5758_RANGE_4mA_20mA, 4000, 20000 },
|
||||
{ AD5758_RANGE_PLUSMINUS_20mA, -20000, 20000 },
|
||||
{ AD5758_RANGE_PLUSMINUS_24mA, -24000, 24000 },
|
||||
{ AD5758_RANGE_MINUS_1mA_PLUS_22mA, -1000, 22000 },
|
||||
|
||||
@@ -356,6 +356,8 @@ static int mcp4725_write_raw(struct iio_dev *indio_dev,
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
ret = mcp4725_set_value(indio_dev, val);
|
||||
if (ret)
|
||||
return ret;
|
||||
data->dac_value = val;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -696,6 +696,9 @@ static int mcp47feb02_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
if (val < 0 || val > GENMASK(data->chip_features->resolution - 1, 0))
|
||||
return -EINVAL;
|
||||
|
||||
ret = regmap_write(data->regmap, REG_ADDR(ch->address), val);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@@ -761,7 +761,7 @@ static int bmg160_write_event_config(struct iio_dev *indio_dev,
|
||||
struct bmg160_data *data = iio_priv(indio_dev);
|
||||
int ret;
|
||||
|
||||
if (state && data->ev_enable_state)
|
||||
if (state == data->ev_enable_state)
|
||||
return 0;
|
||||
|
||||
mutex_lock(&data->mutex);
|
||||
|
||||
@@ -123,6 +123,7 @@ static int am2315_read_data(struct am2315_data *data,
|
||||
*/
|
||||
u8 rx_buf[8];
|
||||
u16 crc;
|
||||
u16 temp_raw;
|
||||
|
||||
/* First wake up the device. */
|
||||
am2315_ping(data->client);
|
||||
@@ -154,8 +155,15 @@ static int am2315_read_data(struct am2315_data *data,
|
||||
|
||||
sensor_data->hum_data = (rx_buf[AM2315_HUM_OFFSET] << 8) |
|
||||
rx_buf[AM2315_HUM_OFFSET + 1];
|
||||
sensor_data->temp_data = (rx_buf[AM2315_TEMP_OFFSET] << 8) |
|
||||
rx_buf[AM2315_TEMP_OFFSET + 1];
|
||||
|
||||
/*
|
||||
* Temperature is sign-magnitude, not two's complement:
|
||||
* bit 15 is the sign, bits 14-0 are the magnitude (x0.1 degC).
|
||||
*/
|
||||
temp_raw = (rx_buf[AM2315_TEMP_OFFSET] << 8) |
|
||||
rx_buf[AM2315_TEMP_OFFSET + 1];
|
||||
sensor_data->temp_data = (temp_raw & 0x8000) ?
|
||||
-(temp_raw & 0x7fff) : temp_raw;
|
||||
|
||||
return ret;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
struct hid_humidity_state {
|
||||
struct hid_sensor_common common_attributes;
|
||||
struct hid_sensor_hub_attribute_info humidity_attr;
|
||||
struct hid_sensor_hub_callbacks callbacks;
|
||||
struct {
|
||||
s32 humidity_data;
|
||||
aligned_s64 timestamp;
|
||||
@@ -184,11 +185,6 @@ static int humidity_parse_report(struct platform_device *pdev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct hid_sensor_hub_callbacks humidity_callbacks = {
|
||||
.send_event = &humidity_proc_event,
|
||||
.capture_sample = &humidity_capture_sample,
|
||||
};
|
||||
|
||||
/* Function to initialize the processing for usage id */
|
||||
static int hid_humidity_probe(struct platform_device *pdev)
|
||||
{
|
||||
@@ -240,9 +236,13 @@ static int hid_humidity_probe(struct platform_device *pdev)
|
||||
|
||||
platform_set_drvdata(pdev, indio_dev);
|
||||
|
||||
humidity_callbacks.pdev = pdev;
|
||||
humid_st->callbacks = (struct hid_sensor_hub_callbacks) {
|
||||
.send_event = humidity_proc_event,
|
||||
.capture_sample = humidity_capture_sample,
|
||||
.pdev = pdev,
|
||||
};
|
||||
ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_HUMIDITY,
|
||||
&humidity_callbacks);
|
||||
&humid_st->callbacks);
|
||||
if (ret)
|
||||
goto error_remove_trigger;
|
||||
|
||||
|
||||
@@ -532,22 +532,20 @@ int inv_icm42600_buffer_fifo_parse(struct inv_icm42600_state *st)
|
||||
ts = &gyro_st->ts;
|
||||
inv_sensors_timestamp_interrupt(ts, st->fifo.watermark.eff_gyro,
|
||||
st->timestamp.gyro);
|
||||
ret = inv_icm42600_gyro_parse_fifo(st->indio_gyro);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = inv_icm42600_gyro_parse_fifo(st->indio_gyro);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* handle accelerometer timestamp and FIFO data parsing */
|
||||
if (st->fifo.nb.accel > 0) {
|
||||
ts = &accel_st->ts;
|
||||
inv_sensors_timestamp_interrupt(ts, st->fifo.watermark.eff_accel,
|
||||
st->timestamp.accel);
|
||||
ret = inv_icm42600_accel_parse_fifo(st->indio_accel);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return inv_icm42600_accel_parse_fifo(st->indio_accel);
|
||||
}
|
||||
|
||||
int inv_icm42600_buffer_hwfifo_flush(struct inv_icm42600_state *st,
|
||||
@@ -572,20 +570,18 @@ int inv_icm42600_buffer_hwfifo_flush(struct inv_icm42600_state *st,
|
||||
if (st->fifo.nb.gyro > 0) {
|
||||
ts = &gyro_st->ts;
|
||||
inv_sensors_timestamp_interrupt(ts, st->fifo.nb.gyro, gyro_ts);
|
||||
ret = inv_icm42600_gyro_parse_fifo(st->indio_gyro);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = inv_icm42600_gyro_parse_fifo(st->indio_gyro);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (st->fifo.nb.accel > 0) {
|
||||
ts = &accel_st->ts;
|
||||
inv_sensors_timestamp_interrupt(ts, st->fifo.nb.accel, accel_ts);
|
||||
ret = inv_icm42600_accel_parse_fifo(st->indio_accel);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return inv_icm42600_accel_parse_fifo(st->indio_accel);
|
||||
}
|
||||
|
||||
int inv_icm42600_buffer_init(struct inv_icm42600_state *st)
|
||||
|
||||
@@ -150,7 +150,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
|
||||
.config = &chip_config_6050,
|
||||
.fifo_size = 1024,
|
||||
.temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE},
|
||||
.startup_time = {INV_MPU6050_GYRO_STARTUP_TIME, INV_MPU6050_ACCEL_STARTUP_TIME},
|
||||
.startup_time = {
|
||||
.accel = INV_MPU6050_ACCEL_STARTUP_TIME,
|
||||
.gyro = INV_MPU6050_GYRO_STARTUP_TIME,
|
||||
},
|
||||
},
|
||||
{
|
||||
.whoami = INV_MPU6500_WHOAMI_VALUE,
|
||||
@@ -159,7 +162,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
|
||||
.config = &chip_config_6500,
|
||||
.fifo_size = 512,
|
||||
.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
|
||||
.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
|
||||
.startup_time = {
|
||||
.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
|
||||
.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
|
||||
},
|
||||
},
|
||||
{
|
||||
.whoami = INV_MPU6515_WHOAMI_VALUE,
|
||||
@@ -168,7 +174,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
|
||||
.config = &chip_config_6500,
|
||||
.fifo_size = 512,
|
||||
.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
|
||||
.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
|
||||
.startup_time = {
|
||||
.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
|
||||
.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
|
||||
},
|
||||
},
|
||||
{
|
||||
.whoami = INV_MPU6880_WHOAMI_VALUE,
|
||||
@@ -177,7 +186,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
|
||||
.config = &chip_config_6500,
|
||||
.fifo_size = 4096,
|
||||
.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
|
||||
.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
|
||||
.startup_time = {
|
||||
.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
|
||||
.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
|
||||
},
|
||||
},
|
||||
{
|
||||
.whoami = INV_MPU6000_WHOAMI_VALUE,
|
||||
@@ -186,7 +198,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
|
||||
.config = &chip_config_6050,
|
||||
.fifo_size = 1024,
|
||||
.temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE},
|
||||
.startup_time = {INV_MPU6050_GYRO_STARTUP_TIME, INV_MPU6050_ACCEL_STARTUP_TIME},
|
||||
.startup_time = {
|
||||
.accel = INV_MPU6050_ACCEL_STARTUP_TIME,
|
||||
.gyro = INV_MPU6050_GYRO_STARTUP_TIME,
|
||||
},
|
||||
},
|
||||
{
|
||||
.whoami = INV_MPU9150_WHOAMI_VALUE,
|
||||
@@ -195,7 +210,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
|
||||
.config = &chip_config_6050,
|
||||
.fifo_size = 1024,
|
||||
.temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE},
|
||||
.startup_time = {INV_MPU6050_GYRO_STARTUP_TIME, INV_MPU6050_ACCEL_STARTUP_TIME},
|
||||
.startup_time = {
|
||||
.accel = INV_MPU6050_ACCEL_STARTUP_TIME,
|
||||
.gyro = INV_MPU6050_GYRO_STARTUP_TIME,
|
||||
},
|
||||
},
|
||||
{
|
||||
.whoami = INV_MPU9250_WHOAMI_VALUE,
|
||||
@@ -204,7 +222,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
|
||||
.config = &chip_config_6500,
|
||||
.fifo_size = 512,
|
||||
.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
|
||||
.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
|
||||
.startup_time = {
|
||||
.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
|
||||
.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
|
||||
},
|
||||
},
|
||||
{
|
||||
.whoami = INV_MPU9255_WHOAMI_VALUE,
|
||||
@@ -213,7 +234,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
|
||||
.config = &chip_config_6500,
|
||||
.fifo_size = 512,
|
||||
.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
|
||||
.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
|
||||
.startup_time = {
|
||||
.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
|
||||
.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
|
||||
},
|
||||
},
|
||||
{
|
||||
.whoami = INV_ICM20608_WHOAMI_VALUE,
|
||||
@@ -222,7 +246,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
|
||||
.config = &chip_config_6500,
|
||||
.fifo_size = 512,
|
||||
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
|
||||
.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
|
||||
.startup_time = {
|
||||
.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
|
||||
.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
|
||||
},
|
||||
},
|
||||
{
|
||||
.whoami = INV_ICM20608D_WHOAMI_VALUE,
|
||||
@@ -231,7 +258,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
|
||||
.config = &chip_config_6500,
|
||||
.fifo_size = 512,
|
||||
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
|
||||
.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
|
||||
.startup_time = {
|
||||
.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
|
||||
.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
|
||||
},
|
||||
},
|
||||
{
|
||||
.whoami = INV_ICM20609_WHOAMI_VALUE,
|
||||
@@ -240,7 +270,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
|
||||
.config = &chip_config_6500,
|
||||
.fifo_size = 4 * 1024,
|
||||
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
|
||||
.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
|
||||
.startup_time = {
|
||||
.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
|
||||
.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
|
||||
},
|
||||
},
|
||||
{
|
||||
.whoami = INV_ICM20689_WHOAMI_VALUE,
|
||||
@@ -249,7 +282,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
|
||||
.config = &chip_config_6500,
|
||||
.fifo_size = 4 * 1024,
|
||||
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
|
||||
.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
|
||||
.startup_time = {
|
||||
.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
|
||||
.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
|
||||
},
|
||||
},
|
||||
{
|
||||
.whoami = INV_ICM20600_WHOAMI_VALUE,
|
||||
@@ -258,7 +294,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
|
||||
.config = &chip_config_6500,
|
||||
.fifo_size = 1008,
|
||||
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
|
||||
.startup_time = {INV_ICM20602_GYRO_STARTUP_TIME, INV_ICM20602_ACCEL_STARTUP_TIME},
|
||||
.startup_time = {
|
||||
.accel = INV_ICM20602_ACCEL_STARTUP_TIME,
|
||||
.gyro = INV_ICM20602_GYRO_STARTUP_TIME,
|
||||
},
|
||||
},
|
||||
{
|
||||
.whoami = INV_ICM20602_WHOAMI_VALUE,
|
||||
@@ -267,7 +306,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
|
||||
.config = &chip_config_6500,
|
||||
.fifo_size = 1008,
|
||||
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
|
||||
.startup_time = {INV_ICM20602_GYRO_STARTUP_TIME, INV_ICM20602_ACCEL_STARTUP_TIME},
|
||||
.startup_time = {
|
||||
.accel = INV_ICM20602_ACCEL_STARTUP_TIME,
|
||||
.gyro = INV_ICM20602_GYRO_STARTUP_TIME,
|
||||
},
|
||||
},
|
||||
{
|
||||
.whoami = INV_ICM20690_WHOAMI_VALUE,
|
||||
@@ -276,7 +318,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
|
||||
.config = &chip_config_6500,
|
||||
.fifo_size = 1024,
|
||||
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
|
||||
.startup_time = {INV_ICM20690_GYRO_STARTUP_TIME, INV_ICM20690_ACCEL_STARTUP_TIME},
|
||||
.startup_time = {
|
||||
.accel = INV_ICM20690_ACCEL_STARTUP_TIME,
|
||||
.gyro = INV_ICM20690_GYRO_STARTUP_TIME,
|
||||
},
|
||||
},
|
||||
{ .whoami = INV_IAM20380_WHOAMI_VALUE,
|
||||
.name = "IAM20380",
|
||||
@@ -284,7 +329,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
|
||||
.config = &chip_config_6500,
|
||||
.fifo_size = 512,
|
||||
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
|
||||
.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
|
||||
.startup_time = {
|
||||
.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
|
||||
.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
|
||||
},
|
||||
},
|
||||
{
|
||||
.whoami = INV_IAM20680_WHOAMI_VALUE,
|
||||
@@ -293,7 +341,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
|
||||
.config = &chip_config_6500,
|
||||
.fifo_size = 512,
|
||||
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
|
||||
.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
|
||||
.startup_time = {
|
||||
.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
|
||||
.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
|
||||
},
|
||||
},
|
||||
{
|
||||
.whoami = INV_IAM20680HP_WHOAMI_VALUE,
|
||||
@@ -302,7 +353,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
|
||||
.config = &chip_config_6500,
|
||||
.fifo_size = 4 * 1024,
|
||||
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
|
||||
.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
|
||||
.startup_time = {
|
||||
.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
|
||||
.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
|
||||
},
|
||||
},
|
||||
{
|
||||
.whoami = INV_IAM20680HT_WHOAMI_VALUE,
|
||||
@@ -311,7 +365,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
|
||||
.config = &chip_config_6500,
|
||||
.fifo_size = 4 * 1024,
|
||||
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
|
||||
.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
|
||||
.startup_time = {
|
||||
.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
|
||||
.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1576,6 +1633,8 @@ static const unsigned long inv_mpu_scan_masks[] = {
|
||||
.type = IIO_MAGN, \
|
||||
.modified = 1, \
|
||||
.channel2 = _chan2, \
|
||||
/* index of the axis in magn_raw_to_gauss[] */ \
|
||||
.address = (_chan2) - IIO_MOD_X, \
|
||||
.info_mask_separate = BIT(IIO_CHAN_INFO_SCALE) | \
|
||||
BIT(IIO_CHAN_INFO_RAW), \
|
||||
.scan_index = _index, \
|
||||
|
||||
@@ -939,7 +939,7 @@ static int kmx61_write_event_config(struct iio_dev *indio_dev,
|
||||
struct kmx61_data *data = kmx61_get_data(indio_dev);
|
||||
int ret = 0;
|
||||
|
||||
if (state && data->ev_enable_state)
|
||||
if (state == data->ev_enable_state)
|
||||
return 0;
|
||||
|
||||
guard(mutex)(&data->lock);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <linux/export.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/sprintf.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
/**
|
||||
* iio_read_acpi_mount_matrix() - Read accelerometer mount matrix info from ACPI
|
||||
@@ -63,6 +64,14 @@ bool iio_read_acpi_mount_matrix(struct device *dev,
|
||||
}
|
||||
|
||||
str = elements[i].string.pointer;
|
||||
/*
|
||||
* Microsoft's example separates the values with spaces, "0 1 0".
|
||||
* Some BIOSes use commas instead, with or without spaces around
|
||||
* them: "0, 1, 0", "0, -1 , 0", "1, 0,0". The string lives in
|
||||
* the buffer allocated for us above, so turn the commas into
|
||||
* spaces in place before parsing.
|
||||
*/
|
||||
strreplace(str, ',', ' ');
|
||||
if (sscanf(str, "%d %d %d", &val[0], &val[1], &val[2]) != 3) {
|
||||
dev_err(dev, "Incorrect ACPI mount matrix string format\n");
|
||||
goto out_free_buffer;
|
||||
|
||||
@@ -105,9 +105,8 @@ void iio_trigger_unregister(struct iio_trigger *trig_info)
|
||||
scoped_guard(mutex, &iio_trigger_list_lock)
|
||||
list_del(&trig_info->list);
|
||||
|
||||
ida_free(&iio_trigger_ida, trig_info->id);
|
||||
/* Possible issue in here */
|
||||
device_del(&trig_info->dev);
|
||||
ida_free(&iio_trigger_ida, trig_info->id);
|
||||
}
|
||||
EXPORT_SYMBOL(iio_trigger_unregister);
|
||||
|
||||
@@ -293,6 +292,7 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig,
|
||||
if (pf->irq < 0) {
|
||||
pr_err("Could not find an available irq for trigger %s, CONFIG_IIO_CONSUMERS_PER_TRIGGER=%d limit might be exceeded\n",
|
||||
trig->name, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
|
||||
ret = pf->irq;
|
||||
goto out_put_module;
|
||||
}
|
||||
|
||||
|
||||
@@ -267,7 +267,21 @@ static int als_capture_sample(struct hid_sensor_hub_device *hsdev,
|
||||
struct iio_dev *indio_dev = platform_get_drvdata(priv);
|
||||
struct als_state *als_state = iio_priv(indio_dev);
|
||||
int ret = -EINVAL;
|
||||
u32 sample_data = *(u32 *)raw_data;
|
||||
u32 sample_data;
|
||||
|
||||
switch (raw_len) {
|
||||
case 1:
|
||||
sample_data = *(u8 *)raw_data;
|
||||
break;
|
||||
case 2:
|
||||
sample_data = *(u16 *)raw_data;
|
||||
break;
|
||||
default:
|
||||
if (raw_len < sizeof(u32))
|
||||
return -EINVAL;
|
||||
sample_data = *(u32 *)raw_data;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (usage_id) {
|
||||
case HID_USAGE_SENSOR_LIGHT_ILLUM:
|
||||
|
||||
+22
-10
@@ -16,6 +16,7 @@
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/iopoll.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/math64.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
@@ -362,6 +363,10 @@ static int tsl2591_wait_adc_complete(struct tsl2591_chip *chip)
|
||||
* Scale values to get more representative value of lux i.e.
|
||||
* lux = ((C0DATA - C1DATA) * (1000 - ((C1DATA * 1000) / C0DATA))) / CPL
|
||||
*
|
||||
* CPL is not computed on its own: at 1x gain it is below 1 for integration
|
||||
* times under 500 ms, so the division by LUX DF is folded into the final
|
||||
* division instead.
|
||||
*
|
||||
* Channel 0 = IR + Visible
|
||||
* Channel 1 = IR only
|
||||
*/
|
||||
@@ -373,8 +378,10 @@ static int tsl2591_read_channel_data(struct iio_dev *indio_dev,
|
||||
struct tsl2591_als_settings *settings = &chip->als_settings;
|
||||
struct i2c_client *client = chip->client;
|
||||
u8 als_data[TSL2591_NUM_DATA_REGISTERS];
|
||||
int counts_per_lux, int_time_fval, gain_multi, lux;
|
||||
int int_time_fval, gain_multi;
|
||||
u16 als_ch0, als_ch1;
|
||||
u64 lux;
|
||||
u32 rem;
|
||||
int ret;
|
||||
|
||||
ret = tsl2591_wait_adc_complete(chip);
|
||||
@@ -410,23 +417,28 @@ static int tsl2591_read_channel_data(struct iio_dev *indio_dev,
|
||||
return gain_multi;
|
||||
}
|
||||
|
||||
int_time_fval = TSL2591_FVAL_TO_MSEC(settings->als_int_time);
|
||||
/* Calculate counts per lux value */
|
||||
counts_per_lux = (int_time_fval * gain_multi) / TSL2591_LUX_COEFFICIENT;
|
||||
/* No visible light, this also catches C0DATA == 0 */
|
||||
if (als_ch0 <= als_ch1) {
|
||||
*val = 0;
|
||||
*val2 = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
dev_dbg(&client->dev, "Counts Per Lux: %d\n", counts_per_lux);
|
||||
int_time_fval = TSL2591_FVAL_TO_MSEC(settings->als_int_time);
|
||||
|
||||
/* Calculate lux value */
|
||||
lux = ((als_ch0 - als_ch1) *
|
||||
(1000 - ((als_ch1 * 1000) / als_ch0))) / counts_per_lux;
|
||||
lux = (u64)(als_ch0 - als_ch1) *
|
||||
(1000 - ((als_ch1 * 1000) / als_ch0)) *
|
||||
TSL2591_LUX_COEFFICIENT;
|
||||
lux = div_u64(lux, int_time_fval * gain_multi);
|
||||
|
||||
dev_dbg(&client->dev, "Raw lux calculation: %d\n", lux);
|
||||
dev_dbg(&client->dev, "Raw lux calculation: %llu\n", lux);
|
||||
|
||||
/* Divide by 1000 to get real lux value before scaling */
|
||||
*val = lux / 1000;
|
||||
*val = div_u64_rem(lux, 1000, &rem);
|
||||
|
||||
/* Get the decimal part of lux reading */
|
||||
*val2 = (lux - (*val * 1000)) * 1000;
|
||||
*val2 = rem * 1000;
|
||||
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -44,8 +44,8 @@
|
||||
#define VCNL4035_DEV_ID_MASK GENMASK(7, 0)
|
||||
|
||||
/* Default values */
|
||||
#define VCNL4035_MODE_ALS_ENABLE BIT(0)
|
||||
#define VCNL4035_MODE_ALS_DISABLE 0x00
|
||||
#define VCNL4035_MODE_ALS_ENABLE 0x00
|
||||
#define VCNL4035_MODE_ALS_DISABLE BIT(0)
|
||||
#define VCNL4035_MODE_ALS_INT_ENABLE BIT(1)
|
||||
#define VCNL4035_MODE_ALS_INT_DISABLE 0
|
||||
#define VCNL4035_DEV_ID_VAL 0x80
|
||||
|
||||
@@ -532,14 +532,13 @@ static int mmc35240_resume(struct device *dev)
|
||||
struct mmc35240_data *data = iio_priv(indio_dev);
|
||||
int ret;
|
||||
|
||||
regcache_cache_only(data->regmap, false);
|
||||
regcache_mark_dirty(data->regmap);
|
||||
ret = regcache_sync_region(data->regmap, MMC35240_REG_CTRL0,
|
||||
MMC35240_REG_CTRL1);
|
||||
if (ret < 0)
|
||||
dev_err(dev, "Failed to restore control registers\n");
|
||||
|
||||
regcache_cache_only(data->regmap, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -499,13 +499,12 @@ static int mmc5633_resume(struct device *dev)
|
||||
struct regmap *regmap = dev_get_regmap(dev, NULL);
|
||||
int ret;
|
||||
|
||||
regcache_cache_only(regmap, false);
|
||||
regcache_mark_dirty(regmap);
|
||||
ret = regcache_sync_region(regmap, MMC5633_REG_CTRL0, MMC5633_REG_CTRL1);
|
||||
if (ret)
|
||||
dev_err(dev, "Failed to restore control registers\n");
|
||||
|
||||
regcache_cache_only(regmap, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -299,11 +299,11 @@ static int tlv493d_read_raw(struct iio_dev *indio_dev,
|
||||
switch (chan->type) {
|
||||
case IIO_MAGN:
|
||||
/*
|
||||
* Magnetic field scale: 0.0098 mTesla (i.e. 9.8 µT)
|
||||
* Magnetic field in Gauss: mT * 10 = 0.098.
|
||||
* Magnetic field scale: 0.098 mTesla (i.e. 98 µT) per LSB.
|
||||
* In Gauss (1 mT = 10 G): 0.98 G per LSB.
|
||||
*/
|
||||
*val = 98;
|
||||
*val2 = 1000;
|
||||
*val2 = 100;
|
||||
return IIO_VAL_FRACTIONAL;
|
||||
case IIO_TEMP:
|
||||
/*
|
||||
|
||||
@@ -1133,14 +1133,6 @@ static int hx9023s_probe(struct i2c_client *client)
|
||||
return dev_err_probe(dev, ret, "reg config failed\n");
|
||||
|
||||
if (client->irq) {
|
||||
ret = devm_request_threaded_irq(dev, client->irq,
|
||||
hx9023s_irq_handler,
|
||||
hx9023s_irq_thread_handler,
|
||||
IRQF_ONESHOT,
|
||||
"hx9023s_event", indio_dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
data->trig = devm_iio_trigger_alloc(dev, "%s-dev%d",
|
||||
indio_dev->name,
|
||||
iio_device_id(indio_dev));
|
||||
@@ -1150,6 +1142,14 @@ static int hx9023s_probe(struct i2c_client *client)
|
||||
data->trig->ops = &hx9023s_trigger_ops;
|
||||
iio_trigger_set_drvdata(data->trig, indio_dev);
|
||||
|
||||
ret = devm_request_threaded_irq(dev, client->irq,
|
||||
hx9023s_irq_handler,
|
||||
hx9023s_irq_thread_handler,
|
||||
IRQF_ONESHOT,
|
||||
"hx9023s_event", indio_dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = devm_iio_trigger_register(dev, data->trig);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret,
|
||||
|
||||
@@ -891,7 +891,7 @@ static int sx9310_check_whoami(struct device *dev,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ddata = device_get_match_data(dev);
|
||||
ddata = i2c_get_match_data(data->client);
|
||||
if (ddata->whoami != whoami)
|
||||
return -ENODEV;
|
||||
|
||||
|
||||
@@ -279,11 +279,20 @@ static const struct {
|
||||
{ 0, 250000 }, /* 11111: 4 s */
|
||||
};
|
||||
|
||||
/*
|
||||
* The scan period of the SX9324 is selected by the 5-bit wide
|
||||
* SX9324_REG_GNRL_CTRL0_SCANPERIOD field. The values below are the scan
|
||||
* periods in ms of the corresponding sx9324_samp_freq_table[] entries.
|
||||
*/
|
||||
static const unsigned int sx9324_scan_period_table[] = {
|
||||
2, 15, 30, 45, 60, 90, 120, 200,
|
||||
400, 600, 800, 1000, 2000, 3000, 4000, 5000,
|
||||
1, 2, 4, 6, 8, 10, 14, 18, /* 0x00 - 0x07 */
|
||||
22, 26, 30, 34, 38, 42, 46, 50, /* 0x08 - 0x0f */
|
||||
56, 62, 68, 74, 80, 90, 100, 200, /* 0x10 - 0x17 */
|
||||
300, 400, 600, 800, 1000, 2000, 3000, 4000, /* 0x18 - 0x1f */
|
||||
};
|
||||
|
||||
static_assert(ARRAY_SIZE(sx9324_scan_period_table) == ARRAY_SIZE(sx9324_samp_freq_table));
|
||||
|
||||
static const struct regmap_range sx9324_writable_reg_ranges[] = {
|
||||
/*
|
||||
* To set COMPSTAT for compensation, even if datasheet says register is
|
||||
|
||||
@@ -14,10 +14,12 @@
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/log2.h>
|
||||
#include <linux/math64.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/pm.h>
|
||||
#include <linux/property.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/units.h>
|
||||
|
||||
#include <linux/iio/iio.h>
|
||||
|
||||
@@ -43,6 +45,7 @@
|
||||
#define SX9360_REG_GNRL_CTRL1_SCANPERIOD_MASK GENMASK(2, 0)
|
||||
#define SX9360_REG_GNRL_CTRL2 0x12
|
||||
#define SX9360_REG_GNRL_CTRL2_PERIOD_102MS 0x32
|
||||
#define SX9360_REG_GNRL_SCANPERIOD_MAX GENMASK(10, 0)
|
||||
#define SX9360_REG_GNRL_REG_2_PERIOD_MS(_r) \
|
||||
(((_r) * 8192) / (SX9360_FOSC_HZ / 1000))
|
||||
#define SX9360_REG_GNRL_FREQ_2_REG(_f) (((_f) * 8192) / SX9360_FOSC_HZ)
|
||||
@@ -182,9 +185,9 @@ static const struct {
|
||||
int val;
|
||||
int val2;
|
||||
} sx9360_samp_freq_interval[] = {
|
||||
{ 0, 281250 }, /* 4MHz / (8192 * 2047) */
|
||||
{ 0, 281250 },
|
||||
{ 448, 281250 }, /* 4MHz / 8192 */
|
||||
{ 0, 238535 }, /* 4MHz / (8192 * 2047) */
|
||||
{ 0, 238419 },
|
||||
{ 488, 281250 }, /* 4MHz / 8192 */
|
||||
};
|
||||
|
||||
static const struct regmap_range sx9360_writable_reg_ranges[] = {
|
||||
@@ -383,11 +386,25 @@ static int sx9360_read_avail(struct iio_dev *indio_dev,
|
||||
static int sx9360_set_samp_freq(struct sx_common_data *data,
|
||||
int val, int val2)
|
||||
{
|
||||
int reg;
|
||||
unsigned int period_ticks;
|
||||
u64 freq_uHz;
|
||||
__be16 buf;
|
||||
|
||||
reg = val * 8192 / SX9360_FOSC_HZ + val2 * 8192 / (SX9360_FOSC_MHZ);
|
||||
buf = cpu_to_be16(reg);
|
||||
if (val < 0 || val2 < 0)
|
||||
return -EINVAL;
|
||||
|
||||
freq_uHz = (u64)val * MICROHZ_PER_HZ + val2;
|
||||
if (!freq_uHz)
|
||||
return -EINVAL;
|
||||
|
||||
/* The register holds the scan period in ticks of 8192 FOSC cycles. */
|
||||
period_ticks = DIV64_U64_ROUND_CLOSEST((u64)SX9360_FOSC_HZ * MICROHZ_PER_HZ,
|
||||
freq_uHz * 8192);
|
||||
if (!period_ticks || period_ticks > SX9360_REG_GNRL_SCANPERIOD_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
buf = cpu_to_be16(period_ticks);
|
||||
|
||||
guard(mutex)(&data->mutex);
|
||||
|
||||
return regmap_bulk_write(data->regmap, SX9360_REG_GNRL_CTRL1, &buf,
|
||||
|
||||
@@ -548,6 +548,12 @@ static int sx9500_write_event_config(struct iio_dev *indio_dev,
|
||||
|
||||
mutex_lock(&data->mutex);
|
||||
|
||||
/* The user counts must only change when the state does. */
|
||||
if (data->event_enabled[chan->channel] == state) {
|
||||
ret = 0;
|
||||
goto out_unlock;
|
||||
}
|
||||
|
||||
if (state) {
|
||||
ret = sx9500_inc_chan_users(data, chan->channel);
|
||||
if (ret < 0)
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
struct temperature_state {
|
||||
struct hid_sensor_common common_attributes;
|
||||
struct hid_sensor_hub_attribute_info temperature_attr;
|
||||
struct hid_sensor_hub_callbacks callbacks;
|
||||
struct {
|
||||
s32 temperature_data;
|
||||
aligned_s64 timestamp;
|
||||
@@ -181,11 +182,6 @@ static int temperature_parse_report(struct platform_device *pdev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct hid_sensor_hub_callbacks temperature_callbacks = {
|
||||
.send_event = &temperature_proc_event,
|
||||
.capture_sample = &temperature_capture_sample,
|
||||
};
|
||||
|
||||
/* Function to initialize the processing for usage id */
|
||||
static int hid_temperature_probe(struct platform_device *pdev)
|
||||
{
|
||||
@@ -237,9 +233,13 @@ static int hid_temperature_probe(struct platform_device *pdev)
|
||||
|
||||
platform_set_drvdata(pdev, indio_dev);
|
||||
|
||||
temperature_callbacks.pdev = pdev;
|
||||
temp_st->callbacks = (struct hid_sensor_hub_callbacks) {
|
||||
.send_event = temperature_proc_event,
|
||||
.capture_sample = temperature_capture_sample,
|
||||
.pdev = pdev,
|
||||
};
|
||||
ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_TEMPERATURE,
|
||||
&temperature_callbacks);
|
||||
&temp_st->callbacks);
|
||||
if (ret)
|
||||
goto error_remove_trigger;
|
||||
|
||||
|
||||
@@ -565,7 +565,7 @@ static int mlx90614_probe_num_ir_sensors(struct i2c_client *client)
|
||||
const struct mlx_chip_info *chip_info = data->chip_info;
|
||||
s32 ret;
|
||||
|
||||
if (chip_info->dual_channel)
|
||||
if (!chip_info->dual_channel)
|
||||
return 0;
|
||||
|
||||
ret = i2c_smbus_read_word_data(client, chip_info->op_eeprom_config1);
|
||||
|
||||
@@ -78,7 +78,8 @@ static int bcm_vk_dma_alloc(struct device *dev,
|
||||
dma->nr_pages = (err >= 0) ? err : 0;
|
||||
dev_err(dev, "get_user_pages_fast, err=%d [%d]\n",
|
||||
err, dma->nr_pages);
|
||||
return err < 0 ? err : -EINVAL;
|
||||
err = err < 0 ? err : -EINVAL;
|
||||
goto err_pages;
|
||||
}
|
||||
|
||||
/* Max size of sg list is 1 per mapped page + fields at start */
|
||||
@@ -90,8 +91,10 @@ static int bcm_vk_dma_alloc(struct device *dev,
|
||||
dma->sglen,
|
||||
&dma->handle,
|
||||
GFP_KERNEL);
|
||||
if (!dma->sglist)
|
||||
return -ENOMEM;
|
||||
if (!dma->sglist) {
|
||||
err = -ENOMEM;
|
||||
goto err_pages;
|
||||
}
|
||||
|
||||
dma->sglist[SGLIST_NUM_SG] = 0;
|
||||
dma->sglist[SGLIST_TOTALSIZE] = vkdata->size;
|
||||
@@ -108,8 +111,8 @@ static int bcm_vk_dma_alloc(struct device *dev,
|
||||
dma->direction);
|
||||
transfer_size = size;
|
||||
if (unlikely(dma_mapping_error(dev, sg_addr))) {
|
||||
__free_page(dma->pages[0]);
|
||||
return -EIO;
|
||||
err = -EIO;
|
||||
goto err_sglist;
|
||||
}
|
||||
|
||||
for (i = 1; i < dma->nr_pages; i++) {
|
||||
@@ -121,8 +124,8 @@ static int bcm_vk_dma_alloc(struct device *dev,
|
||||
size,
|
||||
dma->direction);
|
||||
if (unlikely(dma_mapping_error(dev, addr))) {
|
||||
__free_page(dma->pages[i]);
|
||||
return -EIO;
|
||||
err = -EIO;
|
||||
goto err_unmap;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -167,6 +170,32 @@ static int bcm_vk_dma_alloc(struct device *dev,
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
err_unmap:
|
||||
/*
|
||||
* Unmap completed SG entries and the in-progress DMA range,
|
||||
* which has not been written to the SG list yet.
|
||||
*/
|
||||
sgdata = (struct _vk_data *)&dma->sglist[SGLIST_VKDATA_START];
|
||||
for (i = 0; i < dma->sglist[SGLIST_NUM_SG]; i++) {
|
||||
size = sgdata[i].size;
|
||||
addr = get_unaligned(&sgdata[i].address);
|
||||
dma_unmap_page(dev, addr, size, dma->direction);
|
||||
}
|
||||
dma_unmap_page(dev, sg_addr, transfer_size, dma->direction);
|
||||
|
||||
err_sglist:
|
||||
dma_free_coherent(dev, dma->sglen, dma->sglist, dma->handle);
|
||||
|
||||
err_pages:
|
||||
for (i = 0; i < dma->nr_pages; i++)
|
||||
put_page(dma->pages[i]);
|
||||
kfree(dma->pages);
|
||||
dma->pages = NULL;
|
||||
dma->sglist = NULL;
|
||||
dma->sglen = 0;
|
||||
dma->nr_pages = 0;
|
||||
return err;
|
||||
}
|
||||
|
||||
int bcm_vk_sg_alloc(struct device *dev,
|
||||
|
||||
@@ -2366,14 +2366,6 @@ static int __init ibmvmc_module_init(void)
|
||||
ibmvmc.state = ibmvmc_state_initial;
|
||||
pr_info("ibmvmc: version %s\n", IBMVMC_DRIVER_VERSION);
|
||||
|
||||
rc = misc_register(&ibmvmc_miscdev);
|
||||
if (rc) {
|
||||
pr_err("ibmvmc: misc registration failed\n");
|
||||
goto misc_register_failed;
|
||||
}
|
||||
pr_info("ibmvmc: node %d:%d\n", MISC_MAJOR,
|
||||
ibmvmc_miscdev.minor);
|
||||
|
||||
/* Initialize data structures */
|
||||
memset(hmcs, 0, sizeof(struct ibmvmc_hmc) * MAX_HMCS);
|
||||
for (i = 0; i < MAX_HMCS; i++) {
|
||||
@@ -2383,6 +2375,14 @@ static int __init ibmvmc_module_init(void)
|
||||
hmcs[i].queue_outbound_msgs[j] = VMC_INVALID_BUFFER_ID;
|
||||
}
|
||||
|
||||
rc = misc_register(&ibmvmc_miscdev);
|
||||
if (rc) {
|
||||
pr_err("ibmvmc: misc registration failed\n");
|
||||
goto misc_register_failed;
|
||||
}
|
||||
pr_info("ibmvmc: node %d:%d\n", MISC_MAJOR,
|
||||
ibmvmc_miscdev.minor);
|
||||
|
||||
/* Sanity check module parms */
|
||||
ibmvmc_scrub_module_parms();
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@
|
||||
#define PCI_DEVICE_ID_INTEL_MEI_CDF 0x18D3 /* Cedar Fork */
|
||||
|
||||
#define PCI_DEVICE_ID_INTEL_MEI_ICP_LP 0x34E0 /* Ice Lake Point LP */
|
||||
#define PCI_DEVICE_ID_INTEL_MEI_ICP_LP_3 0x34E4 /* Ice Lake Point LP 3 (iTouch) */
|
||||
#define PCI_DEVICE_ID_INTEL_MEI_ICP_N 0x38E0 /* Ice Lake Point N */
|
||||
|
||||
#define PCI_DEVICE_ID_INTEL_MEI_JSP_N 0x4DE0 /* Jasper Lake Point N */
|
||||
|
||||
@@ -312,16 +312,24 @@ static int mei_lb_push_payload_v2(struct device *dev, struct mei_cl_device *clde
|
||||
size_t chunk_size;
|
||||
size_t req_size;
|
||||
ssize_t bytes;
|
||||
size_t mtu;
|
||||
int ret;
|
||||
|
||||
struct mei_lb2_req *req __free(kfree) = kzalloc(mei_cldev_mtu(cldev), GFP_KERNEL);
|
||||
/* The MTU turns into 0 when a link reset disconnects the client */
|
||||
mtu = mei_cldev_mtu(cldev);
|
||||
if (mtu <= sizeof(struct mei_lb2_req)) {
|
||||
dev_err(dev, "MTU is too small: %zu\n", mtu);
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
|
||||
struct mei_lb2_req *req __free(kfree) = kzalloc(mtu, GFP_KERNEL);
|
||||
if (!req)
|
||||
return -ENOMEM;
|
||||
|
||||
first_chunk = MEI_LB2_FLAG_FST_CHUNK;
|
||||
last_chunk = 0;
|
||||
do {
|
||||
chunk_size = min(payload_size - sent_data, mei_cldev_mtu(cldev) - sizeof(*req));
|
||||
chunk_size = min(payload_size - sent_data, mtu - sizeof(*req));
|
||||
|
||||
req_size = struct_size(req, payload, chunk_size);
|
||||
if (sent_data + chunk_size == payload_size)
|
||||
|
||||
@@ -98,6 +98,7 @@ static const struct pci_device_id mei_me_pci_tbl[] = {
|
||||
{ PCI_DEVICE_DATA(INTEL, MEI_CMP_H_3, MEI_ME_PCH8_ITOUCH_CFG) },
|
||||
|
||||
{ PCI_DEVICE_DATA(INTEL, MEI_ICP_LP, MEI_ME_PCH12_CFG) },
|
||||
{ PCI_DEVICE_DATA(INTEL, MEI_ICP_LP_3, MEI_ME_PCH12_SPS_ITOUCH_CFG) },
|
||||
{ PCI_DEVICE_DATA(INTEL, MEI_ICP_N, MEI_ME_PCH12_CFG) },
|
||||
|
||||
{ PCI_DEVICE_DATA(INTEL, MEI_TGP_LP, MEI_ME_PCH15_CFG) },
|
||||
|
||||
@@ -213,7 +213,12 @@ int vmci_event_unsubscribe(u32 sub_id)
|
||||
if (!s)
|
||||
return VMCI_ERROR_NOT_FOUND;
|
||||
|
||||
kvfree_rcu_mightsleep(s);
|
||||
/*
|
||||
* Wait for event_deliver(): the caller is going to free what the
|
||||
* callback works on.
|
||||
*/
|
||||
synchronize_rcu();
|
||||
kfree(s);
|
||||
|
||||
return VMCI_SUCCESS;
|
||||
}
|
||||
|
||||
+21
-15
@@ -103,6 +103,7 @@ struct ds2482_data;
|
||||
struct ds2482_w1_chan {
|
||||
struct ds2482_data *pdev;
|
||||
u8 channel;
|
||||
bool spu; /* strong pullup after the next byte */
|
||||
struct w1_bus_master w1_bm;
|
||||
};
|
||||
|
||||
@@ -336,6 +337,19 @@ static void ds2482_w1_write_byte(void *data, u8 byte)
|
||||
if (pdev->w1_count > 1)
|
||||
ds2482_set_channel(pdev, pchan->channel);
|
||||
|
||||
if (pchan->spu) {
|
||||
pchan->spu = false;
|
||||
/* the wait above and this one are crucial, otherwise devices
|
||||
* might not be powered long enough, causing e.g. a w1_therm
|
||||
* sensor to provide wrong conversion results
|
||||
*/
|
||||
/* note: it seems like both SPU and APU have to be set! */
|
||||
ds2482_send_cmd_data(pdev, DS2482_CMD_WRITE_CONFIG,
|
||||
ds2482_calculate_config(DS2482_REG_CFG_SPU |
|
||||
DS2482_REG_CFG_APU));
|
||||
ds2482_wait_1wire_idle(pdev);
|
||||
}
|
||||
|
||||
/* Send the write byte command */
|
||||
ds2482_send_cmd_data(pdev, DS2482_CMD_1WIRE_WRITE_BYTE, byte);
|
||||
|
||||
@@ -420,27 +434,19 @@ static u8 ds2482_w1_reset_bus(void *data)
|
||||
static u8 ds2482_w1_set_pullup(void *data, int delay)
|
||||
{
|
||||
struct ds2482_w1_chan *pchan = data;
|
||||
struct ds2482_data *pdev = pchan->pdev;
|
||||
u8 retval = 1;
|
||||
|
||||
/* if delay is non-zero activate the pullup,
|
||||
* the strong pullup will be automatically deactivated
|
||||
* by the master, so do not explicitly deactive it
|
||||
*
|
||||
* The setting is used up by the next byte on any channel of the chip:
|
||||
* ds2482_w1_write_byte() makes it, in one go with the byte.
|
||||
*/
|
||||
if (delay) {
|
||||
/* both waits are crucial, otherwise devices might not be
|
||||
* powered long enough, causing e.g. a w1_therm sensor to
|
||||
* provide wrong conversion results
|
||||
*/
|
||||
ds2482_wait_1wire_idle(pdev);
|
||||
/* note: it seems like both SPU and APU have to be set! */
|
||||
retval = ds2482_send_cmd_data(pdev, DS2482_CMD_WRITE_CONFIG,
|
||||
ds2482_calculate_config(DS2482_REG_CFG_SPU |
|
||||
DS2482_REG_CFG_APU));
|
||||
ds2482_wait_1wire_idle(pdev);
|
||||
}
|
||||
if (!delay)
|
||||
return 1;
|
||||
|
||||
return retval;
|
||||
pchan->spu = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ static ssize_t w1_f0d_read_bin(struct file *filp, struct kobject *kobj,
|
||||
if (count == 0)
|
||||
return 0;
|
||||
|
||||
mutex_lock(&sl->master->mutex);
|
||||
mutex_lock(&sl->master->bus_mutex);
|
||||
|
||||
/* read directly from the EEPROM in chunks of W1_F0D_READ_MAXLEN */
|
||||
while (todo > 0) {
|
||||
@@ -123,7 +123,7 @@ static ssize_t w1_f0d_read_bin(struct file *filp, struct kobject *kobj,
|
||||
off += W1_F0D_READ_MAXLEN;
|
||||
}
|
||||
|
||||
mutex_unlock(&sl->master->mutex);
|
||||
mutex_unlock(&sl->master->bus_mutex);
|
||||
|
||||
return count;
|
||||
}
|
||||
@@ -211,7 +211,7 @@ static ssize_t w1_f0d_write_bin(struct file *filp, struct kobject *kobj,
|
||||
if (count == 0)
|
||||
return 0;
|
||||
|
||||
mutex_lock(&sl->master->mutex);
|
||||
mutex_lock(&sl->master->bus_mutex);
|
||||
|
||||
/* Can only write data in blocks of the size of the scratchpad */
|
||||
addr = off;
|
||||
@@ -256,7 +256,7 @@ static ssize_t w1_f0d_write_bin(struct file *filp, struct kobject *kobj,
|
||||
}
|
||||
|
||||
out_up:
|
||||
mutex_unlock(&sl->master->mutex);
|
||||
mutex_unlock(&sl->master->bus_mutex);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ static ssize_t eeprom_read(struct file *filp, struct kobject *kobj,
|
||||
if (count == 0)
|
||||
return 0;
|
||||
|
||||
mutex_lock(&sl->master->mutex);
|
||||
mutex_lock(&sl->master->bus_mutex);
|
||||
|
||||
if (w1_enable_crccheck) {
|
||||
min_page = (off >> W1_PAGE_BITS);
|
||||
@@ -140,7 +140,7 @@ static ssize_t eeprom_read(struct file *filp, struct kobject *kobj,
|
||||
}
|
||||
|
||||
out_up:
|
||||
mutex_unlock(&sl->master->mutex);
|
||||
mutex_unlock(&sl->master->bus_mutex);
|
||||
|
||||
return count;
|
||||
}
|
||||
@@ -253,7 +253,7 @@ static ssize_t eeprom_write(struct file *filp, struct kobject *kobj,
|
||||
}
|
||||
}
|
||||
|
||||
mutex_lock(&sl->master->mutex);
|
||||
mutex_lock(&sl->master->bus_mutex);
|
||||
|
||||
/* Can only write data to one page at a time */
|
||||
idx = 0;
|
||||
@@ -271,7 +271,7 @@ static ssize_t eeprom_write(struct file *filp, struct kobject *kobj,
|
||||
}
|
||||
|
||||
out_up:
|
||||
mutex_unlock(&sl->master->mutex);
|
||||
mutex_unlock(&sl->master->bus_mutex);
|
||||
|
||||
return count;
|
||||
}
|
||||
@@ -290,9 +290,9 @@ static ssize_t pio_read(struct file *filp, struct kobject *kobj,
|
||||
if (off != 0 || count != 1 || buf == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&sl->master->mutex);
|
||||
mutex_lock(&sl->master->bus_mutex);
|
||||
ret = w1_f1C_read(sl, W1_1C_REG_LOGIC_STATE, count, buf);
|
||||
mutex_unlock(&sl->master->mutex);
|
||||
mutex_unlock(&sl->master->bus_mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -310,11 +310,11 @@ static ssize_t pio_write(struct file *filp, struct kobject *kobj,
|
||||
if (off != 0 || count != 1 || buf == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&sl->master->mutex);
|
||||
mutex_lock(&sl->master->bus_mutex);
|
||||
|
||||
/* Write the PIO data */
|
||||
if (w1_reset_select_slave(sl)) {
|
||||
mutex_unlock(&sl->master->mutex);
|
||||
mutex_unlock(&sl->master->bus_mutex);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ static ssize_t pio_write(struct file *filp, struct kobject *kobj,
|
||||
|
||||
w1_read_block(sl->master, &ack, sizeof(ack));
|
||||
|
||||
mutex_unlock(&sl->master->mutex);
|
||||
mutex_unlock(&sl->master->bus_mutex);
|
||||
|
||||
/* check for acknowledgement */
|
||||
if (ack != 0xAA)
|
||||
|
||||
@@ -906,6 +906,19 @@ static inline bool bulk_read_support(struct w1_slave *sl)
|
||||
return false; /* No device family */
|
||||
}
|
||||
|
||||
/**
|
||||
* bulk_read_slave() - check if a slave of the bus takes part in a bulk read
|
||||
* @sl: any slave on the list of the master
|
||||
*
|
||||
* The family data of the slaves of other families is none of our business.
|
||||
*
|
||||
* Return: true if it is one of our devices and supports bulk read
|
||||
*/
|
||||
static bool bulk_read_slave(struct w1_slave *sl)
|
||||
{
|
||||
return device_family(sl) && sl->family_data && bulk_read_support(sl);
|
||||
}
|
||||
|
||||
/**
|
||||
* conversion_time() - get the Tconv for the slave
|
||||
* @sl: device to get the conversion time
|
||||
@@ -1495,10 +1508,9 @@ static int trigger_bulk_read(struct w1_master *dev_master)
|
||||
* and compute duration of conversion for these devices
|
||||
* so we can apply a strong pullup if required
|
||||
*/
|
||||
mutex_lock(&dev_master->list_mutex);
|
||||
list_for_each_entry(sl, &dev_master->slist, w1_slave_entry) {
|
||||
if (!sl->family_data)
|
||||
goto error;
|
||||
if (bulk_read_support(sl)) {
|
||||
if (bulk_read_slave(sl)) {
|
||||
int t_cur = conversion_time(sl);
|
||||
|
||||
t_conv = max(t_cur, t_conv);
|
||||
@@ -1508,6 +1520,7 @@ static int trigger_bulk_read(struct w1_master *dev_master)
|
||||
w1_strong_pullup));
|
||||
}
|
||||
}
|
||||
mutex_unlock(&dev_master->list_mutex);
|
||||
|
||||
/*
|
||||
* t_conv is the max conversion time required on the bus
|
||||
@@ -1534,11 +1547,13 @@ static int trigger_bulk_read(struct w1_master *dev_master)
|
||||
w1_write_8(dev_master, W1_CONVERT_TEMP);
|
||||
|
||||
/* set a flag to instruct that converT pending */
|
||||
mutex_lock(&dev_master->list_mutex);
|
||||
list_for_each_entry(sl,
|
||||
&dev_master->slist, w1_slave_entry) {
|
||||
if (bulk_read_support(sl))
|
||||
if (bulk_read_slave(sl))
|
||||
SLAVE_CONVERT_TRIGGERED(sl) = -1;
|
||||
}
|
||||
mutex_unlock(&dev_master->list_mutex);
|
||||
|
||||
if (strong_pullup) { /* some device need pullup */
|
||||
sleep_rem = msleep_interruptible(t_conv);
|
||||
@@ -1564,10 +1579,12 @@ mt_unlock:
|
||||
mutex_unlock(&dev_master->bus_mutex);
|
||||
set_flag:
|
||||
/* set a flag to register convsersion is done */
|
||||
mutex_lock(&dev_master->list_mutex);
|
||||
list_for_each_entry(sl, &dev_master->slist, w1_slave_entry) {
|
||||
if (bulk_read_support(sl))
|
||||
if (bulk_read_slave(sl))
|
||||
SLAVE_CONVERT_TRIGGERED(sl) = 1;
|
||||
}
|
||||
mutex_unlock(&dev_master->list_mutex);
|
||||
error:
|
||||
return ret;
|
||||
}
|
||||
@@ -1932,20 +1949,20 @@ static ssize_t therm_bulk_read_show(struct device *device,
|
||||
struct w1_slave *sl = NULL;
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&dev_master->list_mutex);
|
||||
list_for_each_entry(sl, &dev_master->slist, w1_slave_entry) {
|
||||
if (sl->family_data) {
|
||||
if (bulk_read_support(sl)) {
|
||||
if (SLAVE_CONVERT_TRIGGERED(sl) == -1) {
|
||||
ret = -1;
|
||||
goto show_result;
|
||||
}
|
||||
if (SLAVE_CONVERT_TRIGGERED(sl) == 1)
|
||||
/* continue to check other slaves */
|
||||
ret = 1;
|
||||
if (bulk_read_slave(sl)) {
|
||||
if (SLAVE_CONVERT_TRIGGERED(sl) == -1) {
|
||||
ret = -1;
|
||||
goto show_result;
|
||||
}
|
||||
if (SLAVE_CONVERT_TRIGGERED(sl) == 1)
|
||||
/* continue to check other slaves */
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
show_result:
|
||||
mutex_unlock(&dev_master->list_mutex);
|
||||
return sprintf(buf, "%d\n", ret);
|
||||
}
|
||||
|
||||
|
||||
+14
-7
@@ -116,7 +116,7 @@ static ssize_t rw_write(struct file *filp, struct kobject *kobj,
|
||||
{
|
||||
struct w1_slave *sl = kobj_to_w1_slave(kobj);
|
||||
|
||||
mutex_lock(&sl->master->mutex);
|
||||
mutex_lock(&sl->master->bus_mutex);
|
||||
if (w1_reset_select_slave(sl)) {
|
||||
count = 0;
|
||||
goto out_up;
|
||||
@@ -125,7 +125,7 @@ static ssize_t rw_write(struct file *filp, struct kobject *kobj,
|
||||
w1_write_block(sl->master, buf, count);
|
||||
|
||||
out_up:
|
||||
mutex_unlock(&sl->master->mutex);
|
||||
mutex_unlock(&sl->master->bus_mutex);
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -135,9 +135,9 @@ static ssize_t rw_read(struct file *filp, struct kobject *kobj,
|
||||
{
|
||||
struct w1_slave *sl = kobj_to_w1_slave(kobj);
|
||||
|
||||
mutex_lock(&sl->master->mutex);
|
||||
mutex_lock(&sl->master->bus_mutex);
|
||||
w1_read_block(sl->master, buf, count);
|
||||
mutex_unlock(&sl->master->mutex);
|
||||
mutex_unlock(&sl->master->bus_mutex);
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -781,16 +781,24 @@ int w1_unref_slave(struct w1_slave *sl)
|
||||
{
|
||||
struct w1_master *dev = sl->master;
|
||||
int refcnt;
|
||||
|
||||
/*
|
||||
* Once it is off the list nobody can find the slave and take a new
|
||||
* reference. The lock must not be held any longer than that: the rest
|
||||
* waits for sysfs callbacks and for users of the family data.
|
||||
*/
|
||||
mutex_lock(&dev->list_mutex);
|
||||
refcnt = atomic_sub_return(1, &sl->refcnt);
|
||||
if (refcnt == 0)
|
||||
list_del(&sl->w1_slave_entry);
|
||||
mutex_unlock(&dev->list_mutex);
|
||||
|
||||
if (refcnt == 0) {
|
||||
struct w1_netlink_msg msg;
|
||||
|
||||
dev_dbg(&sl->dev, "%s: detaching %s [%p].\n", __func__,
|
||||
sl->name, sl);
|
||||
|
||||
list_del(&sl->w1_slave_entry);
|
||||
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
memcpy(msg.id.id, &sl->reg_num, sizeof(msg.id));
|
||||
msg.type = W1_SLAVE_REMOVE;
|
||||
@@ -804,7 +812,6 @@ int w1_unref_slave(struct w1_slave *sl)
|
||||
kfree(sl);
|
||||
}
|
||||
atomic_dec(&dev->refcnt);
|
||||
mutex_unlock(&dev->list_mutex);
|
||||
return refcnt;
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -176,6 +176,13 @@ void __w1_remove_master_device(struct w1_master *dev)
|
||||
mutex_unlock(&w1_mlock);
|
||||
|
||||
set_bit(W1_ABORT_SEARCH, &dev->flags);
|
||||
|
||||
/*
|
||||
* This waits for the callbacks, which take the locks below. One of
|
||||
* them wakes the thread up.
|
||||
*/
|
||||
w1_destroy_master_attributes(dev);
|
||||
|
||||
kthread_stop(dev->thread);
|
||||
|
||||
mutex_lock(&dev->mutex);
|
||||
@@ -185,7 +192,6 @@ void __w1_remove_master_device(struct w1_master *dev)
|
||||
w1_slave_detach(sl);
|
||||
mutex_lock(&dev->list_mutex);
|
||||
}
|
||||
w1_destroy_master_attributes(dev);
|
||||
mutex_unlock(&dev->list_mutex);
|
||||
mutex_unlock(&dev->mutex);
|
||||
atomic_dec(&dev->refcnt);
|
||||
|
||||
@@ -478,15 +478,17 @@ static void w1_process_cb(struct w1_master *dev, struct w1_async_cmd *async_cmd)
|
||||
if (!cmd || err)
|
||||
w1_netlink_queue_status(node->block, node->msg, cmd, err);
|
||||
|
||||
dev->priv = NULL;
|
||||
mutex_unlock(&dev->bus_mutex);
|
||||
|
||||
/* ref taken in w1_search_slave or w1_search_master_id when building
|
||||
* the block
|
||||
* the block. If it is the last one, the slave is removed, which waits
|
||||
* for users of the bus.
|
||||
*/
|
||||
if (sl)
|
||||
w1_unref_slave(sl);
|
||||
else
|
||||
atomic_dec(&dev->refcnt);
|
||||
dev->priv = NULL;
|
||||
mutex_unlock(&dev->bus_mutex);
|
||||
|
||||
mutex_lock(&dev->list_mutex);
|
||||
list_del(&async_cmd->async_entry);
|
||||
|
||||
@@ -66,6 +66,7 @@ struct inv_sensors_timestamp {
|
||||
u32 new_mult;
|
||||
u32 period;
|
||||
struct inv_sensors_timestamp_acc chip_period;
|
||||
bool init;
|
||||
};
|
||||
|
||||
void inv_sensors_timestamp_init(struct inv_sensors_timestamp *ts,
|
||||
@@ -94,7 +95,7 @@ static inline void inv_sensors_timestamp_reset(struct inv_sensors_timestamp *ts)
|
||||
ts->it = interval_init;
|
||||
ts->delta = interval_init;
|
||||
ts->delta_counter = 0;
|
||||
ts->timestamp = 0;
|
||||
ts->init = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user