linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] media: atomisp_gmin_platform: Unexport and split camera_sensor_csi()
@ 2022-07-30 16:20 Andy Shevchenko
  2022-08-01  6:45 ` Sakari Ailus
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2022-07-30 16:20 UTC (permalink / raw)
  To: Andy Shevchenko, linux-media, linux-staging, linux-kernel
  Cc: Mauro Carvalho Chehab, Sakari Ailus, Greg Kroah-Hartman

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 <andriy.shevchenko@linux.intel.com>
---
 .../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


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

* Re: [PATCH v1 1/1] media: atomisp_gmin_platform: Unexport and split camera_sensor_csi()
  2022-07-30 16:20 [PATCH v1 1/1] media: atomisp_gmin_platform: Unexport and split camera_sensor_csi() Andy Shevchenko
@ 2022-08-01  6:45 ` Sakari Ailus
  2022-09-05 15:30   ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Sakari Ailus @ 2022-08-01  6:45 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-media, linux-staging, linux-kernel, Mauro Carvalho Chehab,
	Greg Kroah-Hartman

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 <andriy.shevchenko@linux.intel.com>

Thanks!

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Sakari Ailus

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

* Re: [PATCH v1 1/1] media: atomisp_gmin_platform: Unexport and split camera_sensor_csi()
  2022-08-01  6:45 ` Sakari Ailus
@ 2022-09-05 15:30   ` Andy Shevchenko
  2022-09-11 15:54     ` Hans de Goede
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2022-09-05 15:30 UTC (permalink / raw)
  To: Sakari Ailus, Hans de Goede
  Cc: linux-media, linux-staging, linux-kernel, Mauro Carvalho Chehab,
	Greg Kroah-Hartman

+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 <sakari.ailus@linux.intel.com>

Thanks!

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

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v1 1/1] media: atomisp_gmin_platform: Unexport and split camera_sensor_csi()
  2022-09-05 15:30   ` Andy Shevchenko
@ 2022-09-11 15:54     ` Hans de Goede
  0 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2022-09-11 15:54 UTC (permalink / raw)
  To: Andy Shevchenko, Sakari Ailus
  Cc: linux-media, linux-staging, linux-kernel, Mauro Carvalho Chehab,
	Greg Kroah-Hartman

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 <sakari.ailus@linux.intel.com>
> 
> 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


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

end of thread, other threads:[~2022-09-11 15:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-30 16:20 [PATCH v1 1/1] media: atomisp_gmin_platform: Unexport and split camera_sensor_csi() Andy Shevchenko
2022-08-01  6:45 ` Sakari Ailus
2022-09-05 15:30   ` Andy Shevchenko
2022-09-11 15:54     ` Hans de Goede

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