Commit graph

19 commits

Author SHA1 Message Date
Dmitry Rokosov
fe49ce7abd iio: accel: adxl345: use HZ macro from units.h
Remove duplicated definition of NHZ_PER_HZ, because it's available in
the units.h as NANOHZ_PER_HZ.

Signed-off-by: Dmitry Rokosov <ddrokosov@sberdevices.ru>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220812165243.22177-4-ddrokosov@sberdevices.ru
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-08-28 16:57:37 +01:00
Andy Shevchenko
b8f83abdd2 iio: accel: adxl345: Drop comma in terminator entries
Terminator entries are by definition should terminate the array.
Dropping comma make this enforced at compile time.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20220222090009.2060-7-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-02-26 19:11:32 +00:00
Andy Shevchenko
5b4c63f691 iio: accel: adxl345: Extract adxl345_powerup() helper
For the sake of symmetry and possible reuse in the future
extract adxl435_powerup() helper.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20220222090009.2060-6-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-02-26 19:11:26 +00:00
Andy Shevchenko
266be7cb11 iio: accel: adxl345: Make use of device properties
Convert the module to be property provider agnostic and allow
it to be used on non-OF platforms.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20220222090009.2060-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-02-26 19:11:13 +00:00
Andy Shevchenko
c1db3d5cab iio: accel: adxl345: Get rid of name parameter in adxl345_core_probe()
As a preparation to switch to use device properties, get rid of name
parameter in adxl345_core_probe(). Instead, choose it based on the type.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20220222090009.2060-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-02-26 19:11:05 +00:00
Andy Shevchenko
01676b0f3b iio: accel: adxl345: Convert to use dev_err_probe()
It's fine to call dev_err_probe() in ->probe() when error code is known.
Convert the driver to use dev_err_probe().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20220222090009.2060-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-02-26 19:10:40 +00:00
Jonathan Cameron
0a18114d3f iio:accel:adxl345: Move exports into IIO_ADXL345 namespace
To avoid unnecessary pollution of the global symbol namespace move the
driver core exports into their own namespace and import that into the two
bus modules.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20220116180535.2367780-7-jic23@kernel.org
2022-02-18 11:36:54 +00:00
Alexandru Ardelean
d372e5a19a iio: accel: adxl345: convert probe to device-managed functions
This driver has two parts, one for i2c and one for spi, since the chip can
operate with both wire protocols.

The core file has a common adxl345_core_remove() function which puts the
chip into a powerdown state. This can be implemented with a
devm_add_action_or_reset() hook.

Doing that means we can register the IIO device with
devm_iio_device_register() and get rid of the adxl345_core_remove()
function.

The dev_set_drvdata() call can be removed as there is no other user of this
private data anymore.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210624080441.8710-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-07-19 09:51:59 +01:00
Alexander A. Klimov
3593cd5396 Replace HTTP links with HTTPS ones: drivers/iio
Rationale:
Reduces attack surface on kernel devs opening the links for MITM
as HTTPS traffic is much harder to manipulate.

Deterministic algorithm:
For each file:
  If not .svg:
    For each line:
      If doesn't contain `\bxmlns\b`:
        For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`:
          If both the HTTP and HTTPS versions
          return 200 OK and serve the same content:
            Replace HTTP with HTTPS.

Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-13 15:05:59 +01:00
Alexandru Ardelean
d3be83244c iio: remove explicit IIO device parent assignment
This patch applies the semantic patch:
@@
expression I, P, SP;
@@
   I = devm_iio_device_alloc(P, SP);
   ...
-  I->dev.parent = P;

It updates 302 files and does 307 deletions.
This semantic patch also removes some comments like
'/* Establish that the iio_dev is a child of the i2c device */'

But this is is only done in case where the block is left empty.

The patch does not seem to cover all cases. It looks like in some cases a
different variable is used in some cases to assign the parent, but it
points to the same reference.
In other cases, the block covered by ... may be just too big to be covered
by the semantic patch.

However, this looks pretty good as well, as it does cover a big bulk of the
drivers that should remove the parent assignment.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:49:59 +01:00
Thomas Gleixner
36edc93958 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 330
Based on 1 normalized pattern(s):

  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

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

has been chosen to replace the boilerplate/reference in 55 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190530000436.108941081@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-05 17:37:06 +02:00
Luciana da Costa Marques
d4cd36220e iio:accel:adxl345: Change alignment to match paranthesis
Align broken line to match upper line parenthesis. Solves the
checkpatch.pl's message:

CHECK: Alignment should match open parenthesis

Signed-off-by: Luciana da Costa Marques <lucianadacostamarques@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09 18:46:02 +00:00
Lars-Peter Clausen
ef89f4b96a iio: adxl345: Add support for the ADXL375
The ADXL375 is fully register map compatible to the ADXL345 (including the
device ID register returning the same value ...).

The only difference is the resolution of the acceleration sensor. The
ADXL375 can measure up to +-200g of acceleration.

Datasheet:
http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL375.PDF

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-07-15 10:18:15 +01:00
Akinobu Mita
382fa58125 iio: accel: adxl345: add sampling frequency support
The ADXL345 provides selectable output data rate.  This adds the iio
channel information for the sampling frequency with that feature.

Cc: Eva Rachel Retuya <eraretuya@gmail.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-07-15 09:19:06 +01:00
Akinobu Mita
732238e22e iio: accel: adxl345: add calibration offset support
The ADXL345 provides the offset adjustment registers for each axis.
This adds the iio channel information for the calibraion offsets with
that feature.

Cc: Eva Rachel Retuya <eraretuya@gmail.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-06-30 18:27:27 +01:00
Akinobu Mita
9048f1f18a iio: accel: adxl345: convert address field usage in iio_chan_spec
Currently the address field in iio_chan_spec is filled with an accel
data register address for the corresponding axis.

In preparation for adding calibration offset support, this sets the
address field to the index of accel data registers instead of the actual
register address.

This change makes it easier to access both accel registers and
calibration offset registers with fewer lines of code as these are
located in X-axis, Y-axis, Z-axis order.

Cc: Eva Rachel Retuya <eraretuya@gmail.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-06-30 18:25:05 +01:00
Akinobu Mita
4b5de1fa97 iio: accel: adxl345: add link to datasheet
Add a link to the ADXL345 datasheet

Cc: Eva Rachel Retuya <eraretuya@gmail.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-06-30 18:23:42 +01:00
Jonathan Cameron
6c5bffa80e iio:accel: drop assign iio_info.driver_module and iio_trigger_ops.owner
The equivalent of both of these are now done via macro magic when
the relevant register calls are made.  The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:22:40 +01:00
Eva Rachel Retuya
5170512cf6 iio: accel: adxl345: Split driver into core and I2C
Move I2C-specific code into its own file and rely on regmap to access
registers. The core code provides access to x, y, z and scale readings.

Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-04 16:45:08 +00:00
Renamed from drivers/iio/accel/adxl345.c (Browse further)