diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
index 26f200b1ed6d..d0b9d906a563 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
@@ -459,13 +459,13 @@ static int gmin_pmic_detect(struct v4l2_subdev *subdev)
 	return pmic_id;
 }
 
-static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
+static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev, struct gmin_subdev *gdev)
 {
 	struct i2c_client *client = v4l2_get_subdevdata(subdev);
 	struct device *dev = &client->dev;
 	struct acpi_device *adev;
 	acpi_handle handle;
-	int i, ret;
+	int ret;
 
 	handle = ACPI_HANDLE(dev);
 
@@ -478,13 +478,8 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
 	dev_info(&client->dev, "%s: ACPI detected it on bus ID=%s, HID=%s\n",
 		__func__, acpi_device_bid(adev), acpi_device_hid(adev));
 
-	for (i = 0; i < MAX_SUBDEVS && gmin_subdevs[i].subdev; i++)
-		;
-	if (i >= MAX_SUBDEVS)
-		return NULL;
-
 	if (power) {
-		gmin_subdevs[i].pwm_i2c_addr = power->addr;
+		gdev->pwm_i2c_addr = power->addr;
 		dev_info(dev,
 			 "gmin: power management provided via %s (i2c addr 0x%02x)\n",
 			 pmic_name[pmic_id], power->addr);
@@ -493,28 +488,21 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
 			 pmic_name[pmic_id]);
 	}
 
-	gmin_subdevs[i].subdev = subdev;
-	gmin_subdevs[i].clock_num = gmin_get_var_int(dev, false, "CamClk", 0);
+	gdev->subdev = subdev;
+	gdev->clock_num = gmin_get_var_int(dev, false, "CamClk", 0);
 	/*WA:CHT requires XTAL clock as PLL is not stable.*/
-	gmin_subdevs[i].clock_src = gmin_get_var_int(dev, false, "ClkSrc",
-				    VLV2_CLK_PLL_19P2MHZ);
-	gmin_subdevs[i].csi_port = gmin_get_var_int(dev, false, "CsiPort", 0);
-	gmin_subdevs[i].csi_lanes = gmin_get_var_int(dev, false, "CsiLanes", 1);
+	gdev->clock_src = gmin_get_var_int(dev, false, "ClkSrc", VLV2_CLK_PLL_19P2MHZ);
+	gdev->csi_port = gmin_get_var_int(dev, false, "CsiPort", 0);
+	gdev->csi_lanes = gmin_get_var_int(dev, false, "CsiLanes", 1);
 
 	/* get PMC clock with clock framework */
