* [PATCHv2 0/2] phy: miphy28lp: build and simplify allocation
@ 2026-03-06 22:24 Rosen Penev
2026-03-06 22:24 ` [PATCHv2 1/2] phy: miphy28lp: add COMPILE_TEST Rosen Penev
2026-03-06 22:24 ` [PATCHv2 2/2] phy: miphy28lp: kzalloc + kcalloc to single kzalloc Rosen Penev
0 siblings, 2 replies; 5+ messages in thread
From: Rosen Penev @ 2026-03-06 22:24 UTC (permalink / raw)
To: linux-phy
Cc: Vinod Koul, Neil Armstrong, Patrice Chotard, Kees Cook,
Gustavo A. R. Silva, open list,
moderated list:ARM/STI ARCHITECTURE,
open list:KERNEL HARDENING (not covered by other areas):Keyword:b__counted_by(_le|_be)?b
First patch allows compilation on at least x86.
Second uses a flexible array member to simplify allocation.
v2: add first patch and fix second.
Rosen Penev (2):
phy: miphy28lp: add COMPILE_TEST
phy: miphy28lp: kzalloc + kcalloc to single kzalloc
drivers/phy/st/Kconfig | 2 +-
drivers/phy/st/phy-miphy28lp.c | 12 +++++-------
2 files changed, 6 insertions(+), 8 deletions(-)
--
2.53.0
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCHv2 1/2] phy: miphy28lp: add COMPILE_TEST
2026-03-06 22:24 [PATCHv2 0/2] phy: miphy28lp: build and simplify allocation Rosen Penev
@ 2026-03-06 22:24 ` Rosen Penev
2026-03-09 6:49 ` Patrice CHOTARD
2026-03-06 22:24 ` [PATCHv2 2/2] phy: miphy28lp: kzalloc + kcalloc to single kzalloc Rosen Penev
1 sibling, 1 reply; 5+ messages in thread
From: Rosen Penev @ 2026-03-06 22:24 UTC (permalink / raw)
To: linux-phy
Cc: Vinod Koul, Neil Armstrong, Patrice Chotard, Kees Cook,
Gustavo A. R. Silva, open list,
moderated list:ARM/STI ARCHITECTURE,
open list:KERNEL HARDENING (not covered by other areas):Keyword:b__counted_by(_le|_be)?b
There's nothing special here to prevent compilation on non ARM hosts.
Matches every other st phy driver.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/phy/st/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/phy/st/Kconfig b/drivers/phy/st/Kconfig
index 304614b6dabf..49206185e563 100644
--- a/drivers/phy/st/Kconfig
+++ b/drivers/phy/st/Kconfig
@@ -4,7 +4,7 @@
#
config PHY_MIPHY28LP
tristate "STMicroelectronics MIPHY28LP PHY driver for STiH407"
- depends on ARCH_STI
+ depends on ARCH_STI || COMPILE_TEST
select GENERIC_PHY
help
Enable this to support the miphy transceiver (for SATA/PCIE/USB3)
--
2.53.0
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCHv2 2/2] phy: miphy28lp: kzalloc + kcalloc to single kzalloc
2026-03-06 22:24 [PATCHv2 0/2] phy: miphy28lp: build and simplify allocation Rosen Penev
2026-03-06 22:24 ` [PATCHv2 1/2] phy: miphy28lp: add COMPILE_TEST Rosen Penev
@ 2026-03-06 22:24 ` Rosen Penev
2026-03-09 7:00 ` Patrice CHOTARD
1 sibling, 1 reply; 5+ messages in thread
From: Rosen Penev @ 2026-03-06 22:24 UTC (permalink / raw)
To: linux-phy
Cc: Vinod Koul, Neil Armstrong, Patrice Chotard, Kees Cook,
Gustavo A. R. Silva, open list,
moderated list:ARM/STI ARCHITECTURE,
open list:KERNEL HARDENING (not covered by other areas):Keyword:b__counted_by(_le|_be)?b
Use flex array to simplify allocation.
Allows using __counted_by for extra runtime analysis.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/phy/st/phy-miphy28lp.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/phy/st/phy-miphy28lp.c b/drivers/phy/st/phy-miphy28lp.c
index 43cef89af55e..c576fc5569fe 100644
--- a/drivers/phy/st/phy-miphy28lp.c
+++ b/drivers/phy/st/phy-miphy28lp.c
@@ -224,8 +224,8 @@ struct miphy28lp_dev {
struct device *dev;
struct regmap *regmap;
struct mutex miphy_mutex;
- struct miphy28lp_phy **phys;
int nphys;
+ struct miphy28lp_phy *phys[] __counted_by(nphys);
};
enum miphy_sata_gen { SATA_GEN1, SATA_GEN2, SATA_GEN3 };
@@ -1168,16 +1168,14 @@ static int miphy28lp_probe(struct platform_device *pdev)
struct phy_provider *provider;
struct phy *phy;
int ret, port = 0;
+ size_t nphys;
- miphy_dev = devm_kzalloc(&pdev->dev, sizeof(*miphy_dev), GFP_KERNEL);
+ nphys = of_get_child_count(np);
+ miphy_dev = devm_kzalloc(&pdev->dev, struct_size(miphy_dev, phys, nphys), GFP_KERNEL);
if (!miphy_dev)
return -ENOMEM;
- miphy_dev->nphys = of_get_child_count(np);
- miphy_dev->phys = devm_kcalloc(&pdev->dev, miphy_dev->nphys,
- sizeof(*miphy_dev->phys), GFP_KERNEL);
- if (!miphy_dev->phys)
- return -ENOMEM;
+ miphy_dev->nphys = nphys;
miphy_dev->regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg");
if (IS_ERR(miphy_dev->regmap)) {
--
2.53.0
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCHv2 1/2] phy: miphy28lp: add COMPILE_TEST
2026-03-06 22:24 ` [PATCHv2 1/2] phy: miphy28lp: add COMPILE_TEST Rosen Penev
@ 2026-03-09 6:49 ` Patrice CHOTARD
0 siblings, 0 replies; 5+ messages in thread
From: Patrice CHOTARD @ 2026-03-09 6:49 UTC (permalink / raw)
To: Rosen Penev, linux-phy
Cc: Vinod Koul, Neil Armstrong, Kees Cook, Gustavo A. R. Silva,
open list, moderated list:ARM/STI ARCHITECTURE,
open list:KERNEL HARDENING (not covered by other areas):Keyword:b__counted_by(_le|_be)?b
On 3/6/26 23:24, Rosen Penev wrote:
> There's nothing special here to prevent compilation on non ARM hosts.
>
> Matches every other st phy driver.
>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
> drivers/phy/st/Kconfig | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/phy/st/Kconfig b/drivers/phy/st/Kconfig
> index 304614b6dabf..49206185e563 100644
> --- a/drivers/phy/st/Kconfig
> +++ b/drivers/phy/st/Kconfig
> @@ -4,7 +4,7 @@
> #
> config PHY_MIPHY28LP
> tristate "STMicroelectronics MIPHY28LP PHY driver for STiH407"
> - depends on ARCH_STI
> + depends on ARCH_STI || COMPILE_TEST
> select GENERIC_PHY
> help
> Enable this to support the miphy transceiver (for SATA/PCIE/USB3)
> --
> 2.53.0
>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Thanks
Patrice
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCHv2 2/2] phy: miphy28lp: kzalloc + kcalloc to single kzalloc
2026-03-06 22:24 ` [PATCHv2 2/2] phy: miphy28lp: kzalloc + kcalloc to single kzalloc Rosen Penev
@ 2026-03-09 7:00 ` Patrice CHOTARD
0 siblings, 0 replies; 5+ messages in thread
From: Patrice CHOTARD @ 2026-03-09 7:00 UTC (permalink / raw)
To: Rosen Penev, linux-phy
Cc: Vinod Koul, Neil Armstrong, Kees Cook, Gustavo A. R. Silva,
open list, moderated list:ARM/STI ARCHITECTURE,
open list:KERNEL HARDENING (not covered by other areas):Keyword:b__counted_by(_le|_be)?b
On 3/6/26 23:24, Rosen Penev wrote:
> Use flex array to simplify allocation.
>
> Allows using __counted_by for extra runtime analysis.
>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
> drivers/phy/st/phy-miphy28lp.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/phy/st/phy-miphy28lp.c b/drivers/phy/st/phy-miphy28lp.c
> index 43cef89af55e..c576fc5569fe 100644
> --- a/drivers/phy/st/phy-miphy28lp.c
> +++ b/drivers/phy/st/phy-miphy28lp.c
> @@ -224,8 +224,8 @@ struct miphy28lp_dev {
> struct device *dev;
> struct regmap *regmap;
> struct mutex miphy_mutex;
> - struct miphy28lp_phy **phys;
> int nphys;
> + struct miphy28lp_phy *phys[] __counted_by(nphys);
> };
>
> enum miphy_sata_gen { SATA_GEN1, SATA_GEN2, SATA_GEN3 };
> @@ -1168,16 +1168,14 @@ static int miphy28lp_probe(struct platform_device *pdev)
> struct phy_provider *provider;
> struct phy *phy;
> int ret, port = 0;
> + size_t nphys;
>
> - miphy_dev = devm_kzalloc(&pdev->dev, sizeof(*miphy_dev), GFP_KERNEL);
> + nphys = of_get_child_count(np);
> + miphy_dev = devm_kzalloc(&pdev->dev, struct_size(miphy_dev, phys, nphys), GFP_KERNEL);
> if (!miphy_dev)
> return -ENOMEM;
>
> - miphy_dev->nphys = of_get_child_count(np);
> - miphy_dev->phys = devm_kcalloc(&pdev->dev, miphy_dev->nphys,
> - sizeof(*miphy_dev->phys), GFP_KERNEL);
> - if (!miphy_dev->phys)
> - return -ENOMEM;
> + miphy_dev->nphys = nphys;
>
> miphy_dev->regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg");
> if (IS_ERR(miphy_dev->regmap)) {
> --
> 2.53.0
>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Thanks
Patrice
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-03-09 7:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-06 22:24 [PATCHv2 0/2] phy: miphy28lp: build and simplify allocation Rosen Penev
2026-03-06 22:24 ` [PATCHv2 1/2] phy: miphy28lp: add COMPILE_TEST Rosen Penev
2026-03-09 6:49 ` Patrice CHOTARD
2026-03-06 22:24 ` [PATCHv2 2/2] phy: miphy28lp: kzalloc + kcalloc to single kzalloc Rosen Penev
2026-03-09 7:00 ` Patrice CHOTARD
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox