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, 21 Jun 2016 23:22:38 +0200
From:	Alexandre Belloni <alexandre.belloni@...e-electrons.com>
To:	Andrey Smirnov <andrew.smirnov@...il.com>
Cc:	rtc-linux@...glegroups.com,
	Alessandro Zummo <a.zummo@...ertech.it>,
	linux-kernel@...r.kernel.org, cphealy@...il.com
Subject: Re: [PATCH v2 13/17] RTC: ds1307: Report oscillator problems more
 intelligently

On 21/06/2016 at 00:22:46 -0700, Andrey Smirnov wrote :
> Report oscillator problems more intelligently, by printing more
> information about what cause the issue and not yelling "SET TIME!" at
> the user.
> 

Well, the proper way of doing that is to ensure that -EINVAL is returned
when reading the time until it has been set once instead of starting the
oscillator and forgetting about that useful information.

> Signed-off-by: Andrey Smirnov <andrew.smirnov@...il.com>
> ---
>  drivers/rtc/rtc-ds1307.c | 28 +++++++++++++++++++++++-----
>  1 file changed, 23 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
> index 2af9c00..2169e5b 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -1424,6 +1424,19 @@ static int ds1307_chip_configure(const struct ds1307 *ds1307)
>  	return 0;
>  }
>  
> +static void ds1307_report_clock_halt(const struct ds1307 *ds1307)
> +{
> +	dev_warn(&ds1307->client->dev, "RTC's oscillator is turned off. "
> +		 "Turning it on. Please set time");
> +}
> +
> +static void ds1307_report_oscillator_fault(const struct ds1307 *ds1307)
> +{
> +	dev_warn(&ds1307->client->dev, "RTC's reported oscillator fault. "
> +		 "Clearing the fault flag and re-reading RTC status. "
> +		 "Please set time");
> +}
> +
>  static int ds1307_chip_sanity_check(const struct ds1307 *ds1307)
>  {
>  	int tmp, retries;
> @@ -1453,7 +1466,7 @@ static int ds1307_chip_sanity_check(const struct ds1307 *ds1307)
>  			if (tmp & DS1307_BIT_CH) {
>  				i2c_smbus_write_byte_data(client,
>  							  DS1307_REG_SECS, 0);
> -				dev_warn(&client->dev, "SET TIME!\n");
> +				ds1307_report_clock_halt(ds1307);
>  				continue;
>  			}
>  			break;
> @@ -1469,15 +1482,17 @@ static int ds1307_chip_sanity_check(const struct ds1307 *ds1307)
>  							  DS1307_REG_CONTROL,
>  							  regs[DS1307_REG_CONTROL]
>  							  & ~DS1338_BIT_OSF);
> -				dev_warn(&client->dev, "SET TIME!\n");
> +				ds1307_report_oscillator_fault(ds1307);
>  				continue;
>  			}
>  			break;
>  		case ds_1340:
>  			/* clock halted?  turn it on, so clock can tick. */
> -			if (tmp & DS1340_BIT_nEOSC)
> +			if (tmp & DS1340_BIT_nEOSC) {
>  				i2c_smbus_write_byte_data(client,
>  							  DS1307_REG_SECS, 0);
> +				ds1307_report_clock_halt(ds1307);
> +			}
>  
>  			tmp = i2c_smbus_read_byte_data(client, DS1340_REG_FLAG);
>  			if (tmp < 0) {
> @@ -1489,7 +1504,7 @@ static int ds1307_chip_sanity_check(const struct ds1307 *ds1307)
>  			if (tmp & DS1340_BIT_OSF) {
>  				i2c_smbus_write_byte_data(client,
>  							  DS1340_REG_FLAG, 0);
> -				dev_warn(&client->dev, "SET TIME!\n");
> +				ds1307_report_oscillator_fault(ds1307);
>  			}
>  			return 0;
>  
> @@ -1500,6 +1515,9 @@ static int ds1307_chip_sanity_check(const struct ds1307 *ds1307)
>  							  DS1307_REG_WDAY,
>  							  regs[DS1307_REG_WDAY]
>  							  | MCP794XX_BIT_VBATEN);
> +				dev_warn(&client->dev,
> +					 "battery backup was disabled. "
> +					 "Re-enabling it\n");
>  			}
>  
>  			/* clock halted?  turn it on, so clock can tick. */
> @@ -1507,7 +1525,7 @@ static int ds1307_chip_sanity_check(const struct ds1307 *ds1307)
>  				i2c_smbus_write_byte_data(client,
>  							  DS1307_REG_SECS,
>  							  MCP794XX_BIT_ST);
> -				dev_warn(&client->dev, "SET TIME!\n");
> +				ds1307_report_clock_halt(ds1307);
>  				continue;
>  			}
>  
> -- 
> 2.5.5
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