All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] [media] camss-csid: Fine-tuning for three function implementations
@ 2017-09-23 19:43 ` SF Markus Elfring
  0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-09-23 19:43 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab, Todor Tomov; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 23 Sep 2017 21:24:56 +0200

Three update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  Use common error handling code in csid_set_power()
  Reduce the scope for a variable in csid_set_power()
  Adjust a null pointer check in two functions

 .../media/platform/qcom/camss-8x16/camss-csid.c    | 26 +++++++++++-----------
 1 file changed, 13 insertions(+), 13 deletions(-)

-- 
2.14.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 0/3] [media] camss-csid: Fine-tuning for three function implementations
@ 2017-09-23 19:43 ` SF Markus Elfring
  0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-09-23 19:43 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab, Todor Tomov; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 23 Sep 2017 21:24:56 +0200

Three update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  Use common error handling code in csid_set_power()
  Reduce the scope for a variable in csid_set_power()
  Adjust a null pointer check in two functions

 .../media/platform/qcom/camss-8x16/camss-csid.c    | 26 +++++++++++-----------
 1 file changed, 13 insertions(+), 13 deletions(-)

-- 
2.14.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] [media] camss-csid: Use common error handling code in csid_set_power()
  2017-09-23 19:43 ` SF Markus Elfring
@ 2017-09-23 19:44   ` SF Markus Elfring
  -1 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-09-23 19:44 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab, Todor Tomov; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 23 Sep 2017 20:48:33 +0200

Add jump targets so that a bit of exception handling can be better reused
at the end of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/platform/qcom/camss-8x16/camss-csid.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/media/platform/qcom/camss-8x16/camss-csid.c b/drivers/media/platform/qcom/camss-8x16/camss-csid.c
index 64df82817de3..92d4dc6b4a66 100644
--- a/drivers/media/platform/qcom/camss-8x16/camss-csid.c
+++ b/drivers/media/platform/qcom/camss-8x16/camss-csid.c
@@ -330,13 +330,9 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
 		ret = csid_set_clock_rates(csid);
-		if (ret < 0) {
-			regulator_disable(csid->vdda);
-			return ret;
-		}
+		if (ret < 0)
+			goto disable_regulator;
 
 		ret = camss_enable_clocks(csid->nclocks, csid->clock, dev);
-		if (ret < 0) {
-			regulator_disable(csid->vdda);
-			return ret;
-		}
+		if (ret < 0)
+			goto disable_regulator;
 
 		enable_irq(csid->irq);
@@ -345,8 +341,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
 		if (ret < 0) {
 			disable_irq(csid->irq);
 			camss_disable_clocks(csid->nclocks, csid->clock);
-			regulator_disable(csid->vdda);
-			return ret;
+			goto disable_regulator;
 		}
 
 		hw_version = readl_relaxed(csid->base + CAMSS_CSID_HW_VERSION);
@@ -357,6 +352,11 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
 		ret = regulator_disable(csid->vdda);
 	}
 
+	goto exit;
+
+disable_regulator:
+	regulator_disable(csid->vdda);
+exit:
 	return ret;
 }
 
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 1/3] [media] camss-csid: Use common error handling code in csid_set_power()
@ 2017-09-23 19:44   ` SF Markus Elfring
  0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-09-23 19:44 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab, Todor Tomov; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 23 Sep 2017 20:48:33 +0200

Add jump targets so that a bit of exception handling can be better reused
at the end of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/platform/qcom/camss-8x16/camss-csid.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/media/platform/qcom/camss-8x16/camss-csid.c b/drivers/media/platform/qcom/camss-8x16/camss-csid.c
index 64df82817de3..92d4dc6b4a66 100644
--- a/drivers/media/platform/qcom/camss-8x16/camss-csid.c
+++ b/drivers/media/platform/qcom/camss-8x16/camss-csid.c
@@ -330,13 +330,9 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
 		ret = csid_set_clock_rates(csid);
-		if (ret < 0) {
-			regulator_disable(csid->vdda);
-			return ret;
-		}
+		if (ret < 0)
+			goto disable_regulator;
 
 		ret = camss_enable_clocks(csid->nclocks, csid->clock, dev);
-		if (ret < 0) {
-			regulator_disable(csid->vdda);
-			return ret;
-		}
+		if (ret < 0)
+			goto disable_regulator;
 
 		enable_irq(csid->irq);
@@ -345,8 +341,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
 		if (ret < 0) {
 			disable_irq(csid->irq);
 			camss_disable_clocks(csid->nclocks, csid->clock);
-			regulator_disable(csid->vdda);
-			return ret;
+			goto disable_regulator;
 		}
 
 		hw_version = readl_relaxed(csid->base + CAMSS_CSID_HW_VERSION);
@@ -357,6 +352,11 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
 		ret = regulator_disable(csid->vdda);
 	}
 
+	goto exit;
+
+disable_regulator:
+	regulator_disable(csid->vdda);
+exit:
 	return ret;
 }
 
-- 
2.14.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] [media] camss-csid: Reduce the scope for a variable in csid_set_power()
  2017-09-23 19:43 ` SF Markus Elfring
