mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH] drivers: treewide: Do not use NULL as driver_data
Date: Wed, 17 Sep 2025 16:02:33 +0200	[thread overview]
Message-ID: <aMq_eYP66kvx_-HZ@pengutronix.de> (raw)
In-Reply-To: <48b12f11-a204-4aeb-9db3-dbc11b49f8ea@pengutronix.de>

On Tue, Sep 16, 2025 at 11:38:48AM +0200, Ahmad Fatoum wrote:
> Hello Sascha,
> 
> On 9/16/25 11:32 AM, Sascha Hauer wrote:
> > Several drivers in the tree use an enum for the chip type casted to int
> > as driver_data. This comes with the problem that device_get_match_data()
> > returns NULL for these devices and a potential error check bails out
> > then.
> > 
> > This patch changes the enums used by the drivers to start from 1 instead
> > of 0 so that the return value of device_get_match_data() can safely
> > checked for being NULL.
> > 
> > Most drivers do not check the return value anyway, but fec_imx.c does
> > which causes the driver to no longer work on i.MX27. This issue is fixed
> > here.
> 
> If they don't check the return value, why bother changing it and risk a
> regression?

To not give others bad examples.

> > +++ b/drivers/mtd/nand/raw/nand_mxs.c
> > @@ -38,7 +38,7 @@
> >  #include "internals.h"
> >  
> >  enum gpmi_type {
> > -	GPMI_MXS,
> > +	GPMI_MXS = 1,
> >  	GPMI_IMX6,
> >  };

Anyway, this indeed introduces a regression. We have mxs_add_nand()
which instantiates a "mxs_nand" device without driver data, so
device_get_match_data() will return 0 aka GPMI_MXS which happens to
be the right thing here.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



  reply	other threads:[~2025-09-17 14:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-16  9:32 Sascha Hauer
2025-09-16  9:38 ` Ahmad Fatoum
2025-09-17 14:02   ` Sascha Hauer [this message]
2025-09-17 14:10     ` Ahmad Fatoum

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=aMq_eYP66kvx_-HZ@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.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