netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: YueHaibing <yuehaibing@huawei.com>
To: <davem@davemloft.net>, <joe@perches.com>, <gregkh@linuxfoundation.org>
Cc: <linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>
Subject: Re: [PATCH v2 -next] appletalk: use remove_proc_subtree to simplify procfs code
Date: Thu, 28 Feb 2019 21:47:50 +0800	[thread overview]
Message-ID: <c0bf4928-9dbe-ebfb-d09b-8f8941f33f81@huawei.com> (raw)
In-Reply-To: <20190228013158.7972-1-yuehaibing@huawei.com>

Pls igore this, will resend a new serials with another patch.

On 2019/2/28 9:31, Yue Haibing wrote:
> From: YueHaibing <yuehaibing@huawei.com>
> 
> Use remove_proc_subtree to remove the whole subtree
> on cleanup.Also do some cleanup.
> 
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  net/appletalk/atalk_proc.c | 56 ++++++++++++++--------------------------------
>  1 file changed, 17 insertions(+), 39 deletions(-)
> 
> diff --git a/net/appletalk/atalk_proc.c b/net/appletalk/atalk_proc.c
> index 8006295..398b767 100644
> --- a/net/appletalk/atalk_proc.c
> +++ b/net/appletalk/atalk_proc.c
> @@ -210,56 +210,34 @@ static const struct seq_operations atalk_seq_socket_ops = {
>  	.show   = atalk_seq_socket_show,
>  };
>  
> -static struct proc_dir_entry *atalk_proc_dir;
> -
>  int __init atalk_proc_init(void)
>  {
> -	struct proc_dir_entry *p;
> -	int rc = -ENOMEM;
> +	if (!proc_mkdir("atalk", init_net.proc_net))
> +		return -ENOMEM;
>  
> -	atalk_proc_dir = proc_mkdir("atalk", init_net.proc_net);
> -	if (!atalk_proc_dir)
> +	if (!proc_create_seq("atalk/interface", 0444, init_net.proc_net,
> +			    &atalk_seq_interface_ops))
>  		goto out;
>  
> -	p = proc_create_seq("interface", 0444, atalk_proc_dir,
> -			&atalk_seq_interface_ops);
> -	if (!p)
> -		goto out_interface;
> -
> -	p = proc_create_seq("route", 0444, atalk_proc_dir,
> -			&atalk_seq_route_ops);
> -	if (!p)
> -		goto out_route;
> +	if (!proc_create_seq("atalk/route", 0444, init_net.proc_net,
> +			    &atalk_seq_route_ops))
> +		goto out;
>  
> -	p = proc_create_seq("socket", 0444, atalk_proc_dir,
> -			&atalk_seq_socket_ops);
> -	if (!p)
> -		goto out_socket;
> +	if (!proc_create_seq("atalk/socket", 0444, init_net.proc_net,
> +			    &atalk_seq_socket_ops))
> +		goto out;
>  
> -	p = proc_create_seq_private("arp", 0444, atalk_proc_dir, &aarp_seq_ops,
> -			sizeof(struct aarp_iter_state), NULL);
> -	if (!p)
> -		goto out_arp;
> +	if (!proc_create_seq_private("atalk/arp", 0444, init_net.proc_net,
> +				     &aarp_seq_ops,
> +				     sizeof(struct aarp_iter_state), NULL))
> +		goto out;
>  
> -	rc = 0;
>  out:
> -	return rc;
> -out_arp:
> -	remove_proc_entry("socket", atalk_proc_dir);
> -out_socket:
> -	remove_proc_entry("route", atalk_proc_dir);
> -out_route:
> -	remove_proc_entry("interface", atalk_proc_dir);
> -out_interface:
> -	remove_proc_entry("atalk", init_net.proc_net);
> -	goto out;
> +	remove_proc_subtree("atalk", init_net.proc_net);
> +	return -ENOMEM;
>  }
>  
>  void __exit atalk_proc_exit(void)
>  {
> -	remove_proc_entry("interface", atalk_proc_dir);
> -	remove_proc_entry("route", atalk_proc_dir);
> -	remove_proc_entry("socket", atalk_proc_dir);
> -	remove_proc_entry("arp", atalk_proc_dir);
> -	remove_proc_entry("atalk", init_net.proc_net);
> +	remove_proc_subtree("atalk", init_net.proc_net);
>  }
> 


      reply	other threads:[~2019-02-28 13:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-28  1:31 [PATCH v2 -next] appletalk: use remove_proc_subtree to simplify procfs code Yue Haibing
2019-02-28 13:47 ` YueHaibing [this message]

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=c0bf4928-9dbe-ebfb-d09b-8f8941f33f81@huawei.com \
    --to=yuehaibing@huawei.com \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --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 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).