diff mbox series

[1/3] media: imx7-media-csi: Use functions instead of macros

Message ID 20190601175140.16305-1-festevam@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/3] media: imx7-media-csi: Use functions instead of macros | expand

Commit Message

Fabio Estevam June 1, 2019, 5:51 p.m. UTC
Currently there is a macro for reading and another macro for writing
to the CSI registers.

Functions can do parameter type checking, which leads to a safer code,
so switch from macro to function implementation.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 drivers/staging/media/imx/imx7-media-csi.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Comments

Rui Miguel Silva June 3, 2019, 5:48 p.m. UTC | #1
Oi Fabio,
On Sat 01 Jun 2019 at 18:51, Fabio Estevam wrote:
> Currently there is a macro for reading and another macro for writing
> to the CSI registers.
>
> Functions can do parameter type checking, which leads to a safer code,
> so switch from macro to function implementation.
>
> Signed-off-by: Fabio Estevam <festevam@gmail.com>
>

Thanks for the patches. for all of them:
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>

---
Cheers,
        Rui

> ---
>  drivers/staging/media/imx/imx7-media-csi.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c
> index b1af8694899e..8abdf253696d 100644
> --- a/drivers/staging/media/imx/imx7-media-csi.c
> +++ b/drivers/staging/media/imx/imx7-media-csi.c
> @@ -195,10 +195,16 @@ struct imx7_csi {
>  	struct completion last_eof_completion;
>  };
>
> -#define imx7_csi_reg_read(_csi, _offset) \
> -	__raw_readl((_csi)->regbase + (_offset))
> -#define imx7_csi_reg_write(_csi, _val, _offset) \
> -	__raw_writel(_val, (_csi)->regbase + (_offset))
> +static u32 imx7_csi_reg_read(struct imx7_csi *csi, unsigned int offset)
> +{
> +	return readl(csi->regbase + offset);
> +}
> +
> +static void imx7_csi_reg_write(struct imx7_csi *csi, unsigned int value,
> +			       unsigned int offset)
> +{
> +	writel(value, csi->regbase + offset);
> +}
>
>  static void imx7_csi_hw_reset(struct imx7_csi *csi)
>  {
diff mbox series

Patch

diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c
index b1af8694899e..8abdf253696d 100644
--- a/drivers/staging/media/imx/imx7-media-csi.c
+++ b/drivers/staging/media/imx/imx7-media-csi.c
@@ -195,10 +195,16 @@  struct imx7_csi {
 	struct completion last_eof_completion;
 };
 
-#define imx7_csi_reg_read(_csi, _offset) \
-	__raw_readl((_csi)->regbase + (_offset))
-#define imx7_csi_reg_write(_csi, _val, _offset) \
-	__raw_writel(_val, (_csi)->regbase + (_offset))
+static u32 imx7_csi_reg_read(struct imx7_csi *csi, unsigned int offset)
+{
+	return readl(csi->regbase + offset);
+}
+
+static void imx7_csi_reg_write(struct imx7_csi *csi, unsigned int value,
+			       unsigned int offset)
+{
+	writel(value, csi->regbase + offset);
+}
 
 static void imx7_csi_hw_reset(struct imx7_csi *csi)
 {