All of lore.kernel.org
 help / color / mirror / Atom feed
From: Raghuram Kothakota <Raghuram.Kothakota@oracle.com>
To: David Miller <davem@davemloft.net>
Cc: david.stevens@oracle.com, netdev@vger.kernel.org
Subject: Re: [PATCHv3 net-next 1/3] sunvnet: upgrade to VIO protocol version 1.6
Date: Sat, 13 Sep 2014 20:43:09 -0700	[thread overview]
Message-ID: <A19FCF2B-0808-4BD5-9AF6-3830312DAEFF@oracle.com> (raw)
In-Reply-To: <20140913.230120.511140402106277600.davem@davemloft.net>


On Sep 13, 2014, at 8:01 PM, David Miller <davem@davemloft.net> wrote:

> From: David L Stevens <david.stevens@oracle.com>
> Date: Sat, 13 Sep 2014 22:39:25 -0400
> 
>> 
>> 
>> On 09/13/2014 04:18 PM, David Miller wrote:
>>> From: David L Stevens <david.stevens@oracle.com>
>> 
>>> static inline bool vio_version_before(struct vio_driver_state *vio,
>>> 				      u16 major, u16 minor)
>>> {
>>> 	u32 have = (u32)vio->major << 16 | vio->minor;
>>> 	u32 want = (u32)major << 16 | minor;
>>> 
>>> 	return have < want;
>>> }
>>> static inline bool vio_version_after_eq(struct vio_driver_state *vio,
>>> 					u16 major, u16 minor)
>>> {
>>> 	u32 have = (u32)vio->major << 16 | vio->minor;
>>> 	u32 want = (u32)major << 16 | minor;
>>> 
>>> 	return have >= want;
>>> }
>>> 
>>> Something like that.
>> 
>> Sure. I was thinking about something like:
>> 
>> #define VIO_VER(major, minor)	(((major)<<16)|(minor))
>> 
>> change the version struct to a 32-bit int, and do things like:
>> 
>> 	if (vio->ver > VIO_VER(1,6)) {
>> 
>> unless you have a preference. (?)
> 
> I hate wasting space in a structure just to avoid some harmless
> casting in a helper function that is simply trying to optimize
> a comparison.
> 
> That's why I suggested the inline helpers above, which arguments
> are strongly typed.

IMO, it would be more readable if we introduce the helper functions
that check for a specific feature than a specific version number
and hide the version number detail inside that helper function. Otherwise,
it will be harder to follow each version number check and why it is
being done. 

-Raghuram

> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2014-09-14  3:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-13 16:01 [PATCHv3 net-next 1/3] sunvnet: upgrade to VIO protocol version 1.6 David L Stevens
2014-09-13 20:18 ` David Miller
2014-09-14  2:39   ` David L Stevens
2014-09-14  3:01     ` David Miller
2014-09-14  3:43       ` Raghuram Kothakota [this message]
2014-09-14  3:30 ` Raghuram Kothakota
2014-09-14 12:02   ` David L Stevens
2014-09-14 17:21     ` Raghuram Kothakota

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=A19FCF2B-0808-4BD5-9AF6-3830312DAEFF@oracle.com \
    --to=raghuram.kothakota@oracle.com \
    --cc=davem@davemloft.net \
    --cc=david.stevens@oracle.com \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.