diff mbox

[2/6] fireworks: Use safer way to arrange ring buffer pointer

Message ID 1401863137-15103-3-git-send-email-o-takashi@sakamocchi.jp (mailing list archive)
State Accepted
Commit cf44a136c062098b099a44698291e50c5bfdce2e
Headers show

Commit Message

Takashi Sakamoto June 4, 2014, 6:25 a.m. UTC
To reverse a pointer for the ring buffer, subtraction by buffer
size is better than assignment to the beginning of the buffer.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/firewire/fireworks/fireworks_hwdep.c       | 2 +-
 sound/firewire/fireworks/fireworks_transaction.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Takashi Iwai June 4, 2014, 12:39 p.m. UTC | #1
At Wed,  4 Jun 2014 15:25:33 +0900,
Takashi Sakamoto wrote:
> 
> To reverse a pointer for the ring buffer, subtraction by buffer
> size is better than assignment to the beginning of the buffer.
> 
> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

Applied, thanks.


Takashi

> ---
>  sound/firewire/fireworks/fireworks_hwdep.c       | 2 +-
>  sound/firewire/fireworks/fireworks_transaction.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/firewire/fireworks/fireworks_hwdep.c b/sound/firewire/fireworks/fireworks_hwdep.c
> index 4f8216f..33df865 100644
> --- a/sound/firewire/fireworks/fireworks_hwdep.c
> +++ b/sound/firewire/fireworks/fireworks_hwdep.c
> @@ -58,7 +58,7 @@ hwdep_read_resp_buf(struct snd_efw *efw, char __user *buf, long remained,
>  			efw->pull_ptr += till_end;
>  			if (efw->pull_ptr >= efw->resp_buf +
>  					     snd_efw_resp_buf_size)
> -				efw->pull_ptr = efw->resp_buf;
> +				efw->pull_ptr -= snd_efw_resp_buf_size;
>  
>  			length -= till_end;
>  			buf += till_end;
> diff --git a/sound/firewire/fireworks/fireworks_transaction.c b/sound/firewire/fireworks/fireworks_transaction.c
> index aa56b8a..a6a9e9f 100644
> --- a/sound/firewire/fireworks/fireworks_transaction.c
> +++ b/sound/firewire/fireworks/fireworks_transaction.c
> @@ -148,7 +148,7 @@ copy_resp_to_buf(struct snd_efw *efw, void *data, size_t length, int *rcode)
>  
>  		efw->push_ptr += till_end;
>  		if (efw->push_ptr >= efw->resp_buf + snd_efw_resp_buf_size)
> -			efw->push_ptr = efw->resp_buf;
> +			efw->push_ptr -= snd_efw_resp_buf_size;
>  
>  		length -= till_end;
>  		data += till_end;
> -- 
> 1.8.3.2
>
diff mbox

Patch

diff --git a/sound/firewire/fireworks/fireworks_hwdep.c b/sound/firewire/fireworks/fireworks_hwdep.c
index 4f8216f..33df865 100644
--- a/sound/firewire/fireworks/fireworks_hwdep.c
+++ b/sound/firewire/fireworks/fireworks_hwdep.c
@@ -58,7 +58,7 @@  hwdep_read_resp_buf(struct snd_efw *efw, char __user *buf, long remained,
 			efw->pull_ptr += till_end;
 			if (efw->pull_ptr >= efw->resp_buf +
 					     snd_efw_resp_buf_size)
-				efw->pull_ptr = efw->resp_buf;
+				efw->pull_ptr -= snd_efw_resp_buf_size;
 
 			length -= till_end;
 			buf += till_end;
diff --git a/sound/firewire/fireworks/fireworks_transaction.c b/sound/firewire/fireworks/fireworks_transaction.c
index aa56b8a..a6a9e9f 100644
--- a/sound/firewire/fireworks/fireworks_transaction.c
+++ b/sound/firewire/fireworks/fireworks_transaction.c
@@ -148,7 +148,7 @@  copy_resp_to_buf(struct snd_efw *efw, void *data, size_t length, int *rcode)
 
 		efw->push_ptr += till_end;
 		if (efw->push_ptr >= efw->resp_buf + snd_efw_resp_buf_size)
-			efw->push_ptr = efw->resp_buf;
+			efw->push_ptr -= snd_efw_resp_buf_size;
 
 		length -= till_end;
 		data += till_end;