diff mbox series

remove identation for common path

Message ID 20240420145522.15018-1-prosunofficial@gmail.com (mailing list archive)
State New
Headers show
Series remove identation for common path | expand

Commit Message

R Sundar April 20, 2024, 2:55 p.m. UTC
Added check if pointer is null and removed identation for common path

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: sundar <prosunofficial@gmail.com>
---

Fixed nitpicks in code according to comments received on other patch.

https://lore.kernel.org/all/2024041103-doornail-professor-7c1e@gregkh/

goal is to get rid of of_node_put,but sending this patch first to do one
thing at a time.

 drivers/usb/typec/mux/nb7vpq904m.c | 49 +++++++++++++++---------------
 1 file changed, 25 insertions(+), 24 deletions(-)

Comments

R Sundar April 20, 2024, 2:59 p.m. UTC | #1
On 20/04/24 20:25, sundar wrote:
> Added check if pointer is null and removed identation for common path
> 
> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: sundar <prosunofficial@gmail.com>
> ---
> 
> Fixed nitpicks in code according to comments received on other patch.
> 
> https://lore.kernel.org/all/2024041103-doornail-professor-7c1e@gregkh/
> 
> goal is to get rid of of_node_put,but sending this patch first to do one
> thing at a time.
> 
>   drivers/usb/typec/mux/nb7vpq904m.c | 49 +++++++++++++++---------------
>   1 file changed, 25 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/usb/typec/mux/nb7vpq904m.c b/drivers/usb/typec/mux/nb7vpq904m.c
> index b17826713753..fe0257840dd5 100644
> --- a/drivers/usb/typec/mux/nb7vpq904m.c
> +++ b/drivers/usb/typec/mux/nb7vpq904m.c
> @@ -321,35 +321,37 @@ static int nb7vpq904m_parse_data_lanes_mapping(struct nb7vpq904m *nb7)
>   
>   	ep = of_graph_get_endpoint_by_regs(nb7->client->dev.of_node, 1, 0);
>   
> -	if (ep) {
> -		ret = of_property_count_u32_elems(ep, "data-lanes");
> -		if (ret == -EINVAL)
> -			/* Property isn't here, consider default mapping */
> -			goto out_done;
> -		if (ret < 0)
> -			goto out_error;
> -
> -		if (ret != DATA_LANES_COUNT) {
> -			dev_err(&nb7->client->dev, "expected 4 data lanes\n");
> -			ret = -EINVAL;
> -			goto out_error;
> -		}
> +	if (!ep)
> +		return 0;
>   
> -		ret = of_property_read_u32_array(ep, "data-lanes", data_lanes, DATA_LANES_COUNT);
> -		if (ret)
> -			goto out_error;
> +	ret = of_property_count_u32_elems(ep, "data-lanes");
> +	if (ret == -EINVAL)
> +		/* Property isn't here, consider default mapping */
> +		goto out_done;
> +	if (ret < 0)
> +		goto out_error;
> +
> +	if (ret != DATA_LANES_COUNT) {
> +		dev_err(&nb7->client->dev, "expected 4 data lanes\n");
> +		ret = -EINVAL;
> +		goto out_error;
> +	}
>   
> -		for (i = 0; i < ARRAY_SIZE(supported_data_lane_mapping); i++) {
> -			for (j = 0; j < DATA_LANES_COUNT; j++) {
> -				if (data_lanes[j] != supported_data_lane_mapping[i][j])
> -					break;
> -			}
> +	ret = of_property_read_u32_array(ep, "data-lanes", data_lanes, DATA_LANES_COUNT);
> +	if (ret)
> +		goto out_error;
>   
> -			if (j == DATA_LANES_COUNT)
> +	for (i = 0; i < ARRAY_SIZE(supported_data_lane_mapping); i++) {
> +		for (j = 0; j < DATA_LANES_COUNT; j++) {
> +			if (data_lanes[j] != supported_data_lane_mapping[i][j])
>   				break;
>   		}
>   
> -		switch (i) {
> +		if (j == DATA_LANES_COUNT)
> +			break;
> +	}
> +
> +	switch (i) {
>   		case NORMAL_LANE_MAPPING:
>   			break;
>   		case INVERT_LANE_MAPPING:
> @@ -360,7 +362,6 @@ static int nb7vpq904m_parse_data_lanes_mapping(struct nb7vpq904m *nb7)
>   			dev_err(&nb7->client->dev, "invalid data lanes mapping\n");
>   			ret = -EINVAL;
>   			goto out_error;
> -		}
>   	}
>   
>   out_done:
Apologise,  Forget to add info.
This patch is for linux-next repo.

Thanks,
Sundar
Randy Dunlap April 20, 2024, 4:23 p.m. UTC | #2
On 4/20/24 7:59 AM, sundar.R wrote:
> On 20/04/24 20:25, sundar wrote:
>> Added check if pointer is null and removed identation for common path

In Subject and the line above, spell "indentation".
R Sundar April 20, 2024, 4:43 p.m. UTC | #3
On 20/04/24 21:53, Randy Dunlap wrote:
> 
> 
> On 4/20/24 7:59 AM, sundar.R wrote:
>> On 20/04/24 20:25, sundar wrote:
>>> Added check if pointer is null and removed identation for common path
> 
> In Subject and the line above, spell "indentation".
> 
Thanks for pointing it out. will fix the typo error.
And send the updated version.

Thanks,
Sundar
diff mbox series

Patch

diff --git a/drivers/usb/typec/mux/nb7vpq904m.c b/drivers/usb/typec/mux/nb7vpq904m.c
index b17826713753..fe0257840dd5 100644
--- a/drivers/usb/typec/mux/nb7vpq904m.c
+++ b/drivers/usb/typec/mux/nb7vpq904m.c
@@ -321,35 +321,37 @@  static int nb7vpq904m_parse_data_lanes_mapping(struct nb7vpq904m *nb7)
 
 	ep = of_graph_get_endpoint_by_regs(nb7->client->dev.of_node, 1, 0);
 
-	if (ep) {
-		ret = of_property_count_u32_elems(ep, "data-lanes");
-		if (ret == -EINVAL)
-			/* Property isn't here, consider default mapping */
-			goto out_done;
-		if (ret < 0)
-			goto out_error;
-
-		if (ret != DATA_LANES_COUNT) {
-			dev_err(&nb7->client->dev, "expected 4 data lanes\n");
-			ret = -EINVAL;
-			goto out_error;
-		}
+	if (!ep)
+		return 0;
 
-		ret = of_property_read_u32_array(ep, "data-lanes", data_lanes, DATA_LANES_COUNT);
-		if (ret)
-			goto out_error;
+	ret = of_property_count_u32_elems(ep, "data-lanes");
+	if (ret == -EINVAL)
+		/* Property isn't here, consider default mapping */
+		goto out_done;
+	if (ret < 0)
+		goto out_error;
+
+	if (ret != DATA_LANES_COUNT) {
+		dev_err(&nb7->client->dev, "expected 4 data lanes\n");
+		ret = -EINVAL;
+		goto out_error;
+	}
 
-		for (i = 0; i < ARRAY_SIZE(supported_data_lane_mapping); i++) {
-			for (j = 0; j < DATA_LANES_COUNT; j++) {
-				if (data_lanes[j] != supported_data_lane_mapping[i][j])
-					break;
-			}
+	ret = of_property_read_u32_array(ep, "data-lanes", data_lanes, DATA_LANES_COUNT);
+	if (ret)
+		goto out_error;
 
-			if (j == DATA_LANES_COUNT)
+	for (i = 0; i < ARRAY_SIZE(supported_data_lane_mapping); i++) {
+		for (j = 0; j < DATA_LANES_COUNT; j++) {
+			if (data_lanes[j] != supported_data_lane_mapping[i][j])
 				break;
 		}
 
-		switch (i) {
+		if (j == DATA_LANES_COUNT)
+			break;
+	}
+
+	switch (i) {
 		case NORMAL_LANE_MAPPING:
 			break;
 		case INVERT_LANE_MAPPING:
@@ -360,7 +362,6 @@  static int nb7vpq904m_parse_data_lanes_mapping(struct nb7vpq904m *nb7)
 			dev_err(&nb7->client->dev, "invalid data lanes mapping\n");
 			ret = -EINVAL;
 			goto out_error;
-		}
 	}
 
 out_done: