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: <5d5d4590-18fc-1d94-08e3-7ffde8d9146d@baylibre.com>
Date:   Mon, 11 Apr 2022 09:27:46 +0200
From:   Neil Armstrong <narmstrong@...libre.com>
To:     Lucas Tanure <tanure@...ux.com>,
        Kevin Hilman <khilman@...libre.com>,
        Jerome Brunet <jbrunet@...libre.com>,
        Martin Blumenstingl <martin.blumenstingl@...glemail.com>
Cc:     linux-i2c@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-amlogic@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/2] i2c: meson: Use _SHIFT and _MASK for register
 definitions

On 09/04/2022 18:43, Lucas Tanure wrote:
> Differentiate between masks and shifts
> 
> Signed-off-by: Lucas Tanure <tanure@...ux.com>
> ---
>   drivers/i2c/busses/i2c-meson.c | 41 ++++++++++++++++++----------------
>   1 file changed, 22 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-meson.c b/drivers/i2c/busses/i2c-meson.c
> index 07eb819072c4..4b4a5b2d77ab 100644
> --- a/drivers/i2c/busses/i2c-meson.c
> +++ b/drivers/i2c/busses/i2c-meson.c
> @@ -30,18 +30,21 @@
>   #define REG_TOK_RDATA1		0x1c
>   
>   /* Control register fields */
> -#define REG_CTRL_START		BIT(0)
> -#define REG_CTRL_ACK_IGNORE	BIT(1)
> -#define REG_CTRL_STATUS		BIT(2)
> -#define REG_CTRL_ERROR		BIT(3)
> -#define REG_CTRL_CLKDIV		GENMASK(21, 12)
> -#define REG_CTRL_CLKDIVEXT	GENMASK(29, 28)
> -
> -#define REG_SLV_ADDR		GENMASK(7, 0)
> -#define REG_SLV_SDA_FILTER	GENMASK(10, 8)
> -#define REG_SLV_SCL_FILTER	GENMASK(13, 11)
> -#define REG_SLV_SCL_LOW		GENMASK(27, 16)
> -#define REG_SLV_SCL_LOW_EN	BIT(28)
> +#define REG_CTRL_START			BIT(0)
> +#define REG_CTRL_ACK_IGNORE		BIT(1)
> +#define REG_CTRL_STATUS			BIT(2)
> +#define REG_CTRL_ERROR			BIT(3)
> +#define REG_CTRL_CLKDIV_SHIFT		12
> +#define REG_CTRL_CLKDIV_MASK		GENMASK(21, REG_CTRL_CLKDIV_SHIFT)
> +#define REG_CTRL_CLKDIVEXT_SHIFT	28
> +#define REG_CTRL_CLKDIVEXT_MASK		GENMASK(29, REG_CTRL_CLKDIVEXT_SHIFT)
> +
> +#define REG_SLV_ADDR_MASK		GENMASK(7, 0)
> +#define REG_SLV_SDA_FILTER_MASK		GENMASK(10, 8)
> +#define REG_SLV_SCL_FILTER_MASK		GENMASK(13, 11)
> +#define REG_SLV_SCL_LOW_SHIFT		16
> +#define REG_SLV_SCL_LOW_MASK		GENMASK(27, REG_SLV_SCL_LOW_SHIFT)
> +#define REG_SLV_SCL_LOW_EN		BIT(28)
>   
>   #define I2C_TIMEOUT_MS		500
>   #define FILTER_DELAY		15
> @@ -149,11 +152,11 @@ static void meson_i2c_set_clk_div(struct meson_i2c *i2c, unsigned int freq)
>   		div = GENMASK(11, 0);
>   	}
>   
> -	meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_CLKDIV,
> -			   FIELD_PREP(REG_CTRL_CLKDIV, div & GENMASK(9, 0)));
> +	meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_CLKDIV_MASK,
> +			   FIELD_PREP(REG_CTRL_CLKDIV_MASK, div & GENMASK(9, 0)));
>   
> -	meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_CLKDIVEXT,
> -			   FIELD_PREP(REG_CTRL_CLKDIVEXT, div >> 10));
> +	meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_CLKDIVEXT_MASK,
> +			   FIELD_PREP(REG_CTRL_CLKDIVEXT_MASK, div >> 10));
>   
>   	/* Disable HIGH/LOW mode */
>   	meson_i2c_set_mask(i2c, REG_SLAVE_ADDR, REG_SLV_SCL_LOW_EN, 0);
> @@ -292,8 +295,8 @@ static void meson_i2c_do_start(struct meson_i2c *i2c, struct i2c_msg *msg)
>   		TOKEN_SLAVE_ADDR_WRITE;
>   
>   
> -	meson_i2c_set_mask(i2c, REG_SLAVE_ADDR, REG_SLV_ADDR,
> -			   FIELD_PREP(REG_SLV_ADDR, msg->addr << 1));
> +	meson_i2c_set_mask(i2c, REG_SLAVE_ADDR, REG_SLV_ADDR_MASK,
> +			   FIELD_PREP(REG_SLV_ADDR_MASK, msg->addr << 1));
>   
>   	meson_i2c_add_token(i2c, TOKEN_START);
>   	meson_i2c_add_token(i2c, token);
> @@ -467,7 +470,7 @@ static int meson_i2c_probe(struct platform_device *pdev)
>   
>   	/* Disable filtering */
>   	meson_i2c_set_mask(i2c, REG_SLAVE_ADDR,
> -			   REG_SLV_SDA_FILTER | REG_SLV_SCL_FILTER, 0);
> +			   REG_SLV_SDA_FILTER_MASK | REG_SLV_SCL_FILTER_MASK, 0);
>   
>   	meson_i2c_set_clk_div(i2c, timings.bus_freq_hz);
>   

Reviewed-by: Neil Armstrong <narmstrong@...libre.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