All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Lucas Tanure <tanure@linux.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: IEEE-754 Float to int
Date: Tue, 22 Nov 2016 12:33:49 -0800	[thread overview]
Message-ID: <20161122203349.GA26020@roeck-us.net> (raw)
In-Reply-To: <CAJX_Q+0bDQmHYpfkK3RGTmWdJoi0RAB+u=5M9WtgyoKdeGXdrQ@mail.gmail.com>

On Tue, Nov 22, 2016 at 05:10:54PM +0000, Lucas Tanure wrote:
> Hi,
> 
> My hardware gives me the board temperature as a float 32bits.
> So, at some point my hardware gives me a 32bit IEEE-754 float, like this :
> 
> regmap_read(device->regmap, ADDR0, &temp);
> value = temp << 16;
> regmap_read(device->regmap, ADDR1, &temp);
> value |= temp;
> 
> So, value has a 32bit float now, and I would like to print over hwmon
> sysfs API. Like :
> 
> temp
> Current temperature as reported by thermal zone (sensor).
> Unit: millidegree Celsius
> RO, Required
> 
> 
> Read 26.92387 --> Read 26923 at /sys/class/hwmon/hwmon0/temp0_input
> Simple, no float operations.
> 
> How I can do it ?
> 
Only idea I have is to write a conversion function.
Note that the attribute name should be temp1_input.

Guenter

  reply	other threads:[~2016-11-22 20:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAJX_Q+1iPpLnbLYB6=9gWR2EEwek5VvioBCZB6gYsChOZ3EyVA@mail.gmail.com>
2016-11-22 17:10 ` IEEE-754 Float to int Lucas Tanure
2016-11-22 20:33   ` Guenter Roeck [this message]
2016-11-22 16:05 Lucas Tanure
2016-11-22 16:19 ` Anupam Kapoor
2016-11-22 16:21   ` Lucas Tanure
2016-11-22 16:28     ` Anupam Kapoor
2016-11-22 16:30       ` Lucas Tanure
2016-11-22 16:39 ` Greg KH
2016-11-22 16:44   ` Lucas Tanure
2016-11-22 16:55     ` Greg KH
2016-11-23 12:30       ` Lucas Tanure
2016-11-23 14:04         ` Anupam Kapoor

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=20161122203349.GA26020@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=tanure@linux.com \
    /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.