linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [REVIEW PATCH v3 00/12] smiapp OF support
@ 2014-12-09  0:04 Sakari Ailus
  2014-12-09  0:04 ` [REVIEW PATCH v3 01/12] smiapp: Remove FSF's address from the license header Sakari Ailus
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Sakari Ailus @ 2014-12-09  0:04 UTC (permalink / raw)
  To: linux-media; +Cc: devicetree, mark.rutland

Hi all,

This patchset adds support for Device tree in the smiapp driver. Platform
data support is retained as well. The actual DT related changes are
prepended by a few simple cleanups.

A new link-frequency property is defined in video-interfaces.txt, as this is
hardly something which is specific to the SMIA compliant sensors.

since v2:

- patch 8 (now 9) "of: smiapp: Add documentation":

	- Cleanups                                                                      

	- Removed clock-names property documentation

	- Port node documentation was really endpoint node documentation

	- Added remote-endpoint as mandatory endpoint node properties

	- Rename link-frequency property as link-frequencies

	- Removed clock-names property from the DT example

	- Fix clock property documentation

- Use struct smiapp_sensor pointer as an argument to many functions, instead
  of struct v4l2_subdev pointer. This modifies patch "smiapp: Fully probe
  the device in probe".

- smiapp_subdev_{init,cleanup} renamed as smiapp_{init,cleanup} (same patch)

- Remove redundant sub-device name change, patch "smiapp: Don't give the
  source sub-device a temporary name" added to the set.

since v1:

- Only use dev->of_node to determine whether the OF node is there.

- Add clock-lanes and data-lanes properties to mandatory properties list in
  documentation.

- Add a patch to include include/uapi/linux/smiapp.h in MAINTAINERS section
  for the smiapp driver.

-- 
Kind regards,
Sakari


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

* [REVIEW PATCH v3 01/12] smiapp: Remove FSF's address from the license header
  2014-12-09  0:04 [REVIEW PATCH v3 00/12] smiapp OF support Sakari Ailus
@ 2014-12-09  0:04 ` Sakari Ailus
  2014-12-09  0:04 ` [REVIEW PATCH v3 02/12] smiapp: List include/uapi/linux/smiapp.h in MAINTAINERS Sakari Ailus
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Sakari Ailus @ 2014-12-09  0:04 UTC (permalink / raw)
  To: linux-media; +Cc: devicetree, mark.rutland

Remove FSF's address information from the license header in the smiapp
driver and the smiapp-pll PLL calculator. This should no longer be needed,
and would be rendered outdated in case the FSF chooses to relocate its
office.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Timo Ahonen <timo.ahonen@nokia.com>
---
 drivers/media/i2c/smiapp-pll.c             |    6 ------
 drivers/media/i2c/smiapp-pll.h             |    6 ------
 drivers/media/i2c/smiapp/smiapp-core.c     |    6 ------
 drivers/media/i2c/smiapp/smiapp-limits.c   |    6 ------
 drivers/media/i2c/smiapp/smiapp-limits.h   |    6 ------
 drivers/media/i2c/smiapp/smiapp-quirk.c    |    6 ------
 drivers/media/i2c/smiapp/smiapp-quirk.h    |    6 ------
 drivers/media/i2c/smiapp/smiapp-reg-defs.h |    6 ------
 drivers/media/i2c/smiapp/smiapp-reg.h      |    6 ------
 drivers/media/i2c/smiapp/smiapp-regs.c     |    6 ------
 drivers/media/i2c/smiapp/smiapp-regs.h     |    6 ------
 drivers/media/i2c/smiapp/smiapp.h          |    6 ------
 12 files changed, 72 deletions(-)

diff --git a/drivers/media/i2c/smiapp-pll.c b/drivers/media/i2c/smiapp-pll.c
index e40d902..2b84d09 100644
--- a/drivers/media/i2c/smiapp-pll.c
+++ b/drivers/media/i2c/smiapp-pll.c
@@ -14,12 +14,6 @@
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
  */
 
 #include <linux/gcd.h>
diff --git a/drivers/media/i2c/smiapp-pll.h b/drivers/media/i2c/smiapp-pll.h
index e8f035a..77f7ff2f 100644
--- a/drivers/media/i2c/smiapp-pll.h
+++ b/drivers/media/i2c/smiapp-pll.h
@@ -14,12 +14,6 @@
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
  */
 
 #ifndef SMIAPP_PLL_H
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 65e4e05..ab917a6 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -18,12 +18,6 @@
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
  */
 
 #include <linux/clk.h>
diff --git a/drivers/media/i2c/smiapp/smiapp-limits.c b/drivers/media/i2c/smiapp/smiapp-limits.c
index 847cb23..784b114 100644
--- a/drivers/media/i2c/smiapp/smiapp-limits.c
+++ b/drivers/media/i2c/smiapp/smiapp-limits.c
@@ -14,12 +14,6 @@
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
  */
 
 #include "smiapp.h"
diff --git a/drivers/media/i2c/smiapp/smiapp-limits.h b/drivers/media/i2c/smiapp/smiapp-limits.h
index 343e9c3..b201248 100644
--- a/drivers/media/i2c/smiapp/smiapp-limits.h
+++ b/drivers/media/i2c/smiapp/smiapp-limits.h
@@ -14,12 +14,6 @@
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
  */
 
 #define SMIAPP_LIMIT_ANALOGUE_GAIN_CAPABILITY			0
diff --git a/drivers/media/i2c/smiapp/smiapp-quirk.c b/drivers/media/i2c/smiapp/smiapp-quirk.c
index e0bee87..dd4ae6f 100644
--- a/drivers/media/i2c/smiapp/smiapp-quirk.c
+++ b/drivers/media/i2c/smiapp/smiapp-quirk.c
@@ -14,12 +14,6 @@
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
  */
 
 #include <linux/delay.h>
diff --git a/drivers/media/i2c/smiapp/smiapp-quirk.h b/drivers/media/i2c/smiapp/smiapp-quirk.h
index 46e9ea8..3a3c3e5 100644
--- a/drivers/media/i2c/smiapp/smiapp-quirk.h
+++ b/drivers/media/i2c/smiapp/smiapp-quirk.h
@@ -14,12 +14,6 @@
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
  */
 
 #ifndef __SMIAPP_QUIRK__
diff --git a/drivers/media/i2c/smiapp/smiapp-reg-defs.h b/drivers/media/i2c/smiapp/smiapp-reg-defs.h
index c488ef0..f928d4c 100644
--- a/drivers/media/i2c/smiapp/smiapp-reg-defs.h
+++ b/drivers/media/i2c/smiapp/smiapp-reg-defs.h
@@ -14,12 +14,6 @@
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
  */
 #define SMIAPP_REG_MK_U8(r) ((SMIAPP_REG_8BIT << 16) | (r))
 #define SMIAPP_REG_MK_U16(r) ((SMIAPP_REG_16BIT << 16) | (r))
diff --git a/drivers/media/i2c/smiapp/smiapp-reg.h b/drivers/media/i2c/smiapp/smiapp-reg.h
index b0dcbb8..4c8b406 100644
--- a/drivers/media/i2c/smiapp/smiapp-reg.h
+++ b/drivers/media/i2c/smiapp/smiapp-reg.h
@@ -14,12 +14,6 @@
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
  */
 
 #ifndef __SMIAPP_REG_H_
diff --git a/drivers/media/i2c/smiapp/smiapp-regs.c b/drivers/media/i2c/smiapp/smiapp-regs.c
index a209800..6b6c20b 100644
--- a/drivers/media/i2c/smiapp/smiapp-regs.c
+++ b/drivers/media/i2c/smiapp/smiapp-regs.c
@@ -14,12 +14,6 @@
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
  */
 
 #include <linux/delay.h>
diff --git a/drivers/media/i2c/smiapp/smiapp-regs.h b/drivers/media/i2c/smiapp/smiapp-regs.h
index 3552112..6dd0e49 100644
--- a/drivers/media/i2c/smiapp/smiapp-regs.h
+++ b/drivers/media/i2c/smiapp/smiapp-regs.h
@@ -14,12 +14,6 @@
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
  */
 
 #ifndef SMIAPP_REGS_H
diff --git a/drivers/media/i2c/smiapp/smiapp.h b/drivers/media/i2c/smiapp/smiapp.h
index f88f8ec..8fded46 100644
--- a/drivers/media/i2c/smiapp/smiapp.h
+++ b/drivers/media/i2c/smiapp/smiapp.h
@@ -14,12 +14,6 @@
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
  */
 
 #ifndef __SMIAPP_PRIV_H_
-- 
1.7.10.4


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

* [REVIEW PATCH v3 02/12] smiapp: List include/uapi/linux/smiapp.h in MAINTAINERS
  2014-12-09  0:04 [REVIEW PATCH v3 00/12] smiapp OF support Sakari Ailus
  2014-12-09  0:04 ` [REVIEW PATCH v3 01/12] smiapp: Remove FSF's address from the license header Sakari Ailus
