From: Ankur Patel <bkankur@gmail.com>
To: Jean Delvare <khali@linux-fr.org>,
Guenter Roeck <guenter.roeck@ericsson.com>
Cc: linux-kernel@vger.kernel.org, Ankur Patel <ankur.patel@quipment.in>
Subject: [PATCH 1/1] HWMON: TMP102 - Added support for 12 bit data
Date: Wed, 22 Jun 2011 09:58:52 +0530 [thread overview]
Message-ID: <1308716932-25562-1-git-send-email-bkankur@gmail.com> (raw)
From: Ankur Patel <ankur.patel@quipment.in>
In tmp102.ko driver support for 12 bit data is added.
Signed-off-by: Ankur Patel <ankur.patel@quipment.in>
---
drivers/hwmon/tmp102.c | 28 ++++++++++++++++++++--------
1 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c
index 5bd1949..6e03a87 100644
--- a/drivers/hwmon/tmp102.c
+++ b/drivers/hwmon/tmp102.c
@@ -47,6 +47,9 @@
#define TMP102_TLOW_REG 0x02
#define TMP102_THIGH_REG 0x03
+#define TMP102_CONFIG (TMP102_CONF_TM | TMP102_CONF_EM | TMP102_CONF_CR1)
+#define TMP102_CONFIG_RD_ONLY (TMP102_CONF_R0 | TMP102_CONF_R1 | TMP102_CONF_AL)
+
struct tmp102 {
struct device *hwmon_dev;
struct mutex lock;
@@ -68,16 +71,26 @@ static inline int tmp102_write_reg(struct i2c_client *client, u8 reg, u16 val)
return i2c_smbus_write_word_data(client, reg, swab16(val));
}
-/* convert left adjusted 13-bit TMP102 register value to milliCelsius */
+/* convert left adjusted TMP102 register value to milliCelsius for 13 bit &
+ * 12 bit by dividing with 128 & 256 respectively*/
static inline int tmp102_reg_to_mC(s16 val)
{
- return ((val & ~0x01) * 1000) / 128;
+ #if TMP102_CONFIG & TMP102_CONF_EM
+ return ((val & ~0x01) * 1000) / 128;
+ #else
+ return ((val & ~0x01) * 1000) / 256;
+ #endif
}
-/* convert milliCelsius to left adjusted 13-bit TMP102 register value */
+/* convert milliCelsius to left adjusted TMP102 register value for 13 bit &
+ * 12 bit by multiplying with 128 & 256 respectivley*/
static inline u16 tmp102_mC_to_reg(int val)
{
- return (val * 128) / 1000;
+ #if TMP102_CONFIG & TMP102_CONF_EM
+ return (val * 128) / 1000;
+ #else
+ return (val * 256) / 1000;
+ #endif
}
static const u8 tmp102_reg[] = {
@@ -126,7 +139,9 @@ static ssize_t tmp102_set_temp(struct device *dev,
if (strict_strtol(buf, 10, &val) < 0)
return -EINVAL;
- val = SENSORS_LIMIT(val, -256000, 255000);
+ /* It will limit the Input temperature range to -55 Deg. Cel to
+ * 150 Deg. Cel */
+ val = SENSORS_LIMIT(val, -55000, 150000);
mutex_lock(&tmp102->lock);
tmp102->temp[sda->index] = val;
@@ -155,9 +170,6 @@ static const struct attribute_group tmp102_attr_group = {
.attrs = tmp102_attributes,
};
-#define TMP102_CONFIG (TMP102_CONF_TM | TMP102_CONF_EM | TMP102_CONF_CR1)
-#define TMP102_CONFIG_RD_ONLY (TMP102_CONF_R0 | TMP102_CONF_R1 | TMP102_CONF_AL)
-
static int __devinit tmp102_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
--
1.7.0.4
next reply other threads:[~2011-06-23 10:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-22 4:28 Ankur Patel [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-06-22 2:21 Ankur Patel
2011-06-23 8:06 ` Jean Delvare
[not found] ` <BANLkTikLSmXKG67NroavRb+FjzVE5ie21Q@mail.gmail.com>
2011-06-23 8:45 ` Jean Delvare
[not found] ` <BANLkTikYbpeSbt5VHndJnsWXax1MX+Xk-w@mail.gmail.com>
2011-06-23 9:08 ` Jean Delvare
2011-06-23 9:26 ` Ankur Patel
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=1308716932-25562-1-git-send-email-bkankur@gmail.com \
--to=bkankur@gmail.com \
--cc=ankur.patel@quipment.in \
--cc=guenter.roeck@ericsson.com \
--cc=khali@linux-fr.org \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®