* [PATCH v5 2/3] media: atmel: atmel-sama5d2-isc: fixed checkpatch warnings
[not found] <1560336983-16843-1-git-send-email-eugen.hristev@microchip.com>
@ 2019-06-12 11:01 ` Eugen.Hristev
2019-06-12 11:01 ` [PATCH v5 3/3] media: atmel: atmel-isc: fix and cleanup potential bugs Eugen.Hristev
1 sibling, 0 replies; 3+ messages in thread
From: Eugen.Hristev @ 2019-06-12 11:01 UTC (permalink / raw)
To: hverkuil, linux-media, linux-arm-kernel, linux-kernel, sakari.ailus
Cc: Eugen.Hristev
From: Eugen Hristev <eugen.hristev@microchip.com>
Checkpatch complaining that locks do not have comments,
unaligned code and macro reuse of same argument in to_isc_clk.
Fixed them by renaming, realigning and adding struct comments
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
Changes in v5:
- none
Changes in v4:
- s/sync/serialize as requested by Sakari
Changes in v3:
- new patch, addresses the checkpatch issues that Hans asked to fix
drivers/media/platform/atmel/atmel-isc.h | 51 +++++++++++++++++++++---
drivers/media/platform/atmel/atmel-sama5d2-isc.c | 4 +-
2 files changed, 48 insertions(+), 7 deletions(-)
diff --git a/drivers/media/platform/atmel/atmel-isc.h b/drivers/media/platform/atmel/atmel-isc.h
index f633e10..5be5b09 100644
--- a/drivers/media/platform/atmel/atmel-isc.h
+++ b/drivers/media/platform/atmel/atmel-isc.h
@@ -24,14 +24,14 @@ struct isc_clk {
struct clk_hw hw;
struct clk *clk;
struct regmap *regmap;
- spinlock_t lock;
+ spinlock_t lock; /* serialize access to clock registers */
u8 id;
u8 parent_id;
u32 div;
struct device *dev;
};
-#define to_isc_clk(hw) container_of(hw, struct isc_clk, hw)
+#define to_isc_clk(v) container_of(v, struct isc_clk, hw)
struct isc_buffer {
struct vb2_v4l2_buffer vb;
@@ -146,6 +146,47 @@ struct isc_ctrls {
#define ISC_PIPE_LINE_NODE_NUM 11
+/*
+ * struct isc_device - ISC device driver data/config struct
+ * @regmap: Register map
+ * @hclock: Hclock clock input (refer datasheet)
+ * @ispck: iscpck clock (refer datasheet)
+ * @isc_clks: ISC clocks
+ *
+ * @dev: Registered device driver
+ * @v4l2_dev: v4l2 registered device
+ * @video_dev: registered video device
+ *
+ * @vb2_vidq: video buffer 2 video queue
+ * @dma_queue_lock: lock to serialize the dma buffer queue
+ * @dma_queue: the queue for dma buffers
+ * @cur_frm: current isc frame/buffer
+ * @sequence: current frame number
+ * @stop: true if isc is not streaming, false if streaming
+ * @comp: completion reference that signals frame completion
+ *
+ * @fmt: current v42l format
+ * @user_formats: list of formats that are supported and agreed with sd
+ * @num_user_formats: how many formats are in user_formats
+ *
+ * @config: current ISC format configuration
+ * @try_config: the current ISC try format , not yet activated
+ *
+ * @ctrls: holds information about ISC controls
+ * @do_wb_ctrl: control regarding the DO_WHITE_BALANCE button
+ * @awb_work: workqueue reference for autowhitebalance histogram
+ * analysis
+ *
+ * @lock: lock for serializing userspace file operations
+ * with ISC operations
+ * @awb_lock: lock for serializing awb work queue operations
+ * with DMA/buffer operations
+ *
+ * @pipeline: configuration of the ISC pipeline
+ *
+ * @current_subdev: current subdevice: the sensor
+ * @subdev_entities: list of subdevice entitites
+ */
struct isc_device {
struct regmap *regmap;
struct clk *hclock;
@@ -157,7 +198,7 @@ struct isc_device {
struct video_device video_dev;
struct vb2_queue vb2_vidq;
- spinlock_t dma_queue_lock;
+ spinlock_t dma_queue_lock; /* serialize access to dma queue */
struct list_head dma_queue;
struct isc_buffer *cur_frm;
unsigned int sequence;
@@ -175,8 +216,8 @@ struct isc_device {
struct v4l2_ctrl *do_wb_ctrl;
struct work_struct awb_work;
- struct mutex lock;
- spinlock_t awb_lock;
+ struct mutex lock; /* serialize access to file operations */
+ spinlock_t awb_lock; /* serialize access to DMA buffers from awb work queue */
struct regmap_field *pipeline[ISC_PIPE_LINE_NODE_NUM];
diff --git a/drivers/media/platform/atmel/atmel-sama5d2-isc.c b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
index 93fb839..127e79c 100644
--- a/drivers/media/platform/atmel/atmel-sama5d2-isc.c
+++ b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
@@ -87,8 +87,8 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc)
break;
}
- subdev_entity = devm_kzalloc(dev,
- sizeof(*subdev_entity), GFP_KERNEL);
+ subdev_entity = devm_kzalloc(dev, sizeof(*subdev_entity),
+ GFP_KERNEL);
if (!subdev_entity) {
of_node_put(rem);
ret = -ENOMEM;
--
2.7.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v5 3/3] media: atmel: atmel-isc: fix and cleanup potential bugs
[not found] <1560336983-16843-1-git-send-email-eugen.hristev@microchip.com>
2019-06-12 11:01 ` [PATCH v5 2/3] media: atmel: atmel-sama5d2-isc: fixed checkpatch warnings Eugen.Hristev
@ 2019-06-12 11:01 ` Eugen.Hristev
2019-06-12 11:30 ` Sakari Ailus
1 sibling, 1 reply; 3+ messages in thread
From: Eugen.Hristev @ 2019-06-12 11:01 UTC (permalink / raw)
To: hverkuil, linux-media, linux-arm-kernel, linux-kernel, sakari.ailus
Cc: Eugen.Hristev
From: Eugen Hristev <eugen.hristev@microchip.com>
Fixed issues that can lead to potential bugs.
Cleanup order in the driver
Taking into consideration std control creation can fail
mutex_destroy call
changing controller_formats with const specifier
some cosmetic cleanups
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
---
Changes in v5:
- new patch that fixes issues reviewed by Sakari
drivers/media/platform/atmel/atmel-isc-base.c | 28 +++++++++++++++---------
drivers/media/platform/atmel/atmel-isc.h | 2 +-
drivers/media/platform/atmel/atmel-sama5d2-isc.c | 14 +++++++-----
3 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/drivers/media/platform/atmel/atmel-isc-base.c b/drivers/media/platform/atmel/atmel-isc-base.c
index edfd7e0..678383e 100644
--- a/drivers/media/platform/atmel/atmel-isc-base.c
+++ b/drivers/media/platform/atmel/atmel-isc-base.c
@@ -45,7 +45,7 @@ MODULE_PARM_DESC(sensor_preferred,
"Sensor is preferred to output the specified format (1-on 0-off), default 1");
/* This is a list of the formats that the ISC can *output* */
-struct isc_format controller_formats[] = {
+const struct isc_format controller_formats[] = {
{
.fourcc = V4L2_PIX_FMT_ARGB444,
},
@@ -231,7 +231,7 @@ static inline void isc_update_awb_ctrls(struct isc_device *isc)
static inline void isc_reset_awb_ctrls(struct isc_device *isc)
{
- int c;
+ unsigned int c;
for (c = ISC_HIS_CFG_MODE_GR; c <= ISC_HIS_CFG_MODE_B; c++) {
/* gains have a fixed point at 9 decimals */
@@ -1456,7 +1456,7 @@ static int isc_enum_frameintervals(struct file *file, void *fh,
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
int ret = -EINVAL;
- int i;
+ unsigned int i;
for (i = 0; i < isc->num_user_formats; i++)
if (isc->user_formats[i]->fourcc == fival->pixel_format)
@@ -1883,6 +1883,12 @@ static int isc_ctrl_init(struct isc_device *isc)
isc->do_wb_ctrl = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_DO_WHITE_BALANCE,
0, 0, 0, 0);
+ if (!isc->do_wb_ctrl) {
+ ret = hdl->error;
+ v4l2_ctrl_handler_free(hdl);
+ return ret;
+ }
+
v4l2_ctrl_activate(isc->do_wb_ctrl, false);
v4l2_ctrl_handler_setup(hdl);
@@ -2010,7 +2016,7 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier)
struct isc_device, v4l2_dev);
struct video_device *vdev = &isc->video_dev;
struct vb2_queue *q = &isc->vb2_vidq;
- int ret;
+ int ret = 0;
INIT_WORK(&isc->awb_work, isc_awb_work);
@@ -2041,7 +2047,7 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier)
if (ret < 0) {
v4l2_err(&isc->v4l2_dev,
"vb2_queue_init() failed: %d\n", ret);
- return ret;
+ goto isc_async_complete_err;
}
/* Init video dma queues */
@@ -2053,19 +2059,19 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier)
if (ret < 0) {
v4l2_err(&isc->v4l2_dev,
"Init format failed: %d\n", ret);
- return ret;
+ goto isc_async_complete_err;
}
ret = isc_set_default_fmt(isc);
if (ret) {
v4l2_err(&isc->v4l2_dev, "Could not set default format\n");
- return ret;
+ goto isc_async_complete_err;
}
ret = isc_ctrl_init(isc);
if (ret) {
v4l2_err(&isc->v4l2_dev, "Init isc ctrols failed: %d\n", ret);
- return ret;
+ goto isc_async_complete_err;
}
/* Register video device */
@@ -2085,10 +2091,12 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier)
if (ret < 0) {
v4l2_err(&isc->v4l2_dev,
"video_register_device failed: %d\n", ret);
- return ret;
+ goto isc_async_complete_err;
}
- return 0;
+isc_async_complete_err:
+ mutex_destroy(&isc->lock);
+ return ret;
}
const struct v4l2_async_notifier_operations isc_async_ops = {
diff --git a/drivers/media/platform/atmel/atmel-isc.h b/drivers/media/platform/atmel/atmel-isc.h
index 5be5b09..f5f5932 100644
--- a/drivers/media/platform/atmel/atmel-isc.h
+++ b/drivers/media/platform/atmel/atmel-isc.h
@@ -235,7 +235,7 @@ extern unsigned int debug;
extern unsigned int sensor_preferred;
extern struct isc_format formats_list[];
-extern struct isc_format controller_formats[];
+extern const struct isc_format controller_formats[];
extern const u32 isc_gamma_table[GAMMA_MAX + 1][GAMMA_ENTRIES];
extern const struct regmap_config isc_regmap_config;
extern const struct v4l2_async_notifier_operations isc_async_ops;
diff --git a/drivers/media/platform/atmel/atmel-sama5d2-isc.c b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
index 127e79c..266df14 100644
--- a/drivers/media/platform/atmel/atmel-sama5d2-isc.c
+++ b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
@@ -122,8 +122,7 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc)
ISC_PFE_CFG0_CCIR656;
subdev_entity->asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
- subdev_entity->asd->match.fwnode =
- of_fwnode_handle(rem);
+ subdev_entity->asd->match.fwnode = of_fwnode_handle(rem);
list_add_tail(&subdev_entity->list, &isc->subdev_entities);
}
@@ -282,13 +281,14 @@ static int atmel_isc_remove(struct platform_device *pdev)
struct isc_device *isc = platform_get_drvdata(pdev);
pm_runtime_disable(&pdev->dev);
- clk_disable_unprepare(isc->ispck);
- clk_disable_unprepare(isc->hclock);
isc_subdev_cleanup(isc);
v4l2_device_unregister(&isc->v4l2_dev);
+ clk_disable_unprepare(isc->ispck);
+ clk_disable_unprepare(isc->hclock);
+
isc_clk_cleanup(isc);
return 0;
@@ -313,7 +313,11 @@ static int __maybe_unused isc_runtime_resume(struct device *dev)
if (ret)
return ret;
- return clk_prepare_enable(isc->ispck);
+ ret = clk_prepare_enable(isc->ispck);
+ if (ret)
+ clk_disable_unprepare(isc->hclock);
+
+ return ret;
}
static const struct dev_pm_ops atmel_isc_dev_pm_ops = {
--
2.7.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v5 3/3] media: atmel: atmel-isc: fix and cleanup potential bugs
2019-06-12 11:01 ` [PATCH v5 3/3] media: atmel: atmel-isc: fix and cleanup potential bugs Eugen.Hristev
@ 2019-06-12 11:30 ` Sakari Ailus
0 siblings, 0 replies; 3+ messages in thread
From: Sakari Ailus @ 2019-06-12 11:30 UTC (permalink / raw)
To: Eugen.Hristev; +Cc: hverkuil, linux-kernel, linux-arm-kernel, linux-media
Hi Eugen,
On Wed, Jun 12, 2019 at 11:01:15AM +0000, Eugen.Hristev@microchip.com wrote:
> From: Eugen Hristev <eugen.hristev@microchip.com>
>
> Fixed issues that can lead to potential bugs.
> Cleanup order in the driver
> Taking into consideration std control creation can fail
> mutex_destroy call
> changing controller_formats with const specifier
> some cosmetic cleanups
>
> Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
> ---
> Changes in v5:
> - new patch that fixes issues reviewed by Sakari
>
> drivers/media/platform/atmel/atmel-isc-base.c | 28 +++++++++++++++---------
> drivers/media/platform/atmel/atmel-isc.h | 2 +-
> drivers/media/platform/atmel/atmel-sama5d2-isc.c | 14 +++++++-----
> 3 files changed, 28 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/media/platform/atmel/atmel-isc-base.c b/drivers/media/platform/atmel/atmel-isc-base.c
> index edfd7e0..678383e 100644
> --- a/drivers/media/platform/atmel/atmel-isc-base.c
> +++ b/drivers/media/platform/atmel/atmel-isc-base.c
> @@ -45,7 +45,7 @@ MODULE_PARM_DESC(sensor_preferred,
> "Sensor is preferred to output the specified format (1-on 0-off), default 1");
>
> /* This is a list of the formats that the ISC can *output* */
> -struct isc_format controller_formats[] = {
> +const struct isc_format controller_formats[] = {
> {
> .fourcc = V4L2_PIX_FMT_ARGB444,
> },
> @@ -231,7 +231,7 @@ static inline void isc_update_awb_ctrls(struct isc_device *isc)
>
> static inline void isc_reset_awb_ctrls(struct isc_device *isc)
> {
> - int c;
> + unsigned int c;
>
> for (c = ISC_HIS_CFG_MODE_GR; c <= ISC_HIS_CFG_MODE_B; c++) {
> /* gains have a fixed point at 9 decimals */
> @@ -1456,7 +1456,7 @@ static int isc_enum_frameintervals(struct file *file, void *fh,
> .which = V4L2_SUBDEV_FORMAT_ACTIVE,
> };
> int ret = -EINVAL;
> - int i;
> + unsigned int i;
>
> for (i = 0; i < isc->num_user_formats; i++)
> if (isc->user_formats[i]->fourcc == fival->pixel_format)
> @@ -1883,6 +1883,12 @@ static int isc_ctrl_init(struct isc_device *isc)
> isc->do_wb_ctrl = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_DO_WHITE_BALANCE,
> 0, 0, 0, 0);
>
> + if (!isc->do_wb_ctrl) {
> + ret = hdl->error;
> + v4l2_ctrl_handler_free(hdl);
> + return ret;
> + }
> +
> v4l2_ctrl_activate(isc->do_wb_ctrl, false);
>
> v4l2_ctrl_handler_setup(hdl);
> @@ -2010,7 +2016,7 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier)
> struct isc_device, v4l2_dev);
> struct video_device *vdev = &isc->video_dev;
> struct vb2_queue *q = &isc->vb2_vidq;
> - int ret;
> + int ret = 0;
>
> INIT_WORK(&isc->awb_work, isc_awb_work);
>
> @@ -2041,7 +2047,7 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier)
> if (ret < 0) {
> v4l2_err(&isc->v4l2_dev,
> "vb2_queue_init() failed: %d\n", ret);
> - return ret;
> + goto isc_async_complete_err;
> }
>
> /* Init video dma queues */
> @@ -2053,19 +2059,19 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier)
> if (ret < 0) {
> v4l2_err(&isc->v4l2_dev,
> "Init format failed: %d\n", ret);
> - return ret;
> + goto isc_async_complete_err;
> }
>
> ret = isc_set_default_fmt(isc);
> if (ret) {
> v4l2_err(&isc->v4l2_dev, "Could not set default format\n");
> - return ret;
> + goto isc_async_complete_err;
> }
>
> ret = isc_ctrl_init(isc);
> if (ret) {
> v4l2_err(&isc->v4l2_dev, "Init isc ctrols failed: %d\n", ret);
> - return ret;
> + goto isc_async_complete_err;
> }
>
> /* Register video device */
> @@ -2085,10 +2091,12 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier)
> if (ret < 0) {
> v4l2_err(&isc->v4l2_dev,
> "video_register_device failed: %d\n", ret);
> - return ret;
> + goto isc_async_complete_err;
> }
>
> - return 0;
I presume you did not intend to remove that line?
The patch seems good apart from that.
> +isc_async_complete_err:
> + mutex_destroy(&isc->lock);
> + return ret;
> }
>
> const struct v4l2_async_notifier_operations isc_async_ops = {
> diff --git a/drivers/media/platform/atmel/atmel-isc.h b/drivers/media/platform/atmel/atmel-isc.h
> index 5be5b09..f5f5932 100644
> --- a/drivers/media/platform/atmel/atmel-isc.h
> +++ b/drivers/media/platform/atmel/atmel-isc.h
> @@ -235,7 +235,7 @@ extern unsigned int debug;
> extern unsigned int sensor_preferred;
>
> extern struct isc_format formats_list[];
> -extern struct isc_format controller_formats[];
> +extern const struct isc_format controller_formats[];
> extern const u32 isc_gamma_table[GAMMA_MAX + 1][GAMMA_ENTRIES];
> extern const struct regmap_config isc_regmap_config;
> extern const struct v4l2_async_notifier_operations isc_async_ops;
> diff --git a/drivers/media/platform/atmel/atmel-sama5d2-isc.c b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
> index 127e79c..266df14 100644
> --- a/drivers/media/platform/atmel/atmel-sama5d2-isc.c
> +++ b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
> @@ -122,8 +122,7 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc)
> ISC_PFE_CFG0_CCIR656;
>
> subdev_entity->asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
> - subdev_entity->asd->match.fwnode =
> - of_fwnode_handle(rem);
> + subdev_entity->asd->match.fwnode = of_fwnode_handle(rem);
> list_add_tail(&subdev_entity->list, &isc->subdev_entities);
> }
>
> @@ -282,13 +281,14 @@ static int atmel_isc_remove(struct platform_device *pdev)
> struct isc_device *isc = platform_get_drvdata(pdev);
>
> pm_runtime_disable(&pdev->dev);
> - clk_disable_unprepare(isc->ispck);
> - clk_disable_unprepare(isc->hclock);
>
> isc_subdev_cleanup(isc);
>
> v4l2_device_unregister(&isc->v4l2_dev);
>
> + clk_disable_unprepare(isc->ispck);
> + clk_disable_unprepare(isc->hclock);
> +
> isc_clk_cleanup(isc);
>
> return 0;
> @@ -313,7 +313,11 @@ static int __maybe_unused isc_runtime_resume(struct device *dev)
> if (ret)
> return ret;
>
> - return clk_prepare_enable(isc->ispck);
> + ret = clk_prepare_enable(isc->ispck);
> + if (ret)
> + clk_disable_unprepare(isc->hclock);
> +
> + return ret;
> }
>
> static const struct dev_pm_ops atmel_isc_dev_pm_ops = {
> --
> 2.7.4
>
--
Sakari Ailus
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-06-12 11:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1560336983-16843-1-git-send-email-eugen.hristev@microchip.com>
2019-06-12 11:01 ` [PATCH v5 2/3] media: atmel: atmel-sama5d2-isc: fixed checkpatch warnings Eugen.Hristev
2019-06-12 11:01 ` [PATCH v5 3/3] media: atmel: atmel-isc: fix and cleanup potential bugs Eugen.Hristev
2019-06-12 11:30 ` Sakari Ailus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).