[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0a154fdf-15ed-6bcc-676a-8d8eb213d6dc@ideasonboard.com>
Date: Fri, 3 Apr 2020 20:09:34 +0100
From: Kieran Bingham <kieran.bingham@...asonboard.com>
To: Alex Riesen <alexander.riesen@...itec.com>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Hans Verkuil <hverkuil-cisco@...all.nl>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>,
devel@...verdev.osuosl.org, linux-media@...r.kernel.org,
linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
linux-renesas-soc@...r.kernel.org
Subject: Re: [PATCH v5 3/9] media: adv748x: reduce amount of code for bitwise
modifications of device registers
Hi Alex,
On 02/04/2020 19:34, Alex Riesen wrote:
> The regmap provides a convenient utility for this.
> The hdmi_* and dpll_* register modification macros added for symmetry
> with the existing operations (io_*, sdp_*).
Ah yes, perhaps I should have done that when I converted this driver to
regmap :-) (although looking at the history I think that was
pre-submission of the driver, so it's all a long time ago anyway).
This also should prevent the issues we solved in 0d962e061a (media: i2c:
adv748x: Fix unsafe macros), so I think it's still a good move.
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@...asonboard.com>
> Signed-off-by: Alexander Riesen <alexander.riesen@...itec.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@...asonboard.com>
>
> --
> v3: remove _update name in favor of existing _clrset
> ---
> drivers/media/i2c/adv748x/adv748x-core.c | 6 ++++++
> drivers/media/i2c/adv748x/adv748x.h | 14 +++++++++++---
> 2 files changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
> index 5c59aad319d1..8580e6624276 100644
> --- a/drivers/media/i2c/adv748x/adv748x-core.c
> +++ b/drivers/media/i2c/adv748x/adv748x-core.c
> @@ -133,6 +133,12 @@ static int adv748x_write_check(struct adv748x_state *state, u8 page, u8 reg,
> return *error;
> }
>
> +int adv748x_update_bits(struct adv748x_state *state, u8 page, u8 reg, u8 mask,
> + u8 value)
> +{
> + return regmap_update_bits(state->regmap[page], reg, mask, value);
> +}
> +
> /* adv748x_write_block(): Write raw data with a maximum of I2C_SMBUS_BLOCK_MAX
> * size to one or more registers.
> *
> diff --git a/drivers/media/i2c/adv748x/adv748x.h b/drivers/media/i2c/adv748x/adv748x.h
> index 09aab4138c3f..0a9d78c2870b 100644
> --- a/drivers/media/i2c/adv748x/adv748x.h
> +++ b/drivers/media/i2c/adv748x/adv748x.h
> @@ -393,25 +393,33 @@ int adv748x_write(struct adv748x_state *state, u8 page, u8 reg, u8 value);
> int adv748x_write_block(struct adv748x_state *state, int client_page,
> unsigned int init_reg, const void *val,
> size_t val_len);
> +int adv748x_update_bits(struct adv748x_state *state, u8 page, u8 reg,
> + u8 mask, u8 value);
>
> #define io_read(s, r) adv748x_read(s, ADV748X_PAGE_IO, r)
> #define io_write(s, r, v) adv748x_write(s, ADV748X_PAGE_IO, r, v)
> -#define io_clrset(s, r, m, v) io_write(s, r, (io_read(s, r) & ~(m)) | (v))
> +#define io_clrset(s, r, m, v) adv748x_update_bits(s, ADV748X_PAGE_IO, r, m, v)
>
> #define hdmi_read(s, r) adv748x_read(s, ADV748X_PAGE_HDMI, r)
> #define hdmi_read16(s, r, m) (((hdmi_read(s, r) << 8) | hdmi_read(s, (r)+1)) & (m))
> #define hdmi_write(s, r, v) adv748x_write(s, ADV748X_PAGE_HDMI, r, v)
> +#define hdmi_clrset(s, r, m, v) \
> + adv748x_update_bits(s, ADV748X_PAGE_HDMI, r, m, v)
> +
> +#define dpll_read(s, r) adv748x_read(s, ADV748X_PAGE_DPLL, r)
> +#define dpll_clrset(s, r, m, v) \
> + adv748x_update_bits(s, ADV748X_PAGE_DPLL, r, m, v)
>
> #define repeater_read(s, r) adv748x_read(s, ADV748X_PAGE_REPEATER, r)
> #define repeater_write(s, r, v) adv748x_write(s, ADV748X_PAGE_REPEATER, r, v)
>
> #define sdp_read(s, r) adv748x_read(s, ADV748X_PAGE_SDP, r)
> #define sdp_write(s, r, v) adv748x_write(s, ADV748X_PAGE_SDP, r, v)
> -#define sdp_clrset(s, r, m, v) sdp_write(s, r, (sdp_read(s, r) & ~(m)) | (v))
> +#define sdp_clrset(s, r, m, v) adv748x_update_bits(s, ADV748X_PAGE_SDP, r, m, v)
>
> #define cp_read(s, r) adv748x_read(s, ADV748X_PAGE_CP, r)
> #define cp_write(s, r, v) adv748x_write(s, ADV748X_PAGE_CP, r, v)
> -#define cp_clrset(s, r, m, v) cp_write(s, r, (cp_read(s, r) & ~(m)) | (v))
> +#define cp_clrset(s, r, m, v) adv748x_update_bits(s, ADV748X_PAGE_CP, r, m, v)
>
> #define tx_read(t, r) adv748x_read(t->state, t->page, r)
> #define tx_write(t, r, v) adv748x_write(t->state, t->page, r, v)
>
--
Regards
--
Kieran
Powered by blists - more mailing lists