-	snprintf(gmin_pmc_clk_name,
-		 sizeof(gmin_pmc_clk_name),
-		 "%s_%d", "pmc_plt_clk", gmin_subdevs[i].clock_num);
-
-	gmin_subdevs[i].pmc_clk = devm_clk_get(dev, gmin_pmc_clk_name);
-	if (IS_ERR(gmin_subdevs[i].pmc_clk)) {
-		ret = PTR_ERR(gmin_subdevs[i].pmc_clk);
-
-		dev_err(dev,
-			"Failed to get clk from %s : %d\n",
-			gmin_pmc_clk_name,
-			ret);
+	snprintf(gmin_pmc_clk_name, sizeof(gmin_pmc_clk_name),
+		 "pmc_plt_clk_%d", gdev->clock_num);
 
+	gdev->pmc_clk = devm_clk_get(dev, gmin_pmc_clk_name);
+	if (IS_ERR(gdev->pmc_clk)) {
+		ret = PTR_ERR(gdev->pmc_clk);
+		dev_err(dev, "Failed to get clk from %s: %d\n", gmin_pmc_clk_name, ret);
 		return NULL;
 	}
 
@@ -528,25 +516,25 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
 	 * to disable a clock that has not been enabled,
 	 * we need to enable the clock first.
 	 */
-	ret = clk_prepare_enable(gmin_subdevs[i].pmc_clk);
+	ret = clk_prepare_enable(gdev->pmc_clk);
 	if (!ret)
-		clk_disable_unprepare(gmin_subdevs[i].pmc_clk);
+		clk_disable_unprepare(gdev->pmc_clk);
 
-	gmin_subdevs[i].gpio0 = gpiod_get_index(dev, NULL, 0, GPIOD_OUT_LOW);
-	if (IS_ERR(gmin_subdevs[i].gpio0))
-		gmin_subdevs[i].gpio0 = NULL;
+	gdev->gpio0 = gpiod_get_index(dev, NULL, 0, GPIOD_OUT_LOW);
+	if (IS_ERR(gdev->gpio0))
+		gdev->gpio0 = NULL;
 
-	gmin_subdevs[i].gpio1 = gpiod_get_index(dev, NULL, 1, GPIOD_OUT_LOW);
-	if (IS_ERR(gmin_subdevs[i].gpio1))
-		gmin_subdevs[i].gpio1 = NULL;
+	gdev->gpio1 = gpiod_get_index(dev, NULL, 1, GPIOD_OUT_LOW);
+	if (IS_ERR(gdev->gpio1))
+		gdev->gpio1 = NULL;
 
 	switch (pmic_id) {
 	case PMIC_REGULATOR:
-		gmin_subdevs[i].v1p8_reg = regulator_get(dev, "V1P8SX");
-		gmin_subdevs[i].v2p8_reg = regulator_get(dev, "V2P8SX");
+		gdev->v1p8_reg = regulator_get(dev, "V1P8SX");
+		gdev->v2p8_reg = regulator_get(dev, "V2P8SX");
 
-		gmin_subdevs[i].v1p2_reg = regulator_get(dev, "V1P2A");
-		gmin_subdevs[i].v2p8_vcm_reg = regulator_get(dev, "VPROG4B");
+		gdev->v1p2_reg = regulator_get(dev, "V1P2A");
+		gdev->v2p8_vcm_reg = regulator_get(dev, "VPROG4B");
 
 		/* Note: ideally we would initialize v[12]p8_on to the
 		 * output of regulator_is_enabled(), but sadly that
@@ -558,31 +546,25 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev)
 		break;
 
 	case PMIC_AXP:
-		gmin_subdevs[i].eldo1_1p8v = gmin_get_var_int(dev, false,
-							      "eldo1_1p8v",
-							      ELDO1_1P8V);
-		gmin_subdevs[i].eldo1_sel_reg = gmin_get_var_int(dev, false,
-								 "eldo1_sel_reg",
-								 ELDO1_SEL_REG);
-		gmin_subdevs[i].eldo1_ctrl_shift = gmin_get_var_int(dev, false,
-								    "eldo1_ctrl_shift",
-								    ELDO1_CTRL_SHIFT);
-		gmin_subdevs[i].eldo2_1p8v = gmin_get_var_int(dev, false,
-							      "eldo2_1p8v",
-							      ELDO2_1P8V);
-		gmin_subdevs[i].eldo2_sel_reg = gmin_get_var_int(dev, false,
-								 "eldo2_sel_reg",
-								 ELDO2_SEL_REG);
-		gmin_subdevs[i].eldo2_ctrl_shift = gmin_get_var_int(dev, false,
-								    "eldo2_ctrl_shift",
-								    ELDO2_CTRL_SHIFT);
+		gdev->eldo1_1p8v = gmin_get_var_int(dev, false, "eldo1_1p8v",
+						    ELDO1_1P8V);
+		gdev->eldo1_sel_reg = gmin_get_var_int(dev, false, "eldo1_sel_reg",
+						       ELDO1_SEL_REG);
+		gdev->eldo1_ctrl_shift = gmin_get_var_int(dev, false, "eldo1_ctrl_shift",
+							  ELDO1_CTRL_SHIFT);
+		gdev->eldo2_1p8v = gmin_get_var_int(dev, false, "eldo2_1p8v",
+						    ELDO2_1P8V);
+		gdev->eldo2_sel_reg = gmin_get_var_int(dev, false, "eldo2_sel_reg",
+						       ELDO2_SEL_REG);
+		gdev->eldo2_ctrl_shift = gmin_get_var_int(dev, false, "eldo2_ctrl_shift",
+							  ELDO2_CTRL_SHIFT);
 		break;
 
 	default:
 		break;
 	}
 
-	return &gmin_subdevs[i];
+	return gdev;
 }
 
 static struct gmin_subdev *find_gmin_subdev(struct v4l2_subdev *subdev)
@@ -593,8 +575,14 @@ static struct gmin_subdev *find_gmin_subdev(struct v4l2_subdev *subdev)
 		if (gmin_subdevs[i].subdev == subdev)
 			return &gmin_subdevs[i];
 
+	for (i = 0; i < MAX_SUBDEVS; i++)
+		if (gmin_subdevs[i].subdev == NULL)
+			break;
+	if (i == MAX_SUBDEVS)
+		return NULL;
+
 	gmin_pmic_detect(subdev);
-	return gmin_subdev_add(subdev);
+	return gmin_subdev_add(subdev, &gmin_subdevs[i]);
 }
 
 static int axp_regulator_set(struct device *dev, struct gmin_subdev *gs,
