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, 30 Nov 2021 23:45:18 +0100
From:   Alexandre Belloni <alexandre.belloni@...tlin.com>
To:     Emmanuel Gil Peyrot <linkmauve@...kmauve.fr>
Cc:     Alessandro Zummo <a.zummo@...ertech.it>,
        rw-r-r-0644 <r.r.qwertyuiop.r.r@...il.com>,
        Ash Logan <ash@...quark.com>,
        Jonathan Neuschäfer <j.ne@...teo.net>,
        Rob Herring <robh+dt@...nel.org>,
        Michael Ellerman <mpe@...erman.id.au>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Paul Mackerras <paulus@...ba.org>,
        linux-kernel@...r.kernel.org, linux-rtc@...r.kernel.org,
        linuxppc-dev@...ts.ozlabs.org, devicetree@...r.kernel.org
Subject: Re: [PATCH v2 2/5] rtc: gamecube: Report low battery as invalid data

Hello,

On 28/10/2021 00:35:12+0200, Emmanuel Gil Peyrot wrote:
> I haven’t been able to test this patch as all of my consoles have a
> working RTC battery, but according to the documentation it should work
> like that.
> 
> Signed-off-by: Emmanuel Gil Peyrot <linkmauve@...kmauve.fr>
> ---
>  drivers/rtc/rtc-gamecube.c | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/drivers/rtc/rtc-gamecube.c b/drivers/rtc/rtc-gamecube.c
> index e8260c82c07d..1932c6fe1301 100644
> --- a/drivers/rtc/rtc-gamecube.c
> +++ b/drivers/rtc/rtc-gamecube.c
> @@ -83,6 +83,10 @@
>  #define RTC_CONTROL0	0x21000c
>  #define RTC_CONTROL1	0x21000d
>  
> +/* RTC flags */
> +#define RTC_CONTROL0_UNSTABLE_POWER	0x00000800
> +#define RTC_CONTROL0_LOW_BATTERY	0x00000200
> +
>  struct priv {
>  	struct regmap *regmap;
>  	void __iomem *iob;
> @@ -182,9 +186,35 @@ static int gamecube_rtc_set_time(struct device *dev, struct rtc_time *t)
>  	return regmap_write(d->regmap, RTC_COUNTER, timestamp - d->rtc_bias);
>  }
>  
> +static int gamecube_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
> +{
> +	struct priv *d = dev_get_drvdata(dev);
> +	int value;
> +	int control0;
> +	int ret;
> +
> +	switch (cmd) {
> +	case RTC_VL_READ:
> +		ret = regmap_read(d->regmap, RTC_CONTROL0, &control0);
> +		if (ret)
> +			return ret;
> +
> +		value = 0;
> +		if (control0 & RTC_CONTROL0_UNSTABLE_POWER)
> +			value |= RTC_VL_DATA_INVALID;
> +		if (control0 & RTC_CONTROL0_LOW_BATTERY)
> +			value |= RTC_VL_DATA_INVALID;

Shouldn't that one be RTC_VL_BACKUP_LOW?

Else, the driver is great, I'm ready to apply it.

> +		return put_user(value, (unsigned int __user *)arg);
> +
> +	default:
> +		return -ENOIOCTLCMD;
> +	}
> +}
> +
>  static const struct rtc_class_ops gamecube_rtc_ops = {
>  	.read_time	= gamecube_rtc_read_time,
>  	.set_time	= gamecube_rtc_set_time,
> +	.ioctl		= gamecube_rtc_ioctl,
>  };
>  
>  static int gamecube_rtc_read_offset_from_sram(struct priv *d)
> -- 
> 2.33.1
> 

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