[PATCH 1/5] omap3isp: Fix async notifier registration order

From: Sakari Ailus
Date: Sat May 16 2015 - 16:34:34 EST


The async notifier was registered before the v4l2_device was registered and
before the notifier callbacks were set. This could lead to missing the
bound() and complete() callbacks and to attempting to spin_lock() and
uninitialised spin lock.

Also fix unregistering the async notifier in the case of an error --- the
function may not fail anymore after the notifier is registered.

Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxx>

Conflicts:
drivers/media/platform/omap3isp/isp.c
---
arch/arm/boot/dts/omap3-n900.dts | 24 ++++++++++++++++++++++++
drivers/media/i2c/ad5820.c | 2 +-
drivers/media/i2c/adp1653.c | 9 ++++++++-
drivers/media/platform/omap3isp/isp.c | 12 ++++++++++++
4 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index 640d409..0729c69 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -186,6 +186,7 @@
module {
model = "TCM8341MD";
sensor = <&cam1>;
+ focus = <&autofocus>;
};
};

@@ -198,6 +199,11 @@
};
};

+ autofocus: dac-camera-autofocus {
+ compatible = "dac-camera-autofocus";
+ io-channels = <&ad5820>;
+ };
+
video-bus-switch {
compatible = "video-bus-switch";

@@ -255,6 +261,11 @@
crc = <0>;
};
};
+ port@99 {
+ adp1653_link: endpoint {
+ remote-endpoint = <&adp1653_ep>;
+ };
+ };
};
};

@@ -696,6 +707,11 @@
indicator {
led-max-microamp = <17500>;
};
+ port {
+ adp1653_ep: endpoint {
+ remote-endpoint = <&adp1653_link>;
+ };
+ };
};

lp5523: lp5523@32 {
@@ -879,6 +895,14 @@
};
};
};
+
+ /* D/A converter for auto-focus */
+ ad5820: dac@0c {
+ compatible = "adi,ad5820";
+ reg = <0x0c>;
+
+ #io-channel-cells = <0>;
+ };
};

&mmc1 {
diff --git a/drivers/media/i2c/ad5820.c b/drivers/media/i2c/ad5820.c
index 58a44f1..400200c 100644
--- a/drivers/media/i2c/ad5820.c
+++ b/drivers/media/i2c/ad5820.c
@@ -421,7 +421,7 @@ static int ad5820_probe(struct i2c_client *client,
coil->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
coil->subdev.internal_ops = &ad5820_internal_ops;

- ret = media_entity_init(&coil->subdev.entity, 0, NULL, 0);
+ ret = media_entity_pads_init(&coil->subdev.entity, 0, NULL);
if (ret < 0)
kfree(coil);

diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c
index b90e15b..6dd5d6a 100644
--- a/drivers/media/i2c/adp1653.c
+++ b/drivers/media/i2c/adp1653.c
@@ -515,6 +515,7 @@ static int adp1653_probe(struct i2c_client *client,
v4l2_i2c_subdev_init(&flash->subdev, client, &adp1653_ops);
flash->subdev.internal_ops = &adp1653_internal_ops;
flash->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
+ strcpy(flash->subdev.name, "adp1653 flash");

ret = adp1653_init_controls(flash);
if (ret)
@@ -524,7 +525,13 @@ static int adp1653_probe(struct i2c_client *client,
if (ret < 0)
goto free_and_quit;

- dev_info(&client->dev, "adp1653 probe: should be ok\n");
+ dev_info(&client->dev, "adp1653 probe: should be ok\n");
+
+ ret = v4l2_async_register_subdev(&flash->subdev);
+ if (ret < 0)
+ goto free_and_quit;
+
+ dev_info(&client->dev, "adp1653 probe: async register subdev ok\n");

flash->subdev.entity.function = MEDIA_ENT_F_FLASH;

diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
index 6361fde..9f51127 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -2392,6 +2392,7 @@ static int isp_probe(struct platform_device *pdev)
if (ret < 0)
goto error_modules;

+<<<<<<< HEAD
ret = isp_create_links(isp);
if (ret < 0)
goto error_register_entities;
@@ -2402,6 +2403,17 @@ static int isp_probe(struct platform_device *pdev)
ret = v4l2_async_notifier_register(&isp->v4l2_dev, &isp->notifier);
if (ret)
goto error_register_entities;
+=======
+ if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) {
+ isp->notifier.bound = isp_subdev_notifier_bound;
+ isp->notifier.complete = isp_subdev_notifier_complete;
+
+ ret = v4l2_async_notifier_register(&isp->v4l2_dev,
+ &isp->notifier);
+ if (ret)
+ goto error_register_entities;
+ }
+>>>>>>> a035633... omap3isp: Fix async notifier registration order

isp_core_init(isp, 1);
omap3isp_put(isp);
--
2.1.4


--azLHFNyN32YCQGCU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0002-Solve-conflict-I-missed.patch"