diff for duplicates of <20180520112312.668e0213@archlinux> diff --git a/a/1.txt b/N1/1.txt index 5430bfe..f0faa52 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -1,9 +1,8 @@ On Sun, 20 May 2018 02:19:17 +0200 Silvan Murer <silvan.murer@gmail.com> wrote: -> Add support for external reference voltage through the regulator framewor= -k. ->=20 +> Add support for external reference voltage through the regulator framework. +> > Signed-off-by: Silvan Murer <silvan.murer@gmail.com> > Reviewed-by: Lars-Peter Clausen <lars@metafoo.de> @@ -26,118 +25,106 @@ Jonathan > - Return an error when a regulator is specified > - Use internal reference when no regulator is specified > - Use iio_device_register instead of devm_iio_device_register ->=20 -> =C2=A0.../devicetree/bindings/iio/dac/ltc2632.txt=C2=A0=C2=A0=C2=A0=C2=A0= -=C2=A0=C2=A0=C2=A0=C2=A0| 14 +++++ -> =C2=A0drivers/iio/dac/ltc2632.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= -=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0| 70 +++++++++++++++++++--- -> =C2=A02 files changed, 75 insertions(+), 9 deletions(-) ->=20 -> diff --git a/Documentation/devicetree/bindings/iio/dac/ltc2632.txt b/Docu= -mentation/devicetree/bindings/iio/dac/ltc2632.txt +> +> .../devicetree/bindings/iio/dac/ltc2632.txt | 14 +++++ +> drivers/iio/dac/ltc2632.c | 70 +++++++++++++++++++--- +> 2 files changed, 75 insertions(+), 9 deletions(-) +> +> diff --git a/Documentation/devicetree/bindings/iio/dac/ltc2632.txt b/Documentation/devicetree/bindings/iio/dac/ltc2632.txt > index eb911e5..e0d5fea 100644 > --- a/Documentation/devicetree/bindings/iio/dac/ltc2632.txt > +++ b/Documentation/devicetree/bindings/iio/dac/ltc2632.txt > @@ -12,12 +12,26 @@ Required properties: -> =C2=A0Property rules described in Documentation/devicetree/bindings/spi/s= -pi-bus.txt -> =C2=A0apply. In particular, "reg" and "spi-max-frequency" properties must= - be given. -> =C2=A0 +> Property rules described in Documentation/devicetree/bindings/spi/spi-bus.txt +> apply. In particular, "reg" and "spi-max-frequency" properties must be given. +> > +Optional properties: -> + - vref-supply: Phandle to the external reference voltage supply. This s= -hould -> + =C2=A0=C2=A0only be set if there is an external reference voltage conne= -cted to the VREF -> + =C2=A0=C2=A0pin. If the property is not set the internal reference is u= -sed. +> + - vref-supply: Phandle to the external reference voltage supply. This should +> + only be set if there is an external reference voltage connected to the VREF +> + pin. If the property is not set the internal reference is used. > + -> =C2=A0Example: -> =C2=A0 +> Example: +> > + vref: regulator-vref { -> + compatible =3D "regulator-fixed"; -> + regulator-name =3D "vref-ltc2632"; -> + regulator-min-microvolt =3D <1250000>; -> + regulator-max-microvolt =3D <1250000>; +> + compatible = "regulator-fixed"; +> + regulator-name = "vref-ltc2632"; +> + regulator-min-microvolt = <1250000>; +> + regulator-max-microvolt = <1250000>; > + regulator-always-on; > + }; > + -> =C2=A0 spi_master { -> =C2=A0 dac: ltc2632@0 { -> =C2=A0 compatible =3D "lltc,ltc2632-l12"; -> =C2=A0 reg =3D <0>; /* CS0 */ -> =C2=A0 spi-max-frequency =3D <1000000>; -> + vref-supply =3D <&vref>; /* optional */ -> =C2=A0 }; -> =C2=A0 }; +> spi_master { +> dac: ltc2632@0 { +> compatible = "lltc,ltc2632-l12"; +> reg = <0>; /* CS0 */ +> spi-max-frequency = <1000000>; +> + vref-supply = <&vref>; /* optional */ +> }; +> }; > diff --git a/drivers/iio/dac/ltc2632.c b/drivers/iio/dac/ltc2632.c > index d322b78..9551156 100644 > --- a/drivers/iio/dac/ltc2632.c > +++ b/drivers/iio/dac/ltc2632.c > @@ -2,6 +2,7 @@ -> =C2=A0 * LTC2632 Digital to analog convertors spi driver -> =C2=A0 * -> =C2=A0 * Copyright 2017 Maxime Roussin-B=C3=A9langer +> * LTC2632 Digital to analog convertors spi driver +> * +> * Copyright 2017 Maxime Roussin-Bélanger > + * expanded by Silvan Murer <silvan.murer@gmail.com> -> =C2=A0 * -> =C2=A0 * Licensed under the GPL-2. -> =C2=A0 */ +> * +> * Licensed under the GPL-2. +> */ > @@ -10,6 +11,7 @@ -> =C2=A0#include <linux/spi/spi.h> -> =C2=A0#include <linux/module.h> -> =C2=A0#include <linux/iio/iio.h> +> #include <linux/spi/spi.h> +> #include <linux/module.h> +> #include <linux/iio/iio.h> > +#include <linux/regulator/consumer.h> -> =C2=A0 -> =C2=A0#define LTC2632_DAC_CHANNELS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= -=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= -=C2=A02 -> =C2=A0 +> +> #define LTC2632_DAC_CHANNELS 2 +> > @@ -28,7 +30,7 @@ -> =C2=A0/** -> =C2=A0 * struct ltc2632_chip_info - chip specific information -> =C2=A0 * @channels: channel spec for the DAC +> /** +> * struct ltc2632_chip_info - chip specific information +> * @channels: channel spec for the DAC > - * @vref_mv: reference voltage > + * @vref_mv: internal reference voltage -> =C2=A0 */ -> =C2=A0struct ltc2632_chip_info { -> =C2=A0 const struct iio_chan_spec *channels; +> */ +> struct ltc2632_chip_info { +> const struct iio_chan_spec *channels; > @@ -39,10 +41,14 @@ struct ltc2632_chip_info { -> =C2=A0 * struct ltc2632_state - driver instance specific data -> =C2=A0 * @spi_dev: pointer to the spi_device struct -> =C2=A0 * @powerdown_cache_mask used to show current channel powerdown sta= -te +> * struct ltc2632_state - driver instance specific data +> * @spi_dev: pointer to the spi_device struct +> * @powerdown_cache_mask used to show current channel powerdown state > + * @vref_mv used reference voltage (internal or external) > + * @vref_reg regulator for the reference voltage -> =C2=A0 */ -> =C2=A0struct ltc2632_state { -> =C2=A0 struct spi_device *spi_dev; -> =C2=A0 unsigned int powerdown_cache_mask; +> */ +> struct ltc2632_state { +> struct spi_device *spi_dev; +> unsigned int powerdown_cache_mask; > + int vref_mv; > + struct regulator *vref_reg; -> =C2=A0}; -> =C2=A0 -> =C2=A0enum ltc2632_supported_device_ids { +> }; +> +> enum ltc2632_supported_device_ids { > @@ -90,7 +96,7 @@ static int ltc2632_read_raw(struct iio_dev *indio_dev, -> =C2=A0 -> =C2=A0 switch (m) { -> =C2=A0 case IIO_CHAN_INFO_SCALE: -> - *val =3D chip_info->vref_mv; -> + *val =3D st->vref_mv; -> =C2=A0 *val2 =3D chan->scan_type.realbits; -> =C2=A0 return IIO_VAL_FRACTIONAL_LOG2; -> =C2=A0 } +> +> switch (m) { +> case IIO_CHAN_INFO_SCALE: +> - *val = chip_info->vref_mv; +> + *val = st->vref_mv; +> *val2 = chan->scan_type.realbits; +> return IIO_VAL_FRACTIONAL_LOG2; +> } > @@ -247,6 +253,45 @@ static int ltc2632_probe(struct spi_device *spi) -> =C2=A0 chip_info =3D (struct ltc2632_chip_info *) -> =C2=A0 spi_get_device_id(spi)->driver_data; -> =C2=A0 -> + st->vref_reg =3D devm_regulator_get_optional(&spi->dev, "vref"); -> + if (PTR_ERR(st->vref_reg) =3D=3D -ENODEV) { +> chip_info = (struct ltc2632_chip_info *) +> spi_get_device_id(spi)->driver_data; +> +> + st->vref_reg = devm_regulator_get_optional(&spi->dev, "vref"); +> + if (PTR_ERR(st->vref_reg) == -ENODEV) { > + /* use internal reference voltage */ -> + st->vref_reg =3D NULL; -> + st->vref_mv =3D chip_info->vref_mv; +> + st->vref_reg = NULL; +> + st->vref_mv = chip_info->vref_mv; > + -> + ret =3D ltc2632_spi_write(spi, LTC2632_CMD_INTERNAL_REFER, +> + ret = ltc2632_spi_write(spi, LTC2632_CMD_INTERNAL_REFER, > + 0, 0, 0); > + if (ret) { > + dev_err(&spi->dev, @@ -151,16 +138,16 @@ te > + return PTR_ERR(st->vref_reg); > + } else { > + /* use external reference voltage */ -> + ret =3D regulator_enable(st->vref_reg); +> + ret = regulator_enable(st->vref_reg); > + if (ret) { > + dev_err(&spi->dev, > + "enable reference regulator failed, %d\n", > + ret); > + return ret; > + } -> + st->vref_mv =3D regulator_get_voltage(st->vref_reg) / 1000; +> + st->vref_mv = regulator_get_voltage(st->vref_reg) / 1000; > + -> + ret =3D ltc2632_spi_write(spi, LTC2632_CMD_EXTERNAL_REFER, +> + ret = ltc2632_spi_write(spi, LTC2632_CMD_EXTERNAL_REFER, > + 0, 0, 0); > + if (ret) { > + dev_err(&spi->dev, @@ -170,15 +157,14 @@ te > + } > + } > + -> =C2=A0 indio_dev->dev.parent =3D &spi->dev; -> =C2=A0 indio_dev->name =3D dev_of_node(&spi->dev) ? dev_of_node(&spi->dev= -)->name -> =C2=A0 =C2=A0: spi_get_device_id(spi)->name; +> indio_dev->dev.parent = &spi->dev; +> indio_dev->name = dev_of_node(&spi->dev) ? dev_of_node(&spi->dev)->name +> : spi_get_device_id(spi)->name; > @@ -255,14 +300,20 @@ static int ltc2632_probe(struct spi_device *spi) -> =C2=A0 indio_dev->channels =3D chip_info->channels; -> =C2=A0 indio_dev->num_channels =3D LTC2632_DAC_CHANNELS; -> =C2=A0 -> - ret =3D ltc2632_spi_write(spi, LTC2632_CMD_INTERNAL_REFER, 0, 0, 0); +> indio_dev->channels = chip_info->channels; +> indio_dev->num_channels = LTC2632_DAC_CHANNELS; +> +> - ret = ltc2632_spi_write(spi, LTC2632_CMD_INTERNAL_REFER, 0, 0, 0); > - if (ret) { > - dev_err(&spi->dev, > - "Set internal reference command failed, %d\n", ret); @@ -189,26 +175,26 @@ te > + > +static int ltc2632_remove(struct spi_device *spi) > +{ -> + struct iio_dev *indio_dev =3D spi_get_drvdata(spi); -> + struct ltc2632_state *st =3D iio_priv(indio_dev); +> + struct iio_dev *indio_dev = spi_get_drvdata(spi); +> + struct ltc2632_state *st = iio_priv(indio_dev); > + > + iio_device_unregister(indio_dev); > + > + if (st->vref_reg) > + regulator_disable(st->vref_reg); -> =C2=A0 +> > - return devm_iio_device_register(&spi->dev, indio_dev); > + return 0; -> =C2=A0} -> =C2=A0 -> =C2=A0static const struct spi_device_id ltc2632_id[] =3D { -> @@ -306,6 +357,7 @@ static struct spi_driver ltc2632_driver =3D { -> =C2=A0 .of_match_table =3D of_match_ptr(ltc2632_of_match), -> =C2=A0 }, -> =C2=A0 .probe =3D ltc2632_probe, -> + .remove =3D ltc2632_remove, -> =C2=A0 .id_table =3D ltc2632_id, -> =C2=A0}; -> =C2=A0module_spi_driver(ltc2632_driver); -> --=C2=A0 +> } +> +> static const struct spi_device_id ltc2632_id[] = { +> @@ -306,6 +357,7 @@ static struct spi_driver ltc2632_driver = { +> .of_match_table = of_match_ptr(ltc2632_of_match), +> }, +> .probe = ltc2632_probe, +> + .remove = ltc2632_remove, +> .id_table = ltc2632_id, +> }; +> module_spi_driver(ltc2632_driver); +> -- > 2.7.4 diff --git a/a/content_digest b/N1/content_digest index ff18632..dfdc9a2 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -11,9 +11,8 @@ "On Sun, 20 May 2018 02:19:17 +0200\n" "Silvan Murer <silvan.murer@gmail.com> wrote:\n" "\n" - "> Add support for external reference voltage through the regulator framewor=\n" - "k.\n" - ">=20\n" + "> Add support for external reference voltage through the regulator framework.\n" + "> \n" "> Signed-off-by: Silvan Murer <silvan.murer@gmail.com>\n" "> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>\n" "\n" @@ -36,118 +35,106 @@ "> \t- Return an error when a regulator is specified\n" "> \t- Use internal reference when no regulator is specified\n" "> \t- Use iio_device_register instead of devm_iio_device_register\n" - ">=20\n" - "> =C2=A0.../devicetree/bindings/iio/dac/ltc2632.txt=C2=A0=C2=A0=C2=A0=C2=A0=\n" - "=C2=A0=C2=A0=C2=A0=C2=A0| 14 +++++\n" - "> =C2=A0drivers/iio/dac/ltc2632.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=\n" - "=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=\n" - "=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0| 70 +++++++++++++++++++---\n" - "> =C2=A02 files changed, 75 insertions(+), 9 deletions(-)\n" - ">=20\n" - "> diff --git a/Documentation/devicetree/bindings/iio/dac/ltc2632.txt b/Docu=\n" - "mentation/devicetree/bindings/iio/dac/ltc2632.txt\n" + "> \n" + "> \302\240.../devicetree/bindings/iio/dac/ltc2632.txt\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240| 14 +++++\n" + "> \302\240drivers/iio/dac/ltc2632.c\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240| 70 +++++++++++++++++++---\n" + "> \302\2402 files changed, 75 insertions(+), 9 deletions(-)\n" + "> \n" + "> diff --git a/Documentation/devicetree/bindings/iio/dac/ltc2632.txt b/Documentation/devicetree/bindings/iio/dac/ltc2632.txt\n" "> index eb911e5..e0d5fea 100644\n" "> --- a/Documentation/devicetree/bindings/iio/dac/ltc2632.txt\n" "> +++ b/Documentation/devicetree/bindings/iio/dac/ltc2632.txt\n" "> @@ -12,12 +12,26 @@ Required properties:\n" - "> =C2=A0Property rules described in Documentation/devicetree/bindings/spi/s=\n" - "pi-bus.txt\n" - "> =C2=A0apply. In particular, \"reg\" and \"spi-max-frequency\" properties must=\n" - " be given.\n" - "> =C2=A0\n" + "> \302\240Property rules described in Documentation/devicetree/bindings/spi/spi-bus.txt\n" + "> \302\240apply. In particular, \"reg\" and \"spi-max-frequency\" properties must be given.\n" + "> \302\240\n" "> +Optional properties:\n" - "> +\t- vref-supply: Phandle to the external reference voltage supply. This s=\n" - "hould\n" - "> +\t=C2=A0=C2=A0only be set if there is an external reference voltage conne=\n" - "cted to the VREF\n" - "> +\t=C2=A0=C2=A0pin. If the property is not set the internal reference is u=\n" - "sed.\n" + "> +\t- vref-supply: Phandle to the external reference voltage supply. This should\n" + "> +\t\302\240\302\240only be set if there is an external reference voltage connected to the VREF\n" + "> +\t\302\240\302\240pin. If the property is not set the internal reference is used.\n" "> +\n" - "> =C2=A0Example:\n" - "> =C2=A0\n" + "> \302\240Example:\n" + "> \302\240\n" "> +\tvref: regulator-vref {\n" - "> +\t\tcompatible =3D \"regulator-fixed\";\n" - "> +\t\tregulator-name =3D \"vref-ltc2632\";\n" - "> +\t\tregulator-min-microvolt =3D <1250000>;\n" - "> +\t\tregulator-max-microvolt =3D <1250000>;\n" + "> +\t\tcompatible = \"regulator-fixed\";\n" + "> +\t\tregulator-name = \"vref-ltc2632\";\n" + "> +\t\tregulator-min-microvolt = <1250000>;\n" + "> +\t\tregulator-max-microvolt = <1250000>;\n" "> +\t\tregulator-always-on;\n" "> +\t};\n" "> +\n" - "> =C2=A0\tspi_master {\n" - "> =C2=A0\t\tdac: ltc2632@0 {\n" - "> =C2=A0\t\t\tcompatible =3D \"lltc,ltc2632-l12\";\n" - "> =C2=A0\t\t\treg =3D <0>; /* CS0 */\n" - "> =C2=A0\t\t\tspi-max-frequency =3D <1000000>;\n" - "> +\t\t\tvref-supply =3D <&vref>; /* optional */\n" - "> =C2=A0\t\t};\n" - "> =C2=A0\t};\n" + "> \302\240\tspi_master {\n" + "> \302\240\t\tdac: ltc2632@0 {\n" + "> \302\240\t\t\tcompatible = \"lltc,ltc2632-l12\";\n" + "> \302\240\t\t\treg = <0>; /* CS0 */\n" + "> \302\240\t\t\tspi-max-frequency = <1000000>;\n" + "> +\t\t\tvref-supply = <&vref>; /* optional */\n" + "> \302\240\t\t};\n" + "> \302\240\t};\n" "> diff --git a/drivers/iio/dac/ltc2632.c b/drivers/iio/dac/ltc2632.c\n" "> index d322b78..9551156 100644\n" "> --- a/drivers/iio/dac/ltc2632.c\n" "> +++ b/drivers/iio/dac/ltc2632.c\n" "> @@ -2,6 +2,7 @@\n" - "> =C2=A0 * LTC2632 Digital to analog convertors spi driver\n" - "> =C2=A0 *\n" - "> =C2=A0 * Copyright 2017 Maxime Roussin-B=C3=A9langer\n" + "> \302\240 * LTC2632 Digital to analog convertors spi driver\n" + "> \302\240 *\n" + "> \302\240 * Copyright 2017 Maxime Roussin-B\303\251langer\n" "> + * expanded by Silvan Murer <silvan.murer@gmail.com>\n" - "> =C2=A0 *\n" - "> =C2=A0 * Licensed under the GPL-2.\n" - "> =C2=A0 */\n" + "> \302\240 *\n" + "> \302\240 * Licensed under the GPL-2.\n" + "> \302\240 */\n" "> @@ -10,6 +11,7 @@\n" - "> =C2=A0#include <linux/spi/spi.h>\n" - "> =C2=A0#include <linux/module.h>\n" - "> =C2=A0#include <linux/iio/iio.h>\n" + "> \302\240#include <linux/spi/spi.h>\n" + "> \302\240#include <linux/module.h>\n" + "> \302\240#include <linux/iio/iio.h>\n" "> +#include <linux/regulator/consumer.h>\n" - "> =C2=A0\n" - "> =C2=A0#define LTC2632_DAC_CHANNELS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=\n" - "=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=\n" - "=C2=A02\n" - "> =C2=A0\n" + "> \302\240\n" + "> \302\240#define LTC2632_DAC_CHANNELS\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\2402\n" + "> \302\240\n" "> @@ -28,7 +30,7 @@\n" - "> =C2=A0/**\n" - "> =C2=A0 * struct ltc2632_chip_info - chip specific information\n" - "> =C2=A0 * @channels:\t\tchannel spec for the DAC\n" + "> \302\240/**\n" + "> \302\240 * struct ltc2632_chip_info - chip specific information\n" + "> \302\240 * @channels:\t\tchannel spec for the DAC\n" "> - * @vref_mv:\t\treference voltage\n" "> + * @vref_mv:\t\tinternal reference voltage\n" - "> =C2=A0 */\n" - "> =C2=A0struct ltc2632_chip_info {\n" - "> =C2=A0\tconst struct iio_chan_spec *channels;\n" + "> \302\240 */\n" + "> \302\240struct ltc2632_chip_info {\n" + "> \302\240\tconst struct iio_chan_spec *channels;\n" "> @@ -39,10 +41,14 @@ struct ltc2632_chip_info {\n" - "> =C2=A0 * struct ltc2632_state - driver instance specific data\n" - "> =C2=A0 * @spi_dev:\t\t\tpointer to the spi_device struct\n" - "> =C2=A0 * @powerdown_cache_mask\tused to show current channel powerdown sta=\n" - "te\n" + "> \302\240 * struct ltc2632_state - driver instance specific data\n" + "> \302\240 * @spi_dev:\t\t\tpointer to the spi_device struct\n" + "> \302\240 * @powerdown_cache_mask\tused to show current channel powerdown state\n" "> + * @vref_mv\t\t\tused reference voltage (internal or external)\n" "> + * @vref_reg\t\tregulator for the reference voltage\n" - "> =C2=A0 */\n" - "> =C2=A0struct ltc2632_state {\n" - "> =C2=A0\tstruct spi_device *spi_dev;\n" - "> =C2=A0\tunsigned int powerdown_cache_mask;\n" + "> \302\240 */\n" + "> \302\240struct ltc2632_state {\n" + "> \302\240\tstruct spi_device *spi_dev;\n" + "> \302\240\tunsigned int powerdown_cache_mask;\n" "> +\tint vref_mv;\n" "> +\tstruct regulator *vref_reg;\n" - "> =C2=A0};\n" - "> =C2=A0\n" - "> =C2=A0enum ltc2632_supported_device_ids {\n" + "> \302\240};\n" + "> \302\240\n" + "> \302\240enum ltc2632_supported_device_ids {\n" "> @@ -90,7 +96,7 @@ static int ltc2632_read_raw(struct iio_dev *indio_dev,\n" - "> =C2=A0\n" - "> =C2=A0\tswitch (m) {\n" - "> =C2=A0\tcase IIO_CHAN_INFO_SCALE:\n" - "> -\t\t*val =3D chip_info->vref_mv;\n" - "> +\t\t*val =3D st->vref_mv;\n" - "> =C2=A0\t\t*val2 =3D chan->scan_type.realbits;\n" - "> =C2=A0\t\treturn IIO_VAL_FRACTIONAL_LOG2;\n" - "> =C2=A0\t}\n" + "> \302\240\n" + "> \302\240\tswitch (m) {\n" + "> \302\240\tcase IIO_CHAN_INFO_SCALE:\n" + "> -\t\t*val = chip_info->vref_mv;\n" + "> +\t\t*val = st->vref_mv;\n" + "> \302\240\t\t*val2 = chan->scan_type.realbits;\n" + "> \302\240\t\treturn IIO_VAL_FRACTIONAL_LOG2;\n" + "> \302\240\t}\n" "> @@ -247,6 +253,45 @@ static int ltc2632_probe(struct spi_device *spi)\n" - "> =C2=A0\tchip_info =3D (struct ltc2632_chip_info *)\n" - "> =C2=A0\t\t\tspi_get_device_id(spi)->driver_data;\n" - "> =C2=A0\n" - "> +\tst->vref_reg =3D devm_regulator_get_optional(&spi->dev, \"vref\");\n" - "> +\tif (PTR_ERR(st->vref_reg) =3D=3D -ENODEV) {\n" + "> \302\240\tchip_info = (struct ltc2632_chip_info *)\n" + "> \302\240\t\t\tspi_get_device_id(spi)->driver_data;\n" + "> \302\240\n" + "> +\tst->vref_reg = devm_regulator_get_optional(&spi->dev, \"vref\");\n" + "> +\tif (PTR_ERR(st->vref_reg) == -ENODEV) {\n" "> +\t\t/* use internal reference voltage */\n" - "> +\t\tst->vref_reg =3D NULL;\n" - "> +\t\tst->vref_mv =3D chip_info->vref_mv;\n" + "> +\t\tst->vref_reg = NULL;\n" + "> +\t\tst->vref_mv = chip_info->vref_mv;\n" "> +\n" - "> +\t\tret =3D ltc2632_spi_write(spi, LTC2632_CMD_INTERNAL_REFER,\n" + "> +\t\tret = ltc2632_spi_write(spi, LTC2632_CMD_INTERNAL_REFER,\n" "> +\t\t\t\t0, 0, 0);\n" "> +\t\tif (ret) {\n" "> +\t\t\tdev_err(&spi->dev,\n" @@ -161,16 +148,16 @@ "> +\t\treturn PTR_ERR(st->vref_reg);\n" "> +\t} else {\n" "> +\t\t/* use external reference voltage */\n" - "> +\t\tret =3D regulator_enable(st->vref_reg);\n" + "> +\t\tret = regulator_enable(st->vref_reg);\n" "> +\t\tif (ret) {\n" "> +\t\t\tdev_err(&spi->dev,\n" "> +\t\t\t\t\"enable reference regulator failed, %d\\n\",\n" "> +\t\t\t\tret);\n" "> +\t\t\treturn ret;\n" "> +\t\t}\n" - "> +\t\tst->vref_mv =3D regulator_get_voltage(st->vref_reg) / 1000;\n" + "> +\t\tst->vref_mv = regulator_get_voltage(st->vref_reg) / 1000;\n" "> +\n" - "> +\t\tret =3D ltc2632_spi_write(spi, LTC2632_CMD_EXTERNAL_REFER,\n" + "> +\t\tret = ltc2632_spi_write(spi, LTC2632_CMD_EXTERNAL_REFER,\n" "> +\t\t\t\t0, 0, 0);\n" "> +\t\tif (ret) {\n" "> +\t\t\tdev_err(&spi->dev,\n" @@ -180,15 +167,14 @@ "> +\t\t}\n" "> +\t}\n" "> +\n" - "> =C2=A0\tindio_dev->dev.parent =3D &spi->dev;\n" - "> =C2=A0\tindio_dev->name =3D dev_of_node(&spi->dev) ? dev_of_node(&spi->dev=\n" - ")->name\n" - "> =C2=A0\t\t\t\t\t\t=C2=A0: spi_get_device_id(spi)->name;\n" + "> \302\240\tindio_dev->dev.parent = &spi->dev;\n" + "> \302\240\tindio_dev->name = dev_of_node(&spi->dev) ? dev_of_node(&spi->dev)->name\n" + "> \302\240\t\t\t\t\t\t\302\240: spi_get_device_id(spi)->name;\n" "> @@ -255,14 +300,20 @@ static int ltc2632_probe(struct spi_device *spi)\n" - "> =C2=A0\tindio_dev->channels =3D chip_info->channels;\n" - "> =C2=A0\tindio_dev->num_channels =3D LTC2632_DAC_CHANNELS;\n" - "> =C2=A0\n" - "> -\tret =3D ltc2632_spi_write(spi, LTC2632_CMD_INTERNAL_REFER, 0, 0, 0);\n" + "> \302\240\tindio_dev->channels = chip_info->channels;\n" + "> \302\240\tindio_dev->num_channels = LTC2632_DAC_CHANNELS;\n" + "> \302\240\n" + "> -\tret = ltc2632_spi_write(spi, LTC2632_CMD_INTERNAL_REFER, 0, 0, 0);\n" "> -\tif (ret) {\n" "> -\t\tdev_err(&spi->dev,\n" "> -\t\t\t\"Set internal reference command failed, %d\\n\", ret);\n" @@ -199,28 +185,28 @@ "> +\n" "> +static int ltc2632_remove(struct spi_device *spi)\n" "> +{\n" - "> +\tstruct iio_dev *indio_dev =3D spi_get_drvdata(spi);\n" - "> +\tstruct ltc2632_state *st =3D iio_priv(indio_dev);\n" + "> +\tstruct iio_dev *indio_dev = spi_get_drvdata(spi);\n" + "> +\tstruct ltc2632_state *st = iio_priv(indio_dev);\n" "> +\n" "> +\tiio_device_unregister(indio_dev);\n" "> +\n" "> +\tif (st->vref_reg)\n" "> +\t\tregulator_disable(st->vref_reg);\n" - "> =C2=A0\n" + "> \302\240\n" "> -\treturn devm_iio_device_register(&spi->dev, indio_dev);\n" "> +\treturn 0;\n" - "> =C2=A0}\n" - "> =C2=A0\n" - "> =C2=A0static const struct spi_device_id ltc2632_id[] =3D {\n" - "> @@ -306,6 +357,7 @@ static struct spi_driver ltc2632_driver =3D {\n" - "> =C2=A0\t\t.of_match_table =3D of_match_ptr(ltc2632_of_match),\n" - "> =C2=A0\t},\n" - "> =C2=A0\t.probe\t\t=3D ltc2632_probe,\n" - "> +\t.remove\t\t=3D ltc2632_remove,\n" - "> =C2=A0\t.id_table\t=3D ltc2632_id,\n" - "> =C2=A0};\n" - "> =C2=A0module_spi_driver(ltc2632_driver);\n" - "> --=C2=A0\n" + "> \302\240}\n" + "> \302\240\n" + "> \302\240static const struct spi_device_id ltc2632_id[] = {\n" + "> @@ -306,6 +357,7 @@ static struct spi_driver ltc2632_driver = {\n" + "> \302\240\t\t.of_match_table = of_match_ptr(ltc2632_of_match),\n" + "> \302\240\t},\n" + "> \302\240\t.probe\t\t= ltc2632_probe,\n" + "> +\t.remove\t\t= ltc2632_remove,\n" + "> \302\240\t.id_table\t= ltc2632_id,\n" + "> \302\240};\n" + "> \302\240module_spi_driver(ltc2632_driver);\n" + "> --\302\240\n" > 2.7.4 -e3617967505e91685edf41a593a37f292407e6e6ce20e41aeee09712b3192b8c +a9c2bf38f668063b8dd76f1dfaf66e9c26ccd1eab7fb89caa062d4ee13a5365b
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.