mrst: get video subdevices using a function
authorTuukka Toivonen <tuukka.toivonen@intel.com>
Thu, 19 Jan 2012 16:58:14 +0000 (18:58 +0200)
committerbuildbot <buildbot@intel.com>
Thu, 26 Jan 2012 08:23:07 +0000 (00:23 -0800)
BZ: 16972

Different platforms supported by the mrst will have different
subdevices. Therefore the list of subdevices can not be obtained
from a fixed table.

Change-Id: I8a6f7fecf35a18f6840b93e4bb1b9591dd3a3ff9
Signed-off-by: Tuukka Toivonen <tuukka.toivonen@intel.com>
Reviewed-on: http://android.intel.com:8080/32611
Reviewed-by: Koski, Anttu <anttu.koski@intel.com>
Tested-by: Koski, Anttu <anttu.koski@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
arch/x86/platform/mrst/mrst.c

index de5d59b..3983ea8 100644 (file)
@@ -1684,21 +1684,27 @@ static const struct devs_id __initconst device_ids[] = {
        {},
 };
 
-static const struct intel_v4l2_subdev_id v4l2_ids[] = {
+static const struct intel_v4l2_subdev_id v4l2_ids_mfld[] = {
        {"mt9e013", RAW_CAMERA, ATOMISP_CAMERA_PORT_PRIMARY},
        {"mt9m114", SOC_CAMERA, ATOMISP_CAMERA_PORT_SECONDARY},
        {"lm3554", LED_FLASH, -1},
        {},
 };
 
-#define N_SUBDEV (sizeof(v4l2_ids)/sizeof(v4l2_ids[0]))
+static const struct intel_v4l2_subdev_id *get_v4l2_ids(int *n_subdev)
+{
+       if (n_subdev)
+               *n_subdev = ARRAY_SIZE(v4l2_ids_mfld);
+       return v4l2_ids_mfld;
+}
 
 static struct atomisp_platform_data *v4l2_subdev_table_head;
 
 static void intel_ignore_i2c_device_register(int bus,
                                             struct i2c_board_info *idev)
 {
-       const struct intel_v4l2_subdev_id *vdev = v4l2_ids;
+       int n_subdev;
+       const struct intel_v4l2_subdev_id *vdev = get_v4l2_ids(&n_subdev);
        struct intel_v4l2_subdev_i2c_board_info *info;
        static struct intel_v4l2_subdev_table *subdev_table;
        enum intel_v4l2_subdev_type type = 0;
@@ -1732,7 +1738,7 @@ static void intel_ignore_i2c_device_register(int bus,
 
        if (v4l2_subdev_table_head == NULL) {
                subdev_table = kzalloc(sizeof(struct intel_v4l2_subdev_table)
-                       * N_SUBDEV, GFP_KERNEL);
+                       * n_subdev, GFP_KERNEL);
 
                if (!subdev_table) {
                        pr_err("MRST: fail to alloc mem for v4l2_subdev_table %s\n",
@@ -1949,7 +1955,7 @@ static void __init sfi_handle_spi_dev(struct spi_board_info *spi_info)
 static void __init sfi_handle_i2c_dev(int bus, struct i2c_board_info *i2c_info)
 {
        const struct devs_id *dev = device_ids;
-       const struct intel_v4l2_subdev_id *vdev = v4l2_ids;
+       const struct intel_v4l2_subdev_id *vdev = get_v4l2_ids(NULL);
        void *pdata = NULL;
 
        while (dev->name[0]) {