public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: lantianyu1986@gmail.com
Cc: Tianyu Lan <Tianyu.Lan@microsoft.com>,
	devel@linuxdriverproject.org, haiyangz@microsoft.com,
	sthemmin@microsoft.com, linux-kernel@vger.kernel.org
Subject: Re: [Patch] vmbus: Simply hv_get_next_write_location() function
Date: Wed, 24 Jan 2018 08:37:07 -0800	[thread overview]
Message-ID: <20180124083707.411368b7@xeon-e3> (raw)
In-Reply-To: <1516774890-5134-1-git-send-email-Tianyu.Lan@microsoft.com>

On Wed, 24 Jan 2018 14:21:30 +0800
lantianyu1986@gmail.com wrote:

> From: Tianyu Lan <Tianyu.Lan@microsoft.com>
> 
> The "next" variable is redundant in hv_get_next_write_location().
> This patch is to remove it and return write_index directly.
> 
> Signed-off-by: Tianyu Lan <Tianyu.Lan@microsoft.com>
> ---
>  drivers/hv/ring_buffer.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
> index 12eb8ca..71558e7 100644
> --- a/drivers/hv/ring_buffer.c
> +++ b/drivers/hv/ring_buffer.c
> @@ -82,9 +82,7 @@ static void hv_signal_on_write(u32 old_write, struct vmbus_channel *channel)
>  static inline u32
>  hv_get_next_write_location(struct hv_ring_buffer_info *ring_info)
>  {
> -	u32 next = ring_info->ring_buffer->write_index;
> -
> -	return next;
> +	return ring_info->ring_buffer->write_index;
>  }
>  
>  /* Set the next write location for the specified ring buffer. */

Looks good.
But let's go farther since function is only used in one location in the file
just eliminate it completely and do simple variable references.

The get/set functions in this file are unnecessary.

Better still it is possible to replace the lock based ring structure
with a compare-exchange solution.
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

  reply	other threads:[~2018-01-24 16:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-24  6:21 [Patch] vmbus: Simply hv_get_next_write_location() function lantianyu1986
2018-01-24 16:37 ` Stephen Hemminger [this message]
2018-01-25  8:33   ` Tianyu Lan

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=20180124083707.411368b7@xeon-e3 \
    --to=stephen@networkplumber.org \
    --cc=Tianyu.Lan@microsoft.com \
    --cc=devel@linuxdriverproject.org \
    --cc=haiyangz@microsoft.com \
    --cc=lantianyu1986@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sthemmin@microsoft.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