lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 1 Dec 2015 07:09:57 -0800
From:	Guenter Roeck <linux@...ck-us.net>
To:	Nishanth Menon <nm@...com>, Jean Delvare <jdelvare@...e.com>
Cc:	linux-kernel@...r.kernel.org, lm-sensors@...sensors.org,
	linux-omap@...r.kernel.org, beagleboard-x15@...glegroups.com,
	Eduardo Valentin <edubezval@...il.com>
Subject: Re: [PATCH] hwmon: (tmp102) Force wait for conversion time for the
 first valid data

On 12/01/2015 06:21 AM, Nishanth Menon wrote:
[ ... ]

>
> Hint about how the patch will look like:

Looks ok (and better).

Guenter

> diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c
> index 65482624ea2c..5289aa0980a8 100644
> --- a/drivers/hwmon/tmp102.c
> +++ b/drivers/hwmon/tmp102.c
> @@ -58,6 +58,7 @@ struct tmp102 {
>   	u16 config_orig;
>   	unsigned long last_update;
>   	int temp[3];
> +	bool first_time;
>   };
>
>   /* convert left adjusted 13-bit TMP102 register value to milliCelsius */
> @@ -93,6 +94,7 @@ static struct tmp102 *tmp102_update_device(struct device *dev)
>   				tmp102->temp[i] = tmp102_reg_to_mC(status);
>   		}
>   		tmp102->last_update = jiffies;
> +		tmp102->first_time = false;
>   	}
>   	mutex_unlock(&tmp102->lock);
>   	return tmp102;
> @@ -102,6 +104,12 @@ static int tmp102_read_temp(void *dev, int *temp)
>   {
>   	struct tmp102 *tmp102 = tmp102_update_device(dev);
>
> +	/* Is it too early even to return a conversion? */
> +	if (tmp102->first_time) {
> +		dev_dbg(dev, "%s: Conversion not ready yet..\n", __func__);
> +		return -EAGAIN;
> +	}
> +
>   	*temp = tmp102->temp[0];
>
>   	return 0;
> @@ -114,6 +122,10 @@ static ssize_t tmp102_show_temp(struct device *dev,
>   	struct sensor_device_attribute *sda = to_sensor_dev_attr(attr);
>   	struct tmp102 *tmp102 = tmp102_update_device(dev);
>
> +	/* Is it too early even to return a read? */
> +	if (tmp102->first_time)
> +		return -EAGAIN;
> +
>   	return sprintf(buf, "%d\n", tmp102->temp[sda->index]);
>   }
>
> @@ -207,7 +219,9 @@ static int tmp102_probe(struct i2c_client *client,
>   		status = -ENODEV;
>   		goto fail_restore_config;
>   	}
> -	tmp102->last_update = jiffies - HZ;
> +	tmp102->last_update = jiffies;
> +	/* Mark that we are not ready with data until conversion is complete */
> +	tmp102->first_time = true;
>   	mutex_init(&tmp102->lock);
>
>   	hwmon_dev = hwmon_device_register_with_groups(dev, client->name,
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