* [PATCH v2 0/5] Congatec Board Controller: Add storage devices support
@ 2026-08-11 16:15 Thomas Richard (congatec GmbH)
2026-08-11 16:15 ` [PATCH v2 1/5] mfd: cgbc: Fix use of negative error code as valid session handle Thomas Richard (congatec GmbH)
2026-08-13 17:20 ` [PATCH v2 0/5] Congatec Board Controller: Add storage devices support Thomas Richard
0 siblings, 2 replies; 5+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-08-11 16:15 UTC (permalink / raw)
To: Lee Jones, Andi Shyti
Cc: Thomas Petazzoni, Werner Gartner, mfd, linux-kernel, linux-i2c,
Thomas Richard (congatec GmbH), stable, Sashiko
Second iteration and nothing fancy, I just fixed a typo in CGBC BIOS EEPROM
label, and added a patch to make cgbc_devs (MFD cells) const in MFD driver.
Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
---
Changes in v2:
- i2c: fix typo in CGBC BIOS EEPROM labeli.
- mfd: make cgbc_devs const
- Link to v1: https://patch.msgid.link/20260804-cgbc-i2c-storage-devices-support-v1-0-fed38510671c@bootlin.com
To: Thomas Richard <thomas.richard@bootlin.com>
To: Lee Jones <lee@kernel.org>
To: Andi Shyti <andi.shyti@kernel.org>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Werner Gartner <Werner.Gartner@congatec.com>
Cc: mfd@lists.linux.dev
Cc: linux-kernel@vger.kernel.org
Cc: linux-i2c@vger.kernel.org
---
Thomas Richard (congatec GmbH) (5):
mfd: cgbc: Fix use of negative error code as valid session handle
mfd: cgbc: Make cgbc_devs const
i2c: cgbc: Add virtual I2C bus support
mfd: cgbc: Add virtual I2C bus support
i2c: cgbc: Add virtual storage devices on the virtual I2C bus
drivers/i2c/busses/i2c-cgbc.c | 174 ++++++++++++++++++++++++++++++++++++++++--
drivers/mfd/cgbc-core.c | 9 ++-
2 files changed, 175 insertions(+), 8 deletions(-)
---
base-commit: 498c377a1ca412502649484c7b1788d5d328fc85
change-id: 20260717-cgbc-i2c-storage-devices-support-b3ee7cea3320
Best regards,
--
Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/5] mfd: cgbc: Fix use of negative error code as valid session handle
2026-08-11 16:15 [PATCH v2 0/5] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
@ 2026-08-11 16:15 ` Thomas Richard (congatec GmbH)
2026-09-02 15:02 ` Lee Jones
2026-08-13 17:20 ` [PATCH v2 0/5] Congatec Board Controller: Add storage devices support Thomas Richard
1 sibling, 1 reply; 5+ messages in thread
From: Thomas Richard (congatec GmbH) @ 2026-08-11 16:15 UTC (permalink / raw)
To: Lee Jones, Andi Shyti
Cc: Thomas Petazzoni, Werner Gartner, mfd, linux-kernel, linux-i2c,
Thomas Richard (congatec GmbH), stable, Sashiko
The cgbc_session_command() return value was directly cast to u8 and used
as session handle without error checking. Casting a negative error to u8
produces a valid-looking session handle. So check if return value is
positive before to cast and use it.
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260713-cgbc-core-fix-cgbc-remove-v1-1-79274ad62b3a%40bootlin.com?part=1
Fixes: 6f1067cfbee7 ("mfd: Add Congatec Board Controller driver")
Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
---
drivers/mfd/cgbc-core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/mfd/cgbc-core.c b/drivers/mfd/cgbc-core.c
index 2becaf797646..4a409234e66c 100644
--- a/drivers/mfd/cgbc-core.c
+++ b/drivers/mfd/cgbc-core.c
@@ -103,7 +103,11 @@ static int cgbc_session_request(struct cgbc_device_data *cgbc)
if (ret)
return dev_err_probe(cgbc->dev, ret, "device not found or not ready\n");
- cgbc->session = cgbc_session_command(cgbc, CGBC_SESSION_CMD_REQUEST);
+ ret = cgbc_session_command(cgbc, CGBC_SESSION_CMD_REQUEST);
+ if (ret < 0)
+ return dev_err_probe(cgbc->dev, ret, "session handle request timed out\n");
+
+ cgbc->session = ret;
/* The Board Controller sent us a wrong session handle, we cannot communicate with it */
if (cgbc->session < CGBC_SESSION_VALID_MIN || cgbc->session > CGBC_SESSION_VALID_MAX)
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/5] Congatec Board Controller: Add storage devices support
2026-08-11 16:15 [PATCH v2 0/5] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
2026-08-11 16:15 ` [PATCH v2 1/5] mfd: cgbc: Fix use of negative error code as valid session handle Thomas Richard (congatec GmbH)
@ 2026-08-13 17:20 ` Thomas Richard
1 sibling, 0 replies; 5+ messages in thread
From: Thomas Richard @ 2026-08-13 17:20 UTC (permalink / raw)
To: Lee Jones, Andi Shyti
Cc: Thomas Petazzoni, Werner Gartner, mfd, linux-kernel, linux-i2c,
stable, Sashiko
On 8/11/26 6:15 PM, Thomas Richard (congatec GmbH) wrote:
> Second iteration and nothing fancy, I just fixed a typo in CGBC BIOS EEPROM
> label, and added a patch to make cgbc_devs (MFD cells) const in MFD driver.
Please ignore this version. Following the discussion with Lee on
hard-coding the cell ID, I'm finally preparing a new version of this
series which switches to PLATFORM_DEVID_AUTO before to add the virtual
bus and virtual storage devices support.
Also IMO having the i2c_board_info struct in the I2C bus driver is a bit
odd. The I2C devices topology on the virtual bus can be different,
depending the Board Controller. I think this complexity shall be handled
on MFD side.
At the end I should have a more generic I2C bus driver, and
platform_data will be used to pass all parameters (including I2C devices
to register on the I2C bus) to the I2C bus driver.
Best Regards,
Thomas
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/5] mfd: cgbc: Fix use of negative error code as valid session handle
2026-08-11 16:15 ` [PATCH v2 1/5] mfd: cgbc: Fix use of negative error code as valid session handle Thomas Richard (congatec GmbH)
@ 2026-09-02 15:02 ` Lee Jones
2026-09-02 15:03 ` Lee Jones
0 siblings, 1 reply; 5+ messages in thread
From: Lee Jones @ 2026-09-02 15:02 UTC (permalink / raw)
To: Thomas Richard (congatec GmbH)
Cc: Andi Shyti, Thomas Petazzoni, Werner Gartner, mfd, linux-kernel,
linux-i2c, stable, Sashiko
On Tue, 11 Aug 2026, Thomas Richard (congatec GmbH) wrote:
> The cgbc_session_command() return value was directly cast to u8 and used
> as session handle without error checking. Casting a negative error to u8
> produces a valid-looking session handle. So check if return value is
> positive before to cast and use it.
>
> Cc: stable@vger.kernel.org
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/patchset/20260713-cgbc-core-fix-cgbc-remove-v1-1-79274ad62b3a%40bootlin.com?part=1
> Fixes: 6f1067cfbee7 ("mfd: Add Congatec Board Controller driver")
> Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
> ---
> drivers/mfd/cgbc-core.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/cgbc-core.c b/drivers/mfd/cgbc-core.c
> index 2becaf797646..4a409234e66c 100644
> --- a/drivers/mfd/cgbc-core.c
> +++ b/drivers/mfd/cgbc-core.c
> @@ -103,7 +103,11 @@ static int cgbc_session_request(struct cgbc_device_data *cgbc)
> if (ret)
> return dev_err_probe(cgbc->dev, ret, "device not found or not ready\n");
>
> - cgbc->session = cgbc_session_command(cgbc, CGBC_SESSION_CMD_REQUEST);
> + ret = cgbc_session_command(cgbc, CGBC_SESSION_CMD_REQUEST);
> + if (ret < 0)
> + return dev_err_probe(cgbc->dev, ret, "session handle request timed out\n");
Can we make this a bit more user friendly?
"Failed to start XYZ session"?
> +
> + cgbc->session = ret;
>
> /* The Board Controller sent us a wrong session handle, we cannot communicate with it */
> if (cgbc->session < CGBC_SESSION_VALID_MIN || cgbc->session > CGBC_SESSION_VALID_MAX)
>
> --
> 2.53.0
>
--
Lee Jones
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/5] mfd: cgbc: Fix use of negative error code as valid session handle
2026-09-02 15:02 ` Lee Jones
@ 2026-09-02 15:03 ` Lee Jones
0 siblings, 0 replies; 5+ messages in thread
From: Lee Jones @ 2026-09-02 15:03 UTC (permalink / raw)
To: Thomas Richard (congatec GmbH)
Cc: Andi Shyti, Thomas Petazzoni, Werner Gartner, mfd, linux-kernel,
linux-i2c, stable, Sashiko
On Wed, 02 Sep 2026, Lee Jones wrote:
> On Tue, 11 Aug 2026, Thomas Richard (congatec GmbH) wrote:
>
> > The cgbc_session_command() return value was directly cast to u8 and used
> > as session handle without error checking. Casting a negative error to u8
> > produces a valid-looking session handle. So check if return value is
> > positive before to cast and use it.
> >
> > Cc: stable@vger.kernel.org
> > Reported-by: Sashiko <sashiko-bot@kernel.org>
> > Closes: https://sashiko.dev/#/patchset/20260713-cgbc-core-fix-cgbc-remove-v1-1-79274ad62b3a%40bootlin.com?part=1
> > Fixes: 6f1067cfbee7 ("mfd: Add Congatec Board Controller driver")
> > Signed-off-by: Thomas Richard (congatec GmbH) <thomas.richard@bootlin.com>
> > ---
> > drivers/mfd/cgbc-core.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/mfd/cgbc-core.c b/drivers/mfd/cgbc-core.c
> > index 2becaf797646..4a409234e66c 100644
> > --- a/drivers/mfd/cgbc-core.c
> > +++ b/drivers/mfd/cgbc-core.c
> > @@ -103,7 +103,11 @@ static int cgbc_session_request(struct cgbc_device_data *cgbc)
> > if (ret)
> > return dev_err_probe(cgbc->dev, ret, "device not found or not ready\n");
> >
> > - cgbc->session = cgbc_session_command(cgbc, CGBC_SESSION_CMD_REQUEST);
> > + ret = cgbc_session_command(cgbc, CGBC_SESSION_CMD_REQUEST);
> > + if (ret < 0)
> > + return dev_err_probe(cgbc->dev, ret, "session handle request timed out\n");
>
> Can we make this a bit more user friendly?
>
> "Failed to start XYZ session"?
The other two MFD patches are fine.
--
Lee Jones
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-02 15:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-11 16:15 [PATCH v2 0/5] Congatec Board Controller: Add storage devices support Thomas Richard (congatec GmbH)
2026-08-11 16:15 ` [PATCH v2 1/5] mfd: cgbc: Fix use of negative error code as valid session handle Thomas Richard (congatec GmbH)
2026-09-02 15:02 ` Lee Jones
2026-09-02 15:03 ` Lee Jones
2026-08-13 17:20 ` [PATCH v2 0/5] Congatec Board Controller: Add storage devices support Thomas Richard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox