mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeff Garzik <jgarzik@pobox.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: mochel@osdl.org
Subject: Re: net devices: Get network devices to show up in sysfs.
Date: Tue, 7 Jan 2003 16:43:15 -0500	[thread overview]
Message-ID: <20030107214315.GA23011@gtf.org> (raw)
In-Reply-To: <200301072106.h07L63v29621@hera.kernel.org>

On Mon, Jan 06, 2003 at 07:50:37PM +0000, Linux Kernel Mailing List wrote:
> ChangeSet 1.838.151.11, 2003/01/06 13:50:37-06:00, mochel@osdl.org
> 
> 	net devices: Get network devices to show up in sysfs.
> 	
> 	- declare net_subsys, and register during net_dev_init().
> 	- Add kobject to struct net_device.
> 	- initialize name and register in register_netdevice().
> 	- remove in unregister_netdevice().
> 	
> diff -Nru a/include/linux/netdevice.h b/include/linux/netdevice.h
> --- a/include/linux/netdevice.h	Tue Jan  7 13:06:05 2003
> +++ b/include/linux/netdevice.h	Tue Jan  7 13:06:05 2003
> @@ -28,6 +28,7 @@
>  #include <linux/if.h>
>  #include <linux/if_ether.h>
>  #include <linux/if_packet.h>
> +#include <linux/kobject.h>
>  
>  #include <asm/atomic.h>
>  #include <asm/cache.h>
> @@ -438,6 +439,9 @@
>  	/* this will get initialized at each interface type init routine */
>  	struct divert_blk	*divert;
>  #endif /* CONFIG_NET_DIVERT */
> +
> +	/* generic object representation */
> +	struct kobject kobj;
>  };

Just curious, is this needed purely for reference counting, or mainly to
hook into sysfs?  If the former, net devices already have reference
counting, so I want to make sure kobjects do not run afoul of that.



> +static struct subsystem net_subsys;
> +
>  
>  /*******************************************************************************
>  
> @@ -2545,7 +2547,10 @@
>  	notifier_call_chain(&netdev_chain, NETDEV_REGISTER, dev);
>  
>  	net_run_sbin_hotplug(dev, "register");
> -	ret = 0;
> +
> +	snprintf(dev->kobj.name,KOBJ_NAME_LEN,dev->name);
> +	kobj_set_kset_s(dev,net_subsys);
> +	ret = kobject_register(&dev->kobj);

If the return code matters, shouldn't you be checking for its success?


> @@ -2671,6 +2676,8 @@
>  		goto out;
>  	}
>  
> +	kobject_unregister(&dev->kobj);
> +

...especially if kobject_register failed above

	Jeff




       reply	other threads:[~2003-01-07 21:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200301072106.h07L63v29621@hera.kernel.org>
2003-01-07 21:43 ` Jeff Garzik [this message]
2003-01-07 21:12   ` Patrick Mochel

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=20030107214315.GA23011@gtf.org \
    --to=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mochel@osdl.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

Powered by JetHome