From patchwork Sat Sep 9 21:47:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Machek X-Patchwork-Id: 43977 Received: from vger.kernel.org ([209.132.180.67]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqnbC-0005pj-5g; Sat, 09 Sep 2017 21:47:34 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750940AbdIIVr2 (ORCPT + 1 other); Sat, 9 Sep 2017 17:47:28 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:42443 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750821AbdIIVr1 (ORCPT ); Sat, 9 Sep 2017 17:47:27 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id DAFE6823A0; Sat, 9 Sep 2017 23:47:25 +0200 (CEST) Date: Sat, 9 Sep 2017 23:47:24 +0200 From: Pavel Machek To: Sakari Ailus Cc: linux-media@vger.kernel.org, niklas.soderlund@ragnatech.se, robh@kernel.org, hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, linux-acpi@vger.kernel.org, mika.westerberg@intel.com, devicetree@vger.kernel.org, sre@kernel.org Subject: [RFC] et8ek8: Add support for flash and lens devices Message-ID: <20170909214724.GA18677@amd> References: <20170908131235.30294-1-sakari.ailus@linux.intel.com> <20170908131822.31020-18-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170908131822.31020-18-sakari.ailus@linux.intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Parse async sub-devices by using v4l2_subdev_fwnode_reference_parse_sensor_common(). These types devices aren't directly related to the sensor, but are nevertheless handled by the et8ek8 driver due to the relationship of these component to the main part of the camera module --- the sensor. Signed-off-by: Pavel Machek # Not yet ready -- broken whitespace --- Whitespace is horribly bad. But otherwise... does it look ok? diff --git a/drivers/media/i2c/et8ek8/et8ek8_driver.c b/drivers/media/i2c/et8ek8/et8ek8_driver.c index c14f0fd..7714d2c 100644 --- a/drivers/media/i2c/et8ek8/et8ek8_driver.c +++ b/drivers/media/i2c/et8ek8/et8ek8_driver.c @@ -34,10 +34,12 @@ #include #include +#include #include #include #include #include +#include #include "et8ek8_reg.h" @@ -46,6 +48,7 @@ #define ET8EK8_MAX_MSG 8 struct et8ek8_sensor { + struct v4l2_async_notifier notifier; struct v4l2_subdev subdev; struct media_pad pad; struct v4l2_mbus_framefmt format; @@ -1446,6 +1449,11 @@ static int et8ek8_probe(struct i2c_client *client, sensor->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; sensor->subdev.internal_ops = &et8ek8_internal_ops; + ret = v4l2_fwnode_reference_parse_sensor_common( + &client->dev, &sensor->notifier); + if (ret < 0 && ret != -ENOENT) + return ret; + sensor->pad.flags = MEDIA_PAD_FL_SOURCE; ret = media_entity_pads_init(&sensor->subdev.entity, 1, &sensor->pad); if (ret < 0) { @@ -1453,14 +1461,21 @@ static int et8ek8_probe(struct i2c_client *client, goto err_mutex; } + ret = v4l2_async_subdev_notifier_register(&sensor->subdev, + &sensor->notifier); + if (ret) + goto err_entity; + ret = v4l2_async_register_subdev(&sensor->subdev); if (ret < 0) - goto err_entity; + goto err_async; dev_dbg(dev, "initialized!\n"); return 0; +err_async: + v4l2_async_notifier_unregister(&sensor->notifier); err_entity: media_entity_cleanup(&sensor->subdev.entity); err_mutex: @@ -1480,6 +1495,7 @@ static int __exit et8ek8_remove(struct i2c_client *client) } v4l2_device_unregister_subdev(&sensor->subdev); + v4l2_async_notifier_unregister(&sensor->notifier); device_remove_file(&client->dev, &dev_attr_priv_mem); v4l2_ctrl_handler_free(&sensor->ctrl_handler); v4l2_async_unregister_subdev(&sensor->subdev);