All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jinpu Wang <jinpu.wang@cloud.ionos.com>
To: Joe Perches <joe@perches.com>
Cc: Doug Ledford <dledford@redhat.com>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	Potnuri Bharat Teja <bharat@chelsio.com>,
	Mike Marciniszyn <mike.marciniszyn@intel.com>,
	Dennis Dalessandro <dennis.dalessandro@intel.com>,
	Yishai Hadas <yishaih@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>,
	Christian Benvenuti <benve@cisco.com>,
	Nelson Escobar <neescoba@cisco.com>,
	Parvi Kaustubhi <pkaustub@cisco.com>,
	Danil Kipnis <danil.kipnis@cloud.ionos.com>,
	Bart Van Assche <bvanassche@acm.org>,
	linux-rdma@vger.kernel.org
Subject: Re: [PATCH 3/4] RDMA: manual changes for sysfs_emit and neatening
Date: Mon, 12 Oct 2020 07:30:27 +0200	[thread overview]
Message-ID: <CAMGffEmJQSzF=kkxD8RreGODZdUktewTEaznCuFFu=kw22o=Jg@mail.gmail.com> (raw)
In-Reply-To: <f5c9e4c9d8dafca1b7b70bd597ee7f8f219c31c8.1602122880.git.joe@perches.com>

On Thu, Oct 8, 2020 at 4:36 AM Joe Perches <joe@perches.com> wrote:
>
> Make changes to use sysfs_emit in the RDMA code as cocci scripts can not
> be written to handle _all_ the possible variants of various sprintf family
> uses in sysfs show functions.
>
> While there, make the code more legible and update its style to be more
> like the typical kernel styles.
>
> Miscellanea:
>
> o Use intermediate pointers for dereferences
> o Add and use string lookup functions
> o return early when any intermediate call fails so normal return is
>   at the bottom of the function
> o mlx4/mcg.c:sysfs_show_group: use scnprintf to format intermediate strings
>
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  drivers/infiniband/core/sysfs.c              | 60 +++++++-------
>  drivers/infiniband/hw/cxgb4/provider.c       |  5 +-
>  drivers/infiniband/hw/hfi1/sysfs.c           | 38 ++++-----
>  drivers/infiniband/hw/mlx4/main.c            |  5 +-
>  drivers/infiniband/hw/mlx4/mcg.c             | 82 +++++++++++---------
>  drivers/infiniband/hw/mlx4/sysfs.c           | 47 ++++++-----
>  drivers/infiniband/hw/mlx5/main.c            |  4 +-
>  drivers/infiniband/hw/mthca/mthca_provider.c | 29 ++++---
>  drivers/infiniband/hw/qib/qib_sysfs.c        | 45 +++++------
>  drivers/infiniband/hw/usnic/usnic_ib_sysfs.c | 66 +++++++---------
>  drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c | 21 +++--
>  drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c | 13 ++--
>  drivers/infiniband/ulp/srp/ib_srp.c          |  4 +
>  13 files changed, 206 insertions(+), 213 deletions(-)
>

