linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kamal Heib <kamalheib1@gmail.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: linux-rdma@vger.kernel.org, Jason Gunthorpe <jgg@ziepe.ca>,
	Doug Ledford <dledford@redhat.com>,
	Potnuri Bharat Teja <bharat@chelsio.com>,
	Selvin Xavier <selvin.xavier@broadcom.com>,
	Gal Pressman <galpress@amazon.com>,
	Michal Kalderon <mkalderon@marvell.com>,
	Christian Benvenuti <benve@cisco.com>,
	Moni Shoua <monis@mellanox.com>,
	Bernard Metzler <bmt@zurich.ibm.com>,
	Shiraz Saleem <shiraz.saleem@intel.com>,
	Andrew Boyer <aboyer@tobark.org>
Subject: Re: [PATCH for-next V3 1/4] RDMA: Introduce ib_port_phys_state enum
Date: Wed, 7 Aug 2019 13:21:02 +0300	[thread overview]
Message-ID: <20190807102102.GA16257@kheib-workstation> (raw)
In-Reply-To: <20190806095638.GU4832@mtr-leonro.mtl.com>

On Tue, Aug 06, 2019 at 12:56:38PM +0300, Leon Romanovsky wrote:
> On Fri, Aug 02, 2019 at 12:32:07PM +0300, Kamal Heib wrote:
> > In order to improve readability, add ib_port_phys_state enum to replace
> > the use of magic numbers.
> >
> > Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
> > Reviewed-by: Andrew Boyer <aboyer@tobark.org>
> > ---
> >  drivers/infiniband/core/sysfs.c              | 24 +++++++++++++-------
> >  drivers/infiniband/hw/bnxt_re/ib_verbs.c     |  4 ++--
> >  drivers/infiniband/hw/efa/efa_verbs.c        |  2 +-
> >  drivers/infiniband/hw/hns/hns_roce_device.h  | 10 --------
> >  drivers/infiniband/hw/hns/hns_roce_main.c    |  3 ++-
> >  drivers/infiniband/hw/mlx4/main.c            |  3 ++-
> >  drivers/infiniband/hw/mlx5/main.c            |  4 ++--
> >  drivers/infiniband/hw/ocrdma/ocrdma_verbs.c  |  4 ++--
> >  drivers/infiniband/hw/qedr/verbs.c           |  4 ++--
> >  drivers/infiniband/hw/usnic/usnic_ib_verbs.c |  7 +++---
> >  drivers/infiniband/sw/rxe/rxe.h              |  4 ----
> >  drivers/infiniband/sw/rxe/rxe_param.h        |  2 +-
> >  drivers/infiniband/sw/rxe/rxe_verbs.c        |  6 ++---
> >  drivers/infiniband/sw/siw/siw_verbs.c        |  3 ++-
> >  include/rdma/ib_verbs.h                      | 10 ++++++++
> >  15 files changed, 49 insertions(+), 41 deletions(-)
> >
> > diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
> > index b477295a96c2..46722e04f6e1 100644
> > --- a/drivers/infiniband/core/sysfs.c
> > +++ b/drivers/infiniband/core/sysfs.c
> > @@ -301,14 +301,22 @@ static ssize_t phys_state_show(struct ib_port *p, struct port_attribute *unused,
> >  		return ret;
> >
> >  	switch (attr.phys_state) {
> > -	case 1:  return sprintf(buf, "1: Sleep\n");
> > -	case 2:  return sprintf(buf, "2: Polling\n");
> > -	case 3:  return sprintf(buf, "3: Disabled\n");
> > -	case 4:  return sprintf(buf, "4: PortConfigurationTraining\n");
> > -	case 5:  return sprintf(buf, "5: LinkUp\n");
> > -	case 6:  return sprintf(buf, "6: LinkErrorRecovery\n");
> > -	case 7:  return sprintf(buf, "7: Phy Test\n");
> > -	default: return sprintf(buf, "%d: <unknown>\n", attr.phys_state);
> > +	case IB_PORT_PHYS_STATE_SLEEP:
> > +		return sprintf(buf, "1: Sleep\n");
> > +	case IB_PORT_PHYS_STATE_POLLING:
> > +		return sprintf(buf, "2: Polling\n");
> > +	case IB_PORT_PHYS_STATE_DISABLED:
> > +		return sprintf(buf, "3: Disabled\n");
> > +	case IB_PORT_PHYS_STATE_PORT_CONFIGURATION_TRAINING:
> > +		return sprintf(buf, "4: PortConfigurationTraining\n");
> > +	case IB_PORT_PHYS_STATE_LINK_UP:
> > +		return sprintf(buf, "5: LinkUp\n");
> > +	case IB_PORT_PHYS_STATE_LINK_ERROR_RECOVERY:
> > +		return sprintf(buf, "6: LinkErrorRecovery\n");
> > +	case IB_PORT_PHYS_STATE_PHY_TEST:
> > +		return sprintf(buf, "7: Phy Test\n");
> > +	default:
> > +		return sprintf(buf, "%d: <unknown>\n", attr.phys_state);
> >  	}
> 
> If you touch that function, the better way to write it will be like here (without OPA)
> https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/rdma/link.c#n209
> 
> sprintf(buf, "%d: %s\n", attr.phys_state, phys_state_to_str(attr.phys_state));
> 
> Thanks

OK, I'll send v4 soon.

Thanks,
Kamal

  reply	other threads:[~2019-08-07 10:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-02  9:32 [PATCH for-next V3 0/4] RDMA: Cleanups and improvements Kamal Heib
2019-08-02  9:32 ` [PATCH for-next V3 1/4] RDMA: Introduce ib_port_phys_state enum Kamal Heib
2019-08-02 19:26   ` [EXT] " Michal Kalderon
2019-08-05 15:18   ` Bernard Metzler
2019-08-06  9:56   ` Leon Romanovsky
2019-08-07 10:21     ` Kamal Heib [this message]
2019-08-02  9:32 ` [PATCH for-next V3 2/4] RDMA/cxgb3: Use ib_device_set_netdev() Kamal Heib
2019-08-02  9:32 ` [PATCH for-next V3 3/4] RDMA/core: Add common iWARP query port Kamal Heib
2019-08-02  9:32 ` [PATCH for-next V3 4/4] RDMA/{cxgb3, cxgb4, i40iw}: Remove common code Kamal Heib

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=20190807102102.GA16257@kheib-workstation \
    --to=kamalheib1@gmail.com \
    --cc=aboyer@tobark.org \
    --cc=benve@cisco.com \
    --cc=bharat@chelsio.com \
    --cc=bmt@zurich.ibm.com \
    --cc=dledford@redhat.com \
    --cc=galpress@amazon.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mkalderon@marvell.com \
    --cc=monis@mellanox.com \
    --cc=selvin.xavier@broadcom.com \
    --cc=shiraz.saleem@intel.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;
as well as URLs for NNTP newsgroup(s).