@ 2014-12-09  0:04 ` Sakari Ailus
  2014-12-09  0:04 ` [REVIEW PATCH v3 03/12] smiapp-pll: include linux/device.h in smiapp-pll.c, not in smiapp-pll.h Sakari Ailus
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Sakari Ailus @ 2014-12-09  0:04 UTC (permalink / raw)
  To: linux-media; +Cc: devicetree, mark.rutland

This is part of the smiapp driver.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
 MAINTAINERS |    1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 9c49eb6..f2d9159 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8624,6 +8624,7 @@ F:	drivers/media/i2c/smiapp/
 F:	include/media/smiapp.h
 F:	drivers/media/i2c/smiapp-pll.c
 F:	drivers/media/i2c/smiapp-pll.h
+F:	include/uapi/linux/smiapp.h
 
 SMM665 HARDWARE MONITOR DRIVER
 M:	Guenter Roeck <linux@roeck-us.net>
-- 
1.7.10.4


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

* [REVIEW PATCH v3 03/12] smiapp-pll: include linux/device.h in smiapp-pll.c, not in smiapp-pll.h
  2014-12-09  0:04 [REVIEW PATCH v3 00/12] smiapp OF support Sakari Ailus
  2014-12-09  0:04 ` [REVIEW PATCH v3 01/12] smiapp: Remove FSF's address from the license header Sakari Ailus
  2014-12-09  0:04 ` [REVIEW PATCH v3 02/12] smiapp: List include/uapi/linux/smiapp.h in MAINTAINERS Sakari Ailus
@ 2014-12-09  0:04 ` Sakari Ailus
  2014-12-09  0:04 ` [REVIEW PATCH v3 04/12] smiapp: Use types better suitable for DT Sakari Ailus
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Sakari Ailus @ 2014-12-09  0:04 UTC (permalink / raw)
  To: linux-media; +Cc: devicetree, mark.rutland

