diff mbox series

[v3] firmware: ti_sci: Parse all resource ranges even if some is not available

Message ID 20190606121357.7932-1-peter.ujfalusi@ti.com (mailing list archive)
State New, archived
Headers show
Series [v3] firmware: ti_sci: Parse all resource ranges even if some is not available | expand

Commit Message

Peter Ujfalusi June 6, 2019, 12:13 p.m. UTC
Do not fail if any of the requested subtypes are not availabe, but set the
number of resources to 0 and continue parsing the resource ranges.

Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
Hi,

Changes since v2:
- changed dev_err to dev_dbg for not allocation subtype as it is no longer an
  error

Changes since v1:
- moved the 'bool valid_set = false;' to avoid 'reverse Christmas tree'
- Added Reviewed-by from Lokesh

Regards,
Peter
 drivers/firmware/ti_sci.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Comments

Tero Kristo June 11, 2019, 5:37 p.m. UTC | #1
On 06/06/2019 15:13, Peter Ujfalusi wrote:
> Do not fail if any of the requested subtypes are not availabe, but set the
> number of resources to 0 and continue parsing the resource ranges.
> 
> Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> ---
> Hi,
> 
> Changes since v2:
> - changed dev_err to dev_dbg for not allocation subtype as it is no longer an
>    error
> 
> Changes since v1:
> - moved the 'bool valid_set = false;' to avoid 'reverse Christmas tree'
> - Added Reviewed-by from Lokesh

Thanks, queuing up for 5.3.

-Tero

> 
> Regards,
> Peter
>   drivers/firmware/ti_sci.c | 13 ++++++++++---
>   1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
> index ef93406ace1b..571ce24d7f43 100644
> --- a/drivers/firmware/ti_sci.c
> +++ b/drivers/firmware/ti_sci.c
> @@ -2342,6 +2342,7 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
>   			    struct device *dev, u32 dev_id, char *of_prop)
>   {
>   	struct ti_sci_resource *res;
> +	bool valid_set = false;
>   	u32 resource_subtype;
>   	int i, ret;
>   
> @@ -2372,15 +2373,18 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
>   							&res->desc[i].start,
>   							&res->desc[i].num);
>   		if (ret) {
> -			dev_err(dev, "dev = %d subtype %d not allocated for this host\n",
> +			dev_dbg(dev, "dev = %d subtype %d not allocated for this host\n",
>   				dev_id, resource_subtype);
> -			return ERR_PTR(ret);
> +			res->desc[i].start = 0;
> +			res->desc[i].num = 0;
> +			continue;
>   		}
>   
>   		dev_dbg(dev, "dev = %d, subtype = %d, start = %d, num = %d\n",
>   			dev_id, resource_subtype, res->desc[i].start,
>   			res->desc[i].num);
>   
> +		valid_set = true;
>   		res->desc[i].res_map =
>   			devm_kzalloc(dev, BITS_TO_LONGS(res->desc[i].num) *
>   				     sizeof(*res->desc[i].res_map), GFP_KERNEL);
> @@ -2389,7 +2393,10 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
>   	}
>   	raw_spin_lock_init(&res->lock);
>   
> -	return res;
> +	if (valid_set)
> +		return res;
> +
> +	return ERR_PTR(-EINVAL);
>   }
>   
>   static int tisci_reboot_handler(struct notifier_block *nb, unsigned long mode,
> 

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
diff mbox series

Patch

diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index ef93406ace1b..571ce24d7f43 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -2342,6 +2342,7 @@  devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
 			    struct device *dev, u32 dev_id, char *of_prop)
 {
 	struct ti_sci_resource *res;
+	bool valid_set = false;
 	u32 resource_subtype;
 	int i, ret;
 
@@ -2372,15 +2373,18 @@  devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
 							&res->desc[i].start,
 							&res->desc[i].num);
 		if (ret) {
-			dev_err(dev, "dev = %d subtype %d not allocated for this host\n",
+			dev_dbg(dev, "dev = %d subtype %d not allocated for this host\n",
 				dev_id, resource_subtype);
-			return ERR_PTR(ret);
+			res->desc[i].start = 0;
+			res->desc[i].num = 0;
+			continue;
 		}
 
 		dev_dbg(dev, "dev = %d, subtype = %d, start = %d, num = %d\n",
 			dev_id, resource_subtype, res->desc[i].start,
 			res->desc[i].num);
 
+		valid_set = true;
 		res->desc[i].res_map =
 			devm_kzalloc(dev, BITS_TO_LONGS(res->desc[i].num) *
 				     sizeof(*res->desc[i].res_map), GFP_KERNEL);
@@ -2389,7 +2393,10 @@  devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
 	}
 	raw_spin_lock_init(&res->lock);
 
-	return res;
+	if (valid_set)
+		return res;
+
+	return ERR_PTR(-EINVAL);
 }
 
 static int tisci_reboot_handler(struct notifier_block *nb, unsigned long mode,