camss-csid: Fine-tuning for three function implementations
cover camss-csid: Fine-tuning for three function implementations
From: Markus Elfring <[email protected]>
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(-)
Signature · 1 line
2.14.1
PATCH 1/3 camss-csid: Use common error handling code in csid_set_power()
From: Markus Elfring <[email protected]>
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.
--- drivers/media/platform/qcom/camss-8x16/camss-csid.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/media/platform/qcom/camss-8x16/camss-csid.c +10 -10
@@ -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; }
Signature · 1 line
2.14.1
PATCH 2/3 camss-csid: Reduce the scope for a variable in csid_set_power()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
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.
--- drivers/media/platform/qcom/camss-8x16/camss-csid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/camss-8x16/camss-csid.c +1 -1
@@ -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);
Signature · 1 line
2.14.1
PATCH 3/3 camss-csid: Adjust a null pointer check in two functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
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.
--- drivers/media/platform/qcom/camss-8x16/camss-csid.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/camss-8x16/camss-csid.c +2 -2
@@ -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);
Signature · 1 line
2.14.1