>
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c
> index 0c767582286b..51ba82fc425c 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c
> @@ -196,11 +196,10 @@ static struct kobj_attribute rtrs_clt_state_attr =
>         __ATTR(state, 0444, rtrs_clt_state_show, NULL);
>
>  static ssize_t rtrs_clt_reconnect_show(struct kobject *kobj,
> -                                       struct kobj_attribute *attr,
> -                                       char *buf)
> +                                      struct kobj_attribute *attr,
> +                                      char *buf)
>  {
> -       return sysfs_emit(buf, "Usage: echo 1 > %s\n",
> -                         attr->attr.name);
> +       return sysfs_emit(buf, "Usage: echo 1 > %s\n", attr->attr.name);
>  }
>
>  static ssize_t rtrs_clt_reconnect_store(struct kobject *kobj,
> @@ -228,11 +227,10 @@ static struct kobj_attribute rtrs_clt_reconnect_attr =
>                rtrs_clt_reconnect_store);
>
>  static ssize_t rtrs_clt_disconnect_show(struct kobject *kobj,
> -                                        struct kobj_attribute *attr,
> -                                        char *buf)
> +                                       struct kobj_attribute *attr,
> +                                       char *buf)
>  {
> -       return sysfs_emit(buf, "Usage: echo 1 > %s\n",
> -                         attr->attr.name);
> +       return sysfs_emit(buf, "Usage: echo 1 > %s\n", attr->attr.name);
>  }
>
>  static ssize_t rtrs_clt_disconnect_store(struct kobject *kobj,
> @@ -260,11 +258,10 @@ static struct kobj_attribute rtrs_clt_disconnect_attr =
>                rtrs_clt_disconnect_store);
>
>  static ssize_t rtrs_clt_remove_path_show(struct kobject *kobj,
> -                                         struct kobj_attribute *attr,
> -                                         char *buf)
> +                                        struct kobj_attribute *attr,
> +                                        char *buf)
>  {
> -       return sysfs_emit(buf, "Usage: echo 1 > %s\n",
> -                         attr->attr.name);
> +       return sysfs_emit(buf, "Usage: echo 1 > %s\n", attr->attr.name);
>  }
>
>  static ssize_t rtrs_clt_remove_path_store(struct kobject *kobj,
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c
> index 381a776ce404..6e7bebe4e064 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c
> @@ -27,11 +27,10 @@ static struct kobj_type ktype = {
>  };
>
>  static ssize_t rtrs_srv_disconnect_show(struct kobject *kobj,
> -                                        struct kobj_attribute *attr,
> -                                        char *buf)
> +                                       struct kobj_attribute *attr,
> +                                       char *buf)
>  {
> -       return sysfs_emit(buf, "Usage: echo 1 > %s\n",
> -                         attr->attr.name);
> +       return sysfs_emit(buf, "Usage: echo 1 > %s\n", attr->attr.name);
>  }
>
>  static ssize_t rtrs_srv_disconnect_store(struct kobject *kobj,
> @@ -72,8 +71,7 @@ static ssize_t rtrs_srv_hca_port_show(struct kobject *kobj,
>         sess = container_of(kobj, typeof(*sess), kobj);
>         usr_con = sess->s.con[0];
>
> -       return sysfs_emit(page, "%u\n",
> -                         usr_con->cm_id->port_num);
> +       return sysfs_emit(page, "%u\n", usr_con->cm_id->port_num);
>  }
>
>  static struct kobj_attribute rtrs_srv_hca_port_attr =
> @@ -87,8 +85,7 @@ static ssize_t rtrs_srv_hca_name_show(struct kobject *kobj,
>
>         sess = container_of(kobj, struct rtrs_srv_sess, kobj);
>
> -       return sysfs_emit(page, "%s\n",
> -                         sess->s.dev->ib_dev->name);
> +       return sysfs_emit(page, "%s\n", sess->s.dev->ib_dev->name);
>  }
>
For rtrs, looks good to me!
Thanks,
Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com>

  parent reply	other threads:[~2020-10-12  5:30 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-08  2:36 [PATCH-next 0/4] RDMA: sprintf to sysfs_emit conversions Joe Perches
2020-10-08  2:36 ` Joe Perches
2020-10-08  2:36 ` [PATCH 1/4] RDMA: Convert sysfs device * show functions to use sysfs_emit() Joe Perches
2020-10-09 14:07   ` Jason Gunthorpe
2020-10-08  2:36 ` [PATCH 2/4] RDMA: Convert sysfs kobject " Joe Perches
2020-10-09 14:09   ` Jason Gunthorpe
2020-10-09 16:25     ` Joe Perches
2020-10-12  5:21   ` Jinpu Wang
2020-10-08  2:36 ` [PATCH 3/4] RDMA: manual changes for sysfs_emit and neatening Joe Perches
2020-10-09 15:20   ` Jason Gunthorpe
2020-10-12  5:30   ` Jinpu Wang [this message]
2020-10-28 17:25   ` Jason Gunthorpe
2020-10-28 17:54     ` Joe Perches
2020-10-28 18:23       ` Jason Gunthorpe
2020-10-29 17:16       ` Joe Perches
2020-10-31  0:04         ` Jason Gunthorpe
2020-10-08  2:36 ` [PATCH 4/4] RDMA: Convert various random sprintf sysfs _show uses to sysfs_emit Joe Perches
2020-10-09 15:27   ` Jason Gunthorpe
2020-10-12  5:25   ` Jinpu Wang
2020-10-28 18:12   ` Jason Gunthorpe
2020-10-28 18:22     ` Joe Perches
2020-10-08  5:41 ` [PATCH-next 0/4] RDMA: sprintf to sysfs_emit conversions Leon Romanovsky
2020-10-08  5:41   ` Leon Romanovsky
2020-10-08  5:52   ` Joe Perches
2020-10-08  5:52     ` Joe Perches
2020-10-08  7:02     ` Leon Romanovsky
2020-10-08  7:02       ` Leon Romanovsky
2020-10-15  5:29   ` Joe Perches
2020-10-15  5:29     ` Joe Perches
2020-10-26 22:54 ` Jason Gunthorpe
2020-10-26 22:54   ` Jason Gunthorpe
2020-10-28 18:27 ` Jason Gunthorpe
2020-10-28 18:27   ` Jason Gunthorpe

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='CAMGffEmJQSzF=kkxD8RreGODZdUktewTEaznCuFFu=kw22o=Jg@mail.gmail.com' \
    --to=jinpu.wang@cloud.ionos.com \
    --cc=benve@cisco.com \
    --cc=bharat@chelsio.com \
    --cc=bvanassche@acm.org \
    --cc=danil.kipnis@cloud.ionos.com \
    --cc=dennis.dalessandro@intel.com \
    --cc=dledford@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=joe@perches.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mike.marciniszyn@intel.com \
    --cc=neescoba@cisco.com \
    --cc=pkaustub@cisco.com \
    --cc=yishaih@nvidia.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 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.