ev)
> {
> struct sunxi_gpadc_dev *info;
> @@ -286,16 +401,20 @@ static int sunxi_gpadc_probe(struct platform_device
> *pdev)
> info = iio_priv(indio_dev);
>
> info->regmap = sunxi_gpadc_mfd_dev->regmap;
> + info->indio_dev = indio_dev;
> init_completion(&info->completion);
> indio_dev->name = dev_name(&pdev->dev);
> indio_dev->dev.parent = &pdev->dev;
> indio_dev->dev.of_node = pdev->dev.of_node;
> indio_dev->info = &sunxi_gpadc_iio_info;
> - indio_dev->modes = INDIO_DIRECT_MODE;
> + indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE;
> indio_dev->num_channels = ARRAY_SIZE(sunxi_gpadc_channels);
> indio_dev->channels = sunxi_gpadc_channels;
> + indio_dev->setup_ops = &sunxi_gpadc_buffer_setup_ops;
>
> info->flags = platform_get_device_id(pdev)->driver_data;
> + info->ts_attached = of_property_read_bool(pdev->dev.parent->of_node,
> + "allwinner,ts-attached");
>
> regmap_write(info->regmap, SUNXI_GPADC_TP_CTRL0, SUNXI_GPADC_FS_DIV(7) |
>SUNXI_GPADC_ADC_CLK_DIVIDER(2) | SUNXI_GPADC_T_ACQ(63));
> @@ -305,6 +424,8 @@ static int sunxi_gpadc_probe(struct platform_device *pdev)
> else
> regmap_write(info->regmap, SUNXI_GPADC_TP_CTRL1,
>SUNXI_GPADC_TP_MODE_EN);
> + regmap_write(info->regmap, SUNXI_GPADC_TP_CTRL2,
> + SUNXI_GPADC_TP_SENSITIVE_ADJUST(15));
> regmap_write(info->regmap, SUNXI_GPADC_TP_CTRL3, SUNXI_GPADC_FILTER_EN |
>SUNXI_GPADC_FILTER_TYPE(1));
> regmap_write(info->regmap, SUNXI_GPADC_TP_TPR,
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
,
> + &hdc_buffer_setup_ops);
> + if (ret < 0) {
> + dev_err(&client->dev, "iio triggered buffer setup failed\n");
> + return ret;
> + }
> + ret = iio_device_register(indio_dev);
> + if (ret < 0)
> + iio_triggered_buffer_cleanup(indio_dev);
> +
> + return ret;
> +}
> +
> +static int hdc100x_remove(struct i2c_client *client)
> +{
> + struct iio_dev *indio_dev = i2c_get_clientdata(client);
> +
> + iio_device_unregister(indio_dev);
> + iio_triggered_buffer_cleanup(indio_dev);
>
> - return devm_iio_device_register(&client->dev, indio_dev);
> + return 0;
> }
>
> static const struct i2c_device_id hdc100x_id[] = {
> @@ -311,6 +442,7 @@ static struct i2c_driver hdc100x_driver = {
> .name = "hdc100x",
> },
> .probe = hdc100x_probe,
> + .remove = hdc100x_remove,
> .id_table = hdc100x_id,
> };
> module_i2c_driver(hdc100x_driver);
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
it in linux.
> >
> > https://git.kernel.org/cgit/linux/kernel/git/jic23/iio.git/log/?h=testing
>
> Means we have to do development here and this testing branch will get
> merged to main branch later.
yes, Jonathan will queue up stuff in testing, then send to GregHK, and
then to mainline
p.
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
dmard06);
> + if (error)
> + return error;
> +
> + i2c_set_clientdata(client, indio_dev);
> + indio_dev->dev.parent = &client->dev;
> + indio_dev->name = DMARD06_DRV_NAME;
> + indio_dev->modes = INDIO_DIRECT_MODE;
> + indio_dev->channels = dmard06_channels;
> + indio_dev->num_channels = ARRAY_SIZE(dmard06_channels);
> + indio_dev->info = &dmard06_info;
> +
> + return devm_iio_device_register(&client->dev, indio_dev);
> +}
> +
> +static const struct i2c_device_id dmard06_id[] = {
> + { "dmard06", 0 },
> + { }
> +};
> +MODULE_DEVICE_TABLE(i2c, dmard06_id);
> +
> +static const struct of_device_id dmard06_of_match[] = {
> + { .compatible = "domintech,dmard06" },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, dmard06_of_match);
> +
> +static struct i2c_driver dmard06_driver = {
> + .probe = dmard06_probe,
> + .id_table = dmard06_id,
> + .driver = {
> + .name = DMARD06_DRV_NAME,
> + .of_match_table = of_match_ptr(dmard06_of_match),
> + },
> +};
> +module_i2c_driver(dmard06_driver);
> +
> +MODULE_AUTHOR("Aleksei Mamlin ");
> +MODULE_DESCRIPTION("Domintech DMARD06 accelerometer driver");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
== 1) err =
> > +i2c_master_recv(client, rx_buf, 2);
>
> This is not thread safe. Another thread could interrupt between
> i2c_master_send() and i2c_master_recv() and cause undefined behavior. Use
> i2c_smbus_read_word_swapped() which makes sure that the I2C communication
> happens atomically.
>
> > +if (err == 2) {
> > +*reg_val = rx_buf[0];
> > +*reg_val = *reg_val << 8;
> > +*reg_val = *reg_val | rx_buf[1];
> > +}
> > +return err;
> > +} else {
> > +return -EINVAL;
> > +}
> > +}
> [...]
> > +
> > +static irqreturn_t alert_isr(int irq, void *dev_id) {
> > +dev_warn(dev_id, "Temperature outside of limits!");
>
> Please use IIO threshold events for this. Such out-of-band communication is
> really not acceptable.
>
> > +return IRQ_HANDLED;
> > +}
> > +
> > +static int setupIRQ(struct iio_dev *indio_dev, bool set_gpio, u8 pol)
> > +{ int err; struct as6200_data *data = iio_priv(indio_dev); struct
> > +device *dev = &data->client->dev; int gpio = -1; int irq_num; int
> > +irq_trig;
> > +
> > +if (pol == 1)
> > +irq_trig = IRQF_TRIGGER_RISING;
> > +else
> > +irq_trig = IRQF_TRIGGER_FALLING;
> > +
> > +if (set_gpio) {
> > +gpio = of_get_named_gpio_flags(dev->of_node,
> > +"as6200,irq-gpio", 0, 0);
> > +err = gpio_request(gpio, "as6200_irq"); if (err) { dev_info(dev, "%s:
> > +requesting gpio %d failed\n", as6200_id[0].name, gpio); return err; }
> > +err = gpio_direction_input(gpio); if (err) { dev_info(dev, "%s: gpio
> > +%d cannot apply direction\n", as6200_id[0].name, gpio); return err; }
> > +} irq_num = gpio_to_irq(gpio); dev_info(dev, "%s: registering for IRQ
> > +%d\n", as6200_id[0].name, irq_num);
>
> Please drop all these dev_info(). That's just noise in the boot log, imagine
> every driver did this you wouldn't be able to spot the critical information.
>
> > +err = request_irq(irq_num, alert_isr, irq_trig, as6200_id[0].name,
> > +dev);
>
> Don't do all the GPIO translation. This pin is only used as a interrupt, so
> specify it directly as an interrupt and use it that way as well.
>
> > +if (err) {
> > +dev_info(dev, "%s: error requesting irq %d\n", as6200_id[0].name,
> > +err);
>
> For errors use dev_err. Also the as6200_id[0].name is redundant since
> dev_info/dev_err already prefixes the message with the device name.
>
> > +return err;
> > +}
> > +dev_info(dev, "%s: registered for IRQ %d\n", as6200_id[0].name,
> > +irq_num); mutex_lock(&data->update_lock);
> > +data->irqn = irq_num;
> > +mutex_unlock(&data->update_lock);
>
> What exactly is protect by that mutex here?
>
> > +
> > +return 0;
> > +}
> > +
> [...]
> > +if (err == 0) {
> > +if ((val < -40) | (val > 150)) {
> > +dev_info(&client->dev,
> > +"Value for THIGH is invalid min = -40%cC, max = 150°C, val = %d°C",
> > +(unsigned char)(248), val);
>
> Please no out-of-band error reporting.
>
> > +return count;
> > +}
> > +val = (val * 1) / 625;
> > +reg_val = val << 4;
> [...]
> > +static int as6200_probe(struct i2c_client *client, const struct
> > +i2c_device_id *id) { struct iio_dev *indio_dev = NULL; struct
> > +as6200_data *data = NULL;
>
> No need to initialize those here with dummy, this will just hide warnings in
> case you forgot to initialize them with actual data.
>
> > +
> > +indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
> > +
> > +if (!indio_dev)
> > +return -ENOMEM;
> > +
> > +data = iio_priv(indio_dev);
> > +i2c_set_clientdata(client, indio_dev);
> > +data->client = client;
> > +
> > +indio_dev->dev.parent = &client->dev; indio_dev->name =
> > +dev_name(&client->dev);
>
> use id->name for this. dev_name() contains things like the I2C bus and device
> address, etc. Whereas the IIO device name should describe the type of device.
>
> > +indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &as6200_info;
> > +
> > +indio_dev->channels = as6200_channels; indio_dev->num_channels =
> > +ARRAY_SIZE(as6200_channels);
> > +
> > +initClientData(data);
> > +mutex_init(&data->update_lock);
> > +setupIRQ(indio_dev, true, 0);
> > +
> > +return iio_device_register(indio_dev);
>
> Error handling is missing here, you need to free the resources that were
> acquired in case of an error.
>
> > +}
> > +
> [...]
>
>
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
ev->dev, "no reset control found\n");
> + info->reset = NULL;
> + }
> +
> init_completion(&info->completion);
>
> irq = platform_get_irq(pdev, 0);
> @@ -252,6 +279,9 @@ static int rockchip_saradc_probe(struct platform_device
> *pdev)
> return PTR_ERR(info->vref);
> }
>
> + if (info->reset)
> + rockchip_saradc_reset_controller(info->reset);
> +
> /*
>* Use a default value for the converter clock.
>* This may become user-configurable in the future.
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
&iio_dev_attr_pol.dev_attr.attr,
> + &iio_dev_attr_cf.dev_attr.attr,
> + &iio_dev_attr_ss.dev_attr.attr,
> + &iio_const_attr_sampling_frequency_available.dev_attr.attr,
> + NULL,
> +};
> +
> +static struct attribute_group as6200_attr_group = {
> + .attrs = as620
; + .type = IIO_TEMP,
> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> + BIT(IIO_CHAN_INFO_PROCESSED) |
> + BIT(IIO_CHAN_INFO_SCALE),
> + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> +
+module_init(uleds_init);
> +
> +static void __exit uleds_exit(void)
> +{
> + misc_deregister(&uleds_misc);
> +}
> +module_exit(uleds_exit);
> +
> +MODULE_AUTHOR("David Lechner ");
> +MODULE_DESCRIPTION("Userspace driver for leds subsystem");
> +MODULE_LICENSE("GPL");
> diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
> index 185f8ea..416f5e6 100644
> --- a/include/uapi/linux/Kbuild
> +++ b/include/uapi/linux/Kbuild
> @@ -421,6 +421,7 @@ header-y += udp.h
> header-y += uhid.h
> header-y += uinput.h
> header-y += uio.h
> +header-y += uleds.h
> header-y += ultrasound.h
> header-y += un.h
> header-y += unistd.h
> diff --git a/include/uapi/linux/uleds.h b/include/uapi/linux/uleds.h
> new file mode 100644
> index 000..e78ed46
> --- /dev/null
> +++ b/include/uapi/linux/uleds.h
> @@ -0,0 +1,23 @@
> +/*
> + * Userspace driver support for leds subsystem
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +#ifndef _UAPI__ULEDS_H_
> +#define _UAPI__ULEDS_H_
> +
> +#define ULEDS_MAX_NAME_SIZE 80
> +
> +struct uleds_user_dev {
> + char name[ULEDS_MAX_NAME_SIZE];
> +};
> +
> +#endif /* _UAPI__ULEDS_H_ */
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
pll_ctrl);
>
> + /* Assist 32KHz mode PLL lock */
> + if (source == DA7213_SYSCLK_PLL_32KHZ) {
> + snd_soc_write(codec, 0xF0, 0x8B);
> + snd_soc_write(codec, 0xF1, 0x03);
> + snd_soc_write(codec, 0xF1, 0x01);
> + snd_soc_write(codec, 0xF0, 0x00);
> + }
> +
> return 0;
> }
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
or 32KHz mode, checks are made on codec master mode and correct
>MCLK rates, to avoid incorrect usage of PLL for this operation.
> - For 32KHz mode, SRM flag now correctly enabled and fout set to
>sensible value to achieve appropriate PLL dividers.
thanks, looks good
Tested-by: P
>
> Signed-off-by: Adam Thomson
Tested-by: Peter Meerwald-Stadler
> ---
> sound/soc/codecs/da7213.c | 20 +++-
> 1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c
> index bcf1834..
> Previously code defaulted to 32 BCLKS per WCLK which meant 24 and
> 32 bit DAI formats would not work properly. This patch fixes the
> issue by defaulting to 64 BCLKs per WCLK.
Tested-by: Peter Meerwald-Stadler
> Signed-off-by: Adam Thomson
> ---
> sound/soc/codecs/da72
{0, 9577}, {0, 19154}, {0, 38307} },
> - .ev_cfg = MMA8452_FF_MT_CFG,
> - .ev_cfg_ele = MMA8452_FF_MT_CFG_ELE,
> - .ev_cfg_chan_shift = 3,
> - .ev_src = MMA8452_FF_MT_SRC,
> - .ev_src_xe = MMA8452_FF_MT_SRC_XHE,
> - .ev_src_ye = MMA8452_FF_MT_SRC_YHE,
> - .ev_src_ze = MMA8452_FF_MT_SRC_ZHE,
> - .ev_ths = MMA8452_FF_MT_THS,
> - .ev_ths_mask = MMA8452_FF_MT_THS_MASK,
> - .ev_count = MMA8452_FF_MT_COUNT,
> },
> [mma8653] = {
> .chip_id = MMA8653_DEVICE_ID,
> .channels = mma8653_channels,
> .num_channels = ARRAY_SIZE(mma8653_channels),
> .mma_scales = { {0, 38307}, {0, 76614}, {0, 153228} },
> - .ev_cfg = MMA8452_FF_MT_CFG,
> - .ev_cfg_ele = MMA8452_FF_MT_CFG_ELE,
> - .ev_cfg_chan_shift = 3,
> - .ev_src = MMA8452_FF_MT_SRC,
> - .ev_src_xe = MMA8452_FF_MT_SRC_XHE,
> - .ev_src_ye = MMA8452_FF_MT_SRC_YHE,
> - .ev_src_ze = MMA8452_FF_MT_SRC_ZHE,
> - .ev_ths = MMA8452_FF_MT_THS,
> - .ev_ths_mask = MMA8452_FF_MT_THS_MASK,
> - .ev_count = MMA8452_FF_MT_COUNT,
> },
> [fxls8471] = {
> .chip_id = FXLS8471_DEVICE_ID,
> .channels = mma8451_channels,
> .num_channels = ARRAY_SIZE(mma8451_channels),
> .mma_scales = { {0, 2394}, {0, 4788}, {0, 9577} },
> - .ev_cfg = MMA8452_TRANSIENT_CFG,
> - .ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE,
> - .ev_cfg_chan_shift = 1,
> - .ev_src = MMA8452_TRANSIENT_SRC,
> - .ev_src_xe = MMA8452_TRANSIENT_SRC_XTRANSE,
> - .ev_src_ye = MMA8452_TRANSIENT_SRC_YTRANSE,
> - .ev_src_ze = MMA8452_TRANSIENT_SRC_ZTRANSE,
> - .ev_ths = MMA8452_TRANSIENT_THS,
> - .ev_ths_mask = MMA8452_TRANSIENT_THS_MASK,
> - .ev_count = MMA8452_TRANSIENT_COUNT,
> },
> };
>
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
uot;, (void *)SRF08},
> { .compatible = "devantech,srf10", (void *)SRF10},
> {},
> @@ -473,6 +511,7 @@ static const struct of_device_id of_srf08_match[] = {
> MODULE_DEVICE_TABLE(of, of_srf08_match);
>
> static const struct i2c_device_id srf08_id[] = {
> + { "srf02", SRF02 },
> { "srf08", SRF08 },
> { "srf10", SRF10 },
> { }
> @@ -490,5 +529,5 @@ static struct i2c_driver srf08_driver = {
> module_i2c_driver(srf08_driver);
>
> MODULE_AUTHOR("Andreas Klinger ");
> -MODULE_DESCRIPTION("Devantech SRF08/SRF10 ultrasonic ranger driver");
> +MODULE_DESCRIPTION("Devantech SRF02/SRF08/SRF10 i2c ultrasonic ranger
> driver");
> MODULE_LICENSE("GPL");
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
ed buffer failed\n");
> + return ret;
> + }
> +
> /*
>* set default values of device here
>* these register values cannot be read from the hardware
> @@ -402,5 +455,5 @@ static struct i2c_driver srf08_driver = {
> module_i2c_driver(srf08_driver);
>
> MODULE_AUTHOR("Andreas Klinger ");
> -MODULE_DESCRIPTION("Devantech SRF08 ultrasonic ranger driver");
> +MODULE_DESCRIPTION("Devantech SRF08/SRF10 ultrasonic ranger driver");
> MODULE_LICENSE("GPL");
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
dln2_register_event_cb(pdev, DLN2_ADC_CONDITION_MET_EV,
> + dln2_adc_event);
> + if (ret) {
> + dev_err(dev, "failed to register event cb: %d\n", ret);
> + goto dealloc_pollfunc;
> + }
> +
> + ret = iio_device_register(indio_dev);
> + if (ret) {
> + dev_err(dev, "failed to register iio device: %d\n", ret);
> + goto dealloc_pollfunc;
> + }
> +
> + dev_info(dev, "DLN2 ADC driver loaded\n");
avoid this kind of logging
> +
> + return 0;
> +
> +dealloc_pollfunc:
> + iio_dealloc_pollfunc(indio_dev->pollfunc);
> +dealloc_kfifo:
> +dealloc_trigger:
> + iio_trigger_unregister(dln2->trig);
> +dealloc_dev:
> +
> + return ret;
> +}
> +
> +static int dln2_adc_remove(struct platform_device *pdev)
> +{
> + struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> + struct dln2_adc *dln2 = iio_priv(indio_dev);
> +
> + dev_info(&indio_dev->dev, "DLN2 ADC driver unloaded\n");
no such logging please
> +
> + dln2_unregister_event_cb(pdev, DLN2_ADC_CONDITION_MET_EV);
should be after device_unregister
> + iio_device_unregister(indio_dev);
> + iio_trigger_unregister(dln2->trig);
> + iio_dealloc_pollfunc(indio_dev->pollfunc);
> +
> + return 0;
> +}
> +
> +static struct platform_driver dln2_adc_driver = {
> + .driver.name= DLN2_ADC_MOD_NAME,
> + .probe = dln2_adc_probe,
> + .remove = dln2_adc_remove,
> +};
> +
> +module_platform_driver(dln2_adc_driver);
> +
> +MODULE_AUTHOR("Jack Andersen +MODULE_DESCRIPTION("Driver for the Diolan DLN2 ADC interface");
> +MODULE_LICENSE("GPL v2");
> +MODULE_ALIAS("platform:dln2-adc");
> diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
> index 704e189..a22ab8c 100644
> --- a/drivers/mfd/dln2.c
> +++ b/drivers/mfd/dln2.c
> @@ -53,6 +53,7 @@ enum dln2_handle {
> DLN2_HANDLE_GPIO,
> DLN2_HANDLE_I2C,
> DLN2_HANDLE_SPI,
> + DLN2_HANDLE_ADC,
> DLN2_HANDLES
> };
>
> @@ -663,6 +664,12 @@ static int dln2_start_rx_urbs(struct dln2_dev *dln2,
> gfp_t gfp)
> .port = 0,
> };
>
> +/* Only one ADC port supported */
> +static struct dln2_platform_data dln2_pdata_adc = {
> + .handle = DLN2_HANDLE_ADC,
> + .port = 0,
> +};
> +
> static const struct mfd_cell dln2_devs[] = {
> {
> .name = "dln2-gpio",
> @@ -679,6 +686,11 @@ static int dln2_start_rx_urbs(struct dln2_dev *dln2,
> gfp_t gfp)
> .platform_data = &dln2_pdata_spi,
> .pdata_size = sizeof(struct dln2_platform_data),
> },
> + {
> + .name = "dln2-adc",
> + .platform_data = &dln2_pdata_adc,
> + .pdata_size = sizeof(struct dln2_platform_data),
> + },
> };
>
> static void dln2_stop(struct dln2_dev *dln2)
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
_id[] = {
> - { "cm32181", 0 },
> + { "cm32181", CM32181_ID },
> + { "cm3218", CM3218_ID },
> { }
> };
>
> MODULE_DEVICE_TABLE(i2c, cm32181_id);
>
> static const struct of_device_id cm32181_of_match[] = {
> - { .compatible = "capella,cm32181" },
> + { .compatible = "capella,cm32181", (void *)CM32181_ID },
> + { .compatible = "capella,cm3218", (void *)CM3218_ID },
> { }
> };
> MODULE_DEVICE_TABLE(of, cm32181_of_match);
>
> +static const struct acpi_device_id cm32181_acpi_match[] = {
> + { "CPLM3218", CM3218_ID },
> + { }
> +};
> +
> +MODULE_DEVICE_TABLE(acpi, cm32181_acpi_match);
> +
> static struct i2c_driver cm32181_driver = {
> .driver = {
> .name = "cm32181",
> .of_match_table = of_match_ptr(cm32181_of_match),
> + .acpi_match_table = ACPI_PTR(cm32181_acpi_match),
> },
> .id_table = cm32181_id,
> .probe = cm32181_probe,
> + .remove = cm32181_remove,
> };
>
> module_i2c_driver(cm32181_driver);
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
t; > If it leads to more complex flow as here, don't do it.
>
> I would appreciate to clarify such a view a bit more.
> How would you like to achieve a complete and efficient
> exception handling in shown places?
regards, p.
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
i2c_unregister_device(cm32181->ara);
> +
> return ret;
> }
>
> return 0;
> }
>
> +static int cm32181_remove(struct i2c_client *client)
> +{
> + struct iio_dev *indio_dev = i2c_get_clientdata(client);
> + struct cm32181_chip *cm32181 = iio_priv(indio_dev);
> +
> + if (cm32181->ara)
> + i2c_unregister_device(cm32181->ara);
> +
> + return 0;
> +};
> +
> static const struct i2c_device_id cm32181_id[] = {
> - { "cm32181", 0 },
> + { "cm32181", CM32181_ID },
> + { "cm3218", CM3218_ID },
> { }
> };
>
> MODULE_DEVICE_TABLE(i2c, cm32181_id);
>
> static const struct of_device_id cm32181_of_match[] = {
> - { .compatible = "capella,cm32181" },
> + { .compatible = "capella,cm32181", (void *)CM32181_ID },
> + { .compatible = "capella,cm3218", (void *)CM3218_ID },
> { }
> };
> MODULE_DEVICE_TABLE(of, cm32181_of_match);
>
> +static const struct acpi_device_id cm32181_acpi_match[] = {
> + { "CPLM3218", CM3218_ID },
> + { }
> +};
> +
> +MODULE_DEVICE_TABLE(acpi, cm32181_acpi_match);
> +
> static struct i2c_driver cm32181_driver = {
> .driver = {
> .name = "cm32181",
> .of_match_table = of_match_ptr(cm32181_of_match),
> + .acpi_match_table = ACPI_PTR(cm32181_acpi_match),
> },
> .id_table = cm32181_id,
> .probe = cm32181_probe,
> + .remove = cm32181_remove,
> };
>
> module_i2c_driver(cm32181_driver);
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
ot;,
> [IIO_MOD_QUATERNION] = "quaternion",
> [IIO_MOD_TEMP_AMBIENT] = "ambient",
> [IIO_MOD_TEMP_OBJECT] = "object",
> @@ -178,6 +179,7 @@ static bool event_is_known(struct iio_event_data *event)
> case IIO_MOD_LIGHT_GREEN:
> case IIO_MOD_LIGHT_BLUE:
> case IIO_MOD_LIGHT_UV:
> + case IIO_MOD_LIGHT_WHITE:
> case IIO_MOD_QUATERNION:
> case IIO_MOD_TEMP_AMBIENT:
> case IIO_MOD_TEMP_OBJECT:
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
);
> + return ret;
> +}
> +
> +static int vcnl4035_remove(struct i2c_client *client)
> +{
> + struct iio_dev *indio_dev = i2c_get_clientdata(client);
> + struct vcnl4035_data *data = iio_priv(indio_dev);
> +
> + iio_triggered_buffer_cleanup(indio_dev);
> + iio_trigger_unregister(data->drdy_trigger0);
> + iio_device_unregister(indio_dev);
> +
> + pm_runtime_disable(&client->dev);
> + pm_runtime_set_suspended(&client->dev);
> + pm_runtime_put_noidle(&client->dev);
> +
> + return vcnl4035_set_als_power_state(iio_priv(indio_dev),
> + VCNL4035_MODE_ALS_DISABLE);
> +}
> +
> +#ifdef CONFIG_PM
> +static int vcnl4035_runtime_suspend(struct device *dev)
> +{
> + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> + struct vcnl4035_data *data = iio_priv(indio_dev);
> + int ret;
> +
> + ret = vcnl4035_set_als_power_state(data, VCNL4035_MODE_ALS_DISABLE);
> + regcache_mark_dirty(data->regmap);
> +
> + return ret;
> +}
> +
> +static int vcnl4035_runtime_resume(struct device *dev)
> +{
> + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> + struct vcnl4035_data *data = iio_priv(indio_dev);
> + int ret;
> +
> + regcache_sync(data->regmap);
> + ret = vcnl4035_set_als_power_state(data, VCNL4035_MODE_ALS_ENABLE);
> + if (ret < 0)
> + return ret;
> + /* wait for 1 ALS integration cycle */
> + msleep(data->als_it_val * 100);
> +
> + return 0;
> +}
> +#endif
> +
> +static const struct dev_pm_ops vcnl4035_pm_ops = {
> + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
> + pm_runtime_force_resume)
> + SET_RUNTIME_PM_OPS(vcnl4035_runtime_suspend,
> +vcnl4035_runtime_resume, NULL)
> +};
> +
> +static const struct of_device_id vcnl4035_of_match[] = {
> + { .compatible = "vishay,vcnl4035", },
> + { },
> +};
> +MODULE_DEVICE_TABLE(of, vcnl4035_of_match);
> +
> +static const struct i2c_device_id vcnl4035_id[] = {
> + { "vcnl4035", 0 },
> + { }
> +};
> +MODULE_DEVICE_TABLE(i2c, vcnl4035_id);
> +
> +static struct i2c_driver vcnl4035_driver = {
> + .driver = {
> + .name = VCNL4035_DRV_NAME,
> + .pm = &vcnl4035_pm_ops,
> + .of_match_table = of_match_ptr(vcnl4035_of_match),
> + },
> + .probe = vcnl4035_probe,
> + .remove = vcnl4035_remove,
> + .id_table = vcnl4035_id,
> +};
> +
> +module_i2c_driver(vcnl4035_driver);
> +
> +MODULE_AUTHOR("Parthiban Nallathambi ");
> +MODULE_DESCRIPTION("VCNL4035 Ambient Light Sensor driver");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
> [IIO_MOD_LIGHT_UV] = "uv",
> > > + [IIO_MOD_LIGHT_WHITE] = "white",
> > > [IIO_MOD_QUATERNION] = "quaternion",
> > > [IIO_MOD_TEMP_AMBIENT] = "ambient",
> > > [IIO_MOD_TEMP_OBJECT] = "object",
> > > @@ -178,6 +179,7 @@ static bool event_is_known(struct iio_event_data
> > > *event)
> > > case IIO_MOD_LIGHT_GREEN:
> > > case IIO_MOD_LIGHT_BLUE:
> > > case IIO_MOD_LIGHT_UV:
> > > + case IIO_MOD_LIGHT_WHITE:
> > > case IIO_MOD_QUATERNION:
> > > case IIO_MOD_TEMP_AMBIENT:
> > > case IIO_MOD_TEMP_OBJECT:
> > >
> >
>
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
return ret;
> + }
> +
> + /* Store gain values to better calculate scale values */
> + mcp3911_get_hwgain(adc, 0, &adc->gain[0]);
> + mcp3911_get_hwgain(adc, 1, &adc->gain[1]);
> +
> + indio_dev->dev.parent = &spi->dev;
> + indio_dev->dev.of_node = spi->dev.of_node;
> + indio_dev->name = spi_get_device_id(spi)->name;
> + indio_dev->modes = INDIO_DIRECT_MODE;
> + indio_dev->info = &mcp3911_info;
> + spi_set_drvdata(spi, indio_dev);
> +
> + indio_dev->channels = mcp3911_channels;
> + indio_dev->num_channels = ARRAY_SIZE(mcp3911_channels);
> +
> + mutex_init(&adc->lock);
> +
> + ret = iio_device_register(indio_dev);
> + if (ret)
> + goto reg_disable;
> +
> + return ret;
> +
> +reg_disable:
> + if (adc->vref)
> + regulator_disable(adc->vref);
> +
> + return ret;
> +}
> +
> +static int mcp3911_remove(struct spi_device *spi)
> +{
> + struct iio_dev *indio_dev = spi_get_drvdata(spi);
> + struct mcp3911 *adc = iio_priv(indio_dev);
> +
> + iio_device_unregister(indio_dev);
> +
> + if (adc->vref)
> + regulator_disable(adc->vref);
> +
> + return 0;
> +}
> +
> +#if defined(CONFIG_OF)
> +static const struct of_device_id mcp3911_dt_ids[] = {
> + { .compatible = "microchip,mcp3911" },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, mcp3911_dt_ids);
> +#endif
> +
> +static const struct spi_device_id mcp3911_id[] = {
> + { "mcp3911", 0 },
> + { }
> +};
> +MODULE_DEVICE_TABLE(spi, mcp3911_id);
> +
> +static struct spi_driver mcp3911_driver = {
> + .driver = {
> + .name = "mcp3911",
> + .of_match_table = of_match_ptr(mcp3911_dt_ids),
> + },
> + .probe = mcp3911_probe,
> + .remove = mcp3911_remove,
> + .id_table = mcp3911_id,
> +};
> +module_spi_driver(mcp3911_driver);
> +
> +MODULE_AUTHOR("Marcus Folkesson ");
> +MODULE_AUTHOR("Kent Gustavsson ");
> +MODULE_DESCRIPTION("Microchip Technology MCP3911");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
> if (ret < 0) {
> @@ -506,6 +831,41 @@ static int adxl372_probe(struct spi_device *spi)
> return ret;
> }
>
> + ret = devm_iio_triggered_buffer_setup(&st->spi->dev,
> + indio_dev, NULL,
> + adxl372_trigger_handler,
> + &adxl372_buffer_ops);
> + if (ret < 0)
> + return ret;
> +
> + iio_buffer_set_attrs(indio_dev->buffer, adxl372_fifo_attributes);
> +
> + if (st->spi->irq) {
> + st->dready_trig = devm_iio_trigger_alloc(&st->spi->dev,
> + "%s-dev%d",
> + indio_dev->name,
> + indio_dev->id);
> + if (st->dready_trig == NULL)
> + return -ENOMEM;
> +
> + st->dready_trig->ops = &adxl372_trigger_ops;
> + st->dready_trig->dev.parent = &st->spi->dev;
> + iio_trigger_set_drvdata(st->dready_trig, indio_dev);
> + ret = devm_iio_trigger_register(&st->spi->dev, st->dready_trig);
> + if (ret < 0)
> + return ret;
> +
> + indio_dev->trig = iio_trigger_get(st->dready_trig);
> +
> + ret = devm_request_threaded_irq(&st->spi->dev, st->spi->irq,
> + iio_trigger_generic_data_rdy_poll,
> + NULL,
> + IRQF_TRIGGER_RISING | IRQF_ONESHOT,
> + indio_dev->name, st->dready_trig);
> + if (ret < 0)
> + return ret;
> + }
> +
> return devm_iio_device_register(&st->spi->dev, indio_dev);
> }
>
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
if (ret != -ERESTARTSYS)
> - zpa2326_warn(indio_dev, "no one shot interrupt occurred (%d)",
> - ret);
> + } else if (timeout < 0) {
> + zpa2326_warn(indio_dev, "wait for one shot interrupt canceled");
> + ret = -ERESTARTSYS;
> + }
>
> return ret;
> }
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
ng
> + VCNL4035_DRV_NAME);
> + return 0;
> +
> +fail_pm_disable:
> + pm_runtime_disable(&client->dev);
> + pm_runtime_set_suspended(&client->dev);
> + pm_runtime_put_noidle(&client->dev);
> +fail_poweroff:
> + return vcnl4035_set_als_power_state(data, VCNL4035_MODE_ALS_DISABLE);
I think we want to return the 'ret' value indicating the original failure,
not the return value of vcnl4035_set_als_power_state() which is likely success
> +}
> +
> +static int vcnl4035_remove(struct i2c_client *client)
> +{
> + struct iio_dev *indio_dev = i2c_get_clientdata(client);
> +
> + iio_device_unregister(indio_dev);
> +
> + pm_runtime_disable(&client->dev);
> + pm_runtime_set_suspended(&client->dev);
> + pm_runtime_put_noidle(&client->dev);
> +
> + return vcnl4035_set_als_power_state(iio_priv(indio_dev),
> + VCNL4035_MODE_ALS_DISABLE);
> +}
> +
> +#ifdef CONFIG_PM
> +static int vcnl4035_runtime_suspend(struct device *dev)
> +{
> + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> + struct vcnl4035_data *data = iio_priv(indio_dev);
> + int ret;
> +
> + mutex_lock(&data->lock);
> + ret = vcnl4035_set_als_power_state(data, VCNL4035_MODE_ALS_DISABLE);
> + regcache_mark_dirty(data->regmap);
> + mutex_unlock(&data->lock);
> +
> + return ret;
> +}
> +
> +static int vcnl4035_runtime_resume(struct device *dev)
> +{
> + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> + struct vcnl4035_data *data = iio_priv(indio_dev);
> + int ret;
> +
> + regcache_sync(data->regmap);
> + ret = vcnl4035_set_als_power_state(data, VCNL4035_MODE_ALS_ENABLE);
> + if (ret < 0)
> + return ret;
> + /* wait for 1 ALS integration cycle */
> + msleep(data->als_it_val * 100);
> +
> + return 0;
> +}
> +#endif
> +
> +static const struct dev_pm_ops vcnl4035_pm_ops = {
> + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
> + pm_runtime_force_resume)
> + SET_RUNTIME_PM_OPS(vcnl4035_runtime_suspend,
> +vcnl4035_runtime_resume, NULL)
> +};
> +
> +static const struct of_device_id vcnl4035_of_match[] = {
> + { .compatible = "vishay,vcnl4035", },
> + { },
> +};
> +MODULE_DEVICE_TABLE(of, vcnl4035_of_match);
> +
> +static const struct i2c_device_id vcnl4035_id[] = {
> + { "vcnl4035", 0 },
> + { }
> +};
> +MODULE_DEVICE_TABLE(i2c, vcnl4035_id);
> +
> +static struct i2c_driver vcnl4035_driver = {
> + .driver = {
> + .name = VCNL4035_DRV_NAME,
> + .pm = &vcnl4035_pm_ops,
> + .of_match_table = of_match_ptr(vcnl4035_of_match),
> + },
> + .probe = vcnl4035_probe,
> + .remove = vcnl4035_remove,
> + .id_table = vcnl4035_id,
> +};
> +
> +module_i2c_driver(vcnl4035_driver);
> +
> +MODULE_AUTHOR("Parthiban Nallathambi ");
> +MODULE_DESCRIPTION("VCNL4035 Ambient Light Sensor driver");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
et_volt_ratio = data;
> + sc27xx_data->dev = &pdev->dev;
> +
> + ret = sc27xx_adc_enable(sc27xx_data);
> + if (ret) {
> + dev_err(&pdev->dev, "failed to enable ADC module\n");
> + goto free_hwlock;
> + }
> +
> + ret = devm_request_threaded_irq(&pdev->dev, sc27xx_data->irq, NULL,
> + sc27xx_adc_isr, IRQF_ONESHOT,
> + pdev->name, sc27xx_data);
> + if (ret) {
> + dev_err(&pdev->dev, "failed to request ADC irq\n");
> + goto disable_adc;
> + }
> +
> + indio_dev->dev.parent = &pdev->dev;
> + indio_dev->name = dev_name(&pdev->dev);
> + indio_dev->modes = INDIO_DIRECT_MODE;
> + indio_dev->info = &sc27xx_info;
> + indio_dev->channels = sc27xx_channels;
> + indio_dev->num_channels = ARRAY_SIZE(sc27xx_channels);
> + ret = devm_iio_device_register(&pdev->dev, indio_dev);
> + if (ret) {
> + dev_err(&pdev->dev, "could not register iio (ADC)");
> + goto disable_adc;
> + }
> +
> + platform_set_drvdata(pdev, indio_dev);
> + return 0;
> +
> +disable_adc:
> + sc27xx_adc_disable(sc27xx_data);
> +free_hwlock:
> + hwspin_lock_free(sc27xx_data->hwlock);
> + return ret;
> +}
> +
> +static int sc27xx_adc_remove(struct platform_device *pdev)
> +{
> + struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> + struct sc27xx_adc_data *sc27xx_data = iio_priv(indio_dev);
> +
> + sc27xx_adc_disable(sc27xx_data);
> + hwspin_lock_free(sc27xx_data->hwlock);
> + return 0;
> +}
> +
> +static const struct of_device_id sc27xx_adc_of_match[] = {
> + {
> + .compatible = "sprd,sc2731-adc",
> + .data = (void *)&sc27xx_adc_2731_ratio,
> + },
> + { }
> +};
> +
> +static struct platform_driver sc27xx_adc_driver = {
> + .probe = sc27xx_adc_probe,
> + .remove = sc27xx_adc_remove,
> + .driver = {
> + .name = "sc27xx-adc",
> + .of_match_table = sc27xx_adc_of_match,
> + },
> +};
> +
> +module_platform_driver(sc27xx_adc_driver);
> +
> +MODULE_AUTHOR("Freeman Liu ");
> +MODULE_DESCRIPTION("Spreadtrum SC27XX ADC Driver");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
; 0)
> + return ret;
> +
> + regval = ad5758_spi_reg_read(st, AD5758_DIGITAL_DIAG_RESULTS);
> + if (regval < 0)
> + return regval;
> +
> + /* Clear all the error flags */
> + ret = ad5758_spi_reg_write(st, AD5758_DIGITAL_DIAG_RESULTS, regval);
> + if (ret < 0)
> + return ret;
> +
> + /* Set the dc-to-dc current limit */
> + ret = ad5758_set_dc_dc_ilim(st, st->dc_dc_ilim);
> + if (ret < 0)
> + return ret;
> +
> + /* Configure the dc-to-dc controller mode */
> + ret = ad5758_set_dc_dc_conv_mode(st, st->dc_dc_mode);
> + if (ret < 0)
> + return ret;
> +
> + /* Configure the output range */
> + ret = ad5758_set_out_range(st, st->out_range);
> + if (ret < 0)
> + return ret;
> +
> + /* Enable Slew Rate Control, set the slew rate clock and step */
> + ret = ad5758_slew_rate_config(st, st->sr_config[0],
> + st->sr_config[1], st->sr_config[2]);
> + if (ret < 0)
> + return ret;
> +
> + /* Enable the VIOUT fault protection switch (FPS is closed) */
> + ret = ad5758_fault_prot_switch_en(st, 1);
> + if (ret < 0)
> + return ret;
> +
> + /* Power up the DAC and internal (INT) amplifiers */
> + ret = ad5758_internal_buffers_en(st, 1);
> + if (ret < 0)
> + return ret;
> +
> + /* Enable VIOUT */
> + ret = ad5758_spi_write_mask(st, AD5758_DAC_CONFIG,
> + AD5758_DAC_CONFIG_OUT_EN_MSK,
> + AD5758_DAC_CONFIG_OUT_EN_MODE(1));
return directly, i.e.
return ad5758_spi...
> +
> + return ret;
> +}
> +
> +static int ad5758_probe(struct spi_device *spi)
> +{
> + struct ad5758_state *st;
> + struct iio_dev *indio_dev;
> + int ret;
> +
> + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> + if (!indio_dev)
> + return -ENOMEM;
> +
> + st = iio_priv(indio_dev);
> + spi_set_drvdata(spi, indio_dev);
> +
> + st->spi = spi;
> +
> + indio_dev->dev.parent = &spi->dev;
> + indio_dev->name = spi_get_device_id(spi)->name;
> + indio_dev->info = &ad5758_info;
> + indio_dev->modes = INDIO_DIRECT_MODE;
> + indio_dev->channels = ad5758_channels;
> + indio_dev->num_channels = ARRAY_SIZE(ad5758_channels);
> +
> + mutex_init(&st->lock);
> +
> + ret = ad5758_init(st);
> + if (ret < 0) {
> + dev_err(&spi->dev, "AD5758 init failed\n");
> + return ret;
> + }
> +
> + ret = iio_device_register(indio_dev);
> + if (ret) {
> + dev_err(&spi->dev, "Failed to register iio device\n");
is the message really necessary/likely?
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> +static const struct spi_device_id ad5758_id[] = {
> + { "ad5758", 0 },
> + {}
> +};
> +MODULE_DEVICE_TABLE(spi, ad5758_id);
> +
> +static struct spi_driver ad5758_driver = {
> + .driver = {
> + .name = KBUILD_MODNAME,
> + },
> + .probe = ad5758_probe,
> + .id_table = ad5758_id,
> +};
> +
> +module_spi_driver(ad5758_driver);
> +
> +MODULE_AUTHOR("Stefan Popa ");
> +MODULE_DESCRIPTION("Analog Devices AD5758 DAC");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
ret);
> + goto error_disable_reg;
> + }
> +
> + st->filter_gpio = devm_gpiod_get_optional(&spi->dev,
> + "filter",
> + GPIOD_OUT_HIGH);
> + if (IS_ERR(st->filter_gpio)) {
> + ret = PTR_ERR(st->filter_gpio);
> + dev_err(&spi->dev,
> + "Failed to request filter GPIO: %d\n",
> + ret);
> + goto error_disable_reg;
> + }
> + }
> +
> ret = ad_sd_setup_buffer_and_trigger(indio_dev);
> if (ret)
> goto error_disable_reg;
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
_device_set_baudrate(serdev, 9600);
> + serdev_device_set_flow_control(serdev, false);
> +
> + ret = serdev_device_set_parity(serdev, SERDEV_PARITY_NONE);
> + if (ret)
> + return ret;
> +
> + ret = pms7003_do_cmd(state, CMD_WAKEUP);
> + if (ret) {
> + dev_err(&serdev->dev, "failed to wakeup sensor\n");
> + return ret;
> + }
> +
> + ret = pms7003_do_cmd(state, CMD_ENTER_PASSIVE_MODE);
> + if (ret) {
> + dev_err(&serdev->dev, "failed to enter passive mode\n");
> + return ret;
> + }
> +
> + ret = devm_add_action_or_reset(&serdev->dev, pms7003_stop, state);
> + if (ret)
> + return ret;
> +
> + ret = devm_iio_triggered_buffer_setup(&serdev->dev, indio_dev, NULL,
> + pms7003_trigger_handler, NULL);
> + if (ret)
> + return ret;
> +
> + return devm_iio_device_register(&serdev->dev, indio_dev);
> +}
> +
> +static const struct of_device_id pms7003_of_match[] = {
> + { .compatible = "plantower,pms7003" },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, pms7003_of_match);
> +
> +static struct serdev_device_driver pms7003_driver = {
> + .driver = {
> + .name = PMS7003_DRIVER_NAME,
> + .of_match_table = pms7003_of_match,
> + },
> + .probe = pms7003_probe,
> +};
> +module_serdev_device_driver(pms7003_driver);
> +
> +MODULE_AUTHOR("Tomasz Duszynski ");
> +MODULE_DESCRIPTION("Plantower PMS7003 particulate matter sensor driver");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
2.o
alphabetic order please
> obj-$(CONFIG_LIDAR_LITE_V2) += pulsedlight-lidar-lite-v2.o
> obj-$(CONFIG_RFD77402) += rfd77402.o
> obj-$(CONFIG_SRF04) += srf04.o
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
+ dev_err(dev, "request_irq: %d\n", ret);
> + return ret;
> + }
> + }
> +
> + ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
> + iio_pollfunc_store_time, mb12x2_trigger_handler, NULL);
> + if (ret < 0) {
> + dev_err(dev, "setup of iio triggered buffer failed\n");
> + return ret;
> + }
> +
> + return devm_iio_device_register(dev, indio_dev);
> +}
> +
> +static const struct of_device_id of_mb12x2_match[] = {
> + { .compatible = "maxbotix,mb12x2", },
> + {},
> +};
> +
> +MODULE_DEVICE_TABLE(of, of_mb12x2_match);
> +
> +static const struct i2c_device_id mb12x2_id[] = {
> + { "maxbotix-mb12x2", },
> + { }
> +};
> +MODULE_DEVICE_TABLE(i2c, mb12x2_id);
> +
> +static struct i2c_driver mb12x2_driver = {
> + .driver = {
> + .name = "maxbotix-mb12x2",
> + .of_match_table = of_mb12x2_match,
> + },
> + .probe = mb12x2_probe,
> + .id_table = mb12x2_id,
> +};
> +module_i2c_driver(mb12x2_driver);
> +
> +MODULE_AUTHOR("Andreas Klinger ");
> +MODULE_DESCRIPTION("Maxbotix I2CXL-MB12X2-EZ i2c ultrasonic ranger driver");
> +MODULE_LICENSE("GPL");
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
> Driver implementation for AMS/TAOS tsl2591 ambient light sensor.
please see comments below
>
> This driver supports configuration via device tree and sysfs.
> Supported channels for raw infrared light, raw visible light,
> raw combined light and combined lux value.
> The driver additionally s
emperature/tmp006.c: indio_dev->name = dev_name(&client->dev);
./chemical/ams-iaq-core.c: indio_dev->name = dev_name(&client->dev);
./chemical/vz89x.c: indio_dev->name = dev_name(&client->dev);
./humidity/si7005.c:indio_dev->name = dev_name(&client->dev);
./humidity/hdc100x.c: indio_dev->name = dev_name(&client->dev);
./humidity/si7020.c:indio_dev->name = dev_name(&client->dev);
regards, p.
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
ata *data;
> +
> + data = iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
> +
> + return mma7660_set_mode(data, MMA7660_MODE_ACTIVE);
> +}
> +
> +static SIMPLE_DEV_PM_OPS(mma7660_pm_ops, mma7660_suspend, mma7660_resume);
> +
> +#define MMA7660_PM_OPS (&mma7660_pm_ops)
> +#else
> +#define MMA7660_PM_OPS NULL
> +#endif
> +
> +static const struct i2c_device_id mma7660_i2c_id[] = {
> + {"MMA7660", 0},
really uppercase?
> + {}
> +};
> +
> +static const struct acpi_device_id mma7660_acpi_id[] = {
> + {"MMA7660", 0},
> + {}
> +};
> +
> +MODULE_DEVICE_TABLE(acpi, mma7660_acpi_id);
> +
> +static struct i2c_driver mma7660_driver = {
> + .driver = {
> + .name = "mma7660",
> + .pm = MMA7660_PM_OPS,
> + .acpi_match_table = ACPI_PTR(mma7660_acpi_id),
> + },
> + .probe = mma7660_probe,
> + .remove = mma7660_remove,
> + .id_table = mma7660_i2c_id,
> +};
> +
> +module_i2c_driver(mma7660_driver);
> +
> +MODULE_AUTHOR("Constantin Musca ");
> +MODULE_DESCRIPTION("Freescale MMA7660FC 3-Axis Accelerometer driver");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
rm_watch(fd, i)); // 0
printf("add %d\n", j=inotify_add_watch(fd, "/tmp/foo", IN_MODIFY)); // 2
return 0;
}
Ubuntu kernel x86_64 4.4.0-21, seems to work here
so we have to guess what's going on between _add and _rm?
regards, p.
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
46 +591,5 @@ int main(int argc, char **argv)
>num_channels);
> }
>
> - /* Stop the buffer */
> - ret = write_sysfs_int("enable", buf_dir_name, 0);
> - if (ret < 0)
> - goto error_close_buffer_access;
> -
> - if (!notrigger)
> - /* Disconnect the trigger - just write a dummy name. */
> - ret = write_sysfs_string("trigger/current_trigger",
> - dev_dir_name, "NULL");
> - if (ret < 0)
> - fprintf(stderr, "Failed to write to %s\n",
> - dev_dir_name);
> -
> -error_close_buffer_access:
> - if (close(fp) == -1)
> - perror("Failed to close buffer");
> -
> -error_free_buffer_access:
> - free(buffer_access);
> -error_free_data:
> - free(data);
> -error_free_buf_dir_name:
> - free(buf_dir_name);
> -error_free_channels:
> - for (i = num_channels - 1; i >= 0; i--) {
> - free(channels[i].name);
> - free(channels[i].generic_name);
> - }
> - free(channels);
> -error_free_triggername:
> - if (datardytrigger)
> - free(trigger_name);
> -error_disable_channels:
> - if (autochannels == AUTOCHANNELS_ACTIVE) {
> - ret = enable_disable_all_channels(dev_dir_name, 0);
> - if (ret)
> - fprintf(stderr, "Failed to disable all channels\n");
> - }
> -error_free_dev_dir_name:
> - free(dev_dir_name);
> -
> - return ret;
> + return 0;
> }
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
write_cmd(spi, MAX5487_COPY_AB_TO_NV);
> +}
> +
> +static const struct spi_device_id max5487_id[] = {
> + { "MAX5487", 10 },
> + { "MAX5488", 50 },
> + { "MAX5489", 100 },
> + { }
> +};
> +MODULE_DEVICE_TABLE(spi, max5487_id);
> +
> +static const struct acpi_device_id max5487_acpi_match[] = {
> + { "MAX5487", 10 },
> + { "MAX5488", 50 },
> + { "MAX5489", 100 },
> + { },
> +};
> +MODULE_DEVICE_TABLE(acpi, max5487_acpi_match);
> +
> +static struct spi_driver max5487_driver = {
> + .driver = {
> + .name = "max5487",
> + .owner = THIS_MODULE,
> + .acpi_match_table = ACPI_PTR(max5487_acpi_match),
> + },
> + .id_table = max5487_id,
> + .probe = max5487_spi_probe,
> + .remove = max5487_spi_remove
> +};
> +module_spi_driver(max5487_driver);
> +
> +MODULE_AUTHOR("Cristina-Gabriela Moraru ");
> +MODULE_DESCRIPTION("max5487 SPI driver");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
/light/si1145.c
@@ -0,0 +1,855 @@
+/*
+ * si1145.c - Support for Silabs SI1132 and SI1141/2/3/5/6/7 combined ambient
+ * light, UV index and proximity sensors
+ *
+ * Copyright 2014 Peter Meerwald-Stadler
+ *
+ * This file is subject to the terms and conditions of version 2 of
+ * the GNU General
> + if (chip->regs[CM36672_ADDR_PRX_CONF] & CM36672_PRX_INT_MASK) {
> + ret = i2c_smbus_write_word_data(chip->client,
> + CM36672_ADDR_PRX_CONF,
> + chip->regs[CM36672_ADDR_PRX_CONF]);
> + if (ret) {
> + dev_err(&client->dev,
> + "%s: enable interrupt failed\n",
> + __func__);
> + return ret;
> + }
> + }
> + }
> +
> + ret = iio_device_register(indio_dev);
> + if (ret) {
> + dev_err(&client->dev,
> + "%s: regist device failed\n",
registering
> + __func__);
> + if (client->irq)
> + free_irq(client->irq, indio_dev);
> + }
> +
> + return 0;
> +}
> +
> +static int cm36672_remove(struct i2c_client *client)
> +{
> + struct iio_dev *indio_dev = i2c_get_clientdata(client);
> + struct cm36672_chip *chip = iio_priv(indio_dev);
> +
> + i2c_smbus_write_word_data(
> + chip->client,
> + CM36672_ADDR_PRX_CONF,
> + CM36672_PRX_DISABLE);
> + if (client->irq)
> + free_irq(client->irq, indio_dev);
> + iio_device_unregister(indio_dev);
> + return 0;
> +}
> +
> +static const struct i2c_device_id cm36672_id[] = {
> + { "cm36672", 0 },
> + { }
> +};
> +
> +MODULE_DEVICE_TABLE(i2c, cm36672_id);
> +
> +static const struct of_device_id cm36672_of_match[] = {
> + { .compatible = "capella,cm36672" },
> + { }
> +};
> +
> +#ifdef CONFIG_ACPI
> +static const struct acpi_device_id cm36672_acpi_match[] = {
> + { "CPLM6672", 0},
> + {},
> +};
> +
> +MODULE_DEVICE_TABLE(acpi, cm36672_acpi_match);
> +#endif
> +
> +#ifdef CONFIG_PM_SLEEP
> +static int cm36672_suspend(struct device *dev)
> +{
> + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> + struct cm36672_chip *chip = iio_priv(indio_dev);
> + int ret;
> +
> + chip->regs[CM36672_ADDR_PRX_CONF] |= CM36672_PRX_DISABLE;
> + ret = i2c_smbus_write_byte_data(
> + chip->client,
> + CM36672_ADDR_PRX_CONF,
> + chip->regs[CM36672_ADDR_PRX_CONF]);
> + return ret;
> +}
> +
> +static int cm36672_resume(struct device *dev)
> +{
> + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> + struct cm36672_chip *chip = iio_priv(indio_dev);
> + int i, ret;
> +
> + chip->regs[CM36672_ADDR_PRX_CONF] &= ~CM36672_PRX_DISABLE;
> +
> + /* Initialize registers*/
whitespace before */ please
> + for (i = 0; i < CM36672_REGS_NUM; i++) {
> + ret = i2c_smbus_write_word_data(
> + chip->client,
> + i,
> + chip->regs[i]);
> + if (ret < 0)
> + return ret;
> + }
> +
> + return ret;
> +}
> +
> +static const struct dev_pm_ops cm36672_pm_ops = {
> + SET_SYSTEM_SLEEP_PM_OPS(cm36672_suspend, cm36672_resume)};
> +#endif
> +
> +static struct i2c_driver cm36672_driver = {
> + .driver = {
> + .name = CM36672_DRIVER_NAME,
> + .of_match_table = cm36672_of_match,
> +#ifdef CONFIG_ACPI
> + .acpi_match_table = ACPI_PTR(cm36672_acpi_match),
> +#endif
> + .owner = THIS_MODULE,
> +#ifdef CONFIG_PM_SLEEP
> + .pm = &cm36672_pm_ops,
> +#endif
> + },
> + .id_table = cm36672_id,
> + .probe = cm36672_probe,
> + .remove = cm36672_remove,
> +};
> +
> +module_i2c_driver(cm36672_driver);
> +
> +MODULE_AUTHOR("Kevin Tsai ");
> +MODULE_DESCRIPTION("CM36672 proximity sensor driver");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
onfig.max_register = chip->config->registers;
> +
> + mutex_init(&chip->state_lock);
> +
> + /* This is only used for device removal purposes. */
> + i2c_set_clientdata(client, indio_dev);
> +
> + indio_dev->name = id->name;
> + indio_dev->
static void imx7d_adc_power_down(struct imx7d_adc *info)
> +{
> + u32 adc_cfg;
> +
> + adc_cfg = readl(info->regs + IMX7D_REG_ADC_ADC_CFG);
> + adc_cfg |= IMX7D_REG_ADC_ADC_CFG_ADC_CLK_DOWN |
> +IMX7D_REG_ADC_ADC_CFG_ADC_POWER_DOWN;
> + adc_cf
> > -Original Message-
> > From: Peter Meerwald-Stadler [mailto:pme...@pmeerw.net]
> > Sent: Tuesday, December 01, 2015 4:51 PM
> > To: Chen Haibo-B51421
> > Cc: ji...@kernel.org; knaac...@gmx.de; l...@metafoo.de;
> > shawn...@kernel.org; linux
a2xx_channels;
> + indio_dev->num_channels = ARRAY_SIZE(ina2xx_channels);
> +
> + indio_dev->dev.parent = &client->dev;
> + indio_dev->info = &ina2xx_info;
> + indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE;
> +
> + ch
31_cfg[MCP426x_103] },
> + { .compatible = "microchip,mcp4261-503",
> + .data = &mcp4131_cfg[MCP426x_503] },
> + { .compatible = "microchip,mcp4261-104",
> + .data = &mcp4131_cfg[MCP426x_104] },
> + { .compatible = "microchip,mcp4262-502",
> + .data = &mcp4131_cfg[MCP426x_502] },
> + { .compatible = "microchip,mcp4262-103",
> + .data = &mcp4131_cfg[MCP426x_103] },
> + { .compatible = "microchip,mcp4262-503",
> + .data = &mcp4131_cfg[MCP426x_503] },
> + { .compatible = "microchip,mcp4262-104",
> + .data = &mcp4131_cfg[MCP426x_104] },
> + {}
> +};
> +MODULE_DEVICE_TABLE(of, mcp4131_dt_ids);
> +#endif /* CONFIG_OF */
> +
> +static const struct spi_device_id mcp4131_id[] = {
> + { "mcp4131-502", MCP413x_502 },
> + { "mcp4131-103", MCP413x_103 },
> + { "mcp4131-503", MCP413x_503 },
> + { "mcp4131-104", MCP413x_104 },
> + { "mcp4132-502", MCP413x_502 },
> + { "mcp4132-103", MCP413x_103 },
> + { "mcp4132-503", MCP413x_503 },
> + { "mcp4132-104", MCP413x_104 },
> + { "mcp4141-502", MCP414x_502 },
> + { "mcp4141-103", MCP414x_103 },
> + { "mcp4141-503", MCP414x_503 },
> + { "mcp4141-104", MCP414x_104 },
> + { "mcp4142-502", MCP414x_502 },
> + { "mcp4142-103", MCP414x_103 },
> + { "mcp4142-503", MCP414x_503 },
> + { "mcp4142-104", MCP414x_104 },
> + { "mcp4151-502", MCP415x_502 },
> + { "mcp4151-103", MCP415x_103 },
> + { "mcp4151-503", MCP415x_503 },
> + { "mcp4151-104", MCP415x_104 },
> + { "mcp4152-502", MCP415x_502 },
> + { "mcp4152-103", MCP415x_103 },
> + { "mcp4152-503", MCP415x_503 },
> + { "mcp4152-104", MCP415x_104 },
> + { "mcp4161-502", MCP416x_502 },
> + { "mcp4161-103", MCP416x_103 },
> + { "mcp4161-503", MCP416x_503 },
> + { "mcp4161-104", MCP416x_104 },
> + { "mcp4162-502", MCP416x_502 },
> + { "mcp4162-103", MCP416x_103 },
> + { "mcp4162-503", MCP416x_503 },
> + { "mcp4162-104", MCP416x_104 },
> + { "mcp4231-502", MCP423x_502 },
> + { "mcp4231-103", MCP423x_103 },
> + { "mcp4231-503", MCP423x_503 },
> + { "mcp4231-104", MCP423x_104 },
> + { "mcp4232-502", MCP423x_502 },
> + { "mcp4232-103", MCP423x_103 },
> + { "mcp4232-503", MCP423x_503 },
> + { "mcp4232-104", MCP423x_104 },
> + { "mcp4241-502", MCP424x_502 },
> + { "mcp4241-103", MCP424x_103 },
> + { "mcp4241-503", MCP424x_503 },
> + { "mcp4241-104", MCP424x_104 },
> + { "mcp4242-502", MCP424x_502 },
> + { "mcp4242-103", MCP424x_103 },
> + { "mcp4242-503", MCP424x_503 },
> + { "mcp4242-104", MCP424x_104 },
> + { "mcp4251-502", MCP425x_502 },
> + { "mcp4251-103", MCP425x_103 },
> + { "mcp4251-503", MCP425x_503 },
> + { "mcp4251-104", MCP425x_104 },
> + { "mcp4252-502", MCP425x_502 },
> + { "mcp4252-103", MCP425x_103 },
> + { "mcp4252-503", MCP425x_503 },
> + { "mcp4252-104", MCP425x_104 },
> + { "mcp4261-502", MCP426x_502 },
> + { "mcp4261-103", MCP426x_103 },
> + { "mcp4261-503", MCP426x_503 },
> + { "mcp4261-104", MCP426x_104 },
> + { "mcp4262-502", MCP426x_502 },
> + { "mcp4262-103", MCP426x_103 },
> + { "mcp4262-503", MCP426x_503 },
> + { "mcp4262-104", MCP426x_104 },
> + {}
> +};
> +MODULE_DEVICE_TABLE(spi, mcp4131_id);
> +
> +static struct spi_driver mcp4131_driver = {
> + .driver = {
> + .name = "mcp4131",
> + .of_match_table = of_match_ptr(mcp4131_dt_ids),
> + },
> + .probe = mcp4131_probe,
> + .remove = mcp4131_remove,
> + .id_table = mcp4131_id,
> +};
> +
> +module_spi_driver(mcp4131_driver);
> +
> +MODULE_AUTHOR("Slawomir Stepien ");
> +MODULE_DESCRIPTION("MCP4131 digital potentiometer");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
_device_register(dev, indio_dev);
> +}
> +
> +#if defined(CONFIG_OF)
> +static const struct of_device_id ds1803_dt_ids[] = {
> + { .compatible = "maxim,ds1803-010", .data = &ds1803_cfg[DS1803_010] },
> + { .compatible = "maxim,ds1803-050", .data = &ds1803_cfg[DS1803_050] },
> + { .compatible = "maxim,ds1803-100", .data = &ds1803_cfg[DS1803_100] },
> + {}
> +};
> +MODULE_DEVICE_TABLE(of, ds1803_dt_ids);
> +#endif /* CONFIG_OF */
> +
> +static const struct i2c_device_id ds1803_id[] = {
> + { "ds1803-010", DS1803_010 },
> + { "ds1803-050", DS1803_050 },
> + { "ds1803-100", DS1803_100 },
> + {}
> +};
> +MODULE_DEVICE_TABLE(i2c, ds1803_id);
> +
> +static struct i2c_driver ds1803_driver = {
> + .driver = {
> + .name = "ds1803",
> + .of_match_table = of_match_ptr(ds1803_dt_ids),
> + },
> + .probe = ds1803_probe,
> + .id_table = ds1803_id,
> +};
> +
> +module_i2c_driver(ds1803_driver);
> +
> +MODULE_AUTHOR("Slawomir Stepien ");
> +MODULE_DESCRIPTION("DS1803 digital potentiometer");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
gt; + return 0;
> +}
> +
> +static const struct i2c_device_id max44000_id[] = {
> + {"max44000", 0},
> + { }
> +};
> +MODULE_DEVICE_TABLE(i2c, max44000_id);
> +
> +#ifdef CONFIG_OF
> +static const struct of_device_id max44000_of_match[] = {
> + { .compatible = "maxim,max44000" },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, max44000_of_match);
> +#endif
> +
> +#ifdef CONFIG_ACPI
> +static const struct acpi_device_id max44000_acpi_match[] = {
> + {"MAX44000", 0},
> + { }
> +};
> +MODULE_DEVICE_TABLE(acpi, max44000_acpi_match);
> +#endif
> +
> +static struct i2c_driver max44000_driver = {
> + .driver = {
> + .name = MAX44000_DRV_NAME,
> + .of_match_table = of_match_ptr(max44000_of_match),
> + .acpi_match_table = ACPI_PTR(max44000_acpi_match),
> + },
> + .probe = max44000_probe,
> + .remove = max44000_remove,
> + .id_table = max44000_id,
> +};
> +
> +module_i2c_driver(max44000_driver);
> +
> +MODULE_AUTHOR("Crestez Dan Leonard ");
> +MODULE_DESCRIPTION("MAX44000 Ambient and Infrared Proximity Sensor");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
dev_err(&client->dev, "iio triggered buffer setup failed\n");
> + return ret;
> + }
> +
> return iio_device_register(indio_dev);
no devm_ possible anymore :-)
> }
>
> @@ -521,6 +583,7 @@ static int max44000_remove(struct i2c_client *client)
> struct iio_dev *indio_dev = i2c_get_clientdata(client);
>
> iio_device_unregister(indio_dev);
> + iio_triggered_buffer_cleanup(indio_dev);
> return 0;
> }
>
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
rite_raw_get_fmt
>
> At this point I do not know why should I do it, but I will look into that.
write_raw expects a VAL_INT_PLUS_MICROS per default, passed
in val and val2
you can change that with .write_raw_get_fmt (e.g. to expect VAL_INT),
or just make sure that the micros are 0
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
EVICE_TABLE(i2c, adc081c_id);
> #ifdef CONFIG_OF
> static const struct of_device_id adc081c_of_match[] = {
> { .compatible = "ti,adc081c" },
> + { .compatible = "ti,adc101c" },
> + { .compatible = "ti,adc121c" },
> { }
> };
> MODULE_DEVICE_TABLE(of, adc081c_of_match);
> @@ -149,5 +172,5 @@ static struct i2c_driver adc081c_driver = {
> module_i2c_driver(adc081c_driver);
>
> MODULE_AUTHOR("Thierry Reding ");
> -MODULE_DESCRIPTION("Texas Instruments ADC081C021/027 driver");
> +MODULE_DESCRIPTION("Texas Instruments ADC081C/ADC101C/ADC121C driver");
> MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
gt; + iio_triggered_buffer_cleanup(iio);
> +err_regulator_disable:
> regulator_disable(adc->ref);
>
> return err;
> @@ -143,9 +210,9 @@ static int adc081c_remove(struct i2c_client *client)
> }
iio_triggered_buffer_cleanup() in _remove()?
> static const struct i2c_device_id adc081c_id[] = {
> - { "adc081c", 8 },
> - { "adc101c", 10 },
> - { "adc121c", 12 },
> + { "adc081c", (long)&adc081c_model },
often an enum is used instead of a pointer
> + { "adc101c", (long)&adc101c_model },
> + { "adc121c", (long)&adc121c_model },
> { }
> };
> MODULE_DEVICE_TABLE(i2c, adc081c_id);
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
t; +};
> +MODULE_DEVICE_TABLE(i2c, bmi160_i2c_id);
> +
> +static const struct acpi_device_id bmi160_acpi_match[] = {
> + {"BMI0160", 0},
> + { },
> +};
> +MODULE_DEVICE_TABLE(acpi, bmi160_acpi_match);
> +
> +static struct i2c_driver bmi160_i2c_driver = {
> + .driver = {
> + .name = BMI160_I2C_DRV_NAME,
> + .acpi_match_table = ACPI_PTR(bmi160_acpi_match),
> + },
> + .probe = bmi160_i2c_probe,
> + .remove = bmi160_i2c_remove,
> + .id_table = bmi160_i2c_id,
> +};
> +
> +module_i2c_driver(bmi160_i2c_driver);
> +
> +MODULE_AUTHOR("Daniel Baluta ");
> +MODULE_DESCRIPTION("BMI160 I2C driver");
> +MODULE_LICENSE("GPL v2");
> diff --git a/drivers/iio/imu/bmi160/bmi160_spi.c
> b/drivers/iio/imu/bmi160/bmi160_spi.c
> new file mode 100644
> index 000..444b723
> --- /dev/null
> +++ b/drivers/iio/imu/bmi160/bmi160_spi.c
> @@ -0,0 +1,71 @@
> +/*
> + * BMI160 - Bosch IMU, SPI bits
> + *
> + * Copyright (c) 2016, Intel Corporation.
> + *
> + * This file is subject to the terms and conditions of version 2 of
> + * the GNU General Public License. See the file COPYING in the main
> + * directory of this archive for more details.
> + *
> + */
> +#include
> +#include
> +#include
> +
> +#include "bmi160.h"
> +
> +#define BMI160_SPI_DRV_NAME "bmi160_spi"
> +
> +static const struct regmap_config bmi160_regmap_config = {
> + .reg_bits = 8,
> + .val_bits = 8,
> +};
> +
> +static int bmi160_spi_probe(struct spi_device *spi)
> +{
> + struct regmap *regmap;
> + const struct spi_device_id *id = spi_get_device_id(spi);
> +
> + regmap = devm_regmap_init_spi(spi, &bmi160_regmap_config);
> + if (IS_ERR(regmap)) {
> + dev_err(&spi->dev, "Failed to register spi regmap %d\n",
> + (int)PTR_ERR(regmap));
> + return PTR_ERR(regmap);
> + }
> + return bmi160_core_probe(&spi->dev, regmap, id->name, true);
> +}
> +
> +static int bmi160_spi_remove(struct spi_device *spi)
> +{
> + bmi160_core_remove(&spi->dev);
> +
> + return 0;
> +}
> +
> +static const struct spi_device_id bmi160_spi_id[] = {
> + {"bmi160", 0},
> + {}
> +};
> +
> +MODULE_DEVICE_TABLE(spi, bmi160_spi_id);
> +
> +static const struct acpi_device_id bmi160_acpi_match[] = {
> + {"BMI0160", 0},
> + { },
> +};
> +MODULE_DEVICE_TABLE(acpi, bmi160_acpi_match);
> +
> +static struct spi_driver bmi160_spi_driver = {
> + .probe = bmi160_spi_probe,
> + .remove = bmi160_spi_remove,
> + .id_table = bmi160_spi_id,
> + .driver = {
> + .acpi_match_table = ACPI_PTR(bmi160_acpi_match),
> + .name = BMI160_SPI_DRV_NAME,
> + },
> +};
> +module_spi_driver(bmi160_spi_driver);
> +
> +MODULE_AUTHOR("Daniel Baluta +MODULE_DESCRIPTION("Bosch BMI160 SPI driver");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
> +error_iio_device_register:
> + clk_disable_unprepare(info->clk);
> +error_adc_clk_enable:
> + regulator_disable(info->vref);
> +
> + return ret;
> +}
> +
> +static int imx7d_adc_remove(struct platform_device *pdev)
> +{
> + struct iio_dev *indio_
earing IRQ\n");
> +
> + return IRQ_HANDLED;
> +}
> +
> +static int ap3216c_probe(struct i2c_client *client,
> + const struct i2c_device_id *id)
> +{
> + struct ap3216c_data *data;
> + struct iio_dev *indio_dev;
> + int ret;
> +
> + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
> + if (!indio_dev)
> + return -ENOMEM;
> +
> + data = iio_priv(indio_dev);
> + data->client = client;
> + indio_dev->dev.parent = &client->dev;
> + indio_dev->info = &ap3216c_info;
> + indio_dev->name = AP3216C_DRV_NAME;
> + indio_dev->channels = ap3216c_channels;
> + indio_dev->num_channels = ARRAY_SIZE(ap3216c_channels);
> +
> + data->regmap = devm_regmap_init_i2c(client, &ap3216c_regmap_config);
> + if (IS_ERR(data->regmap)) {
> + dev_err(&client->dev, "Failed to allocate register map\n");
> + return PTR_ERR(data->regmap);
> + }
> +
> + /* Default to thresh events disabled */
> + data->als_thresh_en = false;
> + data->prox_thresh_en = false;
> +
> + /*
> + * Require that that the interrupt is cleared only when the INT
that that
> + * register is written to, instead of when data is read. This
> + * prevents the interrupt from falsely reporting IRQ_NONE.
> + */
> + ret = regmap_write(data->regmap,
> +AP3216C_INT_CLR, AP3216C_INT_CLR_MANUAL);
> + if (ret < 0)
> + return ret;
> +
> + /* Before setting up IRQ, clear any stale interrupt */
> + ret = ap3216c_clear_int(data);
> + if (ret < 0)
> + return ret;
> +
> + if (client->irq) {
> + ret = devm_request_threaded_irq(&client->dev, client->irq,
> + NULL, ap3216c_event_handler,
> + IRQF_TRIGGER_FALLING |
> + IRQF_SHARED | IRQF_ONESHOT,
> + client->name, indio_dev);
> + if (ret)
> + return ret;
> + }
> +
> + /* Enable ALS and PS+IR */
> + ret = regmap_write(data->regmap, AP3216C_SYS, AP3216C_SYS_MODE_ALS_PS);
> + if (ret < 0)
> + return ret;
> +
> + return devm_iio_device_register(&client->dev, indio_dev);
> +}
> +
> +static const struct of_device_id ap3216c_of_match[] = {
> + { .compatible = "liteon,ap3216c", },
> + { },
> +};
> +MODULE_DEVICE_TABLE(of, ap3216c_of_match);
> +
> +static const struct i2c_device_id ap3216c_id[] = {
> + {"ap3216c", 0},
> + { }
> +};
> +MODULE_DEVICE_TABLE(i2c, ap3216c_id);
> +
> +static struct i2c_driver ap3216c_driver = {
> + .driver = {
> + .name = AP3216C_DRV_NAME,
> + },
> + .probe = ap3216c_probe,
> + .id_table = ap3216c_id,
> +};
> +module_i2c_driver(ap3216c_driver);
> +
> +MODULE_AUTHOR("Robert Eshleman ");
> +MODULE_DESCRIPTION("APC3216C Ambient Light and Proximity Sensor");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
struct iio_chan_spec const *chan, int val, int val2,
> > + long mask)
> > +{
> > + int ret;
> > + struct bma400_data *data = iio_priv(indio_dev);
> > +
> > + switch (mask) {
> > + case IIO_CHAN_INFO_SAMP_FREQ:
> > + /*
> > +* The sample frequency is readonly for the temperature
> > +* register and a fixed value in low-power mode.
> > +*/
> > + if (chan->type != IIO_ACCEL)
> > + return -EINVAL;
> > +
> > + mutex_lock(&data->mutex);
> > + ret = bma400_set_accel_output_data_rate(data, val, val2);
> > + mutex_unlock(&data->mutex);
> > + return ret;
> > + case IIO_CHAN_INFO_SCALE:
> > + if (val != 0)
> > + return -EINVAL;
> > +
> > + mutex_lock(&data->mutex);
> > + ret = bma400_set_accel_scale(data, val2);
> > + mutex_unlock(&data->mutex);
> > + return ret;
> > + case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
> > + mutex_lock(&data->mutex);
> > + ret = bma400_set_accel_oversampling_ratio(data, val);
> > + mutex_unlock(&data->mutex);
> > + return ret;
> > + default:
> > + return -EINVAL;
> > + }
> > +}
> > +
> > +static int bma400_write_raw_get_fmt(struct iio_dev *indio_dev,
> > + struct iio_chan_spec const *chan,
> > + long mask)
> > +{
> > + switch (mask) {
> > + case IIO_CHAN_INFO_SAMP_FREQ:
> > + return IIO_VAL_INT_PLUS_MICRO;
> > + case IIO_CHAN_INFO_SCALE:
> > + return IIO_VAL_INT_PLUS_MICRO;
> > + case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
> > + return IIO_VAL_INT;
> > + default:
> > + return -EINVAL;
> > + }
> > +}
> > +
> > +static const struct iio_info bma400_info = {
> > + .attrs = &bma400_attrs_group,
> > + .read_raw = bma400_read_raw,
> > + .write_raw = bma400_write_raw,
> > + .write_raw_get_fmt = bma400_write_raw_get_fmt,
> > +};
> > +
> > +int bma400_probe(struct device *dev,
> > +struct regmap *regmap,
> > +const char *name)
> > +{
> > + int ret;
> > + struct bma400_data *data;
> > + struct iio_dev *indio_dev;
> > +
> > + indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
> > + if (!indio_dev)
> > + return -ENOMEM;
> > +
> > + data = iio_priv(indio_dev);
> > + data->regmap = regmap;
> > + data->dev = dev;
> > +
> > + ret = bma400_init(data);
> > + if (ret < 0)
> > + return ret;
> > +
> > + ret = iio_read_mount_matrix(dev, "mount-matrix",
> > + &data->orientation);
>
> Looks like the above will fit on one line..
>
> > + if (ret)
> > + return ret;
> > +
> > + mutex_init(&data->mutex);
> > + indio_dev->dev.parent = dev;
> > + indio_dev->name = name;
> > + indio_dev->info = &bma400_info;
> > + indio_dev->channels = bma400_channels;
> > + indio_dev->num_channels = ARRAY_SIZE(bma400_channels);
> > + indio_dev->modes = INDIO_DIRECT_MODE;
> > +
> > + dev_set_drvdata(dev, indio_dev);
> > +
> > + ret = iio_device_register(indio_dev);
> > + if (ret < 0) {
> > + dev_err(dev, "unable to register iio device\n");
> > + return ret;
>
> Drop the return out of the if statement and no need for the return 0 below.
I'd also avoid the error message altogether
>
> > + }
> > +
> > + return 0;
> > +}
> > +EXPORT_SYMBOL(bma400_probe);
> > +
> > +int bma400_remove(struct device *dev)
> > +{
> > + int ret;
> > + struct iio_dev *indio_dev = dev_get_drvdata(dev);
> > + struct bma400_data *data = iio_priv(indio_dev);
> > +
> > + mutex_lock(&data->mutex);
> > + ret = bma400_softreset(data);
> > + if (ret < 0) {
> > + /*
> > +* If the softreset failed, try to put the device in
> > +* sleep mode, but still report the error.
> > +*/
> > + dev_err(data->dev, "Failed to reset the device");
> > + bma400_set_power_mode(data, POWER_MODE_SLEEP);
> > + }
> > + mutex_unlock(&data->mutex);
> > +
> > + iio_device_unregister(indio_dev);
> > +
> > + return ret;
> > +}
> > +EXPORT_SYMBOL(bma400_remove);
> > +
> > +MODULE_AUTHOR("Dan Robertson ");
> > +MODULE_DESCRIPTION("Bosch BMA400 triaxial acceleration sensor");
> > +MODULE_LICENSE("GPL");
> > diff --git a/drivers/iio/accel/bma400_i2c.c b/drivers/iio/accel/bma400_i2c.c
> > new file mode 100644
> > index ..227012a32e13
> > --- /dev/null
> > +++ b/drivers/iio/accel/bma400_i2c.c
> > @@ -0,0 +1,54 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * bma400-i2c.c - I2C IIO driver for Bosch BMA400 triaxial acceleration
> > sensor.
> > + *
> > + * Copyright 2019 Dan Robertson
> > + *
> > + * I2C address is either 0x14 or 0x15 depending on SDO
> > + *
>
> This blank line doesn't add anything (nitpick)
>
> > + */
> > +#include
> > +#include
> > +#include
>
> Slight preference for alphabetical order. Also why ACPI?
>
> > +#include
> > +#include
> > +
> > +#include "bma400.h"
> > +
> > +static int bma400_i2c_probe(struct i2c_client *client,
> > + const struct i2c_device_id *id)
> > +{
> > + struct regmap *regmap;
> > +
> > + regmap = devm_regmap_init_i2c(client,
> > + &bma400_regmap_config);
> > +
> > + return bma400_probe(&client->dev, regmap, id->name);
> > +}
> > +
> > +static int bma400_i2c_remove(struct i2c_client *client)
> > +{
> > + return bma400_remove(&client->dev);
> > +}
> > +
> > +static const struct i2c_device_id bma400_i2c_ids[] = {
> > + { "bma400", 0 },
> > + { }
> > +};
> > +
> > +MODULE_DEVICE_TABLE(i2c, bma400_i2c_ids);
> > +
>
> Good to have a of_device_id table as well from the start.
> There is a general (but slow) move to stop using the fallback
> to the i2c_device_id table.
>
> > +static struct i2c_driver bma400_i2c_driver = {
> > + .driver = {
> > + .name = "bma400",
> > + },
> > + .probe= bma400_i2c_probe,
> > + .remove = bma400_i2c_remove,
> > + .id_table = bma400_i2c_ids,
> > +};
> > +
> > +module_i2c_driver(bma400_i2c_driver);
> > +
> > +MODULE_AUTHOR("Dan Robertson ");
> > +MODULE_DESCRIPTION("Bosch BMA400 triaxial acceleration sensor");
> > +MODULE_LICENSE("GPL");
> >
> >
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
+{
> > + struct iio_dev *indio_dev = p;
> > + struct max44009_data *data = iio_priv(indio_dev);
> > +
> > + data->timestamp = iio_get_time_ns(indio_dev);
>
> We have a standard core function to do this..
> iio_pollfunc_store_time.
>
> There 'mig
esume(struct hid_device *hdev)
> +{
> + struct appleals_device *als_dev =
> + appleib_get_drvdata(hid_get_drvdata(hdev),
> + &appleals_hid_driver);
> +
> + appleals_config_sensor(als_dev, als_dev->events_enabled,
> +als_dev->cur_sensitivity);
> +
> + return 0;
> +}
> +#endif
> +
> +static struct hid_driver appleals_hid_driver = {
> + .name = "apple-ib-als",
> + .probe = appleals_probe,
> + .remove = appleals_remove,
> + .event = appleals_hid_event,
> +#ifdef CONFIG_PM
> + .reset_resume = appleals_reset_resume,
> +#endif
> +};
> +
> +static int appleals_platform_probe(struct platform_device *pdev)
> +{
> + struct appleib_platform_data *pdata = pdev->dev.platform_data;
> + struct appleib_device *ib_dev = pdata->ib_dev;
> + struct appleals_device *als_dev;
> + int rc;
> +
> + als_dev = kzalloc(sizeof(*als_dev), GFP_KERNEL);
> + if (!als_dev)
> + return -ENOMEM;
> +
> + als_dev->ib_dev = ib_dev;
> + als_dev->log_dev = pdata->log_dev;
> +
> + rc = appleib_register_hid_driver(ib_dev, &appleals_hid_driver, als_dev);
> + if (rc) {
> + dev_err(als_dev->log_dev, "Error registering hid driver: %d\n",
> + rc);
> + goto error;
> + }
> +
> + platform_set_drvdata(pdev, als_dev);
> +
> + return 0;
> +
> +error:
> + kfree(als_dev);
> + return rc;
> +}
> +
> +static int appleals_platform_remove(struct platform_device *pdev)
> +{
> + struct appleib_platform_data *pdata = pdev->dev.platform_data;
> + struct appleib_device *ib_dev = pdata->ib_dev;
> + struct appleals_device *als_dev = platform_get_drvdata(pdev);
> + int rc;
> +
> + rc = appleib_unregister_hid_driver(ib_dev, &appleals_hid_driver);
> + if (rc) {
> + dev_err(als_dev->log_dev,
> + "Error unregistering hid driver: %d\n", rc);
> + goto error;
> + }
> +
> + kfree(als_dev);
> +
> + return 0;
> +
> +error:
> + return rc;
> +}
> +
> +static const struct platform_device_id appleals_platform_ids[] = {
> + { .name = PLAT_NAME_IB_ALS },
> + { }
> +};
> +MODULE_DEVICE_TABLE(platform, appleals_platform_ids);
> +
> +static struct platform_driver appleals_platform_driver = {
> + .id_table = appleals_platform_ids,
> + .driver = {
> + .name = "apple-ib-als",
> + },
> + .probe = appleals_platform_probe,
> + .remove = appleals_platform_remove,
> +};
> +
> +module_platform_driver(appleals_platform_driver);
> +
> +MODULE_AUTHOR("Ronald Tschalär");
> +MODULE_DESCRIPTION("Apple iBridge ALS driver");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
pat9125";
> + reg = <0x75>;
> + interrupt-parent = <&gpio3>;
> + interrupts = <12 IRQ_TYPE_EDGE_FALLING>;
> +};
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
r(&client->dev, indio_dev);
> + if (ret) {
> + dev_err(&client->dev, "IIO device register failed");
> + iio_triggered_buffer_cleanup(indio_dev);
> + return ret;
> + }
> +
> + i2c_set_clientdata(client, indio_dev);
> +
> + dev_info(&client->dev, "%s: sensor '%s'\n",
> + dev_name(&indio_dev->dev),
> + client->name);
please avoid log output, it just clutters the log
> +
> + /* Make read to reset motion bit status */
> + ret = pat9125_read_delta(data);
> + if (ret) {
> + dev_err(&client->dev, "Read register failed");
> + return ret;
> + }
> +
> + /* Init GPIO IRQ */
> + if (client->irq) {
> + ret = devm_request_threaded_irq(&client->dev,
> + client->irq,
> + pat9125_event_handler,
> + NULL,
> + IRQF_TRIGGER_FALLING,
> + "pat9125",
> + indio_dev);
> + if (ret) {
> + dev_err(&client->dev, "GPIO IRQ init failed");
> + return ret;
> + }
> + }
> + return 0;
> +}
> +
> +static int pat9125_remove(struct i2c_client *client)
> +{
> + struct iio_dev *indio_dev = devm_iio_device_alloc(&client->dev,
> sizeof(struct pat9125_data));
> +
> + iio_device_unregister(indio_dev);
> + iio_triggered_buffer_cleanup(indio_dev);
> +
> + dev_info(&client->dev, "PAT9125 removed\n");
> +
> + return 0;
> +}
> +
> +static const struct i2c_device_id pat9125_id[] = {
> + { "pat9125", 0 },
> + {}
> +};
> +MODULE_DEVICE_TABLE(i2c, pat9125_id);
> +
> +static const unsigned short normal_i2c[] = {
> + PAT9125_I2C_ADDR_HI,
> + PAT9125_I2C_ADDR_LO,
> + PAT9125_I2C_ADDR_NC,
> + I2C_CLIENT_END
> +};
> +
> +static struct i2c_driver pat9125_driver = {
> + .driver = {
> + .name = "pat9125",
> + },
> + .probe = pat9125_probe,
> + .remove = pat9125_remove,
> + .address_list = normal_i2c,
> + .id_table = pat9125_id,
> +};
> +
> +module_i2c_driver(pat9125_driver);
> +
> +MODULE_AUTHOR("Alexandre Mergnat ");
> +MODULE_DESCRIPTION("Optical Tracking sensor");
> +MODULE_LICENSE("GPL");
> \ No newline at end of file
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
_BACKGROUND);
> + if (r < 0)
> + goto err;
> +
> + /*
> + * Calibration coefficients required for reporting temperature.
> + * They are available 40ms after the device has started
> + */
> + r = regmap_read_poll_timeout(data->regmap, DPS310_MEAS_CFG, ready,
> + ready & DPS310_COEF_RDY, 1, 4);
> + if (r < 0)
> + goto err;
> +
> + r = dps310_get_temp_coef(data);
> + if (r < 0)
> + goto err;
> +
> + r = devm_iio_device_register(&client->dev, iio);
> + if (r)
> + goto err;
> +
> + i2c_set_clientdata(client, iio);
> +
> + dev_info(&client->dev, "%s: sensor '%s'\n", dev_name(&iio->dev),
> + client->name);
don't clutter the log
> +
> + return 0;
> +
> +err:
> + regmap_write(data->regmap, DPS310_RESET, DPS310_RESET_MAGIC);
> + return r;
> +}
> +
> +static int dps310_remove(struct i2c_client *client)
> +{
> + struct dps310_data *data = i2c_get_clientdata(client);
> +
> + return regmap_write(data->regmap, DPS310_RESET, DPS310_RESET_MAGIC);
> +}
> +
> +static const struct i2c_device_id dps310_id[] = {
> + { "dps310", 0 },
> + {}
> +};
> +MODULE_DEVICE_TABLE(i2c, dps310_id);
> +
> +static const unsigned short normal_i2c[] = {
> + 0x77, 0x76, I2C_CLIENT_END
> +};
> +
> +static struct i2c_driver dps310_driver = {
> + .driver = {
> + .name = "dps310",
> + },
> + .probe = dps310_probe,
> + .remove = dps310_remove,
> + .address_list = normal_i2c,
> + .id_table = dps310_id,
> +};
> +module_i2c_driver(dps310_driver);
> +
> +MODULE_AUTHOR("Joel Stanley ");
> +MODULE_DESCRIPTION("Infineon DPS310 pressure and temperature sensor");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
Set up pressure sensor in single sample, one measurement per second
> + * mode
> + */
> + r = regmap_write(data->regmap, DPS310_PRS_CFG,
> + DPS310_CALC_RATE(1) | DPS310_CALC_PRC(1));
> +
> + /*
>* Set up external (MEMS) temperature sensor in single sample, one
>* measurement per second mode
>*/
> @@ -399,16 +667,23 @@ static int dps310_probe(struct i2c_client *client,
> if (r < 0)
> goto err;
>
> - /* Temp shift is disabled when PRC <= 8 */
> + /* Temp and pressure shifts are disabled when PRC <= 8 */
> r = regmap_write_bits(data->regmap, DPS310_CFG_REG,
> - DPS310_TMP_SHIFT_EN, 0);
> + DPS310_TMP_SHIFT_EN | DPS310_PRS_SHIFT_EN, 0);
> + if (r < 0)
> + goto err;
> +
> + /* MEAS_CFG doesn't seem to update unless first written with 0 */
> + r = regmap_write_bits(data->regmap, DPS310_MEAS_CFG,
> + DPS310_MEAS_CTRL_BITS, 0);
> if (r < 0)
> goto err;
>
> - /* Turn on temperature measurement in the background */
> + /* Turn on temperature and pressure measurement in the background */
> r = regmap_write_bits(data->regmap, DPS310_MEAS_CFG,
> DPS310_MEAS_CTRL_BITS,
> - DPS310_TEMP_EN | DPS310_BACKGROUND);
> + DPS310_PRS_EN | DPS310_TEMP_EN |
> + DPS310_BACKGROUND);
> if (r < 0)
> goto err;
>
> @@ -421,7 +696,7 @@ static int dps310_probe(struct i2c_client *client,
> if (r < 0)
> goto err;
>
> - r = dps310_get_temp_coef(data);
> + r = dps310_get_coefs(data);
> if (r < 0)
> goto err;
>
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
return -ENODEV;
> +
> + /* Switch to bank0 (Magic number)*/
> + ret = regmap_write(data->regmap, 0x7F, 0x00);
maybe a #define for 0x7f, PAT9125_BANK_SWITCH_REG
> + if (ret < 0) {
> + dev_err(indio_dev->dev.parent, "register 0x%x access failed
> %d\n",
> + 0x7F, ret);
> + return ret;
> + }
> +
> + /* Software reset */
> + ret = regmap_write_bits(data->regmap,
> + PAT9125_CONFIG_REG,
> + PAT9125_RESET_BIT,
> + 1);
> + if (ret < 0) {
> + dev_err(&client->dev, "register 0x%x access failed %d\n",
> + PAT9125_CONFIG_REG, ret);
> + return ret;
> + }
> +
> + msleep(20);
> +
> + /* Init GPIO IRQ */
> + if (client->irq) {
> + ret = devm_request_threaded_irq(&client->dev,
> + client->irq,
> + NULL,
> + pat9125_threaded_event_handler,
> + IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> + "pat9125",
> + indio_dev);
> + if (ret) {
> + dev_err(&client->dev, "GPIO IRQ init failed\n");
> + return ret;
> + }
> + }
> +
> + ret = devm_iio_device_register(&client->dev, indio_dev);
> + if (ret) {
> + dev_err(&client->dev, "IIO device register failed\n");
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> +static const struct i2c_device_id pat9125_id[] = {
> + { "pat9125", 0 },
> + {}
> +};
> +MODULE_DEVICE_TABLE(i2c, pat9125_id);
> +
> +static const unsigned short normal_i2c[] = {
pat9125_ prefix please
> + PAT9125_I2C_ADDR_HI,
> + PAT9125_I2C_ADDR_LO,
> + PAT9125_I2C_ADDR_NC,
> + I2C_CLIENT_END
> +};
> +
> +static struct i2c_driver pat9125_driver = {
> + .driver = {
> + .name = "pat9125",
> + },
> + .probe = pat9125_probe,
> + .address_list = normal_i2c,
> + .id_table = pat9125_id,
> +};
> +
> +module_i2c_driver(pat9125_driver);
> +
> +MODULE_AUTHOR("Alexandre Mergnat ");
> +MODULE_DESCRIPTION("Optical Tracking sensor");
> +MODULE_LICENSE("GPL");
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
ev);
> +}
> +
> +static const struct of_device_id max5432_dt_ids[] = {
> + { .compatible = "maxim,max5432", .data = (void *)OHM_50K },
> + { .compatible = "maxim,max5433", .data = (void *)OHM_100K },
> + { .compatible = "maxim,max5434", .data = (void *)OHM_50K },
> + { .compatible = "maxim,max5435", .data = (void *)OHM_100K },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, max5432_dt_ids);
> +
> +static struct i2c_driver max5432_driver = {
> + .driver = {
> + .name = "max5432",
> + .of_match_table = of_match_ptr(max5432_dt_ids),
> + },
> + .probe = max5432_probe,
> +};
> +
> +module_i2c_driver(max5432_driver);
> +
> +MODULE_AUTHOR("Martin Kaiser ");
> +MODULE_DESCRIPTION("max5432-max5435 digital potentiometers");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
return data->irqnr;
> + }
> +
> + ret = devm_request_irq(dev, data->irqnr, mb12x2_handle_irq,
> + IRQF_TRIGGER_FALLING, id->name, indio_dev);
> + if (ret < 0) {
> + dev_err(dev, "request_irq: %d\n", ret);
> + return ret;
> + }
> + }
> +
> + ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
> + iio_pollfunc_store_time, mb12x2_trigger_handler, NULL);
> + if (ret < 0) {
> + dev_err(dev, "setup of iio triggered buffer failed\n");
> + return ret;
> + }
> +
> + return devm_iio_device_register(dev, indio_dev);
> +}
> +
> +static const struct of_device_id of_mb12x2_match[] = {
> + { .compatible = "maxbotix,i2cxl", },
> + {},
> +};
> +
> +MODULE_DEVICE_TABLE(of, of_mb12x2_match);
> +
> +static const struct i2c_device_id mb12x2_id[] = {
> + { "maxbotix-i2cxl", },
> + { }
> +};
> +MODULE_DEVICE_TABLE(i2c, mb12x2_id);
> +
> +static struct i2c_driver mb12x2_driver = {
> + .driver = {
> + .name = "maxbotix-i2cxl",
> + .of_match_table = of_mb12x2_match,
> + },
> + .probe = mb12x2_probe,
> + .id_table = mb12x2_id,
> +};
> +module_i2c_driver(mb12x2_driver);
> +
> +MODULE_AUTHOR("Andreas Klinger ");
> +MODULE_DESCRIPTION("Maxbotix I2CXL-MaxSonar i2c ultrasonic ranger driver");
> +MODULE_LICENSE("GPL");
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
0_remove,
> +};
> +module_spi_driver(rm3100_driver);
> +
> +MODULE_AUTHOR("Song Qiang ");
> +MODULE_DESCRIPTION("PNI RM3100 9-axis magnetometer spi driver");
> +MODULE_LICENSE("GPL v2");
> diff --git a/drivers/iio/magnetometer/rm3100.h
> b/drive
minor comments below
> The AMS includes an ADC as well as on-chip sensors that can be used to
> sample external voltages and monitor on-die operating conditions, such as
> temperature and supply voltage levels. The AMS has two SYSMON blocks.
> PL-SYSMON block is capable of monitoring off chip vol
8 100644
> --- a/include/uapi/linux/iio/types.h
> +++ b/include/uapi/linux/iio/types.h
> @@ -80,6 +80,7 @@ enum iio_modifier {
> IIO_MOD_CO2,
> IIO_MOD_VOC,
> IIO_MOD_LIGHT_UV,
> + IIO_MOD_DOUBLE_TAP,
> };
>
> enum iio_event_type {
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
= "ti,lm3533-als", },
> + { },
> +};
> +MODULE_DEVICE_TABLE(of, lm3533_als_of_match);
> +
> static struct platform_driver lm3533_als_driver = {
> .driver = {
> .name = "lm3533-als",
> + .of_match_table = lm3533_als_of_match,
> },
> .probe = lm3533_als_probe,
> .remove = lm3533_als_remove,
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
or distance measuring using
> > GPIOs");
> > +MODULE_LICENSE("GPL");
> > +MODULE_ALIAS("platform:srf04");
> >
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
.scan_index = 1,
> .scan_type = {
> .sign = 's',
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
gt;.sign = 'u',
> >> @@ -203,7 +203,7 @@ static const struct iio_chan_spec mpl3115_channels[] =
> >> {
> >>{
> >>.type = IIO_TEMP,
> >>.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> >> - BIT(IIO_CHAN_INFO_SCALE),
> >> + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
> >>.scan_index = 1,
> >>.scan_type = {
> >>.sign = 's',
> >>
> >
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
> >>>> .type = IIO_TEMP,
> >>>> .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> >>>> -BIT(IIO_CHAN_INFO_SCALE),
> >>>> +.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
> >>>> .scan_index = 1,
> >>>> .scan_type = {
> >>>> .sign = 's',
> >>>>
> >>>
> >>
> >
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
t *client,
> + const struct i2c_device_id *id)
> +{
> + struct iio_dev *indio_dev;
> + struct srf08_data *data;
> +
> + if (!i2c_check_functionality(client->adapter,
> + I2C_FUNC_SMBUS_READ_BYTE_DATA |
> + I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
WORD_DATA if using word_swapped() above
> + return -ENODEV;
> +
> + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
> + if (!indio_dev)
> + return -ENOMEM;
> +
> + data = iio_priv(indio_dev);
> + i2c_set_clientdata(client, indio_dev);
> + data->client = client;
> +
> + /* set default values of device */
> + data->gain = 1025;
use some defines, where do these magics come from?
> + data->range_mm = 11008;
> +
> + indio_dev->name = dev_name(&client->dev);
> + indio_dev->dev.parent = &client->dev;
> + indio_dev->modes = INDIO_DIRECT_MODE;
> + indio_dev->info = &srf08_info;
> + indio_dev->channels = srf08_channels;
> + indio_dev->num_channels = ARRAY_SIZE(srf08_channels);
> +
> + mutex_init(&data->lock);
> +
> + return devm_iio_device_register(&client->dev, indio_dev);
> +}
> +
> +static const struct i2c_device_id srf08_id[] = {
> + { "srf08", 0 },
> + { }
> +};
> +MODULE_DEVICE_TABLE(i2c, srf08_id);
> +
> +static struct i2c_driver srf08_driver = {
> + .driver = {
> + .name = "srf08",
> + },
> + .probe = srf08_probe,
> + .id_table = srf08_id,
> +};
> +module_i2c_driver(srf08_driver);
> +
> +MODULE_AUTHOR("Andreas Klinger ");
> +MODULE_DESCRIPTION("Devantech SRF08 ultrasonic ranger driver");
> +MODULE_LICENSE("GPL");
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
> Driver was checking for direct mode but not locking it. Use
> claim/release helper functions to guarantee the device stays
> in direct mode during raw writes.
looks good,
Acked-by: Peter Meerwald-Stadler
> Signed-off-by: Alison Schofield
> ---
> drivers/iio/magnetome
>;
> >> +
> >> + channels = "sync-1", "", "out";
> >> + };
> >> +
> >> +
> >> + /*
> >> + * Three parallel muxes with one mux controller, useful e.g. if
> >> + * the adc is differential, thus needing two signals to be muxed
> >> + * simultaneously for correct operation.
> >> + */
> >> + &i2c0 {
> >> + pmux: adg792a@50 {
> >> + compatible = "adi,adg792a";
> >> + reg = <0x50>;
> >> + #mux-control-cells = <0>;
> >> + adi,parallel;
> >> + };
> >> + };
> >> +
> >> + diff-adc-mux {
> >> + compatible = "io-channel-mux";
> >> + io-channels = <&adc 0>;
> >> + io-channel-names = "parent";
> >> +
> >> + mux-controls = <&pmux>;
> >> +
> >> + channels = "sync-1", "", "out";
> >> + };
> >> --
> >> 2.1.4
> >>
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> >> the body of a message to majord...@vger.kernel.org
> >> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
modes = INDIO_DIRECT_MODE;
> + indio_dev->channels = srf04_chan_spec;
> + indio_dev->num_channels = ARRAY_SIZE(srf04_chan_spec);
> +
> + return devm_iio_device_register(dev, indio_dev);
you can't use devm_iio_device_register() if you need/have a _remove()
> +}
> +
> +static int srf04_remove(struct platform_device *pdev)
> +{
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
struct srf04_data *data = iio_priv(indio_dev); // (but not needed anymore)
> + struct srf04_data *data = NULL;
> + struct iio_dev *indio_dev;
> +
> + indio_dev = platform_get_drvdata(pdev);
> + data = iio_priv(indio_dev);
> +
> + free_irq(data->irqnr, indio_dev);
I suggest to use in _probe()
devm_request_irq()
iio_device_register()
and in _remove() just
iio_device_unregister()
> +
> + return 0;
> +}
> +
> +static const struct of_device_id of_srf04_match[] = {
> + { .compatible = "devantech,srf04", },
> + {},
> +};
> +
> +MODULE_DEVICE_TABLE(of, of_srf04_match);
> +
> +static struct platform_driver srf04_driver = {
> + .probe = srf04_probe,
> + .remove = srf04_remove,
> + .driver = {
> + .name = "srf04-gpio",
> + .of_match_table = of_srf04_match,
> + },
> +};
> +
> +module_platform_driver(srf04_driver);
> +
> +MODULE_AUTHOR("Andreas Klinger ");
> +MODULE_DESCRIPTION("SRF04 ultrasonic sensor for distance measuring using
> GPIOs");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS("platform:srf04");
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
> + See Documentation/devicetree/bindings/gpio/gpio.txt
> +
> +Example:
> +srf04@0 {
> + compatible = "devantech,srf04";
> + trig-gpios = <&gpio1 15 GPIO_ACTIVE_HIGH>;
> + echo-gpios = <&gpio2 6 GPIO_ACTIVE_HIGH>;
> +};
> +
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
ensor */
> + enum motionsensor_type type;
> + enum motionsensor_location loc;
> +
> + /*
> + * Calibration parameters. Note that trigger captured data will always
> + * provide the calibrated values.
> + */
> + struct calib_data {
> + s16 offset;
> + } calib[MAX_AXIS];
> +
> + /*
> + * Static array to hold data from a single capture. For each
> + * channel we need 2 bytes, except for the timestamp. The timestamp
> + * is always last and is always 8-byte aligned.
> + */
> + u8 samples[CROS_EC_SAMPLE_SIZE];
> +
> + /* Pointer to function used for accessing sensors values. */
> + cros_ec_sensors_read_t *read_ec_sensors_data;
> +
> + /* Current sampling period */
> + int curr_sampl_freq;
> +};
> +
> +/* Basic initialization of the core structure. */
> +int cros_ec_sensors_core_init(struct platform_device *pdev,
> + struct iio_dev *indio_dev,
> + bool physical_device);
> +
> +/*
> + * cros_ec_sensors_capture - the trigger handler function
> + *
> + * @irq: the interrupt number
> + * @p: private data - always a pointer to the poll func.
> + *
> + * On a trigger event occurring, if the pollfunc is attached then this
> + * handler is called as a threaded interrupt (and hence may sleep). It
> + * is responsible for grabbing data from the device and pushing it into
> + * the associated buffer.
> + */
> +irqreturn_t cros_ec_sensors_capture(int irq, void *p);
> +
> +
> +/*
> + * cros_ec_motion_send_host_cmd - send motion sense host command
> + *
> + * @st Pointer to state information for device.
> + * @opt_length: optional length: to reduce the response size,
> + *useful on the data path.
> + *Otherwise, the maximal allowed response size is used.
> + * @return 0 if ok, -ve on error.
> + *
> + * Note, when called, the sub-command is assumed to be set in param->cmd.
> + */
> +int cros_ec_motion_send_host_cmd(struct cros_ec_sensors_core_state *st,
> + u16 opt_length);
> +
> +/*
> + * cros_ec_sensors_core_read/write: handler for core attributes.
> + *
> + * Handler for attributes identical among sensors:
> + * - frequency,
> + * - sampling_frequency.
> + *
> + * cmd_lock lock must be held.
> + */
> +int cros_ec_sensors_core_read(struct cros_ec_sensors_core_state *st,
> + struct iio_chan_spec const *chan,
> + int *val, int *val2, long mask);
> +
> +int cros_ec_sensors_core_write(struct cros_ec_sensors_core_state *st,
> +struct iio_chan_spec const *chan,
> +int val, int val2, long mask);
> +
> +extern const struct dev_pm_ops cros_ec_sensors_pm_ops;
> +
> +/* List of extended channel specification for all sensors */
> +extern const struct iio_chan_spec_ext_info cros_ec_sensors_ext_info[];
> +extern const struct iio_chan_spec_ext_info cros_ec_sensors_limited_info[];
> +
> +#endif /* __CROS_EC_SENSORS_CORE_H */
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
l4000_readable_reg,
> + .writeable_reg = vcnl4000_writeable_reg,
> +};
> +
> static int vcnl4000_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> @@ -162,7 +269,13 @@ static int vcnl4000_probe(struct i2c_client *client,
> return -ENOMEM;
>
> data = iio_priv(indio_dev);
> + data->regmap = devm_regmap_init_i2c(client, &vcnl4000_regmap_config);
> + if (IS_ERR(data->regmap)) {
> + dev_err(&client->dev, "regmap_init failed!\n");
> + return PTR_ERR(data->regmap);
> + }
> i2c_set_clientdata(client, indio_dev);
> + mutex_init(&data->lock);
> data->client = client;
>
> ret = i2c_smbus_read_byte_data(data->client, VCNL4000_PROD_REV);
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
; - if (!devm_request_region(dev, base[id], STX104_EXTENT,
> - dev_name(dev))) {
> - dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n",
> - base[id], base[id] + STX104_EXTENT);
> - return -EBUSY;
> - }
> -
> - indio_dev->info = &stx104_info;
> - indio_dev->modes = INDIO_DIRECT_MODE;
> - indio_dev->num_channels = IN_CHAN_OFFSET + STX104_NUM_IN_CHAN;
> -
> - /* determine if differential inputs */
> - if (inb(base[id] + 8) & BIT(5)) {
> - indio_dev->num_channels -= STX104_NUM_IN_CHAN / 2;
> -
> - for (i = 0; i < STX104_NUM_IN_CHAN / 2; i++) {
> - stx104_channels[i + IN_CHAN_OFFSET].differential = 1;
> - stx104_channels[i + IN_CHAN_OFFSET].channel2 = i;
> - }
> - }
> -
> - indio_dev->channels = stx104_channels;
> - indio_dev->name = dev_name(dev);
> -
> - priv = iio_priv(indio_dev);
> - priv->base = base[id];
> -
> - /* configure device for software trigger operation */
> - outb(0, base[id] + 9);
> -
> - /* initialize gain setting to x1 */
> - outb(0, base[id] + 11);
> -
> - /* initialize DAC output to 0V */
> - outw(0, base[id] + 4);
> - outw(0, base[id] + 6);
> -
> - err = devm_iio_device_register(dev, indio_dev);
> - if (err) {
> - dev_err(dev, "IIO device registering failed (%d)\n", err);
> - return err;
> - }
> -
> - stx104gpio->chip.label = dev_name(dev);
> - stx104gpio->chip.parent = dev;
> - stx104gpio->chip.owner = THIS_MODULE;
> - stx104gpio->chip.base = -1;
> - stx104gpio->chip.ngpio = 8;
> - stx104gpio->chip.get_direction = stx104_gpio_get_direction;
> - stx104gpio->chip.direction_input = stx104_gpio_direction_input;
> - stx104gpio->chip.direction_output = stx104_gpio_direction_output;
> - stx104gpio->chip.get = stx104_gpio_get;
> - stx104gpio->chip.set = stx104_gpio_set;
> - stx104gpio->base = base[id] + 3;
> - stx104gpio->out_state = 0x0;
> -
> - spin_lock_init(&stx104gpio->lock);
> -
> - dev_set_drvdata(dev, stx104gpio);
> -
> - err = gpiochip_add_data(&stx104gpio->chip, stx104gpio);
> - if (err) {
> - dev_err(dev, "GPIO registering failed (%d)\n", err);
> - return err;
> - }
> -
> - return 0;
> -}
> -
> -static int stx104_remove(struct device *dev, unsigned int id)
> -{
> - struct stx104_gpio *const stx104gpio = dev_get_drvdata(dev);
> -
> - gpiochip_remove(&stx104gpio->chip);
> -
> - return 0;
> -}
> -
> -static struct isa_driver stx104_driver = {
> - .probe = stx104_probe,
> - .driver = {
> - .name = "stx104"
> - },
> - .remove = stx104_remove
> -};
> -
> -module_isa_driver(stx104_driver, num_stx104);
> -
> -MODULE_AUTHOR("William Breathitt Gray ");
> -MODULE_DESCRIPTION("Apex Embedded Systems STX104 IIO driver");
> -MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
git/jic23/iio.git/log/?h=testing
p.
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
> > >> +.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
> > >> +.modified = 1, \
> > >> +}
> > >> +
> > >> +#define DMARD06_TEMP_CHANNEL(reg) { \
> > >> +.type = IIO_TEMP, \
> > >> +.address = reg, \
> > >> +.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
> > >> + BIT(IIO_CHAN_INFO_OFFSET),\
> > >> +}
> > >> +
> > >> +static const struct iio_chan_spec dmard06_channels[] = {
> > >> +DMARD06_ACCEL_CHANNEL(X, DMARD06_XOUT_REG),
> > >> +DMARD06_ACCEL_CHANNEL(Y, DMARD06_YOUT_REG),
> > >> +DMARD06_ACCEL_CHANNEL(Z, DMARD06_ZOUT_REG),
> > >> +DMARD06_TEMP_CHANNEL(DMARD06_TOUT_REG),
> > >> +};
> > >> +
> > >> +static int dmard06_probe(struct i2c_client *client,
> > >> +const struct i2c_device_id *id)
> > >> +{
> > >> +int error;
> > >> +struct iio_dev *indio_dev;
> > >> +struct dmard06_data *dmard06;
> > >> +
> > >> +dev_dbg(&client->dev, "I2C Address: 0x%02x\n", client->addr);
> > >
> > > not needed
> > >
> > >> +
> > >> +if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
> > >> +dev_err(&client->dev, "I2C check functionality
> > >> failed\n");
> > >> +return -ENXIO;
> > >> +}
> > >> +
> > >> +indio_dev = devm_iio_device_alloc(&client->dev,
> > >> sizeof(*dmard06));
> > >> +if (!indio_dev) {
> > >> +dev_err(&client->dev, "Failed to allocate iio
> > >> device\n");
> > >> +return -ENOMEM;
> > >> +}
> > >> +
> > >> +dmard06 = iio_priv(indio_dev);
> > >> +dmard06->client = client;
> > >> +
> > >> +error = dmard06_read_chip_id(dmard06);
> > >> +if (error)
> > >> +return error;
> > >> +
> > >> +i2c_set_clientdata(client, indio_dev);
> > >> +indio_dev->dev.parent = &client->dev;
> > >> +indio_dev->name = DMARD06_DRV_NAME;
> > >> +indio_dev->modes = INDIO_DIRECT_MODE;
> > >> +indio_dev->channels = dmard06_channels;
> > >> +indio_dev->num_channels = ARRAY_SIZE(dmard06_channels);
> > >> +indio_dev->info = &dmard06_info;
> > >> +
> > >> +return devm_iio_device_register(&client->dev, indio_dev);
> > >> +}
> > >> +
> > >> +static const struct i2c_device_id dmard06_id[] = {
> > >> +{ "dmard06", 0 },
> > >> +{ }
> > >> +};
> > >> +MODULE_DEVICE_TABLE(i2c, dmard06_id);
> > >> +
> > >> +static const struct of_device_id dmard06_of_match[] = {
> > >> +{ .compatible = "domintech,dmard06" },
> > >> +{ }
> > >> +};
> > >> +MODULE_DEVICE_TABLE(of, dmard06_of_match);
> > >> +
> > >> +static struct i2c_driver dmard06_driver = {
> > >> +.probe = dmard06_probe,
> > >> +.id_table = dmard06_id,
> > >> +.driver = {
> > >> +.name = DMARD06_DRV_NAME,
> > >> +.of_match_table = of_match_ptr(dmard06_of_match),
> > >> +},
> > >> +};
> > >> +module_i2c_driver(dmard06_driver);
> > >> +
> > >> +MODULE_AUTHOR("Aleksei Mamlin ");
> > >> +MODULE_DESCRIPTION("Domintech DMARD06 accelerometer driver");
> > >> +MODULE_LICENSE("GPL v2");
> > >>
> > >
> >
>
>
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
; + return -EINVAL;
> + }
> +
> + ret = bno055_chip_init(data);
> + if (ret < 0)
> + return ret;
> +
> + ret = devm_iio_device_register(&client->dev, indio_dev);
> + if (ret){
space before {
> + dev_err(&cli
our policy is first come, first served; I have compared the two
patches, maybe you can collaborate on a common proposal?
regards, p.
> regards,
> --navin-patidar
>
> On Tue, Jul 26, 2016 at 1:07 AM, Peter Meerwald-Stadler
> wrote:
>
> >
> > > BNO055 provid
p4725_probe(struct i2c_client *client,
> return err;
> }
> pd = (inbuf[0] >> 1) & 0x3;
> - data->powerdown = pd > 0 ? true : false;
> + data->powerdown = pd > 0;
> data->powerdown_mode = pd ? pd - 1 : 2; /* largest register to
ndex 1cd38a7e0064..c68b72088945 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -6111,6 +6111,12 @@ L: linux-me...@vger.kernel.org
> S: Maintained
> F: drivers/media/rc/iguanair.c
>
> +IIO DIGITAL POTENTIOMETER DAC
> +M: Peter Rosin
> +L: linux-...@vger.kernel.org
> +S: Maintained
> +F: Documentation/devicetree/bindings/iio/dac/dpot-dac.txt
> +
> IIO SUBSYSTEM AND DRIVERS
> M: Jonathan Cameron
> R: Hartmut Knaack
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
; > +++ b/include/linux/iio/iio.h
> > @@ -315,6 +315,23 @@ static inline bool iio_channel_has_info(const struct
> > iio_chan_spec *chan,
> > (chan->info_mask_shared_by_all & BIT(type));
> > }
> >
> > +/**
> > + * iio_channel_has_available() - Checks if a channel has an available
> > attribute
> > + * @chan: The channel to be queried
> > + * @type: Type of the available attribute to be checked
> > + *
> > + * Returns true if the channels supports reporting available values for the
channel
> > + * given attribute type, false otherwise.
> > + */
> > +static inline bool iio_channel_has_available(const struct iio_chan_spec
> > *chan,
> > +enum iio_chan_info_enum type)
> > +{
> > + return (chan->info_mask_separate_available & BIT(type)) |
> > + (chan->info_mask_shared_by_type_available & BIT(type)) |
> > + (chan->info_mask_shared_by_dir_available & BIT(type)) |
> > + (chan->info_mask_shared_by_all_available & BIT(type));
> > +}
> > +
> > #define IIO_CHAN_SOFT_TIMESTAMP(_si) {
> > \
> > .type = IIO_TIMESTAMP, \
> > .channel = -1, \
> >
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
R_ERR(dac->dpot) != -EPROBE_DEFER)
> > + dev_err(dev, "failed to get dpot input channel\n");
> > + return PTR_ERR(dac->dpot);
> > + }
> > +
> > + ret = iio_get_channel_type(dac->dpot, &type);
> > + if (ret < 0)
> > + return ret;
> > +
> > + if (type != IIO_RESISTANCE) {
> > + dev_err(dev, "dpot is of the wrong type\n");
> > + return -EINVAL;
> > + }
> > +
> > + ret = dpot_dac_channel_max_ohms(indio_dev);
> > + if (ret < 0)
> > + return ret;
> > + dac->max_ohms = ret;
> > + dev_info(dev, "dpot max is %d\n", dac->max_ohms);
> Given we can query this (indirectly) from the dpot itself, I'd drop this now.
max_ohms is u32, so this should be %u not %d?
>
> > +
> > + ret = regulator_enable(dac->vref);
> > + if (ret) {
> > + dev_err(dev, "failed to enable the vref regulator\n");
> > + return ret;
> > + }
> > +
> > + ret = iio_device_register(indio_dev);
> > + if (ret) {
> > + dev_err(dev, "failed to register iio device\n");
> > + goto disable_reg;
> > + }
> > +
> > + return 0;
> > +
> > +disable_reg:
> > + regulator_disable(dac->vref);
> > + return ret;
> > +}
> > +
> > +static int dpot_dac_remove(struct platform_device *pdev)
> > +{
> > + struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> > + struct dpot_dac *dac = iio_priv(indio_dev);
> > +
> > + iio_device_unregister(indio_dev);
> > + regulator_disable(dac->vref);
> > +
> > + return 0;
> > +}
> > +
> > +static const struct of_device_id dpot_dac_match[] = {
> > + { .compatible = "dpot-dac" },
> > + { /* sentinel */ }
> > +};
> > +MODULE_DEVICE_TABLE(of, dpot_dac_match);
> > +
> > +static struct platform_driver dpot_dac_driver = {
> > + .probe = dpot_dac_probe,
> > + .remove = dpot_dac_remove,
> > + .driver = {
> > + .name = "iio-dpot-dac",
> > + .of_match_table = dpot_dac_match,
> > + },
> > +};
> > +module_platform_driver(dpot_dac_driver);
> > +
> > +MODULE_DESCRIPTION("DAC emulation driver using a digital potentiometer");
> > +MODULE_AUTHOR("Peter Rosin ");
> > +MODULE_LICENSE("GPL v2");
> >
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
ximately to fit into a 32 bit number:
> + * 1 LSB = (AVDD * 100) / GAIN / 1678 [10^-9 mV]
> + */
> + ret = regulator_get_voltage(hx711_data->reg_avdd);
> + if (ret < 0)
disable regulator
> + return ret;
> + /* we need 10^-9 mV */
> + ret *= 100;
> +
> + for (i = 0; i < HX711_GAIN_MAX; i++)
> + hx711_gain_to_scale[i].scale =
> + ret / hx711_gain_to_scale[i].gain / 1678;
> +
> + hx711_data->gain_set = 128;
> + hx711_data->gain_chan_a = 128;
> +
> + platform_set_drvdata(pdev, iio);
> +
> + iio->name = "hx711";
> + iio->dev.parent = &pdev->dev;
> + iio->info = &hx711_iio_info;
> + iio->modes = INDIO_DIRECT_MODE;
> + iio->channels = hx711_chan_spec;
> + iio->num_channels = ARRAY_SIZE(hx711_chan_spec);
> +
> + return devm_iio_device_register(dev, iio);
disable regulator if this fails
> +}
> +
> +static int hx711_remove(struct platform_device *pdev)
> +{
> + struct hx711_data *hx711_data;
> + struct iio_dev *iio;
> +
> + iio = platform_get_drvdata(pdev);
> + hx711_data = iio_priv(iio);
> +
devm_iio_device_register and _remove() doesn't mix
> + regulator_disable(hx711_data->reg_avdd);
> +
> + return 0;
> +}
> +
> +static const struct of_device_id of_hx711_match[] = {
> + { .compatible = "avia,hx711", },
> + {},
> +};
> +
> +MODULE_DEVICE_TABLE(of, of_hx711_match);
> +
> +static struct platform_driver hx711_driver = {
> + .probe = hx711_probe,
> + .remove = hx711_remove,
> + .driver = {
> + .name = "hx711-gpio",
> + .of_match_table = of_hx711_match,
> + },
> +};
> +
> +module_platform_driver(hx711_driver);
> +
> +MODULE_AUTHOR("Andreas Klinger ");
> +MODULE_DESCRIPTION("HX711 bitbanging driver - ADC for weight cells");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS("platform:hx711-gpio");
> +
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -32,6 +32,7 @@ atlas Atlas Scientific LLC
> atmelAtmel Corporation
> auo AU Optronics Corporation
> avago Avago Technologies
> +avia avia semiconductor
> avic Shanghai AVIC Optoelectronics Co., Ltd.
> axis Axis Communications AB
> boe BOE Technology Group Co., Ltd.
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
iio->modes = INDIO_DIRECT_MODE;
> + iio->channels = hx711_chan_spec;
> + iio->num_channels = ARRAY_SIZE(hx711_chan_spec);
> +
> + dev_err(hx711_data->dev, "initialized\n");
excessive logging, please remove
> +
> + return devm_iio_device_register(dev, iio);
> +
> +err:
> + return ret;
just return directly without goto?
> +}
> +
> +
> +static int hx711_suspend(struct device *dev)
> +{
pointless, just don't do PM support
> + return 0;
> +}
> +
> +static int hx711_resume(struct device *dev)
> +{
> + return 0;
> +}
> +
> +static SIMPLE_DEV_PM_OPS(hx711_pm_ops, hx711_suspend, hx711_resume);
> +
> +
> +static const struct of_device_id of_hx711_match[] = {
> + { .compatible = "avia,hx711", },
> + {},
> +};
> +
> +MODULE_DEVICE_TABLE(of, of_hx711_match);
> +
> +static struct platform_driver hx711_driver = {
> + .probe = hx711_probe,
> + .driver = {
> + .name = "hx711-gpio",
> + .pm = &hx711_pm_ops,
> + .of_match_table = of_hx711_match,
> + },
> +};
> +
> +module_platform_driver(hx711_driver);
> +
> +MODULE_AUTHOR("Andreas Klinger ");
> +MODULE_DESCRIPTION("HX711 bitbanging driver - ADC for weight cells");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS("platform:hx711-gpio");
> +
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
ge = 1;
> > + st->scan_single_xfer[2].rx_buf = &st->rx_buf[0];
> > + st->scan_single_xfer[2].len = 2;
> > +
> Use spi_message_init_with_transfers (really minor but why not ;)
> > + spi_message_init(&st->scan_single_msg);
> > + spi_message_add_tail(&st->scan_single_xfer[0], &st->scan_single_msg);
> > + spi_message_add_tail(&st->scan_single_xfer[1], &st->scan_single_msg);
> > + spi_message_add_tail(&st->scan_single_xfer[2], &st->scan_single_msg);
> > +
> > + st->reg = devm_regulator_get(&spi->dev, "refin");
> > + if (IS_ERR(st->reg)) {
> > + dev_err(&spi->dev, "Failed get get regulator \"refin\"\n");
> > + return PTR_ERR(st->reg);
> > + }
> > +
> > + ret = regulator_enable(st->reg);
> > + if (ret) {
> > + dev_err(&spi->dev, "Failed to enable regulator \"refin\"\n");
> > + return ret;
> > + }
> > +
> > + ret = iio_triggered_buffer_setup(indio_dev, NULL,
> > +&ti_ads79xx_trigger_handler, NULL);
> > + if (ret) {
> > + dev_err(&spi->dev, "Failed to setup triggered buffer\n");
> > + goto error_disable_reg;
> > + }
> > +
> > + ret = iio_device_register(indio_dev);
> > + if (ret) {
> > + dev_err(&spi->dev, "Failed to register iio device\n");
> > + goto error_cleanup_ring;
> > + }
> > +
> Don't bother with this. It's easy to tell from sysfs or the results of the
> probe that it worked or not. This just puts uninformative noise in the
> logs (different matter if there is a serial number of similar that provides
> additional info!)
> > + dev_info(&spi->dev, "Registered %s\n", indio_dev->name);
> > +
> > + return 0;
> > +
> > +error_cleanup_ring:
> > + iio_triggered_buffer_cleanup(indio_dev);
> > +error_disable_reg:
> > + regulator_disable(st->reg);
> > +
> > + return ret;
> > +}
> > +
> > +static int ti_ads79xx_remove(struct spi_device *spi)
> > +{
> > + struct iio_dev *indio_dev = spi_get_drvdata(spi);
> > + struct ti_ads79xx_state *st = iio_priv(indio_dev);
> > +
> > + iio_device_unregister(indio_dev);
> > + iio_triggered_buffer_cleanup(indio_dev);
> > + regulator_disable(st->reg);
> > +
> > + return 0;
> > +}
> > +
> > +static const struct spi_device_id ti_ads79xx_id[] = {
> > + {"ti-ads7950", ADS7950},
> > + {"ti-ads7951", ADS7951},
> > + {"ti-ads7952", ADS7952},
> > + {"ti-ads7953", ADS7953},
> > + {"ti-ads7954", ADS7954},
> > + {"ti-ads7955", ADS7955},
> > + {"ti-ads7956", ADS7956},
> > + {"ti-ads7957", ADS7957},
> > + {"ti-ads7958", ADS7958},
> > + {"ti-ads7959", ADS7959},
> > + {"ti-ads7960", ADS7960},
> > + {"ti-ads7961", ADS7961},
> > + { }
> > +};
> > +MODULE_DEVICE_TABLE(spi, ti_ads79xx_id);
> > +
> > +static struct spi_driver ti_ads79xx_driver = {
> > + .driver = {
> > + .name = "ti-ads79xx",
> > + },
> > + .probe = ti_ads79xx_probe,
> > + .remove = ti_ads79xx_remove,
> > + .id_table = ti_ads79xx_id,
> > +};
> > +module_spi_driver(ti_ads79xx_driver);
> > +
> > +MODULE_AUTHOR("David Lechner ");
> > +MODULE_DESCRIPTION("TI ADS79XX ADC");
> > +MODULE_LICENSE("GPL v2");
> >
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
that *val * scale gives mV
> > +
> > + return IIO_VAL_INT;
> > + case IIO_CHAN_INFO_SCALE:
> > + ret = ti_ads7950_get_range(st);
> > + if (ret < 0)
> > + return ret;
> > +
> > + *val = ret;
> > + *val2 = chan->scan_type.realbits;
> > +
> > + return IIO_VAL_FRACTIONAL_LOG2;
> > + }
> > +
> > + return -EINVAL;
> > +}
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
k_disable_unprepare(data->clk_scaler->clk);
> + clk_hw_unregister_divider(data->clk_scaler);
> +
> +scaler_error:
> + clk_hw_unregister_divider(data->clk_prescaler);
> +
> +prescaler_error:
> +resource_error:
> + return ret;
> +}
> +
> +static int asp
io_device_register(&client->dev, indio_dev);
no devm_ since we have a non-empty _remove()?
> + if (ret < 0)
> + goto err_regulator_disable;
> +
> + return 0;
> +
> +err_regulator_disable:
> + regulator_disable(st->ref);
> +
> + return ret;
> +}
> +
> +static int ltc2497_remove(struct i2c_client *client)
> +{
> + struct iio_dev *indio_dev = i2c_get_clientdata(client);
> + struct ltc2497_st *st = iio_priv(indio_dev);
> +
> + regulator_disable(st->ref);
> +
> + return 0;
> +}
> +
> +static const struct i2c_device_id ltc2497_id[] = {
> + { "ltc2497", 0 },
> + { }
> +};
> +MODULE_DEVICE_TABLE(i2c, ltc2497_id);
> +
> +static const struct of_device_id ltc2497_of_match[] = {
> + { .compatible = "lltc,ltc2497", },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, ltc2497_of_match);
> +
> +static struct i2c_driver ltc2497_driver = {
> + .driver = {
> + .name = "ltc2497",
> + .of_match_table = of_match_ptr(ltc2497_of_match),
> + },
> + .probe = ltc2497_probe,
> + .remove = ltc2497_remove,
> + .id_table = ltc2497_id,
> +};
> +module_i2c_driver(ltc2497_driver);
> +
> +MODULE_AUTHOR("Michael Hennerich ");
> +MODULE_DESCRIPTION("Linear Technology LTC2497 ADC driver");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
DATA |
> + I2C_FUNC_SMBUS_READ_I2C_BLOCK))
> + return -ENODEV;
> +
> + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
> + if (!indio_dev)
> + return -ENOMEM;
> +
> + data = iio_priv(indio_dev);
> + i2c_set_clientdata(client, indio_dev);
> + data->client = client;
> + mutex_init(&data->lock);
> +
> + indio_dev->dev.parent = &client->dev;
> + indio_dev->name = id->name;
> + indio_dev->modes = INDIO_DIRECT_MODE;
> + indio_dev->info = &sht21_info;
> + indio_dev->channels = sht21_channels;
> + indio_dev->num_channels = ARRAY_SIZE(sht21_channels);
> +
> + ret = sht21_soft_reset(data);
> + if (ret)
> + return ret;
> +
> + ret = iio_triggered_buffer_setup(indio_dev, NULL,
> + sht21_trigger_handler, NULL);
> + if (ret)
> + return ret;
> +
> + ret = iio_device_register(indio_dev);
> + if (ret)
> + iio_triggered_buffer_cleanup(indio_dev);
> +
> + return ret;
> +}
> +
> +static int sht21_remove(struct i2c_client *client)
> +{
> + struct iio_dev *indio_dev = i2c_get_clientdata(client);
> +
> + iio_device_unregister(indio_dev);
> + iio_triggered_buffer_cleanup(indio_dev);
> +
> + return 0;
> +}
> +
> +static const struct i2c_device_id sht21_id[] = {
> + { "sht21", 0 },
> + { }
> +};
> +MODULE_DEVICE_TABLE(i2c, sht21_id);
> +
> +static const struct of_device_id sht21_of_match[] = {
> + { .compatible = "sensirion,sht21" },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, sht21_of_match);
> +
> +static struct i2c_driver sht21_driver = {
> + .driver = {
> + .name = SHT21_DRV_NAME,
> + .of_match_table = of_match_ptr(sht21_of_match),
> + },
> + .id_table = sht21_id,
> + .probe = sht21_probe,
> + .remove = sht21_remove,
> +};
> +module_i2c_driver(sht21_driver);
> +
> +MODULE_DESCRIPTION("Sensirion SHT21 relative humidity and temperature sensor
> driver");
> +MODULE_AUTHOR("Tomasz Duszynski ");
> +MODULE_LICENSE("GPL v2");
> --
> 2.11.1
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
1_info;
> + indio_dev->modes = INDIO_DIRECT_MODE;
> + indio_dev->channels = dsm501_channels;
> + indio_dev->num_channels = ARRAY_SIZE(dsm501_channels);
> +
> + return devm_iio_device_register(&pdev->dev, indio_dev);
> +}
> +
> +static const struct of_device_id dsm501_id[] = {
> + {
> + .compatible = "samyoung,dsm501",
> + .data = dsm501_number_concentartion,
type: concentration
> + },
> + {
> + .compatible = "shinyei,ppd42ns",
> + .data = ppd42ns_number_concentration,
> + },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, dsm501_id);
> +
> +static struct platform_driver dsm501_driver = {
> + .driver = {
> + .name = DSM501_DRV_NAME,
> + .of_match_table = of_match_ptr(dsm501_id)
> + },
> + .probe = dsm501_probe
> +};
> +module_platform_driver(dsm501_driver);
> +
> +MODULE_AUTHOR("Tomasz Duszynski ");
> +MODULE_DESCRIPTION("Samyoung DSM501 particle sensor driver");
> +MODULE_LICENSE("GPL v2");
>
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
};
>
> static const char * const iio_modifier_names[] = {
> diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h
> index ffafd6c25a48..52696e251c4d 100644
> --- a/include/uapi/linux/iio/types.h
> +++ b/include/uapi/linux/iio/types.h
> @@ -43,6 +43,7 @@ enum iio
gs, CR, SSC_BIT(CR_SWRST));
which is performed unconditionally when a stream starts
code was introduced with
ASoC: atmel_ssc_dai: refactor the startup and shutdown, commit cbaadf0f90d6
tested with the 4.1 branch of linux-at91 git
thanks, regards, p.
--
Peter Meerwald-Stadler
+43-664-218 (mobile)
1 - 100 of 144 matches
Mail list logo