All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yoann Padioleau <padator@wanadoo.fr>
To: kernel-janitors@vger.kernel.org
Subject: Re: netdev_priv()
Date: Thu, 19 Jul 2007 13:59:29 +0000	[thread overview]
Message-ID: <87zm1s5wam.fsf@wanadoo.fr> (raw)
In-Reply-To: <d858bca40707181524r30f501dcnd1ecf1b4e9d2af86@mail.gmail.com>

"Alexey Dobriyan" <adobriyan@gmail.com> writes:

> This reminds me OOP wankers adding private members to class and
> two accessors per member of get_foo, set_foo variety instead of
> simple assignments.
>
> General direction is that struct net_device::priv will be made integer,

Why an integer ? 

> If yes, 

"If yes" what ? What is the question ? 

> patch is OK, if not -- quite reverse patch should be done.

I don't understand. By reverse patch you mean "don't do anything" ? 

>
> On 7/19/07, Yoann Padioleau <padator@wanadoo.fr> wrote:
>> "Thomas Surrel" <thomas.surrel@gmail.com> writes:
>>
>> >> @@
>> >> struct net_device *dev;
>> >> type T;
>> >> @@
>> >>
>> >> - (T) dev->priv
>> >> + netdev_priv(dev)
>> >>
>> >>
>> >
>> > Sounds good. But from what I saw, you have to be really careful with
>> > what your semantic patch would do. Correct me if I am wrong, but the
>> > point of using netdev_priv is to access a private structure that is
>> > right next to the net_device structure in memory.
>>
>> Yes, you are right according to
>> http://groups.google.com/group/comp.os.linux.development.system/browse_thread/thread/de19321bcd94dbb8/0d74a4adcd6177bd
>>
>> Thanks for pointing out a problem. I have refined my semantic patch:
>>
>> @ rule1 @
>> type T;
>> struct net_device *dev;
>> @@
>>
>>  dev = alloc_netdev(sizeof(T), ...)
>>
>>
>> @ rule1bis @
>> struct net_device *dev;
>> expression E;
>> @@
>>  dev->priv = E
>>
>>
>> @ rule2 depends on rule1 && !rule1bis  @
>> struct net_device *dev;
>> type rule1.T;
>> @@
>>
>> - (T*) dev->priv
>> + netdev_priv(dev)
>>
>>
>> @ rule3 depends on rule1 && !rule1bis @
>> struct net_device *dev;
>> @@
>>
>> - dev->priv
>> + netdev_priv(dev)
>>
>>
>>
>> I have put the generated patch in the end of this mail for all drivers
>> under drivers/net/. Because of the new condition on alloc_netdev, the patch
>> does not touch anymore net/wireless/libertas/main.c.
>>
>> > Unfortunately, some
>> > drivers are allocating their private structure in other memory area,
>> > e.g. net/wireless/libertas/main.c:
>> >
>> > int libertas_add_mesh(wlan_private *priv, struct device *dev)
>> > {
>> > 	struct net_device *mesh_dev = NULL;
>> > 	int ret = 0;
>> >
>> > 	lbs_deb_enter(LBS_DEB_MESH);
>> >
>> > 	/* Allocate a virtual mesh device */
>> > 	if (!(mesh_dev = alloc_netdev(0, "msh%d", ether_setup))) {
>> > 		lbs_deb_mesh("init mshX device failed\n");
>> > 		ret = -ENOMEM;
>> > 		goto done;
>> > 	}
>> > 	mesh_dev->priv = priv;
>> > 	priv->mesh_dev = mesh_dev;
>> > 	[...]
>> >
>> > In that case, using netdev_priv() would break things. I guess we
>> > should not try to change anything to these drivers.
>>
>> That's what my new semantic patch does. But maybe I am now too
>> restrictive. Do you know other conditions where we can safely
>> do the transformation ?
>>
>> >
>> > Regards,
>> >
>> > Thomas

[...]


  parent reply	other threads:[~2007-07-19 13:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-18 22:24 netdev_priv() Thomas Surrel
2007-07-19  7:25 ` netdev_priv() pradeep singh
2007-07-19  7:51 ` netdev_priv() Yoann Padioleau
2007-07-19  8:18 ` netdev_priv() Yoann Padioleau
2007-07-19  8:57 ` netdev_priv() Thomas Surrel
2007-07-19  9:01 ` netdev_priv() Thomas Surrel
2007-07-19  9:14 ` netdev_priv() pradeep singh
2007-07-19 11:49 ` netdev_priv() Yoann Padioleau
2007-07-19 13:27 ` netdev_priv() Thomas Surrel
2007-07-19 13:34 ` netdev_priv() Alexey Dobriyan
2007-07-19 13:52 ` netdev_priv() Yoann Padioleau
2007-07-19 13:59 ` Yoann Padioleau [this message]
2007-07-19 14:33 ` netdev_priv() Thomas Surrel
2007-07-19 15:22 ` netdev_priv() pradeep singh
2007-07-19 15:35 ` netdev_priv() Yoann Padioleau
2007-07-19 15:57 ` netdev_priv() Thomas Surrel
2007-07-19 17:06 ` netdev_priv() Yoann Padioleau
2007-07-20  8:20 ` netdev_priv() Thomas Surrel
2007-07-20 10:41 ` netdev_priv() Yoann Padioleau

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=87zm1s5wam.fsf@wanadoo.fr \
    --to=padator@wanadoo.fr \
    --cc=kernel-janitors@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 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.