diff mbox series

[v2,1/2] slimbus: stream: handle unsupported bitrates for presence rate

Message ID 20220930100015.259106-1-krzysztof.kozlowski@linaro.org (mailing list archive)
State New, archived
Headers show
Series [v2,1/2] slimbus: stream: handle unsupported bitrates for presence rate | expand

Commit Message

Krzysztof Kozlowski Sept. 30, 2022, 10 a.m. UTC
Handle errors of getting presence rate for unsupported stream bitrate,
instead of sending -EINVAL in change content message.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@somainline.org>

---

Changes since v1:
1. Rebase (drop development pieces in the context).
2. Return prrate (which has errno) instead of -EINVAL.
3. Add Rb tag.
---
 drivers/slimbus/stream.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Srinivas Kandagatla Oct. 31, 2022, 6:28 p.m. UTC | #1
On 30/09/2022 11:00, Krzysztof Kozlowski wrote:
> Handle errors of getting presence rate for unsupported stream bitrate,
> instead of sending -EINVAL in change content message.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Reviewed-by: Konrad Dybcio <konrad.dybcio@somainline.org>
> 
> ---

Applied both,
thanks,

--srini
> 
> Changes since v1:
> 1. Rebase (drop development pieces in the context).
> 2. Return prrate (which has errno) instead of -EINVAL.
> 3. Add Rb tag.
> ---
>   drivers/slimbus/stream.c | 11 +++++++++--
>   1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/slimbus/stream.c b/drivers/slimbus/stream.c
> index d5ce974e880b..f631d5ed9809 100644
> --- a/drivers/slimbus/stream.c
> +++ b/drivers/slimbus/stream.c
> @@ -204,7 +204,7 @@ int slim_stream_prepare(struct slim_stream_runtime *rt,
>   {
>   	struct slim_controller *ctrl = rt->dev->ctrl;
>   	struct slim_port *port;
> -	int num_ports, i, port_id;
> +	int num_ports, i, port_id, prrate;
>   
>   	if (rt->ports) {
>   		dev_err(&rt->dev->dev, "Stream already Prepared\n");
> @@ -221,6 +221,13 @@ int slim_stream_prepare(struct slim_stream_runtime *rt,
>   	rt->bps = cfg->bps;
>   	rt->direction = cfg->direction;
>   
> +	prrate = slim_get_prate_code(cfg->rate);
> +	if (prrate < 0) {
> +		dev_err(&rt->dev->dev, "Cannot get presence rate for rate %d Hz\n",
> +			cfg->rate);
> +		return prrate;
> +	}
> +
>   	if (cfg->rate % ctrl->a_framer->superfreq) {
>   		/*
>   		 * data rate not exactly multiple of super frame,
> @@ -241,7 +248,7 @@ int slim_stream_prepare(struct slim_stream_runtime *rt,
>   		port = &rt->ports[i];
>   		port->state = SLIM_PORT_DISCONNECTED;
>   		port->id = port_id;
> -		port->ch.prrate = slim_get_prate_code(cfg->rate);
> +		port->ch.prrate = prrate;
>   		port->ch.id = cfg->chs[i];
>   		port->ch.data_fmt = SLIM_CH_DATA_FMT_NOT_DEFINED;
>   		port->ch.aux_fmt = SLIM_CH_AUX_FMT_NOT_APPLICABLE;
diff mbox series

Patch

diff --git a/drivers/slimbus/stream.c b/drivers/slimbus/stream.c
index d5ce974e880b..f631d5ed9809 100644
--- a/drivers/slimbus/stream.c
+++ b/drivers/slimbus/stream.c
@@ -204,7 +204,7 @@  int slim_stream_prepare(struct slim_stream_runtime *rt,
 {
 	struct slim_controller *ctrl = rt->dev->ctrl;
 	struct slim_port *port;
-	int num_ports, i, port_id;
+	int num_ports, i, port_id, prrate;
 
 	if (rt->ports) {
 		dev_err(&rt->dev->dev, "Stream already Prepared\n");
@@ -221,6 +221,13 @@  int slim_stream_prepare(struct slim_stream_runtime *rt,
 	rt->bps = cfg->bps;
 	rt->direction = cfg->direction;
 
+	prrate = slim_get_prate_code(cfg->rate);
+	if (prrate < 0) {
+		dev_err(&rt->dev->dev, "Cannot get presence rate for rate %d Hz\n",
+			cfg->rate);
+		return prrate;
+	}
+
 	if (cfg->rate % ctrl->a_framer->superfreq) {
 		/*
 		 * data rate not exactly multiple of super frame,
@@ -241,7 +248,7 @@  int slim_stream_prepare(struct slim_stream_runtime *rt,
 		port = &rt->ports[i];
 		port->state = SLIM_PORT_DISCONNECTED;
 		port->id = port_id;
-		port->ch.prrate = slim_get_prate_code(cfg->rate);
+		port->ch.prrate = prrate;
 		port->ch.id = cfg->chs[i];
 		port->ch.data_fmt = SLIM_CH_DATA_FMT_NOT_DEFINED;
 		port->ch.aux_fmt = SLIM_CH_AUX_FMT_NOT_APPLICABLE;