@ 2017-09-23 19:45   ` SF Markus Elfring
  -1 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-09-23 19:45 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab, Todor Tomov; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 23 Sep 2017 21:00:30 +0200

Move the definition for the local variable "dev" into an if branch
so that the corresponding setting will only be performed if it was
selected by the parameter "on" of this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/platform/qcom/camss-8x16/camss-csid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/camss-8x16/camss-csid.c b/drivers/media/platform/qcom/camss-8x16/camss-csid.c
index 92d4dc6b4a66..ffda0fbfe4d8 100644
--- a/drivers/media/platform/qcom/camss-8x16/camss-csid.c
+++ b/drivers/media/platform/qcom/camss-8x16/camss-csid.c
@@ -317,10 +317,10 @@ static int csid_reset(struct csid_device *csid)
 static int csid_set_power(struct v4l2_subdev *sd, int on)
 {
 	struct csid_device *csid = v4l2_get_subdevdata(sd);
-	struct device *dev = to_device_index(csid, csid->id);
 	int ret;
 
 	if (on) {
+		struct device *dev = to_device_index(csid, csid->id);
 		u32 hw_version;
 
 		ret = regulator_enable(csid->vdda);
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] [media] camss-csid: Reduce the scope for a variable in csid_set_power()
@ 2017-09-23 19:45   ` SF Markus Elfring
  0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-09-23 19:45 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab, Todor Tomov; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 23 Sep 2017 21:00:30 +0200

Move the definition for the local variable "dev" into an if branch
so that the corresponding setting will only be performed if it was
selected by the parameter "on" of this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/platform/qcom/camss-8x16/camss-csid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/camss-8x16/camss-csid.c b/drivers/media/platform/qcom/camss-8x16/camss-csid.c
index 92d4dc6b4a66..ffda0fbfe4d8 100644
--- a/drivers/media/platform/qcom/camss-8x16/camss-csid.c
+++ b/drivers/media/platform/qcom/camss-8x16/camss-csid.c
@@ -317,10 +317,10 @@ static int csid_reset(struct csid_device *csid)
 static int csid_set_power(struct v4l2_subdev *sd, int on)
 {
 	struct csid_device *csid = v4l2_get_subdevdata(sd);
-	struct device *dev = to_device_index(csid, csid->id);
 	int ret;
 
 	if (on) {
+		struct device *dev = to_device_index(csid, csid->id);
 		u32 hw_version;
 
 		ret = regulator_enable(csid->vdda);
-- 
2.14.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] [media] camss-csid: Adjust a null pointer check in two functions
  2017-09-23 19:43 ` SF Markus Elfring
@ 2017-09-23 19:46   ` SF Markus Elfring
  -1 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-09-23 19:46 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab, Todor Tomov; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 23 Sep 2017 21:10:02 +0200

The script "checkpatch.pl" pointed information out like the following.

Comparison to NULL could be written "!format"

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/platform/qcom/camss-8x16/camss-csid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/qcom/camss-8x16/camss-csid.c b/drivers/media/platform/qcom/camss-8x16/camss-csid.c
index ffda0fbfe4d8..e546f97fa68c 100644
--- a/drivers/media/platform/qcom/camss-8x16/camss-csid.c
+++ b/drivers/media/platform/qcom/camss-8x16/camss-csid.c
@@ -653,4 +653,4 @@ static int csid_get_format(struct v4l2_subdev *sd,
-	if (format == NULL)
+	if (!format)
 		return -EINVAL;
 
 	fmt->format = *format;
@@ -677,4 +677,4 @@ static int csid_set_format(struct v4l2_subdev *sd,
-	if (format == NULL)
+	if (!format)
 		return -EINVAL;
 
 	csid_try_format(csid, cfg, fmt->pad, &fmt->format, fmt->which);
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] [media] camss-csid: Adjust a null pointer check in two functions
@ 2017-09-23 19:46   ` SF Markus Elfring
  0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-09-23 19:46 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab, Todor Tomov; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 23 Sep 2017 21:10:02 +0200

The script "checkpatch.pl" pointed information out like the following.

Comparison to NULL could be written "!format"

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/platform/qcom/camss-8x16/camss-csid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/qcom/camss-8x16/camss-csid.c b/drivers/media/platform/qcom/camss-8x16/camss-csid.c
index ffda0fbfe4d8..e546f97fa68c 100644
--- a/drivers/media/platform/qcom/camss-8x16/camss-csid.c
+++ b/drivers/media/platform/qcom/camss-8x16/camss-csid.c
@@ -653,4 +653,4 @@ static int csid_get_format(struct v4l2_subdev *sd,
-	if (format = NULL)
+	if (!format)
 		return -EINVAL;
 
 	fmt->format = *format;
@@ -677,4 +677,4 @@ static int csid_set_format(struct v4l2_subdev *sd,
-	if (format = NULL)
+	if (!format)
 		return -EINVAL;
 
 	csid_try_format(csid, cfg, fmt->pad, &fmt->format, fmt->which);
-- 
2.14.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-09-23 19:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-23 19:43 [PATCH 0/3] [media] camss-csid: Fine-tuning for three function implementations SF Markus Elfring
2017-09-23 19:43 ` SF Markus Elfring
2017-09-23 19:44 ` [PATCH 1/3] [media] camss-csid: Use common error handling code in csid_set_power() SF Markus Elfring
2017-09-23 19:44   ` SF Markus Elfring
2017-09-23 19:45 ` [PATCH 2/3] [media] camss-csid: Reduce the scope for a variable " SF Markus Elfring
2017-09-23 19:45   ` SF Markus Elfring
2017-09-23 19:46 ` [PATCH 3/3] [media] camss-csid: Adjust a null pointer check in two functions SF Markus Elfring
2017-09-23 19:46   ` SF Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.