mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] drivers: treewide: Do not use NULL as driver_data
Date: Tue, 16 Sep 2025 11:32:37 +0200	[thread overview]
Message-ID: <20250916093237.712407-1-s.hauer@pengutronix.de> (raw)

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.

Fixes: Fixes: 20d87123a6 ("treewide: replace dev_get_drvdata with device_get_match_data")
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/nand/raw/nand_mxs.c | 2 +-
 drivers/net/fec_imx.h           | 2 +-
 drivers/net/fsl-fman.c          | 2 +-
 drivers/regulator/fan53555.c    | 2 +-
 include/linux/mfd/axp20x.h      | 2 +-
 include/mfd/bd71837.h           | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/nand/raw/nand_mxs.c b/drivers/mtd/nand/raw/nand_mxs.c
index 02f8546b87..4293f4e0e0 100644
--- a/drivers/mtd/nand/raw/nand_mxs.c
+++ 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,
 };
 
diff --git a/drivers/net/fec_imx.h b/drivers/net/fec_imx.h
index 1aaff87fdd..33b8db2745 100644
--- a/drivers/net/fec_imx.h
+++ b/drivers/net/fec_imx.h
@@ -114,7 +114,7 @@ struct buffer_descriptor {
 };
 
 enum fec_type {
-	FEC_TYPE_IMX27,
+	FEC_TYPE_IMX27 = 1,
 	FEC_TYPE_IMX28,
 	FEC_TYPE_IMX6,
 };
diff --git a/drivers/net/fsl-fman.c b/drivers/net/fsl-fman.c
index bde054d751..ac716c7468 100644
--- a/drivers/net/fsl-fman.c
+++ b/drivers/net/fsl-fman.c
@@ -123,7 +123,7 @@ struct fsl_fman_mdio {
 };
 
 enum fman_port_type {
-	FMAN_PORT_TYPE_RX = 0,	/* RX Port */
+	FMAN_PORT_TYPE_RX = 1,	/* RX Port */
 	FMAN_PORT_TYPE_TX,	/* TX Port */
 };
 
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index 2dcc6f5394..7477543915 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -44,7 +44,7 @@ enum {
 };
 
 enum fan53555_vendor {
-	FAN53526_VENDOR_FAIRCHILD = 0,
+	FAN53526_VENDOR_FAIRCHILD = 1,
 	FAN53555_VENDOR_FAIRCHILD,
 	FAN53555_VENDOR_ROCKCHIP,	/* RK8600, RK8601 */
 	RK8602_VENDOR_ROCKCHIP,		/* RK8602, RK8603 */
diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
index 93d303c459..0ba4568faf 100644
--- a/include/linux/mfd/axp20x.h
+++ b/include/linux/mfd/axp20x.h
@@ -11,7 +11,7 @@
 #include <poweroff.h>
 
 enum axp20x_variants {
-	AXP152_ID = 0,
+	AXP152_ID = 1,
 	AXP202_ID,
 	AXP209_ID,
 	AXP221_ID,
diff --git a/include/mfd/bd71837.h b/include/mfd/bd71837.h
index 4e285a647a..ab4cc57c88 100644
--- a/include/mfd/bd71837.h
+++ b/include/mfd/bd71837.h
@@ -7,7 +7,7 @@
 #define BD718XX_REGULATOR_DRIVER "bd718x7_regulator"
 
 enum {
-	ROHM_CHIP_TYPE_BD71837 = 0,
+	ROHM_CHIP_TYPE_BD71837 = 1,
 	ROHM_CHIP_TYPE_BD71847,
 	ROHM_CHIP_TYPE_BD70528,
 	ROHM_CHIP_TYPE_AMOUNT
-- 
2.47.3




             reply	other threads:[~2025-09-16  9:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-16  9:32 Sascha Hauer [this message]
2025-09-16  9:38 ` Ahmad Fatoum
2025-09-17 14:02   ` Sascha Hauer
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=20250916093237.712407-1-s.hauer@pengutronix.de \
    --to=s.hauer@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