Re: [PATCH v7 2/2] scsi: ufs: core: Add support for static TX Equalization settings
From: Peter Wang (王信友)
Date: Thu Jun 11 2026 - 06:11:32 EST
On Wed, 2026-06-10 at 00:15 -0700, Can Guo wrote:
> +static int ufshcd_parse_tx_eq_value_array(struct ufs_hba *hba,
> + const char *prop_name,
> + const u32 max_value,
> + u32 values[UFS_MAX_LANES *
> 2])
> +{
> + u32 num_elems = 2 * hba->lanes_per_direction;
> + struct device *dev = hba->dev;
> + int count, err, i;
> +
> + count = of_property_count_u32_elems(dev->of_node, prop_name);
> + if (count <= 0)
> + return count ? count : -ENOENT;
>
Hi Can,
Returning -ENOENT when count == 0 is not correct.
count == 0 means "empty property," whereas -ENOENT means "property
not present."
I suggest only checking for < 0 as follows:
if (count < 0)
return count;
and letting the count == 0 case be handled below:
if (count != num_elems) {
...
return -EINVAL;
}
Thanks.
Peter
> +
> + if (count != num_elems) {
> + dev_err(dev, "Property %s has invalid count (%d),
> expecting %u\n",
> + prop_name, count, num_elems);
> + return -EINVAL;
> + }