2022-07-30 16:21:27

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 1/1] media: atomisp_gmin_platform: Unexport and split camera_sensor_csi()

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().

Signed-off-by: Andy Shevchenko <[email protected]>
---
.../include/linux/atomisp_gmin_platform.h | 2 -
.../media/atomisp/pci/atomisp_gmin_platform.c | 68 ++++++++++---------
2 files changed, 37 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/media/atomisp/include/linux/atomisp_gmin_platform.h b/drivers/staging/media/atomisp/include/linux/atomisp_gmin_platform.h
index 58e0ea5355a3..5463d11d4295 100644
--- a/drivers/staging/media/atomisp/include/linux/atomisp_gmin_platform.h
+++ b/drivers/staging/media/atomisp/include/linux/atomisp_gmin_platform.h
@@ -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,
diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
index f7fc5137199c..4032239fcb86 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
@@ -1066,6 +1066,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);
@@ -1074,8 +1106,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,
@@ -1358,35 +1393,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
--
2.35.1



2022-08-01 06:50:07

by Sakari Ailus

[permalink] [raw]
Subject: Re: [PATCH v1 1/1] media: atomisp_gmin_platform: Unexport and split camera_sensor_csi()

On Sat, Jul 30, 2022 at 07:20:27PM +0300, Andy Shevchenko wrote:
> 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().
>
> Signed-off-by: Andy Shevchenko <[email protected]>

Thanks!

Acked-by: Sakari Ailus <[email protected]>

--
Sakari Ailus

2022-09-05 16:23:23

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v1 1/1] media: atomisp_gmin_platform: Unexport and split camera_sensor_csi()

+Cc: Hans

On Mon, Aug 01, 2022 at 06:45:07AM +0000, Sakari Ailus wrote:
> On Sat, Jul 30, 2022 at 07:20:27PM +0300, Andy Shevchenko wrote:

...

> Acked-by: Sakari Ailus <[email protected]>

Thanks!

Hans, maybe you want to include this one into your bunch?

--
With Best Regards,
Andy Shevchenko


2022-09-11 16:14:09

by Hans de Goede

[permalink] [raw]
Subject: Re: [PATCH v1 1/1] media: atomisp_gmin_platform: Unexport and split camera_sensor_csi()

Hi,

On 9/5/22 17:30, Andy Shevchenko wrote:
> +Cc: Hans
>
> On Mon, Aug 01, 2022 at 06:45:07AM +0000, Sakari Ailus wrote:
>> On Sat, Jul 30, 2022 at 07:20:27PM +0300, Andy Shevchenko wrote:
>
> ...
>
>> Acked-by: Sakari Ailus <[email protected]>
>
> Thanks!
>
> Hans, maybe you want to include this one into your bunch?

Ack, I've added this to my next batch of atomisp cleanup
patches which I'm sending out right after this email.

Regards,

Hans