media: atomisp_gmin_platform: Unexport and split camera_sensor_csi()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Sat, 30 Jul 2022 16:20:27 +0000 (18:20 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sat, 24 Sep 2022 08:15:15 +0000 (10:15 +0200)
The camera_sensor_csi() is not used outside the module, hence make it
static. While at it, split it to _alloc() and _free() to clearly show
the idea behind the last parameter @flag that is passed to
gmin_csi_cfg().

Link: https://lore.kernel.org/r/20220730162027.1011-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/staging/media/atomisp/include/linux/atomisp_gmin_platform.h
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c

index 58e0ea5..5463d11 100644 (file)
@@ -26,8 +26,6 @@ struct v4l2_subdev *atomisp_gmin_find_subdev(struct i2c_adapter *adapter,
 int atomisp_gmin_remove_subdev(struct v4l2_subdev *sd);
 int gmin_get_var_int(struct device *dev, bool is_gmin,
                     const char *var, int def);
-int camera_sensor_csi(struct v4l2_subdev *sd, u32 port,
-                     u32 lanes, u32 format, u32 bayer_order, int flag);
 struct camera_sensor_platform_data *
 gmin_camera_platform_data(
     struct v4l2_subdev *subdev,
index 254e8c9..3d41fab 100644 (file)
@@ -1048,6 +1048,38 @@ static int gmin_flisclk_ctrl(struct v4l2_subdev *subdev, int on)
        return ret;
 }
 
+static int camera_sensor_csi_alloc(struct v4l2_subdev *sd, u32 port, u32 lanes,
+                                  u32 format, u32 bayer_order)
+{
+       struct i2c_client *client = v4l2_get_subdevdata(sd);
+       struct camera_mipi_info *csi;
+
+       csi = kzalloc(sizeof(*csi), GFP_KERNEL);
+       if (!csi)
+               return -ENOMEM;
+
+       csi->port = port;
+       csi->num_lanes = lanes;
+       csi->input_format = format;
+       csi->raw_bayer_order = bayer_order;
+       v4l2_set_subdev_hostdata(sd, csi);
+       csi->metadata_format = ATOMISP_INPUT_FORMAT_EMBEDDED;
+       csi->metadata_effective_width = NULL;
+       dev_info(&client->dev,
+                "camera pdata: port: %d lanes: %d order: %8.8x\n",
+                port, lanes, bayer_order);
+
+       return 0;
+}
+
+static void camera_sensor_csi_free(struct v4l2_subdev *sd)
+{
+       struct camera_mipi_info *csi;
+
+       csi = v4l2_get_subdev_hostdata(sd);
+       kfree(csi);
+}
+
 static int gmin_csi_cfg(struct v4l2_subdev *sd, int flag)
 {
        struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -1056,8 +1088,11 @@ static int gmin_csi_cfg(struct v4l2_subdev *sd, int flag)
        if (!client || !gs)
                return -ENODEV;
 
-       return camera_sensor_csi(sd, gs->csi_port, gs->csi_lanes,
-                                gs->csi_fmt, gs->csi_bayer, flag);
+       if (flag)
+               return camera_sensor_csi_alloc(sd, gs->csi_port, gs->csi_lanes,
+                                              gs->csi_fmt, gs->csi_bayer);
+       camera_sensor_csi_free(sd);
+       return 0;
 }
 
 static struct camera_vcm_control *gmin_get_vcm_ctrl(struct v4l2_subdev *subdev,
@@ -1340,35 +1375,6 @@ int gmin_get_var_int(struct device *dev, bool is_gmin, const char *var, int def)
 }
 EXPORT_SYMBOL_GPL(gmin_get_var_int);
 
-int camera_sensor_csi(struct v4l2_subdev *sd, u32 port,
-                     u32 lanes, u32 format, u32 bayer_order, int flag)
-{
-       struct i2c_client *client = v4l2_get_subdevdata(sd);
-       struct camera_mipi_info *csi = NULL;
-
-       if (flag) {
-               csi = kzalloc(sizeof(*csi), GFP_KERNEL);
-               if (!csi)
-                       return -ENOMEM;
-               csi->port = port;
-               csi->num_lanes = lanes;
-               csi->input_format = format;
-               csi->raw_bayer_order = bayer_order;
-               v4l2_set_subdev_hostdata(sd, (void *)csi);
-               csi->metadata_format = ATOMISP_INPUT_FORMAT_EMBEDDED;
-               csi->metadata_effective_width = NULL;
-               dev_info(&client->dev,
-                        "camera pdata: port: %d lanes: %d order: %8.8x\n",
-                        port, lanes, bayer_order);
-       } else {
-               csi = v4l2_get_subdev_hostdata(sd);
-               kfree(csi);
-       }
-
-       return 0;
-}
-EXPORT_SYMBOL_GPL(camera_sensor_csi);
-
 /* PCI quirk: The BYT ISP advertises PCI runtime PM but it doesn't
  * work.  Disable so the kernel framework doesn't hang the device
  * trying.  The driver itself does direct calls to the PUNIT to manage