From: Guenter Roeck <guenter.roeck@ericsson.com>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH v4] hwmon: Add support for Texas
Date: Tue, 08 Mar 2011 14:45:01 +0000 [thread overview]
Message-ID: <20110308144500.GA17162@ericsson.com> (raw)
In-Reply-To: <20110302185718.3c0e06dc@endymion.delvare>
Hi Emiliano,
On Tue, Mar 08, 2011 at 05:04:20AM -0500, Emiliano Carnati wrote:
> Hi Dirk,
> thanks for your work!
>
> I've used your code in my system and it works fine, except for a small bug when the
> code checks for the end of conversion flag (it should be negated)
>
If this is really a bug, there should be two patches - one for the bug fix,
the other for ads1115 support.
> I've extended it to work with ADS1115 (the 16 bit version) and below there
> is the "patch of patch v4"
>
Couple of comments below.
> I hope it would be useful for someone else.
>
> Thanks again
>
> Emiliano.
>
> <<<<<< start of patch >>>>>>
> diff --git a/drivers/hwmon/ads1015.c b/drivers/hwmon/ads1015.c
> index 4572024..6025a90 100644
> --- a/drivers/hwmon/ads1015.c
> +++ b/drivers/hwmon/ads1015.c
> @@ -53,6 +53,12 @@ struct ads1015_data {
> struct mutex update_lock; /* mutex protect updates */
> struct attribute *attr_table[ADS1015_CONFIG_CHANNELS + 1];
> struct attribute_group attr_group;
> + int id;
> +};
> +
> +enum ads1015_num_id {
> + ADS1015 = 0,
> + ADS1115,
> };
We commonly use lowercase here.
>
> static s32 ads1015_read_reg(struct i2c_client *client, unsigned int reg)
> @@ -78,6 +84,7 @@ static int ads1015_read_value(struct i2c_client *client, unsigned int channel,
> unsigned int k;
> struct ads1015_data *data = i2c_get_clientdata(client);
> int res;
> + int msec;
>
> mutex_lock(&data->update_lock);
>
> @@ -89,6 +96,14 @@ static int ads1015_read_value(struct i2c_client *client, unsigned int channel,
> pga = (config >> 9) & 0x0007;
> fullscale = fullscale_table[pga];
>
> + /* for ADS1115, get the conversion time */
> + if(data->id = ADS1115)
> + {
> + msec = (config >> 5) & 0x0007;
> + msec = 128 >> msec;
> + }
> + else
> + msec = 1;
Please follow Linux coding style.
(Location of { }, and use { } in both branches of if/else)
> /* set channel and start single conversion */
> config &= ~(0x0007 << 12);
> config |= (1 << 15) | (1 << 8) | (channel & 0x0007) << 12;
> @@ -98,12 +113,12 @@ static int ads1015_read_value(struct i2c_client *client, unsigned int channel,
> if (res < 0)
> goto err_unlock;
> for (k = 0; k < 5; ++k) {
> - schedule_timeout(msecs_to_jiffies(1));
> + schedule_timeout(msecs_to_jiffies(msec));
> res = ads1015_read_reg(client, ADS1015_CONFIG);
> if (res < 0)
> goto err_unlock;
> config = res;
> - if (config & (1 << 15))
> + if (~(config) & (1 << 15))
Again, please follow Linux coding style (no unnecessary () )
> break;
> }
> if (k = 5) {
> @@ -118,7 +133,10 @@ static int ads1015_read_value(struct i2c_client *client, unsigned int channel,
>
> mutex_unlock(&data->update_lock);
>
> - *value = DIV_ROUND_CLOSEST(conversion * fullscale, 0x7ff0);
> + if(data->id = ADS1115)
> + *value = DIV_ROUND_CLOSEST(conversion * fullscale, 0x7fff);
> + else
> + *value = DIV_ROUND_CLOSEST(conversion * fullscale, 0x7ff0);
>
> return 0;
>
> @@ -133,7 +151,7 @@ static ssize_t show_in(struct device *dev, struct device_attribute *da,
> {
> struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
> struct i2c_client *client = to_i2c_client(dev);
> - int in;
> + int in = 0;
> int res;
>
> res = ads1015_read_value(client, attr->index, &in);
> @@ -239,7 +257,9 @@ static int ads1015_probe(struct i2c_client *client,
> err = PTR_ERR(data->hwmon_dev);
> goto exit_remove;
> }
> -
> +
> + data->id = id->driver_data;
> +
> return 0;
>
> exit_remove:
> @@ -251,7 +271,8 @@ exit:
> }
>
> static const struct i2c_device_id ads1015_id[] = {
> - { "ads1015", 0 },
> + { "ads1015", ADS1015 },
> + { "ads1115", ADS1115 },
> { }
> };
> MODULE_DEVICE_TABLE(i2c, ads1015_id);
> <<<<<< end of patch >>>>>>
>
> -----------------------------
>
> Emiliano Carnati
> _______________________________________________
> lm-sensors mailing list
> lm-sensors@lm-sensors.org
> http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
next prev parent reply other threads:[~2011-03-08 14:45 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-14 9:26 [lm-sensors] [PATCH] hwmon: Add support for Texas Instruments Dirk Eibach
2011-02-14 9:26 ` [PATCH] hwmon: Add support for Texas Instruments ADS1015 Dirk Eibach
2011-02-14 10:22 ` [lm-sensors] [PATCH] hwmon: Add support for Texas Instruments Jean Delvare
2011-02-14 10:22 ` [PATCH] hwmon: Add support for Texas Instruments ADS1015 Jean Delvare
2011-02-14 13:21 ` [lm-sensors] [PATCH v2] hwmon: Add support for Texas Instruments Dirk Eibach
2011-02-14 13:21 ` [PATCH v2] hwmon: Add support for Texas Instruments ADS1015 Dirk Eibach
2011-02-16 4:50 ` [lm-sensors] [PATCH v2] hwmon: Add support for Texas Guenter Roeck
2011-02-16 4:50 ` [PATCH v2] hwmon: Add support for Texas Instruments ADS1015 Guenter Roeck
2011-02-17 12:17 ` [lm-sensors] [PATCH v2] hwmon: Add support for Texas Jean Delvare
2011-02-17 12:17 ` [PATCH v2] hwmon: Add support for Texas Instruments ADS1015 Jean Delvare
2011-02-17 12:42 ` [lm-sensors] [PATCH v2] hwmon: Add support for Texas Jean Delvare
2011-02-17 12:42 ` [PATCH v2] hwmon: Add support for Texas Instruments ADS1015 Jean Delvare
2011-02-18 10:15 ` [lm-sensors] [PATCH v3] hwmon: Add support for Texas Instruments Dirk Eibach
2011-02-18 10:15 ` [PATCH v3] hwmon: Add support for Texas Instruments ADS1015 Dirk Eibach
2011-02-24 16:48 ` [lm-sensors] [PATCH v3] hwmon: Add support for Texas Jean Delvare
2011-02-24 16:48 ` [PATCH v3] hwmon: Add support for Texas Instruments ADS1015 Jean Delvare
2011-02-25 13:18 ` [lm-sensors] [PATCH v4] hwmon: Add support for Texas Instruments Dirk Eibach
2011-02-25 13:18 ` [PATCH v4] hwmon: Add support for Texas Instruments ADS1015 Dirk Eibach
2011-03-02 17:57 ` [lm-sensors] [PATCH v4] hwmon: Add support for Texas Jean Delvare
2011-03-02 17:57 ` [PATCH v4] hwmon: Add support for Texas Instruments ADS1015 Jean Delvare
2011-03-02 18:16 ` [lm-sensors] [PATCH v4] hwmon: Add support for Texas Wolfram Sang
2011-03-02 18:16 ` [PATCH v4] hwmon: Add support for Texas Instruments ADS1015 Wolfram Sang
2011-03-03 7:49 ` [lm-sensors] (WARNING!!! PGP with incorrect signature) Eibach, Dirk
2011-03-03 7:49 ` (WARNING!!! PGP with incorrect signature) Re: [PATCH v4] hwmon: Add support for Texas Instruments ADS1015 Eibach, Dirk
2011-03-03 7:56 ` [lm-sensors] [PATCH v4] hwmon: Add support for Texas Jean Delvare
2011-03-03 7:56 ` [PATCH v4] hwmon: Add support for Texas Instruments ADS1015 Jean Delvare
2011-03-03 7:53 ` [lm-sensors] [PATCH v4] hwmon: Add support for Texas Eibach, Dirk
2011-03-03 7:53 ` [PATCH v4] hwmon: Add support for Texas Instruments ADS1015 Eibach, Dirk
2011-03-08 11:27 ` [lm-sensors] [PATCH v4] hwmon: Add support for Texas Eibach, Dirk
2011-03-08 12:07 ` Emiliano Carnati
2011-03-08 14:45 ` Guenter Roeck [this message]
2011-03-08 15:36 ` Emiliano Carnati
2011-03-08 17:43 ` Emiliano Carnati
2011-03-08 18:02 ` Guenter Roeck
2011-03-09 10:05 ` Emiliano Carnati
2011-03-16 15:50 ` Jean Delvare
2011-03-16 15:59 ` Jean Delvare
2011-03-17 7:24 ` Eibach, Dirk
2011-03-17 9:12 ` Jean Delvare
2011-03-17 9:41 ` Eibach, Dirk
2011-03-17 10:20 ` Jean Delvare
2011-03-19 11:34 ` Emiliano Carnati
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=20110308144500.GA17162@ericsson.com \
--to=guenter.roeck@ericsson.com \
--cc=lm-sensors@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.