1. 05 Nov, 2016 2 commits
    • Eva Rachel Retuya's avatar
      staging: iio: rework regulator handling · 3925ff0f
      Eva Rachel Retuya authored
      Currently, the affected drivers ignore all errors from regulator_get().
      The way it is now, it also breaks probe deferral (EPROBE_DEFER). The
      correct behavior is to propagate the error to the upper layers so they
      can handle it accordingly.
      
      Rework the regulator handling so that it matches the standard behavior.
      If the specific design uses a static always-on regulator and does not
      explicitly specify it, regulator_get() will return the dummy regulator.
      
      The following semantic patch was used to apply the change:
      @r1@
      expression reg, dev, en, volt;
      @@
      
      reg = \(devm_regulator_get\|regulator_get\)(dev, ...);
      if (
      - !
         IS_ERR(reg))
      +	return PTR_ERR(reg);
      (
      - {	en = regulator_enable(reg);
      -	if (en) return en; }
      +
      +	en = regulator_enable(reg);
      +	if (en) {
      +		dev_err(dev, "Failed to enable specified supply\n");
      +		return en; }
      |
      +
      - {	en = regulator_enable(reg);
      -	if (en)	return en;
      -	volt = regulator_get_voltage(reg); }
      +	en = regulator_enable(reg);
      +	if (en) {
      +		dev_err(dev, "Failed to enable specified supply\n");
      +		return en;
      +	}
      +	volt = regulator_get_voltage(reg);
      )
      
      @r2@
      expression arg;
      @@
      
      -	if (!IS_ERR(arg)) regulator_disable(arg);
      +	regulator_disable(arg);
      
      Hand-edit the debugging prints with the supply name to become more
      specific.
      Suggested-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: default avatarEva Rachel Retuya <eraretuya@gmail.com>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      3925ff0f
    • Eva Rachel Retuya's avatar
      staging: iio: set proper supply name to devm_regulator_get() · c834e171
      Eva Rachel Retuya authored
      The name passed to devm_regulator_get() should match the name of the
      supply as specified in the device datasheet. This makes it clear what
      power supply is being referred to in case of presence of other
      regulators.
      
      Currently, the supply name specified on the affected devices is 'vcc'.
      Use lowercase version of the datasheet name to specify the supply
      voltage.
      Suggested-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: default avatarEva Rachel Retuya <eraretuya@gmail.com>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      c834e171
  2. 01 Nov, 2016 17 commits
  3. 25 Oct, 2016 8 commits
    • Enric Balletbo i Serra's avatar
      platform/chrome: cros_ec_dev - Register cros-ec sensors · 5668bfdd
      Enric Balletbo i Serra authored
      Check whether the ChromeOS Embedded Controller is a sensor hub and in
      such case issue a command to get the number of sensors and register them
      all.
      Signed-off-by: default avatarGwendal Grignou <gwendal@chromium.org>
      Signed-off-by: default avatarEnric Balletbo i Serra <enric.balletbo@collabora.com>
      Reviewed-by: default avatarGuenter Roeck <groeck@chromium.org>
      Acked-by: default avatarOlof Johansson <olof@lixom.net>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      5668bfdd
    • Vincent Palatin's avatar
      platform/chrome: Introduce a new function to check EC features. · e4244ebd
      Vincent Palatin authored
      Use the EC_CMD_GET_FEATURES message to check the supported features for
      each MCU.
      Signed-off-by: default avatarVincent Palatin <vpalatin@chromium.org>
      [tomeu: adapted to changes in mainline]
      Signed-off-by: default avatarTomeu Vizoso <tomeu.vizoso@collabora.com>
      [enric: remove references to USB PD feature and do it more generic]
      Signed-off-by: default avatarEnric Balletbo i Serra <enric.balletbo@collabora.com>
      Reviewed-by: default avatarGuenter Roeck <groeck@chromium.org>
      For the MFD changes:
      Acked-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      e4244ebd
    • Enric Balletbo i Serra's avatar
      iio: cros_ec_sensors: add ChromeOS EC Contiguous Sensors driver · c14dca07
      Enric Balletbo i Serra authored
      Handle 3d contiguous sensors like Accelerometers, Gyroscope and
      Magnetometer that are presented by the ChromeOS EC Sensor hub.
      Signed-off-by: default avatarGuenter Roeck <groeck@chromium.org>
      Signed-off-by: default avatarEnric Balletbo i Serra <enric.balletbo@collabora.com>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      c14dca07
    • Enric Balletbo i Serra's avatar
      iio: cros_ec_sensors_core: Add common functions for the ChromeOS EC Sensor Hub. · 974e6f02
      Enric Balletbo i Serra authored
      Add the core functions to be able to support the sensors attached behind
      the ChromeOS Embedded Controller and used by other IIO cros-ec sensor
      drivers.
      
      The cros_ec_sensor_core driver matches with current driver in ChromeOS
      4.4 tree, so it includes all the fixes at the moment. The support for
      this driver was made by Gwendal Grignou. The original patch and all the
      fixes has been squashed and rebased on top of mainline.
      Signed-off-by: default avatarGwendal Grignou <gwendal@chromium.org>
      Signed-off-by: default avatarGuenter Roeck <groeck@chromium.org>
      [eballetbo: split, squash and rebase on top of mainline the patches
      found in ChromeOS tree]
      Signed-off-by: default avatarEnric Balletbo i Serra <enric.balletbo@collabora.com>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      974e6f02
    • Arnd Bergmann's avatar
      iio: maxim_thermocouple: detect invalid storage size in read() · 32cb7d27
      Arnd Bergmann authored
      As found by gcc -Wmaybe-uninitialized, having a storage_bytes value other
      than 2 or 4 will result in undefined behavior:
      
      drivers/iio/temperature/maxim_thermocouple.c: In function 'maxim_thermocouple_read':
      drivers/iio/temperature/maxim_thermocouple.c:141:5: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      
      This probably cannot happen, but returning -EINVAL here is appropriate
      and makes gcc happy and the code more robust.
      
      Fixes: 231147ee ("iio: maxim_thermocouple: Align 16 bit big endian value of raw reads")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      32cb7d27
    • Arnd Bergmann's avatar
      staging: iio: cdc/ad7746: fix missing return value · 3089ec2c
      Arnd Bergmann authored
      As found by "gcc -Wmaybe-uninitialized", the latest change to the
      driver lacked an initalization for the return code in one of the
      added cases:
      
      drivers/staging/iio/cdc/ad7746.c: In function ‘ad7746_read_raw’:
      drivers/staging/iio/cdc/ad7746.c:655:2: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
      
      This sets it to IIO_VAL_INT, which I think is what we want here.
      
      Fixes: 2296c062 ("staging: iio: cdc: ad7746: implement IIO_CHAN_INFO_SAMP_FREQ")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      3089ec2c
    • Linus Walleij's avatar
      iio: gyro: Add driver for the MPU-3050 gyroscope · 3904b28e
      Linus Walleij authored
      This adds a new driver for the Invensense MPU-3050 gyroscope.
      This driver is based on information from the rough input driver
      in drivers/input/misc/mpu3050.c and the scratch misc driver
      posted by Nathan Royer in 2011. Some years have passed but this
      is finally a fully-fledged driver for this gyroscope. It was
      developed and tested on the Qualcomm APQ8060 Dragonboard.
      
      The driver supports both raw and buffered input. It also
      supports the internal trigger mechanism by registering a trigger
      that can fire in response to the internal sample engine of the
      component. In addition to reading out the gyroscope sensor
      values, the driver also supports reading the temperature from
      the sensor.
      
      The driver currently only supports I2C but the MPU-3050 can
      also be used from SPI, so the I2C portions are split in their
      own file and we just use regmap to access all registers, so
      it will be trivial to plug in SPI support if/when someone has
      a system requiring this.
      
      To conserve power, the driver utilizes the runtime PM
      framework and will put the sensor in off mode and disable the
      regulators when unused, after a timeout of 10 seconds.
      
      The fullscale can be set for the sensor to 250, 500, 1000 or
      2000 deg/s. This corresponds to scale values of rougly 0.000122,
      0.000275, 0.000512 or 0.001068. By writing such values (or close
      to these) into "in_anglevel_scale", the corresponding fullscale
      can be chosen. It will default to 2000 deg/s (~35 rad/s).
      
      The gyro component can have DC offsets on all axes. These can be
      compensated using the standard sysfs ABI property
      "in_anglevel_[xyz]_calibbias". This is in positive/negative
      values of the raw values, so a suitable calibration bias can be
      determined by userspace by reading the "in_anglevel_[xyz]_raw"
      for a few iterations while holding the sensor still, create an
      average integer, and writing the negative inverse of that into
      "in_anglevel_[xyz]_calibbias". After this the hardware will
      automatically subtract the bias, also when using buffered
      readings.
      
      Since the MPU-3050 has an outgoing I2C port it needs to act as
      an I2C mux. This means that the device is switching I2C traffic
      to devices beyond it. On my system this is the only way to reach
      the accelerometer. The "sensor fusion" ability of the MPU-3050
      to directly talk to the device on the outgoing I2C port is
      currently not used by the driver, but it has code to allow I2C
      traffic to pass through so that the Linux kernel can reach the
      device on the other side with a kernel driver.
      
      Example usage with the native trigger:
      
      $ generic_buffer -a -c10 -n mpu3050
      iio device number being used is 0
      iio trigger number being used is 0
      No channels are enabled, enabling all channels
      Enabling: in_anglvel_z_en
      Enabling: in_timestamp_en
      Enabling: in_anglvel_y_en
      Enabling: in_temp_en
      Enabling: in_anglvel_x_en
      /sys/bus/iio/devices/iio:device0 mpu3050-dev0
      29607.142578 -0.117493 0.074768 0.012817 180788797150
      29639.285156 -0.117493 0.076904 0.013885 180888982335
      29696.427734 -0.116425 0.076904 0.012817 180989178039
      29742.857422 -0.117493 0.076904 0.012817 181089377742
      29764.285156 -0.116425 0.077972 0.012817 181189574187
      29860.714844 -0.115356 0.076904 0.012817 181289772705
      29864.285156 -0.117493 0.076904 0.012817 181389971520
      29910.714844 -0.115356 0.076904 0.013885 181490170483
      29917.857422 -0.116425 0.076904 0.011749 181590369742
      29975.000000 -0.116425 0.076904 0.012817 181690567075
      Disabling: in_anglvel_z_en
      Disabling: in_timestamp_en
      Disabling: in_anglvel_y_en
      Disabling: in_temp_en
      Disabling: in_anglvel_x_en
      
      The first column is the temperature in millidegrees, then the x,y,z
      axes in succession followed by the timestamp. Also tested successfully
      using the HRTimer trigger.
      
      Cc: Nick Vaccaro <nvaccaro@google.com>
      Cc: Ge Gao <ggao@invensense.com>
      Cc: Anna Si <asi@invensense.com>
      Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
      Cc: Crestez Dan Leonard <leonard.crestez@intel.com>
      Cc: Daniel Baluta <daniel.baluta@intel.com>
      Cc: Gregor Boirie <gregor.boirie@parrot.com>
      Cc: Peter Rosin <peda@axentia.se>
      Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      3904b28e
    • Linus Walleij's avatar
      iio: gyro: Add MPU-3050 device tree bindings · e0549df6
      Linus Walleij authored
      This adds device tree bindings for the MPU-3050 gyroscope. Since it
      is the first set of bindings for a gyroscope, the folder for it
      is also created.
      
      Cc: devicetree@vger.kernel.org
      Cc: Peter Rosin <peda@axentia.se>
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      e0549df6
  4. 24 Oct, 2016 13 commits