All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Jonathan Cameron <jic23@cam.ac.uk>,
	linux-iio@vger.kernel.org, drivers@analog.com
Subject: Re: [PATCH 01/11] iio: Add some helper macros for unit conversion
Date: Thu, 18 Oct 2012 09:57:47 +0100	[thread overview]
Message-ID: <507FC48B.6030803@kernel.org> (raw)
In-Reply-To: <1350293734-21951-1-git-send-email-lars@metafoo.de>

On 10/15/2012 10:35 AM, Lars-Peter Clausen wrote:
> Some datasheets use a different unit to specify the channel scale than what IIO
> expects it to be. This patch adds two helper macros which allow to convert units
> commonly used in datasheets to IIO units:
>
>  * acceleration: g -> meter / second**2
>  * angular velocity: degree (/ second) -> rad (/ second)
>
> This makes it much more convenient to specify and also easier to verify a
> channel's scale attribute.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Good idea applied to togreg branch of iio.git (or at least will
be when I get home from travelling).

> ---
>  include/linux/iio/iio.h |   16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
> index c0ae76a..7806c24 100644
> --- a/include/linux/iio/iio.h
> +++ b/include/linux/iio/iio.h
> @@ -618,4 +618,20 @@ static inline struct dentry *iio_get_debugfs_dentry(struct iio_dev *indio_dev)
>  };
>  #endif
>
> +/**
> + * IIO_DEGREE_TO_RAD() - Convert degree to rad
> + * @deg: A value in degree
> + *
> + * Returns the given value converted from degree to rad
> + */
> +#define IIO_DEGREE_TO_RAD(deg) (((deg) * 314159ULL + 9000000ULL) / 18000000ULL)
> +
> +/**
> + * IIO_G_TO_M_S_2() - Convert g to meter / second**2
> + * @g: A value in g
> + *
> + * Returns the given value converted from g to meter / second**2
> + */
> +#define IIO_G_TO_M_S_2(g) ((g) * 980665ULL / 100000ULL)
> +
>  #endif /* _INDUSTRIAL_IO_H_ */
>

      parent reply	other threads:[~2012-10-19  5:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-15  9:35 [PATCH 01/11] iio: Add some helper macros for unit conversion Lars-Peter Clausen
2012-10-15  9:35 ` [PATCH 02/11] staging:iio: Fix adis16201 channel offsets and scales Lars-Peter Clausen
2012-10-18  9:06   ` Jonathan Cameron
2012-10-15  9:35 ` [PATCH 03/11] staging:iio: Fix adis16203 " Lars-Peter Clausen
2012-10-18  9:07   ` Jonathan Cameron
2012-10-15  9:35 ` [PATCH 04/11] " Lars-Peter Clausen
2012-10-15  9:42   ` Lars-Peter Clausen
2012-10-18  9:07     ` Jonathan Cameron
2012-10-15  9:35 ` [PATCH 05/11] staging:iio: Fix adis16209 " Lars-Peter Clausen
2012-10-18  9:09   ` Jonathan Cameron
2012-10-15  9:35 ` [PATCH 06/11] staging:iio: Fix adis16220 " Lars-Peter Clausen
2012-10-15  9:35 ` [PATCH 07/11] staging:iio: Fix adis16240 " Lars-Peter Clausen
2012-10-15  9:35 ` [PATCH 08/11] staging:iio: Fix adis16260 " Lars-Peter Clausen
2012-10-15  9:35 ` [PATCH 09/11] staging:iio: Fix adis16400 " Lars-Peter Clausen
2012-10-15  9:35 ` [PATCH 10/11] staging:iio:adis16400: Report correct temperature scale and offset Lars-Peter Clausen
2012-10-15  9:35 ` [PATCH 11/11] staging:iio:adis16400: Fixup adis16336 temp channel attributes Lars-Peter Clausen
2012-10-18  8:57 ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=507FC48B.6030803@kernel.org \
    --to=jic23@kernel.org \
    --cc=drivers@analog.com \
    --cc=jic23@cam.ac.uk \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.