struct device has a forward declaration in the header already. The header is
only needed in the .c file.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
 drivers/media/i2c/smiapp-pll.c |    1 +
 drivers/media/i2c/smiapp-pll.h |    2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/i2c/smiapp-pll.c b/drivers/media/i2c/smiapp-pll.c
index 2b84d09..e3348db 100644
--- a/drivers/media/i2c/smiapp-pll.c
+++ b/drivers/media/i2c/smiapp-pll.c
@@ -16,6 +16,7 @@
  * General Public License for more details.
  */
 
+#include <linux/device.h>
 #include <linux/gcd.h>
 #include <linux/lcm.h>
 #include <linux/module.h>
diff --git a/drivers/media/i2c/smiapp-pll.h b/drivers/media/i2c/smiapp-pll.h
index 77f7ff2f..b98d143 100644
--- a/drivers/media/i2c/smiapp-pll.h
+++ b/drivers/media/i2c/smiapp-pll.h
@@ -19,8 +19,6 @@
 #ifndef SMIAPP_PLL_H
 #define SMIAPP_PLL_H
 
-#include <linux/device.h>
-
 /* CSI-2 or CCP-2 */
 #define SMIAPP_PLL_BUS_TYPE_CSI2				0x00
 #define SMIAPP_PLL_BUS_TYPE_PARALLEL				0x01
-- 
1.7.10.4


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

* [REVIEW PATCH v3 04/12] smiapp: Use types better suitable for DT
  2014-12-09  0:04 [REVIEW PATCH v3 00/12] smiapp OF support Sakari Ailus
                   ` (2 preceding siblings ...)
  2014-12-09  0:04 ` [REVIEW PATCH v3 03/12] smiapp-pll: include linux/device.h in smiapp-pll.c, not in smiapp-pll.h Sakari Ailus
@ 2014-12-09  0:04 ` Sakari Ailus
  2014-12-09  0:04 ` [REVIEW PATCH v3 05/12] smiapp: Don't give the source sub-device a temporary name Sakari Ailus
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Sakari Ailus @ 2014-12-09  0:04 UTC (permalink / raw)
  To: linux-media; +Cc: devicetree, mark.rutland

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
 include/media/smiapp.h |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/media/smiapp.h b/include/media/smiapp.h
index 0b8f124..268a3cd 100644
--- a/include/media/smiapp.h
+++ b/include/media/smiapp.h
@@ -65,19 +65,19 @@ struct smiapp_platform_data {
 	unsigned short i2c_addr_dfl;	/* Default i2c addr */
 	unsigned short i2c_addr_alt;	/* Alternate i2c addr */
 
-	unsigned int nvm_size;			/* bytes */
-	unsigned int ext_clk;			/* sensor external clk */
+	uint32_t nvm_size;		/* bytes */
+	uint32_t ext_clk;		/* sensor external clk */
 
 	unsigned int lanes;		/* Number of CSI-2 lanes */
-	u8 csi_signalling_mode;		/* SMIAPP_CSI_SIGNALLING_MODE_* */
-	const s64 *op_sys_clock;
+	uint32_t csi_signalling_mode;	/* SMIAPP_CSI_SIGNALLING_MODE_* */
+	uint64_t *op_sys_clock;
 
 	enum smiapp_module_board_orient module_board_orient;
 
 	struct smiapp_flash_strobe_parms *strobe_setup;
 
 	int (*set_xclk)(struct v4l2_subdev *sd, int hz);
-	int xshutdown;			/* gpio or SMIAPP_NO_XSHUTDOWN */
+	int32_t xshutdown;		/* gpio or SMIAPP_NO_XSHUTDOWN */
 };
 
 #endif /* __SMIAPP_H_  */
-- 
1.7.10.4


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

* [REVIEW PATCH v3 05/12] smiapp: Don't give the source sub-device a temporary name
  2014-12-09  0:04 [REVIEW PATCH v3 00/12] smiapp OF support Sakari Ailus
                   ` (3 preceding siblings ...)
  2014-12-09  0:04 ` [REVIEW PATCH v3 04/12] smiapp: Use types better suitable for DT Sakari Ailus
@ 2014-12-09  0:04 ` Sakari Ailus
  2014-12-09  0:04 ` [REVIEW PATCH v3 06/12] smiapp: Register async subdev Sakari Ailus
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Sakari Ailus @ 2014-12-09  0:04 UTC (permalink / raw)
  To: linux-media; +Cc: devicetree, mark.rutland

The source sub-device's name will be overwritten shortly. Don't give it a
name in the meantime.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
 drivers/media/i2c/smiapp/smiapp-core.c |    2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index ab917a6..92a7840 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2458,8 +2458,6 @@ static int smiapp_identify_module(struct v4l2_subdev *subdev)
 		minfo->name, minfo->manufacturer_id, minfo->model_id,
 		minfo->revision_number_major);
 
-	strlcpy(subdev->name, sensor->minfo.name, sizeof(subdev->name));
-
 	return 0;
 }
 
-- 
1.7.10.4


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

* [REVIEW PATCH v3 06/12] smiapp: Register async subdev
  2014-12-09  0:04 [REVIEW PATCH v3 00/12] smiapp OF support Sakari Ailus
                   ` (4 preceding siblings ...)
  2014-12-09  0:04 ` [REVIEW PATCH v3 05/12] smiapp: Don't give the source sub-device a temporary name Sakari Ailus
@ 2014-12-09  0:04 ` Sakari Ailus
  2014-12-09  0:04 ` [REVIEW PATCH v3 07/12] smiapp: The sensor only needs a single clock, name may be NULL Sakari Ailus
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Sakari Ailus @ 2014-12-09  0:04 UTC (permalink / raw)
  To: linux-media; +Cc: devicetree, mark.rutland

