mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Johannes Thumshirn <jthumshirn@suse.de>
To: Lukas Bulwahn <lukas.bulwahn@gmail.com>, linux-scsi@vger.kernel.org
Cc: QLogic-Storage-Upstream@qlogic.com,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Johannes Thumshirn <jth@kernel.org>,
	QLogic-Storage-Upstream@cavium.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fcoe: make use of fip_mode enum complete
Date: Mon, 14 Jan 2019 09:40:55 +0100	[thread overview]
Message-ID: <bd956ee5-3265-34bd-bbbc-aac5d4bea83d@suse.de> (raw)
In-Reply-To: <20190112053427.35696-1-lukas.bulwahn@gmail.com>

On 12/01/2019 06:34, Lukas Bulwahn wrote:
> commit 1917d42d14b7 ("fcoe: use enum for fip_mode") introduces a separate
> enum for the fip_mode that shall be used during initialisation handling
> until it is passed to fcoe_ctrl_link_up to set the initial fip_state.
> That change was incomplete and gcc quietly converted in various places
> between the fip_mode and the fip_state enum values with implicit enum
> conversions, which fortunately cannot cause any issues in the actual
> code's execution.
> 
> clang however warns about these implicit enum conversions in the scsi
> drivers. This commit consolidates the use of the two enums, guided by
> clang's enum-conversion warnings.
> 
> This commit now completes the use of the fip_mode:
> It expects and uses fip_mode in {bnx2fc,fcoe}_interface_create and
> fcoe_ctlr_init, and it explicitly converts from fip_mode to fip_state
> only at the single point in fcoe_ctlr_link_up.
> 
> To eliminate that adding or removing values from fip_mode or fip_state enum
> break the right mapping of values, all fip_mode values are assigned to
> their fip_state counterparts.

Hi Lukas,

I have to admit, don't like this patch too much.

While it looks technically correct (I haven't tested it yet) it, it
mixes fip_state and fip_mode even more, which I think is bad for the
readability of the code flow.

Maybe you could add a conversion function for it?

Something like (untested):
static inline enum fip_mode fip_state_to_mode(enum fip_state state)
{
	switch (state) {
	case FIP_ST_AUTO:
		return FIP_MODE_AUTO;
	case FIP_ST_NON_FIP:
		return FIP_MODE_NON_FIP;
	case FIP_ST_ENABLED:
		return FIP_MODE_FABRIC;
	case FIP_ST_VMMP_START:
		return FIP_MODE_VN2VN;
	default:
		WARN(1, "Invalid FIP state");
	}

	return FIP_ST_AUTO;
}

Byte,
	Johannes
-- 
Johannes Thumshirn                            SUSE Labs Filesystems
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

  reply	other threads:[~2019-01-14  8:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-12  5:34 Lukas Bulwahn
2019-01-14  8:40 ` Johannes Thumshirn [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-02-11  8:59 Sedat Dilek
2018-09-06  4:36 Lukas Bulwahn

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=bd956ee5-3265-34bd-bbbc-aac5d4bea83d@suse.de \
    --to=jthumshirn@suse.de \
    --cc=QLogic-Storage-Upstream@cavium.com \
    --cc=QLogic-Storage-Upstream@qlogic.com \
    --cc=jejb@linux.ibm.com \
    --cc=jth@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=lukas.bulwahn@gmail.com \
    --cc=martin.petersen@oracle.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

all inboxes | Powered by JetHome®