From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-acpi@vger.kernel.org, linux-media@vger.kernel.org,
rafael@kernel.org, heikki.krogerus@linux.intel.com
Subject: Re: [PATCH v7 05/10] ACPI: property: Prepare generating swnodes for ACPI and DisCo for Imaging
Date: Tue, 28 Mar 2023 18:44:40 +0300 [thread overview]
Message-ID: <ZCMLaKpPrdl6kDIT@smile.fi.intel.com> (raw)
In-Reply-To: <20230328101303.1458570-6-sakari.ailus@linux.intel.com>
On Tue, Mar 28, 2023 at 01:12:58PM +0300, Sakari Ailus wrote:
> Prepare generating software nodes for information parsed from ACPI _CRS for
> CSI-2 as well as MIPI DisCo for Imaging spec. The software nodes are
> compliant with existing ACPI or DT definitions and are parsed by relevant
> drivers without changes.
...
> #define NO_CSI2_PORT (UINT_MAX - 1)
Has it been used before this patch?
...
> +/* Print graph port name into a buffer, return non-zero if failed. */
> +#define GRAPH_PORT_NAME(var, num) \
> + (snprintf((var), sizeof(var), SWNODE_GRAPH_PORT_NAME_FMT, (num)) >= \
> + sizeof(var))
This macro evaluates sizeof(var) twice. Is it a problem?
...
> +#define NEXT_PROPERTY(index, max) \
> + (WARN_ON(++(index) > ACPI_DEVICE_SWNODE_##max + 1) ? \
> + ACPI_DEVICE_SWNODE_##max : (index) - 1)
This macro full of interesting effects. On top of that it's written in
hard-to-read form.
Why not at least
#define NEXT_PROPERTY(index, max) \
(WARN_ON((index) > ACPI_DEVICE_SWNODE_##max) ? \
ACPI_DEVICE_SWNODE_##max : (index)++)
?
...
> + ret = fwnode_property_count_u8(mipi_port_fwnode, "mipi-img-lane-polarities");
> + if (ret > 0) {
> + unsigned int bytes = min_t(unsigned int, ret, sizeof(val));
> +
> + fwnode_property_read_u8_array(mipi_port_fwnode,
> + "mipi-img-lane-polarities",
> + val, bytes);
> +
> + /* Total number of lanes here is clock lane + data lanes */
> + if (bytes * BITS_PER_TYPE(u8) >= 1 + num_lanes) {
> + unsigned int i;
> +
> + /* Move polarity bits to the lane polarity u32 array */
> + for (i = 0; i < 1 + num_lanes; i++)
> + port->lane_polarities[i] =
> + (bool)(val[i >> 3] & (1 << (i & 7)));
Casting to bool?!
Can we read the array and convert it to bitmap, then this voodoo-ish code can
be simplified to
for_each_set_bit(i, ...)
..._polarities[i] = 1;
(assuming initially they are 0:s)?
> + port->ep_props[NEXT_PROPERTY(*ep_prop_index, EP_LANE_POLARITIES)] =
> + PROPERTY_ENTRY_U32_ARRAY_LEN("lane-polarities",
> + port->lane_polarities,
> + 1 + num_lanes);
> + } else {
> + acpi_handle_warn(acpi_device_handle(device),
> + "too few lane polarity bytes (%u)\n",
> + bytes);
> + }
> + }
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2023-03-28 15:45 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-28 10:12 [PATCH v7 00/10] ACPI _CRS CSI-2 and MIPI DisCo for Imaging support Sakari Ailus
2023-03-28 10:12 ` [PATCH v7 01/10] ACPI: scan: Remove the second DSDT traversal Sakari Ailus
2023-03-28 14:45 ` Andy Shevchenko
2023-03-28 14:48 ` Sakari Ailus
2023-03-28 14:55 ` Sakari Ailus
2023-03-28 10:12 ` [PATCH v7 02/10] ACPI: property: Parse data node string references in properties Sakari Ailus
2023-03-28 10:12 ` [PATCH v7 03/10] ACPI: property: Parse _CRS CSI-2 descriptor Sakari Ailus
2023-03-28 15:12 ` Andy Shevchenko
2023-03-28 15:27 ` Sakari Ailus
2023-03-28 15:46 ` Andy Shevchenko
2023-03-28 15:48 ` Sakari Ailus
2023-03-28 15:53 ` Andy Shevchenko
2023-03-28 19:26 ` Sakari Ailus
2023-03-28 10:12 ` [PATCH v7 04/10] device property: Add SOFTWARE_NODE() macro for defining software nodes Sakari Ailus
2023-03-28 10:12 ` [PATCH v7 05/10] ACPI: property: Prepare generating swnodes for ACPI and DisCo for Imaging Sakari Ailus
2023-03-28 15:44 ` Andy Shevchenko [this message]
2023-03-28 19:21 ` Sakari Ailus
2023-03-29 14:38 ` Andy Shevchenko
2023-03-29 15:20 ` Sakari Ailus
2023-03-28 10:12 ` [PATCH v7 06/10] ACPI: scan: Generate software nodes based on MIPI " Sakari Ailus
2023-03-28 15:51 ` Andy Shevchenko
2023-03-28 19:11 ` Sakari Ailus
2023-03-28 10:13 ` [PATCH v7 07/10] ACPI: property: Dig "rotation" property for devices with CSI2 _CRS Sakari Ailus
2023-03-28 10:13 ` [PATCH v7 08/10] ACPI: property: Rename parsed MIPI DisCo for Imaging properties Sakari Ailus
2023-03-28 10:13 ` [PATCH v7 09/10] ACPI: property: Skip MIPI property table without "mipi-img" prefix Sakari Ailus
2023-03-28 10:13 ` [PATCH v7 10/10] ACPI: property: Document _CRS CSI-2 and DisCo for Imaging support 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=ZCMLaKpPrdl6kDIT@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=rafael@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