mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>,
	barebox@lists.infradead.org
Subject: Re: [PATCH] net:fec: fixed unaligned access and stack corruption
Date: Thu, 30 Jul 2020 23:13:56 +0200	[thread overview]
Message-ID: <20200730211356.GA10482@pengutronix.de> (raw)
In-Reply-To: <d10c9162-4b11-92ad-daea-69f16b0f214d@pengutronix.de>

Hi,

sorry for jumping in.

On 20-07-11 07:28, Ahmad Fatoum wrote:
> Hi,
> 
> On 7/11/20 7:20 AM, Sascha Hauer wrote:
> > On Sat, Jul 11, 2020 at 07:13:11AM +0200, Ahmad Fatoum wrote:
> >>
> >>
> >> On 7/11/20 7:07 AM, Sascha Hauer wrote:
> >>> On Tue, Jul 07, 2020 at 07:11:31PM +0200, Ahmad Fatoum wrote:
> >>>> On 7/7/20 6:01 PM, Enrico Scholz wrote:
> >>>>> on 64 bit architectures, the 'enum fec_type' might not be aligned and
> >>>>> large enough to hold a pointer.  
> >>>>
> >>>> I am wondering if we couldn't just adopt the Linux prototype:
> >>>> void *dev_get_drvdata(const struct device_d *dev);
> >>>>
> >>>> and do away with the error code and most of the casts.
> >>>> Users won't be able to differentiate between NULL from id table
> >>>> and NULL due to lack of drvdata, but I don't think this is
> >>>> that much of a downside, compared with not having casts obscure
> >>>> the more common pitfall (besides fec_imx.c, lm75.c, apbh_dma.c and nand_mxs.c
> >>>> are affected as well of which probably only the first is an issue.)
> >>>
> >>> Sounds good. When we change this we should rename the function
> >>> alongside, because dev_get_drvdata() does something different in Linux.
> >>
> >> Does it? I thought it does the same, with the difference that it can
> >> be set with dev_set_drvdata as well. At the cost of one extra pointer
> >> per device_d, we could have both of them.
> > 
> > dev_set_drvdata() in Linux allows you to store a pointer to private
> > driver data in struct device. We don't have a function for that in
> > barebox and use dev->priv instead.
> > dev_get_drvdata() in barebox gets you the device type data (or however
> > we want to call it). There's no function for that in Linux and we have
> > to first find out if we probe from platform data or from device tree
> > to pick the right function to get the data.
> 
> Ah, I thought the drvdata is pre-populated in Linux. I would rename
> the new function to device_get_match_data then for alignment with
> Linux, with the difference that it returns either platform data or
> device tree driver_data as appropriate.

Linux uses the of_device_get_match_data() [1] for of-based drivers.

[1] https://elixir.bootlin.com/linux/v5.8-rc4/source/drivers/of/device.c#L189

Regards,
  Marco

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2020-07-30 21:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07 16:01 Enrico Scholz
2020-07-07 17:11 ` Ahmad Fatoum
2020-07-11  5:07   ` Sascha Hauer
2020-07-11  5:13     ` Ahmad Fatoum
2020-07-11  5:20       ` Sascha Hauer
2020-07-11  5:28         ` Ahmad Fatoum
2020-07-14 18:39           ` Sascha Hauer
2020-07-30 21:13           ` Marco Felsch [this message]
2020-07-30 21:23             ` Ahmad Fatoum
2020-07-30 21:33               ` Marco Felsch
2020-07-11  5:12 ` Sascha Hauer

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=20200730211356.GA10482@pengutronix.de \
    --to=m.felsch@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=enrico.scholz@sigma-chemnitz.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