From: Hans de Goede <hdegoede@redhat.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Daniel Scally <dan.scally@ideasonboard.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Andy Shevchenko <andy@kernel.org>, Kate Hsuan <hpa@redhat.com>,
Hao Yao <hao.yao@intel.com>, Bingbu Cao <bingbu.cao@intel.com>,
linux-media@vger.kernel.org
Subject: [PATCH 05/12] media: ipu3-cio2: Only keep PLD around while parsing
Date: Tue, 27 Jun 2023 19:56:35 +0200 [thread overview]
Message-ID: <20230627175643.114778-6-hdegoede@redhat.com> (raw)
In-Reply-To: <20230627175643.114778-1-hdegoede@redhat.com>
There is no need to keep a reference to the PLD struct around,
it is only used once the get the sensor orientation.
Rename cio2_bridge_parse_orientation() to cio2_bridge_get_orientation()
and make it also get + put the PLD.
This is a preparation patch for making the cio2-bridge code more generic
so that it can be shared with the atomisp driver.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/media/pci/intel/ipu3/cio2-bridge.c | 51 ++++++++++++----------
drivers/media/pci/intel/ipu3/cio2-bridge.h | 2 +-
2 files changed, 30 insertions(+), 23 deletions(-)
diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.c b/drivers/media/pci/intel/ipu3/cio2-bridge.c
index 746c1dda31d1..741ef54f0d65 100644
--- a/drivers/media/pci/intel/ipu3/cio2-bridge.c
+++ b/drivers/media/pci/intel/ipu3/cio2-bridge.c
@@ -112,23 +112,40 @@ static u32 cio2_bridge_parse_rotation(struct cio2_sensor *sensor)
}
}
-static enum v4l2_fwnode_orientation cio2_bridge_parse_orientation(struct cio2_sensor *sensor)
+static enum v4l2_fwnode_orientation
+cio2_bridge_get_orientation(struct acpi_device *adev)
{
- switch (sensor->pld->panel) {
+ enum v4l2_fwnode_orientation orientation;
+ struct acpi_pld_info *pld;
+ acpi_status status;
+
+ status = acpi_get_physical_device_location(adev->handle, &pld);
+ if (ACPI_FAILURE(status)) {
+ dev_warn(&adev->dev, "_PLD call failed using unknown orientation\n");
+ return V4L2_FWNODE_ORIENTATION_EXTERNAL;
+ }
+
+ switch (pld->panel) {
case ACPI_PLD_PANEL_FRONT:
- return V4L2_FWNODE_ORIENTATION_FRONT;
+ orientation = V4L2_FWNODE_ORIENTATION_FRONT;
+ break;
case ACPI_PLD_PANEL_BACK:
- return V4L2_FWNODE_ORIENTATION_BACK;
+ orientation = V4L2_FWNODE_ORIENTATION_BACK;
+ break;
case ACPI_PLD_PANEL_TOP:
case ACPI_PLD_PANEL_LEFT:
case ACPI_PLD_PANEL_RIGHT:
case ACPI_PLD_PANEL_UNKNOWN:
- return V4L2_FWNODE_ORIENTATION_EXTERNAL;
+ orientation = V4L2_FWNODE_ORIENTATION_EXTERNAL;
+ break;
default:
- dev_warn(&sensor->adev->dev, "Unknown _PLD panel value %d\n",
- sensor->pld->panel);
- return V4L2_FWNODE_ORIENTATION_EXTERNAL;
+ dev_warn(&adev->dev, "Unknown _PLD panel val %d\n", pld->panel);
+ orientation = V4L2_FWNODE_ORIENTATION_EXTERNAL;
+ break;
}
+
+ ACPI_FREE(pld);
+ return orientation;
}
static void cio2_bridge_create_fwnode_properties(
@@ -137,10 +154,8 @@ static void cio2_bridge_create_fwnode_properties(
const struct cio2_sensor_config *cfg)
{
u32 rotation;
- enum v4l2_fwnode_orientation orientation;
rotation = cio2_bridge_parse_rotation(sensor);
- orientation = cio2_bridge_parse_orientation(sensor);
sensor->prop_names = prop_names;
@@ -155,7 +170,7 @@ static void cio2_bridge_create_fwnode_properties(
rotation);
sensor->dev_properties[2] = PROPERTY_ENTRY_U32(
sensor->prop_names.orientation,
- orientation);
+ sensor->orientation);
if (sensor->ssdb.vcmtype) {
sensor->vcm_ref[0] =
SOFTWARE_NODE_REFERENCE(&sensor->swnodes[SWNODE_VCM]);
@@ -279,7 +294,6 @@ static void cio2_bridge_unregister_sensors(struct cio2_bridge *bridge)
for (i = 0; i < bridge->n_sensors; i++) {
sensor = &bridge->sensors[i];
software_node_unregister_node_group(sensor->group);
- ACPI_FREE(sensor->pld);
acpi_dev_put(sensor->adev);
i2c_unregister_device(sensor->vcm_i2c_client);
}
@@ -291,7 +305,6 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
struct fwnode_handle *fwnode, *primary;
struct cio2_sensor *sensor;
struct acpi_device *adev;
- acpi_status status;
int ret;
for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) {
@@ -321,17 +334,13 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
sensor->ssdb.vcmtype = 0;
}
- status = acpi_get_physical_device_location(adev->handle, &sensor->pld);
- if (ACPI_FAILURE(status)) {
- ret = -ENODEV;
- goto err_put_adev;
- }
+ sensor->orientation = cio2_bridge_get_orientation(adev);
if (sensor->ssdb.lanes > CIO2_MAX_LANES) {
dev_err(&adev->dev,
"Number of lanes in SSDB is invalid\n");
ret = -EINVAL;
- goto err_free_pld;
+ goto err_put_adev;
}
cio2_bridge_create_fwnode_properties(sensor, bridge, cfg);
@@ -339,7 +348,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
ret = software_node_register_node_group(sensor->group);
if (ret)
- goto err_free_pld;
+ goto err_put_adev;
fwnode = software_node_fwnode(&sensor->swnodes[
SWNODE_SENSOR_HID]);
@@ -365,8 +374,6 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
err_free_swnodes:
software_node_unregister_node_group(sensor->group);
-err_free_pld:
- ACPI_FREE(sensor->pld);
err_put_adev:
acpi_dev_put(adev);
return ret;
diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.h b/drivers/media/pci/intel/ipu3/cio2-bridge.h
index 8045ceab899b..e42c5c3cf856 100644
--- a/drivers/media/pci/intel/ipu3/cio2-bridge.h
+++ b/drivers/media/pci/intel/ipu3/cio2-bridge.h
@@ -125,7 +125,7 @@ struct cio2_sensor {
struct cio2_node_names node_names;
struct cio2_sensor_ssdb ssdb;
- struct acpi_pld_info *pld;
+ enum v4l2_fwnode_orientation orientation;
struct cio2_property_names prop_names;
struct property_entry ep_properties[5];
--
2.41.0
next prev parent reply other threads:[~2023-06-27 17:57 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-27 17:56 [PATCH 00/12] media: intel-cio2-bridge: Add shared intel-cio2-bridge code, rework VCM instantiation Hans de Goede
2023-06-27 17:56 ` [PATCH 01/12] media: ipu3-cio2: Do not use on stack memory for software_node.name field Hans de Goede
2023-06-27 17:56 ` [PATCH 02/12] media: ipu3-cio2: Move initialization of node_names.vcm to cio2_bridge_init_swnode_names() Hans de Goede
2023-06-27 17:56 ` [PATCH 03/12] media: ipu3-cio2: Make cio2_bridge_init() take a regular struct device as argument Hans de Goede
2023-06-27 17:56 ` [PATCH 04/12] media: ipu3-cio2: Store dev pointer in struct cio2_bridge Hans de Goede
2023-06-27 17:56 ` Hans de Goede [this message]
2023-06-27 17:56 ` [PATCH 06/12] media: ipu3-cio2: Add a cio2_bridge_parse_sensor_fwnode() helper function Hans de Goede
2023-06-27 20:39 ` Andy Shevchenko
2023-06-27 17:56 ` [PATCH 07/12] media: ipu3-cio2: Add a parse_sensor_fwnode callback to cio2_bridge_init() Hans de Goede
2023-06-27 17:56 ` [PATCH 08/12] media: ipu3-cio2: Add supported_sensors parameter " Hans de Goede
2023-06-27 17:56 ` [PATCH 09/12] media: ipu3-cio2: Move cio2_bridge_init() code into a new shared intel-cio2-bridge.ko Hans de Goede
2023-06-27 20:55 ` Andy Shevchenko
2023-06-28 12:53 ` Dan Scally
2023-06-27 17:56 ` [PATCH 10/12] media: atomisp: csi2-bridge: Switch to new common cio2_bridge_init() Hans de Goede
2023-06-27 17:56 ` [PATCH 11/12] media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and sensor Hans de Goede
2023-06-27 21:03 ` Andy Shevchenko
2023-10-30 8:30 ` Bingbu Cao
2023-10-30 8:55 ` Sakari Ailus
2023-10-30 8:58 ` Hans de Goede
2023-10-30 9:23 ` Sakari Ailus
2023-11-01 6:26 ` Cao, Bingbu
2023-11-01 7:12 ` Sakari Ailus
2023-11-01 7:38 ` Cao, Bingbu
2023-11-02 13:35 ` Andy Shevchenko
2023-11-02 13:54 ` Hans de Goede
2023-11-03 2:01 ` Bingbu Cao
2023-06-27 17:56 ` [PATCH 12/12] [RFC] media: dw9719: Drop hack to enable "vsio" regulator Hans de Goede
2023-06-27 21:04 ` [PATCH 00/12] media: intel-cio2-bridge: Add shared intel-cio2-bridge code, rework VCM instantiation Andy Shevchenko
2023-06-28 1:19 ` Cao, Bingbu
2023-06-28 13:57 ` Hans de Goede
2023-06-29 8:22 ` Cao, Bingbu
2023-06-29 20:45 ` Hans de Goede
2023-06-30 9:07 ` Sakari Ailus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230627175643.114778-6-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=andy@kernel.org \
--cc=bingbu.cao@intel.com \
--cc=dan.scally@ideasonboard.com \
--cc=hao.yao@intel.com \
--cc=hpa@redhat.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox