From: Wolfgang Grandegger <wg@grandegger.com>
To: Jonathan Corbet <corbet@lwn.net>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
Subject: Re: [PATCH 4/8] can: Driver for the SJA1000 CAN controller
Date: Fri, 01 May 2009 20:21:15 +0200 [thread overview]
Message-ID: <49FB3D9B.3050704@grandegger.com> (raw)
In-Reply-To: <20090219171440.0c8286a1@bike.lwn.net>
I'm now back fixing the open issues of this patch series...
Jonathan Corbet wrote:
[snip]
>> +/*
>> + * SJA1000 private data structure
>> + */
>> +struct sja1000_priv {
>> + struct can_priv can; /* must be the first member! */
>
> AHA! I knew it!
>
> This kind of pointer trickery is fragile and dangerous, please don't do
> it. Much better would be something like:
>
> dev->priv = &dev_specific_priv->can;
>
> Then the higher layers know they have a proper struct can_priv pointer.
> Then you can use container_of() at this level to get the outer structure
> pointer. Much more robust and in line with normal kernel coding idiom.
Unfortunately, the "struct net_device" does not have a "priv" field. Using
struct can_priv *can = netdev_priv(dev);
struct sja1000_priv *sja1000 = candev_priv(dev);
instead is awkward. That's what we had at first. Any other more elegant
solution in mind?
Wolfgang.
next prev parent reply other threads:[~2009-05-01 18:21 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-19 19:01 [PATCH 0/8] can: CAN network device driver interface and drivers Wolfgang Grandegger
2009-02-19 19:01 ` [PATCH 1/8] can: Documentation for the CAN device driver interface Wolfgang Grandegger
2009-02-19 19:01 ` [PATCH 2/8] can: Update MAINTAINERS and CREDITS file Wolfgang Grandegger
2009-02-19 19:01 ` [PATCH 3/8] can: CAN Network device driver and SYSFS interface Wolfgang Grandegger
2009-02-19 19:01 ` [PATCH 4/8] can: Driver for the SJA1000 CAN controller Wolfgang Grandegger
2009-02-19 19:01 ` [PATCH 5/8] can: SJA1000 generic platform bus driver Wolfgang Grandegger
2009-02-19 19:01 ` [PATCH 6/8] can: SJA1000 driver for EMS PCI cards Wolfgang Grandegger
2009-02-19 19:01 ` [PATCH 7/8] can: SJA1000 driver for Kvaser " Wolfgang Grandegger
2009-02-19 19:01 ` [PATCH 8/8] can: Driver for the Freescale MSCAN controller Wolfgang Grandegger
2009-02-20 0:14 ` [PATCH 4/8] can: Driver for the SJA1000 CAN controller Jonathan Corbet
2009-02-20 8:46 ` David Miller
2009-02-20 9:35 ` Wolfgang Grandegger
2009-05-01 18:21 ` Wolfgang Grandegger [this message]
2009-02-19 23:49 ` [PATCH 3/8] can: CAN Network device driver and SYSFS interface Jonathan Corbet
2009-02-20 8:39 ` Wolfgang Grandegger
2009-02-20 9:44 ` Patrick McHardy
2009-02-21 15:09 ` Wolfgang Grandegger
2009-02-23 9:55 ` Patrick McHardy
2009-02-23 14:57 ` Wolfgang Grandegger
2009-02-24 9:38 ` Patrick McHardy
2009-02-24 16:29 ` Wolfgang Grandegger
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=49FB3D9B.3050704@grandegger.com \
--to=wg@grandegger.com \
--cc=corbet@lwn.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oliver.hartkopp@volkswagen.de \
/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).