Register and unregister async sub-device for DT.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
 drivers/media/i2c/smiapp/smiapp-core.c |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 92a7840..9852c5f 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2942,8 +2942,21 @@ static int smiapp_probe(struct i2c_client *client,
 	sensor->src->sensor = sensor;
 
 	sensor->src->pads[0].flags = MEDIA_PAD_FL_SOURCE;
-	return media_entity_init(&sensor->src->sd.entity, 2,
+	rval = media_entity_init(&sensor->src->sd.entity, 2,
 				 sensor->src->pads, 0);
+	if (rval < 0)
+		return rval;
+
+	rval = v4l2_async_register_subdev(&sensor->src->sd);
+	if (rval < 0)
+		goto out_media_entity_cleanup;
+
+	return 0;
+
+out_media_entity_cleanup:
+	media_entity_cleanup(&sensor->src->sd.entity);
+
+	return rval;
 }
 
 static int smiapp_remove(struct i2c_client *client)
@@ -2952,6 +2965,8 @@ static int smiapp_remove(struct i2c_client *client)
 	struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
 	unsigned int i;
 
+	v4l2_async_unregister_subdev(subdev);
+
 	if (sensor->power_count) {
 		if (gpio_is_valid(sensor->platform_data->xshutdown))
 			gpio_set_value(sensor->platform_data->xshutdown, 0);
-- 
1.7.10.4


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

* [REVIEW PATCH v3 07/12] smiapp: The sensor only needs a single clock, name may be NULL
  2014-12-09  0:04 [REVIEW PATCH v3 00/12] smiapp OF support Sakari Ailus
                   ` (5 preceding siblings ...)
  2014-12-09  0:04 ` [REVIEW PATCH v3 06/12] smiapp: Register async subdev Sakari Ailus
@ 2014-12-09  0:04 ` Sakari Ailus
  2014-12-09  0:04 ` [REVIEW PATCH v3 08/12] of: v4l: Document link-frequencies property in video-interfaces.txt Sakari Ailus
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Sakari Ailus @ 2014-12-09  0:04 UTC (permalink / raw)
  To: linux-media; +Cc: devicetree, mark.rutland

The SMIA compatible sensors only need a single clock.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
 drivers/media/i2c/smiapp/smiapp-core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 9852c5f..2f13735 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2482,7 +2482,7 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
 	}
 
 	if (!sensor->platform_data->set_xclk) {
-		sensor->ext_clk = devm_clk_get(&client->dev, "ext_clk");
+		sensor->ext_clk = devm_clk_get(&client->dev, NULL);
 		if (IS_ERR(sensor->ext_clk)) {
 			dev_err(&client->dev, "could not get clock\n");
 			return PTR_ERR(sensor->ext_clk);
-- 
1.7.10.4


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

* [REVIEW PATCH v3 08/12] of: v4l: Document link-frequencies property in video-interfaces.txt
  2014-12-09  0:04 [REVIEW PATCH v3 00/12] smiapp OF support Sakari Ailus
                   ` (6 preceding siblings ...)
  2014-12-09  0:04 ` [REVIEW PATCH v3 07/12] smiapp: The sensor only needs a single clock, name may be NULL Sakari Ailus
@ 2014-12-09  0:04 ` Sakari Ailus
  2014-12-09  0:04 ` [REVIEW PATCH v3 09/12] of: smiapp: Add documentation Sakari Ailus
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Sakari Ailus @ 2014-12-09  0:04 UTC (permalink / raw)
  To: linux-media; +Cc: devicetree, mark.rutland

link-frequencies is a 64-bit unsigned integer array of allowed link
frequencies.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
 Documentation/devicetree/bindings/media/video-interfaces.txt |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/video-interfaces.txt b/Documentation/devicetree/bindings/media/video-interfaces.txt
index ce719f8..52a14cf 100644
--- a/Documentation/devicetree/bindings/media/video-interfaces.txt
+++ b/Documentation/devicetree/bindings/media/video-interfaces.txt
@@ -103,6 +103,9 @@ Optional endpoint properties
   array contains only one entry.
 - clock-noncontinuous: a boolean property to allow MIPI CSI-2 non-continuous
   clock mode.
+- link-frequencies: Allowed data bus frequencies. For MIPI CSI-2, for
+  instance, this is the actual frequency of the bus, not bits per clock per
+  lane value. An array of 64-bit unsigned integers.
 
 
 Example
-- 
1.7.10.4


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

* [REVIEW PATCH v3 09/12] of: smiapp: Add documentation
  2014-12-09  0:04 [REVIEW PATCH v3 00/12] smiapp OF support Sakari Ailus
                   ` (7 preceding siblings ...)
  2014-12-09  0:04 ` [REVIEW PATCH v3 08/12] of: v4l: Document link-frequencies property in video-interfaces.txt Sakari Ailus
@ 2014-12-09  0:04 ` Sakari Ailus
  2014-12-09  0:04 ` [REVIEW PATCH v3 10/12] smiapp: Obtain device information from the Device Tree if OF node exists Sakari Ailus
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Sakari Ailus @ 2014-12-09  0:04 UTC (permalink / raw)
  To: linux-media; +Cc: devicetree, mark.rutland

Document the smiapp device tree properties.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
 .../devicetree/bindings/media/i2c/nokia,smia.txt   |   63 ++++++++++++++++++++
 MAINTAINERS                                        |    1 +
 2 files changed, 64 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/nokia,smia.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt b/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt
new file mode 100644
index 0000000..855e1fa
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/nokia,smia.txt
@@ -0,0 +1,63 @@
+SMIA/SMIA++ sensor
+
+SMIA (Standard Mobile Imaging Architecture) is an image sensor standard
+defined jointly by Nokia and ST. SMIA++, defined by Nokia, is an extension
+of that. These definitions are valid for both types of sensors.
+
+More detailed documentation can be found in
+Documentation/devicetree/bindings/media/video-interfaces.txt .
+
+
+Mandatory properties
+--------------------
+
+- compatible: "nokia,smia"
+- reg: I2C address (0x10, or an alternative address)
+- vana-supply: Analogue voltage supply (VANA), typically 2,8 volts (sensor
+  dependent).
+- clocks: External clock to the sensor
+- clock-frequency: Frequency of the external clock to the sensor
+- link-frequencies: List of allowed data link frequencies. An array of
+  64-bit elements.
+
+
+Optional properties
+-------------------
+
+- nokia,nvm-size: The size of the NVM, in bytes. If the size is not given,
+  the NVM contents will not be read.
+- reset-gpios: XSHUTDOWN GPIO
+
+
+Endpoint node mandatory properties
+----------------------------------
+
+- clock-lanes: <0>
+- data-lanes: <1..n>
+- remote-endpoint: A phandle to the bus receiver's endpoint node.
+
+
+Example
+-------
+
+&i2c2 {
+	clock-frequency = <400000>;
+
+	smiapp_1: camera@10 {
+		compatible = "nokia,smia";
+		reg = <0x10>;
+		reset-gpios = <&gpio3 20 0>;
+		vana-supply = <&vaux3>;
+		clocks = <&omap3_isp 0>;
+		clock-frequency = <9600000>;
+		nokia,nvm-size = <512>; /* 8 * 64 */
+		link-frequencies = /bits/ 64 <199200000 210000000 499200000>;
+		port {
+			smiapp_1_1: endpoint {
+				clock-lanes = <0>;
+				data-lanes = <1 2>;
+				remote-endpoint = <&csi2a_ep>;
+			};
+		};
+	};
+};
diff --git a/MAINTAINERS b/MAINTAINERS
index f2d9159..437981a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8625,6 +8625,7 @@ F:	include/media/smiapp.h
 F:	drivers/media/i2c/smiapp-pll.c
 F:	drivers/media/i2c/smiapp-pll.h
 F:	include/uapi/linux/smiapp.h
+F:	Documentation/devicetree/bindings/media/i2c/nokia,smia.txt
 
 SMM665 HARDWARE MONITOR DRIVER
 M:	Guenter Roeck <linux@roeck-us.net>
-- 
1.7.10.4


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

* [REVIEW PATCH v3 10/12] smiapp: Obtain device information from the Device Tree if OF node exists
  2014-12-09  0:04 [REVIEW PATCH v3 00/12] smiapp OF support Sakari Ailus
                   ` (8 preceding siblings ...)
  2014-12-09  0:04 ` [REVIEW PATCH v3 09/12] of: smiapp: Add documentation Sakari Ailus
@ 2014-12-09  0:04 ` Sakari Ailus
  2014-12-09  0:04 ` [REVIEW PATCH v3 11/12] smiapp: Split sub-device initialisation off from the registered callback Sakari Ailus
  2014-12-09  0:04 ` [REVIEW PATCH v3 12/12] smiapp: Fully probe the device in probe Sakari Ailus
  11 siblings, 0 replies; 13+ messages in thread
From: Sakari Ailus @ 2014-12-09  0:04 UTC (permalink / raw)
  To: linux-media; +Cc: devicetree, mark.rutland

Platform data support is retained.

of_property_read_u64_array() isn't used yet as it's not in yet.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
 drivers/media/i2c/smiapp/smiapp-core.c |  114 +++++++++++++++++++++++++++++++-
 1 file changed, 112 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 2f13735..1e60f4a 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -25,11 +25,13 @@
 #include <linux/device.h>
 #include <linux/gpio.h>
 #include <linux/module.h>
+#include <linux/of_gpio.h>
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
 #include <linux/smiapp.h>
 #include <linux/v4l2-mediabus.h>
 #include <media/v4l2-device.h>
+#include <media/v4l2-of.h>
 
 #include "smiapp.h"
 
@@ -2919,19 +2921,121 @@ static int smiapp_resume(struct device *dev)
 
 #endif /* CONFIG_PM */
 
+static struct smiapp_platform_data *smiapp_get_pdata(struct device *dev)
+{
+	struct smiapp_platform_data *pdata;
+	struct v4l2_of_endpoint bus_cfg;
+	struct device_node *ep;
+	struct property *prop;
+	__be32 *val;
+	uint32_t asize;
+	unsigned int i;
+	int rval;
+
+	if (!dev->of_node)
+		return dev->platform_data;
+
+	ep = of_graph_get_next_endpoint(dev->of_node, NULL);
+	if (!ep)
+		return NULL;
+
+	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata) {
+		rval = -ENOMEM;
+		goto out_err;
+	}
+
+	v4l2_of_parse_endpoint(ep, &bus_cfg);
+
+	switch (bus_cfg.bus_type) {
+	case V4L2_MBUS_CSI2:
+		pdata->csi_signalling_mode = SMIAPP_CSI_SIGNALLING_MODE_CSI2;
+		break;
+		/* FIXME: add CCP2 support. */
+	default:
+		rval = -EINVAL;
+		goto out_err;
+	}
+
+	pdata->lanes = bus_cfg.bus.mipi_csi2.num_data_lanes;
+	dev_dbg(dev, "lanes %u\n", pdata->lanes);
+
+	/* xshutdown GPIO is optional */
+	pdata->xshutdown = of_get_named_gpio(dev->of_node, "reset-gpios", 0);
+
+	/* NVM size is not mandatory */
+	of_property_read_u32(dev->of_node, "nokia,nvm-size",
+				    &pdata->nvm_size);
+
+	rval = of_property_read_u32(dev->of_node, "clock-frequency",
+				    &pdata->ext_clk);
+	if (rval) {
+		dev_warn(dev, "can't get clock-frequency\n");
+		goto out_err;
+	}
+
+	dev_dbg(dev, "reset %d, nvm %d, clk %d, csi %d\n", pdata->xshutdown,
+		pdata->nvm_size, pdata->ext_clk, pdata->csi_signalling_mode);
+
+	rval = of_get_property(
+		dev->of_node, "link-frequencies", &asize) ? 0 : -ENOENT;
+	if (rval) {
+		dev_warn(dev, "can't get link-frequencies array size\n");
+		goto out_err;
+	}
+
+	pdata->op_sys_clock = devm_kzalloc(dev, asize, GFP_KERNEL);
+	if (!pdata->op_sys_clock) {
+		rval = -ENOMEM;
+		goto out_err;
+	}
+
+	asize /= sizeof(*pdata->op_sys_clock);
+	/*
+	 * Read a 64-bit array --- this will be replaced with a
+	 * of_property_read_u64_array() once it's merged.
+	 */
+	prop = of_find_property(dev->of_node, "link-frequencies", NULL);
+	if (!prop)
+		goto out_err;
+	if (!prop->value)
+		goto out_err;
+	if (asize * sizeof(*pdata->op_sys_clock) > prop->length)
+		goto out_err;
+	val = prop->value;
+	if (IS_ERR(val))
+		goto out_err;
+
+	for (i = 0; i < asize; i++)
+		pdata->op_sys_clock[i] = of_read_number(val + i * 2, 2);
+
+	for (; asize > 0; asize--)
+		dev_dbg(dev, "freq %d: %lld\n", asize - 1,
+			pdata->op_sys_clock[asize - 1]);
+
+	of_node_put(ep);
+	return pdata;
+
+out_err:
+	of_node_put(ep);
+	return NULL;
+}
+
 static int smiapp_probe(struct i2c_client *client,
 			const struct i2c_device_id *devid)
 {
 	struct smiapp_sensor *sensor;
+	struct smiapp_platform_data *pdata = smiapp_get_pdata(&client->dev);
+	int rval;
 
-	if (client->dev.platform_data == NULL)
+	if (pdata == NULL)
 		return -ENODEV;
 
 	sensor = devm_kzalloc(&client->dev, sizeof(*sensor), GFP_KERNEL);
 	if (sensor == NULL)
 		return -ENOMEM;
 
-	sensor->platform_data = client->dev.platform_data;
+	sensor->platform_data = pdata;
 	mutex_init(&sensor->mutex);
 	mutex_init(&sensor->power_mutex);
 	sensor->src = &sensor->ssds[sensor->ssds_used];
@@ -2990,6 +3094,11 @@ static int smiapp_remove(struct i2c_client *client)
 	return 0;
 }
 
+static const struct of_device_id smiapp_of_table[] = {
+	{ .compatible = "nokia,smia" },
+	{ },
+};
+
 static const struct i2c_device_id smiapp_id_table[] = {
 	{ SMIAPP_NAME, 0 },
 	{ },
@@ -3003,6 +3112,7 @@ static const struct dev_pm_ops smiapp_pm_ops = {
 
 static struct i2c_driver smiapp_i2c_driver = {
 	.driver	= {
+		.of_match_table = smiapp_of_table,
 		.name = SMIAPP_NAME,
 		.pm = &smiapp_pm_ops,
 	},
-- 
1.7.10.4


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

* [REVIEW PATCH v3 11/12] smiapp: Split sub-device initialisation off from the registered callback
  2014-12-09  0:04 [REVIEW PATCH v3 00/12] smiapp OF support Sakari Ailus
                   ` (9 preceding siblings ...)
  2014-12-09  0:04 ` [REVIEW PATCH v3 10/12] smiapp: Obtain device information from the Device Tree if OF node exists Sakari Ailus
@ 2014-12-09  0:04 ` Sakari Ailus
  2014-12-09  0:04 ` [REVIEW PATCH v3 12/12] smiapp: Fully probe the device in probe Sakari Ailus
  11 siblings, 0 replies; 13+ messages in thread
From: Sakari Ailus @ 2014-12-09  0:04 UTC (permalink / raw)
  To: linux-media; +Cc: devicetree, mark.rutland

The registered callback is called by the V4L2 async framework after the
bound callback. This allows separating the functionality in the registered
callback so that on DT based systems only sub-device registration is done
there.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
 drivers/media/i2c/smiapp/smiapp-core.c |   82 +++++++++++++++++++++-----------
 1 file changed, 54 insertions(+), 28 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 1e60f4a..c2bf718 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2467,6 +2467,56 @@ static const struct v4l2_subdev_ops smiapp_ops;
 static const struct v4l2_subdev_internal_ops smiapp_internal_ops;
 static const struct media_entity_operations smiapp_entity_ops;
 
+static int smiapp_register_subdevs(struct smiapp_sensor *sensor)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
+	struct smiapp_subdev *ssds[] = {
+		sensor->scaler,
+		sensor->binner,
+		sensor->pixel_array,
+	};
+	unsigned int i;
+	int rval;
+
+	for (i = 0; i < SMIAPP_SUBDEVS - 1; i++) {
+		struct smiapp_subdev *this = ssds[i + 1];
+		struct smiapp_subdev *last = ssds[i];
+
+		if (!last)
+			continue;
+
+		rval = media_entity_init(&this->sd.entity,
+					 this->npads, this->pads, 0);
+		if (rval) {
+			dev_err(&client->dev,
+				"media_entity_init failed\n");
+			return rval;
+		}
+
+		rval = media_entity_create_link(&this->sd.entity,
+						this->source_pad,
+						&last->sd.entity,
+						last->sink_pad,
+						MEDIA_LNK_FL_ENABLED |
+						MEDIA_LNK_FL_IMMUTABLE);
+		if (rval) {
+			dev_err(&client->dev,
+				"media_entity_create_link failed\n");
+			return rval;
+		}
+
+		rval = v4l2_device_register_subdev(sensor->src->sd.v4l2_dev,
+						   &this->sd);
+		if (rval) {
+			dev_err(&client->dev,
+				"v4l2_device_register_subdev failed\n");
+			return rval;
+		}
+	}
+
+	return 0;
+}
+
 static int smiapp_registered(struct v4l2_subdev *subdev)
 {
 	struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
@@ -2705,37 +2755,13 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
 		this->sd.owner = THIS_MODULE;
 		v4l2_set_subdevdata(&this->sd, client);
 
-		rval = media_entity_init(&this->sd.entity,
-					 this->npads, this->pads, 0);
-		if (rval) {
-			dev_err(&client->dev,
-				"media_entity_init failed\n");
-			goto out_nvm_release;
-		}
-
-		rval = media_entity_create_link(&this->sd.entity,
-						this->source_pad,
-						&last->sd.entity,
-						last->sink_pad,
-						MEDIA_LNK_FL_ENABLED |
-						MEDIA_LNK_FL_IMMUTABLE);
-		if (rval) {
-			dev_err(&client->dev,
-				"media_entity_create_link failed\n");
-			goto out_nvm_release;
-		}
-
-		rval = v4l2_device_register_subdev(sensor->src->sd.v4l2_dev,
-						   &this->sd);
-		if (rval) {
-			dev_err(&client->dev,
-				"v4l2_device_register_subdev failed\n");
-			goto out_nvm_release;
-		}
-
 		last = this;
 	}
 
+	rval = smiapp_register_subdevs(sensor);
+	if (rval)
+		goto out_nvm_release;
+
 	dev_dbg(&client->dev, "profile %d\n", sensor->minfo.smiapp_profile);
 
 	sensor->pixel_array->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
-- 
1.7.10.4


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

* [REVIEW PATCH v3 12/12] smiapp: Fully probe the device in probe
  2014-12-09  0:04 [REVIEW PATCH v3 00/12] smiapp OF support Sakari Ailus
                   ` (10 preceding siblings ...)
  2014-12-09  0:04 ` [REVIEW PATCH v3 11/12] smiapp: Split sub-device initialisation off from the registered callback Sakari Ailus
@ 2014-12-09  0:04 ` Sakari Ailus
  11 siblings, 0 replies; 13+ messages in thread
From: Sakari Ailus @ 2014-12-09  0:04 UTC (permalink / raw)
  To: linux-media; +Cc: devicetree, mark.rutland

In the case of platform data, ISPs that provide clocks to the sensor must
probe before the sensor does. Accessing the sensor does require the clocks,
and thus, probe cannot access the sensor in such a system.

This limitation does not exist in the case of the DT. Perform all
initialisation except Media entity initialisation, link creation and
sub-device registration in probe.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
 drivers/media/i2c/smiapp/smiapp-core.c |   68 +++++++++++++++++++++-----------
 1 file changed, 46 insertions(+), 22 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index c2bf718..48e1a1f 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2334,10 +2334,9 @@ static DEVICE_ATTR(ident, S_IRUGO, smiapp_sysfs_ident_read, NULL);
  * V4L2 subdev core operations
  */
 
-static int smiapp_identify_module(struct v4l2_subdev *subdev)
+static int smiapp_identify_module(struct smiapp_sensor *sensor)
 {
-	struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
-	struct i2c_client *client = v4l2_get_subdevdata(subdev);
+	struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
 	struct smiapp_module_info *minfo = &sensor->minfo;
 	unsigned int i;
 	int rval = 0;
@@ -2517,10 +2516,17 @@ static int smiapp_register_subdevs(struct smiapp_sensor *sensor)
 	return 0;
 }
 
-static int smiapp_registered(struct v4l2_subdev *subdev)
+static void smiapp_cleanup(struct smiapp_sensor *sensor)
 {
-	struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
-	struct i2c_client *client = v4l2_get_subdevdata(subdev);
+	struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
+
+	device_remove_file(&client->dev, &dev_attr_nvm);
+	device_remove_file(&client->dev, &dev_attr_ident);
+}
+
+static int smiapp_init(struct smiapp_sensor *sensor)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
 	struct smiapp_pll *pll = &sensor->pll;
 	struct smiapp_subdev *last = NULL;
 	u32 tmp;
@@ -2566,7 +2572,7 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
 	if (rval)
 		return -ENODEV;
 
-	rval = smiapp_identify_module(subdev);
+	rval = smiapp_identify_module(sensor);
 	if (rval) {
 		rval = -ENODEV;
 		goto out_power_off;
@@ -2646,13 +2652,13 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
 		if (sensor->nvm == NULL) {
 			dev_err(&client->dev, "nvm buf allocation failed\n");
 			rval = -ENOMEM;
-			goto out_ident_release;
+			goto out_cleanup;
 		}
 
 		if (device_create_file(&client->dev, &dev_attr_nvm) != 0) {
 			dev_err(&client->dev, "sysfs nvm entry failed\n");
 			rval = -EBUSY;
-			goto out_ident_release;
+			goto out_cleanup;
 		}
 	}
 
@@ -2696,7 +2702,7 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
 	rval = smiapp_get_mbus_formats(sensor);
 	if (rval) {
 		rval = -ENODEV;
-		goto out_nvm_release;
+		goto out_cleanup;
 	}
 
 	for (i = 0; i < SMIAPP_SUBDEVS; i++) {
@@ -2758,10 +2764,6 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
 		last = this;
 	}
 
-	rval = smiapp_register_subdevs(sensor);
-	if (rval)
-		goto out_nvm_release;
-
 	dev_dbg(&client->dev, "profile %d\n", sensor->minfo.smiapp_profile);
 
 	sensor->pixel_array->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
@@ -2770,14 +2772,14 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
 	smiapp_read_frame_fmt(sensor);
 	rval = smiapp_init_controls(sensor);
 	if (rval < 0)
-		goto out_nvm_release;
+		goto out_cleanup;
 
 	mutex_lock(&sensor->mutex);
 	rval = smiapp_update_mode(sensor);
 	mutex_unlock(&sensor->mutex);
 	if (rval) {
 		dev_err(&client->dev, "update mode failed\n");
-		goto out_nvm_release;
+		goto out_cleanup;
 	}
 
 	sensor->streaming = false;
@@ -2787,23 +2789,39 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
 	rval = smiapp_read(sensor, SMIAPP_REG_U8_FLASH_MODE_CAPABILITY, &tmp);
 	sensor->flash_capability = tmp;
 	if (rval)
-		goto out_nvm_release;
+		goto out_cleanup;
 
 	smiapp_power_off(sensor);
 
 	return 0;
 
-out_nvm_release:
-	device_remove_file(&client->dev, &dev_attr_nvm);
-
-out_ident_release:
-	device_remove_file(&client->dev, &dev_attr_ident);
+out_cleanup:
+	smiapp_cleanup(sensor);
 
 out_power_off:
 	smiapp_power_off(sensor);
 	return rval;
 }
 
+static int smiapp_registered(struct v4l2_subdev *subdev)
+{
+	struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
+	struct i2c_client *client = v4l2_get_subdevdata(subdev);
+	int rval;
+
+	if (!client->dev.of_node) {
+		rval = smiapp_init(sensor);
+		if (rval)
+			return rval;
+	}
+
+	rval = smiapp_register_subdevs(sensor);
+	if (rval)
+		smiapp_cleanup(sensor);
+
+	return rval;
+}
+
 static int smiapp_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
 {
 	struct smiapp_subdev *ssd = to_smiapp_subdev(sd);
@@ -3077,6 +3095,12 @@ static int smiapp_probe(struct i2c_client *client,
 	if (rval < 0)
 		return rval;
 
+	if (client->dev.of_node) {
+		rval = smiapp_init(sensor);
+		if (rval)
+			goto out_media_entity_cleanup;
+	}
+
 	rval = v4l2_async_register_subdev(&sensor->src->sd);
 	if (rval < 0)
 		goto out_media_entity_cleanup;
-- 
1.7.10.4


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

end of thread, other threads:[~2014-12-09  0:04 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-09  0:04 [REVIEW PATCH v3 00/12] smiapp OF support Sakari Ailus
2014-12-09  0:04 ` [REVIEW PATCH v3 01/12] smiapp: Remove FSF's address from the license header Sakari Ailus
2014-12-09  0:04 ` [REVIEW PATCH v3 02/12] smiapp: List include/uapi/linux/smiapp.h in MAINTAINERS Sakari Ailus
2014-12-09  0:04 ` [REVIEW PATCH v3 03/12] smiapp-pll: include linux/device.h in smiapp-pll.c, not in smiapp-pll.h Sakari Ailus
2014-12-09  0:04 ` [REVIEW PATCH v3 04/12] smiapp: Use types better suitable for DT Sakari Ailus
2014-12-09  0:04 ` [REVIEW PATCH v3 05/12] smiapp: Don't give the source sub-device a temporary name Sakari Ailus
2014-12-09  0:04 ` [REVIEW PATCH v3 06/12] smiapp: Register async subdev Sakari Ailus
2014-12-09  0:04 ` [REVIEW PATCH v3 07/12] smiapp: The sensor only needs a single clock, name may be NULL Sakari Ailus
2014-12-09  0:04 ` [REVIEW PATCH v3 08/12] of: v4l: Document link-frequencies property in video-interfaces.txt Sakari Ailus
2014-12-09  0:04 ` [REVIEW PATCH v3 09/12] of: smiapp: Add documentation Sakari Ailus
2014-12-09  0:04 ` [REVIEW PATCH v3 10/12] smiapp: Obtain device information from the Device Tree if OF node exists Sakari Ailus
2014-12-09  0:04 ` [REVIEW PATCH v3 11/12] smiapp: Split sub-device initialisation off from the registered callback Sakari Ailus
2014-12-09  0:04 ` [REVIEW PATCH v3 12/12] smiapp: Fully probe the device in probe 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).