[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <46d4b5be-60d3-4949-8eb9-9e8a036cb580@lunn.ch>
Date: Thu, 31 Oct 2024 22:28:29 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Oleksij Rempel <o.rempel@...gutronix.de>
Cc: Kory Maincent <kory.maincent@...tlin.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Jonathan Corbet <corbet@....net>,
Donald Hunter <donald.hunter@...il.com>,
Rob Herring <robh@...nel.org>, Andrew Lunn <andrew+netdev@...n.ch>,
Simon Horman <horms@...nel.org>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
linux-doc@...r.kernel.org, Kyle Swenson <kyle.swenson@....tech>,
Dent Project <dentproject@...uxfoundation.org>,
kernel@...gutronix.de,
Maxime Chevallier <maxime.chevallier@...tlin.com>
Subject: Re: [PATCH RFC net-next v2 05/18] net: pse-pd: Add support for PSE
device index
On Thu, Oct 31, 2024 at 07:27:59AM +0100, Oleksij Rempel wrote:
> On Wed, Oct 30, 2024 at 05:53:07PM +0100, Kory Maincent wrote:
>
> ...
> > /**
> > * struct pse_control - a PSE control
> > @@ -440,18 +441,22 @@ int pse_controller_register(struct pse_controller_dev *pcdev)
> >
> > mutex_init(&pcdev->lock);
> > INIT_LIST_HEAD(&pcdev->pse_control_head);
> > + ret = ida_alloc_max(&pse_ida, INT_MAX, GFP_KERNEL);
>
> s/INT_MAX/U32_MAX
* Return: The allocated ID, or %-ENOMEM if memory could not be allocated,
* or %-ENOSPC if there are no free IDs.
static inline int ida_alloc_max(struct ida *ida, unsigned int max, gfp_t gfp)
We need to be careful here, at least theoretically. Assuming a 32 bit
system, and you pass it U32_MAX, how does it return values in the
range S32_MAX..U32_MAX when it also needs to be able to return
negative numbers as errors?
I think the correct value to pass is S32_MAX, because it will always
fit in a u32, and there is space left for negative values for errors.
But this is probably theoretical, no real system should have that many
controllers.
Andrew
Powered by blists - more mailing lists