diff mbox series

[2/2] media: i2c: max96714: coding style fixes

Message ID 20240628-gmsl2-drivers-style-fixup-v1-2-a4bb49f4c7a1@collabora.com (mailing list archive)
State New
Headers show
Series MAX96714/7 style fixup | expand

Commit Message

Julien Massot June 28, 2024, 12:29 p.m. UTC
Coding style fixes suggested by Sakari during the
driver review.

Signed-off-by: Julien Massot <julien.massot@collabora.com>
---
 drivers/media/i2c/max96714.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Tommaso Merciai July 1, 2024, 7:04 a.m. UTC | #1
Hi Julien,

On Fri, Jun 28, 2024 at 02:29:28PM +0200, Julien Massot wrote:
> Coding style fixes suggested by Sakari during the
> driver review.
> 
> Signed-off-by: Julien Massot <julien.massot@collabora.com>
> ---
>  drivers/media/i2c/max96714.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/media/i2c/max96714.c b/drivers/media/i2c/max96714.c
> index c97de66631e0..c738908bf141 100644
> --- a/drivers/media/i2c/max96714.c
> +++ b/drivers/media/i2c/max96714.c
> @@ -25,6 +25,7 @@
>  #define MAX96714_NPORTS     2
>  #define MAX96714_PAD_SINK   0
>  #define MAX96714_PAD_SOURCE 1
> +#define MAX96714_CSI_NLANES 4
>  
>  /* DEV */
>  #define MAX96714_REG13                 CCI_REG8(0x0d)
> @@ -724,8 +725,9 @@ static int max96714_init_tx_port(struct max96714_priv *priv)
>  	 * Unused lanes need to be mapped as well to not have
>  	 * the same lanes mapped twice.
>  	 */
> -	for (; lane < 4; lane++) {
> -		unsigned int idx = find_first_zero_bit(&lanes_used, 4);
> +	for (; lane < MAX96714_CSI_NLANES; lane++) {
> +		unsigned int idx = find_first_zero_bit(&lanes_used,
> +						       MAX96714_CSI_NLANES);
>  
>  		val |= idx << (lane * 2);
>  		lanes_used |= BIT(idx);
> @@ -757,9 +759,7 @@ static int max96714_rxport_disable_poc(struct max96714_priv *priv)
>  static int max96714_parse_dt_txport(struct max96714_priv *priv)
>  {
>  	struct device *dev = &priv->client->dev;
> -	struct v4l2_fwnode_endpoint vep = {
> -		.bus_type = V4L2_MBUS_CSI2_DPHY
> -	};
> +	struct v4l2_fwnode_endpoint vep = { .bus_type = V4L2_MBUS_CSI2_DPHY };
>  	struct fwnode_handle *ep_fwnode;
>  	u32 num_data_lanes;
>  	int ret;
> @@ -791,14 +791,14 @@ static int max96714_parse_dt_txport(struct max96714_priv *priv)
>  	}
>  
>  	num_data_lanes = vep.bus.mipi_csi2.num_data_lanes;
> -	if (num_data_lanes < 1 || num_data_lanes > 4) {
> +	if (num_data_lanes < 1 || num_data_lanes > MAX96714_CSI_NLANES) {
>  		dev_err(dev,
>  			"tx: invalid number of data lanes must be 1 to 4\n");
>  		ret = -EINVAL;
>  		goto err_free_vep;
>  	}
>  
> -	memcpy(&priv->mipi_csi2, &vep.bus.mipi_csi2, sizeof(priv->mipi_csi2));
> +	priv->mipi_csi2 = vep.bus.mipi_csi2;
>  
>  err_free_vep:
>  	v4l2_fwnode_endpoint_free(&vep);

This Patch looks good to me.
Reviewed-by: Tommaso Merciai <tomm.merciai@gmail.com>
Tested-by: Tommaso Merciai <tomm.merciai@gmail.com>

Note: 
I think we can fix also the following defines here, as a coding style
fixes. Maybe in another patch.

#define MAX96714_PATGEN_DE_CNT         CCI_REG16(0x25B)
#define MAX96714_PATGEN_CHKB_COLOR_A   CCI_REG24(0x25E)

I think hex numbers for regs must be lower case instead of upper case :)

Thanks & Regards,
Tommaso

> 
> -- 
> 2.45.2
>
Julien Massot July 1, 2024, 9:26 a.m. UTC | #2
Hi Tommaso,

On 7/1/24 9:04 AM, Tommaso Merciai wrote:
> Hi Julien,
> 
> On Fri, Jun 28, 2024 at 02:29:28PM +0200, Julien Massot wrote:
>> Coding style fixes suggested by Sakari during the
>> driver review.
>>
>> Signed-off-by: Julien Massot <julien.massot@collabora.com>
>> ---
>>   drivers/media/i2c/max96714.c | 14 +++++++-------
>>   1 file changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/media/i2c/max96714.c b/drivers/media/i2c/max96714.c
>> index c97de66631e0..c738908bf141 100644
>> --- a/drivers/media/i2c/max96714.c
>> +++ b/drivers/media/i2c/max96714.c
>> @@ -25,6 +25,7 @@
>>   #define MAX96714_NPORTS     2
>>   #define MAX96714_PAD_SINK   0
>>   #define MAX96714_PAD_SOURCE 1
>> +#define MAX96714_CSI_NLANES 4
>>   
>>   /* DEV */
>>   #define MAX96714_REG13                 CCI_REG8(0x0d)
>> @@ -724,8 +725,9 @@ static int max96714_init_tx_port(struct max96714_priv *priv)
>>   	 * Unused lanes need to be mapped as well to not have
>>   	 * the same lanes mapped twice.
>>   	 */
>> -	for (; lane < 4; lane++) {
>> -		unsigned int idx = find_first_zero_bit(&lanes_used, 4);
>> +	for (; lane < MAX96714_CSI_NLANES; lane++) {
>> +		unsigned int idx = find_first_zero_bit(&lanes_used,
>> +						       MAX96714_CSI_NLANES);
>>   
>>   		val |= idx << (lane * 2);
>>   		lanes_used |= BIT(idx);
>> @@ -757,9 +759,7 @@ static int max96714_rxport_disable_poc(struct max96714_priv *priv)
>>   static int max96714_parse_dt_txport(struct max96714_priv *priv)
>>   {
>>   	struct device *dev = &priv->client->dev;
>> -	struct v4l2_fwnode_endpoint vep = {
>> -		.bus_type = V4L2_MBUS_CSI2_DPHY
>> -	};
>> +	struct v4l2_fwnode_endpoint vep = { .bus_type = V4L2_MBUS_CSI2_DPHY };
>>   	struct fwnode_handle *ep_fwnode;
>>   	u32 num_data_lanes;
>>   	int ret;
>> @@ -791,14 +791,14 @@ static int max96714_parse_dt_txport(struct max96714_priv *priv)
>>   	}
>>   
>>   	num_data_lanes = vep.bus.mipi_csi2.num_data_lanes;
>> -	if (num_data_lanes < 1 || num_data_lanes > 4) {
>> +	if (num_data_lanes < 1 || num_data_lanes > MAX96714_CSI_NLANES) {
>>   		dev_err(dev,
>>   			"tx: invalid number of data lanes must be 1 to 4\n");
>>   		ret = -EINVAL;
>>   		goto err_free_vep;
>>   	}
>>   
>> -	memcpy(&priv->mipi_csi2, &vep.bus.mipi_csi2, sizeof(priv->mipi_csi2));
>> +	priv->mipi_csi2 = vep.bus.mipi_csi2;
>>   
>>   err_free_vep:
>>   	v4l2_fwnode_endpoint_free(&vep);
> 
> This Patch looks good to me.
> Reviewed-by: Tommaso Merciai <tomm.merciai@gmail.com>
> Tested-by: Tommaso Merciai <tomm.merciai@gmail.com>
> 
> Note:
> I think we can fix also the following defines here, as a coding style
> fixes. Maybe in another patch.
> 
> #define MAX96714_PATGEN_DE_CNT         CCI_REG16(0x25B)
> #define MAX96714_PATGEN_CHKB_COLOR_A   CCI_REG24(0x25E)
> 
> I think hex numbers for regs must be lower case instead of upper case :)

Thanks for the test, I will send a v2 with these hex numbers in lower case.

Regards,
Julien
diff mbox series

Patch

diff --git a/drivers/media/i2c/max96714.c b/drivers/media/i2c/max96714.c
index c97de66631e0..c738908bf141 100644
--- a/drivers/media/i2c/max96714.c
+++ b/drivers/media/i2c/max96714.c
@@ -25,6 +25,7 @@ 
 #define MAX96714_NPORTS     2
 #define MAX96714_PAD_SINK   0
 #define MAX96714_PAD_SOURCE 1
+#define MAX96714_CSI_NLANES 4
 
 /* DEV */
 #define MAX96714_REG13                 CCI_REG8(0x0d)
@@ -724,8 +725,9 @@  static int max96714_init_tx_port(struct max96714_priv *priv)
 	 * Unused lanes need to be mapped as well to not have
 	 * the same lanes mapped twice.
 	 */
-	for (; lane < 4; lane++) {
-		unsigned int idx = find_first_zero_bit(&lanes_used, 4);
+	for (; lane < MAX96714_CSI_NLANES; lane++) {
+		unsigned int idx = find_first_zero_bit(&lanes_used,
+						       MAX96714_CSI_NLANES);
 
 		val |= idx << (lane * 2);
 		lanes_used |= BIT(idx);
@@ -757,9 +759,7 @@  static int max96714_rxport_disable_poc(struct max96714_priv *priv)
 static int max96714_parse_dt_txport(struct max96714_priv *priv)
 {
 	struct device *dev = &priv->client->dev;
-	struct v4l2_fwnode_endpoint vep = {
-		.bus_type = V4L2_MBUS_CSI2_DPHY
-	};
+	struct v4l2_fwnode_endpoint vep = { .bus_type = V4L2_MBUS_CSI2_DPHY };
 	struct fwnode_handle *ep_fwnode;
 	u32 num_data_lanes;
 	int ret;
@@ -791,14 +791,14 @@  static int max96714_parse_dt_txport(struct max96714_priv *priv)
 	}
 
 	num_data_lanes = vep.bus.mipi_csi2.num_data_lanes;
-	if (num_data_lanes < 1 || num_data_lanes > 4) {
+	if (num_data_lanes < 1 || num_data_lanes > MAX96714_CSI_NLANES) {
 		dev_err(dev,
 			"tx: invalid number of data lanes must be 1 to 4\n");
 		ret = -EINVAL;
 		goto err_free_vep;
 	}
 
-	memcpy(&priv->mipi_csi2, &vep.bus.mipi_csi2, sizeof(priv->mipi_csi2));
+	priv->mipi_csi2 = vep.bus.mipi_csi2;
 
 err_free_vep:
 	v4l2_fwnode_endpoint_free(&vep);