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: <047803b9-d09f-d4f8-a674-317cc19dd055@collabora.com>
Date:   Fri, 24 Dec 2021 11:10:54 +0100
From:   AngeloGioacchino Del Regno 
        <angelogioacchino.delregno@...labora.com>
To:     Chunfeng Yun <chunfeng.yun@...iatek.com>,
        Vinod Koul <vkoul@...nel.org>
Cc:     Kishon Vijay Abraham I <kishon@...com>,
        Rob Herring <robh+dt@...nel.org>,
        Matthias Brugger <matthias.bgg@...il.com>,
        linux-arm-kernel@...ts.infradead.org,
        linux-mediatek@...ts.infradead.org, linux-phy@...ts.infradead.org,
        devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
        Eddie Hung <eddie.hung@...iatek.com>
Subject: Re: [PATCH v2 3/5] phy: mediatek: add helpers to update bits of
 registers

Il 18/12/21 09:28, Chunfeng Yun ha scritto:
> Add three helpers mtk_phy_clear/set/update_bits() for registers operation
> 
> Signed-off-by: Chunfeng Yun <chunfeng.yun@...iatek.com>
> ---
> v2: new patch, add register access helpers,
>      Add updatel() macro suggested by Vinod, here add more ones instead.
> ---
>   drivers/phy/mediatek/phy-mtk-io.h | 38 +++++++++++++++++++++++++++++++
>   1 file changed, 38 insertions(+)
>   create mode 100644 drivers/phy/mediatek/phy-mtk-io.h
> 
> diff --git a/drivers/phy/mediatek/phy-mtk-io.h b/drivers/phy/mediatek/phy-mtk-io.h
> new file mode 100644
> index 000000000000..500fcdab165d
> --- /dev/null
> +++ b/drivers/phy/mediatek/phy-mtk-io.h
> @@ -0,0 +1,38 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Copyright (C) 2021 MediaTek Inc.
> + *
> + * Author: Chunfeng Yun <chunfeng.yun@...iatek.com>
> + */
> +
> +#ifndef __PHY_MTK_H__
> +#define __PHY_MTK_H__
> +
> +#include <linux/io.h>
> +
> +static inline void mtk_phy_clear_bits(void __iomem *reg, u32 bits)
> +{
> +	u32 tmp = readl(reg);
> +
> +	tmp &= ~bits;
> +	writel(tmp, reg);
> +}
> +
> +static inline void mtk_phy_set_bits(void __iomem *reg, u32 bits)
> +{
> +	u32 tmp = readl(reg);
> +
> +	tmp |= bits;
> +	writel(tmp, reg);
> +}
> +
> +static inline void mtk_phy_update_bits(void __iomem *reg, u32 mask, u32 val)
> +{
> +	u32 tmp = readl(reg);
> +
> +	tmp &= ~mask;
> +	tmp |= val & mask;
> +	writel(tmp, reg);
> +}
> +
> +#endif
> 

These helpers are almost exactly duplicating what regmap_update_bits() is doing.
I appreciate the effort to stop open-coding the same sequences over and over by
adding such helper functions, but I think that the proper way of doing what you
are proposing is not to add custom functions but rather reuse what the Linux APIs
give you.

What about doing a conversion to use regmap on this driver?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