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]
Message-ID: <bd7eb8dd-647c-241a-ff1c-d5c59429c0d7@quicinc.com>
Date:   Mon, 6 Feb 2023 19:14:35 -0800
From:   David Collins <quic_collinsd@...cinc.com>
To:     Johan Hovold <johan+linaro@...nel.org>,
        Alexandre Belloni <alexandre.belloni@...tlin.com>,
        Bjorn Andersson <andersson@...nel.org>
CC:     Andy Gross <agross@...nel.org>,
        Konrad Dybcio <konrad.dybcio@...aro.org>,
        Alessandro Zummo <a.zummo@...ertech.it>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Maximilian Luz <luzmaximilian@...il.com>,
        <linux-arm-msm@...r.kernel.org>, <linux-rtc@...r.kernel.org>,
        <devicetree@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 03/22] rtc: pm8xxx: use regmap_update_bits()

On 2/2/23 07:54, Johan Hovold wrote:
> Switch to using regmap_update_bits() instead of open coding
> read-modify-write accesses.
> 
> Signed-off-by: Johan Hovold <johan+linaro@...nel.org>
> ---
>  drivers/rtc/rtc-pm8xxx.c | 87 ++++++++++------------------------------
>  1 file changed, 22 insertions(+), 65 deletions(-)

Reviewed-by: David Collins <quic_collinsd@...cinc.com>


> diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
> index f49bda999e02..8c2847ac64f4 100644
> --- a/drivers/rtc/rtc-pm8xxx.c
> +++ b/drivers/rtc/rtc-pm8xxx.c
> @@ -78,10 +78,10 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
>  {
>  	int rc, i;
>  	unsigned long secs, irq_flags;
> -	u8 value[NUM_8_BIT_RTC_REGS], alarm_enabled = 0, rtc_disabled = 0;
> -	unsigned int ctrl_reg, rtc_ctrl_reg;
>  	struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
>  	const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
> +	u8 value[NUM_8_BIT_RTC_REGS];
> +	bool alarm_enabled;
>  
>  	if (!rtc_dd->allow_set_time)
>  		return -ENODEV;
> @@ -97,31 +97,16 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
>  
>  	spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags);
>  
> -	rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg);
> +	rc = regmap_update_bits_check(rtc_dd->regmap, regs->alarm_ctrl,
> +				      regs->alarm_en, 0, &alarm_enabled);
>  	if (rc)
>  		goto rtc_rw_fail;
>  
> -	if (ctrl_reg & regs->alarm_en) {
> -		alarm_enabled = 1;
> -		ctrl_reg &= ~regs->alarm_en;
> -		rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg);
> -		if (rc)
> -			goto rtc_rw_fail;
> -	}
> -

I like this usage of regmap_update_bits_check().  It is a great helper
to use in this situation.  It really helps to simplify the logic.

Take care,
David

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