mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/6] crypto/hwrng: Simplify with of_device_get_match_data()
@ 2025-11-06 16:31 Krzysztof Kozlowski
  2025-11-06 16:31 ` [PATCH 1/6] hwrng: bcm2835 - Move MODULE_DEVICE_TABLE() to table definition Krzysztof Kozlowski
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-06 16:31 UTC (permalink / raw)
  To: Olivia Mackall, Herbert Xu, Florian Fainelli,
	Broadcom internal kernel review list, Ray Jui, Scott Branden,
	Jesper Nilsson, Lars Persson, David S. Miller, Tom Lendacky,
	John Allen, Srujana Challa, Bharat Bhushan
  Cc: linux-crypto, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	linux-arm-kernel, Krzysztof Kozlowski

Few simple cleanups, not tested on the hardware.

Care has to be taken when converting of_match_data() into
of_device_get_match_data(), because first can check arbitrary
device_node and the latter checks device's node.  Cases here should be
safe because of_match_data() uses 'dev.of_node'.

Best regards,
Krzysztof

---
Krzysztof Kozlowski (6):
      hwrng: bcm2835 - Move MODULE_DEVICE_TABLE() to table definition
      hwrng: bcm2835 - Simplify with of_device_get_match_data()
      crypto: artpec6 - Simplify with of_device_get_match_data()
      crypto: ccp - Constify 'dev_vdata' member
      crypto: ccp - Simplify with of_device_get_match_data()
      crypto: cesa - Simplify with of_device_get_match_data()

 drivers/char/hw_random/bcm2835-rng.c | 11 +++--------
 drivers/crypto/axis/artpec6_crypto.c |  9 +++------
 drivers/crypto/ccp/sp-dev.h          |  2 +-
 drivers/crypto/ccp/sp-platform.c     | 17 +++--------------
 drivers/crypto/marvell/cesa/cesa.c   |  7 ++-----
 5 files changed, 12 insertions(+), 34 deletions(-)
---
base-commit: 8297f2f148634bfa98b0faec66bab14942801d95
change-id: 20251106-crypto-of-match-22726ffd20b4

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/6] hwrng: bcm2835 - Move MODULE_DEVICE_TABLE() to table definition
  2025-11-06 16:31 [PATCH 0/6] crypto/hwrng: Simplify with of_device_get_match_data() Krzysztof Kozlowski
@ 2025-11-06 16:31 ` Krzysztof Kozlowski
  2025-11-06 20:34   ` Florian Fainelli
  2025-11-06 16:31 ` [PATCH 2/6] hwrng: bcm2835 - Simplify with of_device_get_match_data() Krzysztof Kozlowski
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-06 16:31 UTC (permalink / raw)
  To: Olivia Mackall, Herbert Xu, Florian Fainelli,
	Broadcom internal kernel review list, Ray Jui, Scott Branden,
	Jesper Nilsson, Lars Persson, David S. Miller, Tom Lendacky,
	John Allen, Srujana Challa, Bharat Bhushan
  Cc: linux-crypto, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	linux-arm-kernel, Krzysztof Kozlowski

Convention is to place MODULE_DEVICE_TABLE() immediately after
definition of the affected table, so one can easily spot missing such.
There is on the other hand no benefits of putting MODULE_DEVICE_TABLE()
far away.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/char/hw_random/bcm2835-rng.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/char/hw_random/bcm2835-rng.c b/drivers/char/hw_random/bcm2835-rng.c
index aa2b135e3ee2..0b67cfd15b11 100644
--- a/drivers/char/hw_random/bcm2835-rng.c
+++ b/drivers/char/hw_random/bcm2835-rng.c
@@ -138,6 +138,7 @@ static const struct of_device_id bcm2835_rng_of_match[] = {
 	{ .compatible = "brcm,bcm6368-rng"},
 	{},
 };
+MODULE_DEVICE_TABLE(of, bcm2835_rng_of_match);
 
 static int bcm2835_rng_probe(struct platform_device *pdev)
 {
@@ -191,8 +192,6 @@ static int bcm2835_rng_probe(struct platform_device *pdev)
 	return err;
 }
 
-MODULE_DEVICE_TABLE(of, bcm2835_rng_of_match);
-
 static const struct platform_device_id bcm2835_rng_devtype[] = {
 	{ .name = "bcm2835-rng" },
 	{ .name = "bcm63xx-rng" },

-- 
2.48.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 2/6] hwrng: bcm2835 - Simplify with of_device_get_match_data()
  2025-11-06 16:31 [PATCH 0/6] crypto/hwrng: Simplify with of_device_get_match_data() Krzysztof Kozlowski
  2025-11-06 16:31 ` [PATCH 1/6] hwrng: bcm2835 - Move MODULE_DEVICE_TABLE() to table definition Krzysztof Kozlowski
@ 2025-11-06 16:31 ` Krzysztof Kozlowski
  2025-11-06 20:44   ` Florian Fainelli
  2025-11-06 16:31 ` [PATCH 3/6] crypto: artpec6 " Krzysztof Kozlowski
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-06 16:31 UTC (permalink / raw)
  To: Olivia Mackall, Herbert Xu, Florian Fainelli,
	Broadcom internal kernel review list, Ray Jui, Scott Branden,
	Jesper Nilsson, Lars Persson, David S. Miller, Tom Lendacky,
	John Allen, Srujana Challa, Bharat Bhushan
  Cc: linux-crypto, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	linux-arm-kernel, Krzysztof Kozlowski

Driver's probe function matches against driver's of_device_id table,
where each entry has non-NULL match data, so of_match_node() can be
simplified with of_device_get_match_data().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/char/hw_random/bcm2835-rng.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/char/hw_random/bcm2835-rng.c b/drivers/char/hw_random/bcm2835-rng.c
index 0b67cfd15b11..6d6ac409efcf 100644
--- a/drivers/char/hw_random/bcm2835-rng.c
+++ b/drivers/char/hw_random/bcm2835-rng.c
@@ -142,9 +142,7 @@ MODULE_DEVICE_TABLE(of, bcm2835_rng_of_match);
 
 static int bcm2835_rng_probe(struct platform_device *pdev)
 {
-	const struct bcm2835_rng_of_data *of_data;
 	struct device *dev = &pdev->dev;
-	const struct of_device_id *rng_id;
 	struct bcm2835_rng_priv *priv;
 	int err;
 
@@ -172,12 +170,10 @@ static int bcm2835_rng_probe(struct platform_device *pdev)
 	priv->rng.cleanup = bcm2835_rng_cleanup;
 
 	if (dev_of_node(dev)) {
-		rng_id = of_match_node(bcm2835_rng_of_match, dev->of_node);
-		if (!rng_id)
-			return -EINVAL;
+		const struct bcm2835_rng_of_data *of_data;
 
 		/* Check for rng init function, execute it */
-		of_data = rng_id->data;
+		of_data = of_device_get_match_data(dev);
 		if (of_data)
 			priv->mask_interrupts = of_data->mask_interrupts;
 	}

-- 
2.48.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 3/6] crypto: artpec6 - Simplify with of_device_get_match_data()
  2025-11-06 16:31 [PATCH 0/6] crypto/hwrng: Simplify with of_device_get_match_data() Krzysztof Kozlowski
  2025-11-06 16:31 ` [PATCH 1/6] hwrng: bcm2835 - Move MODULE_DEVICE_TABLE() to table definition Krzysztof Kozlowski
  2025-11-06 16:31 ` [PATCH 2/6] hwrng: bcm2835 - Simplify with of_device_get_match_data() Krzysztof Kozlowski
@ 2025-11-06 16:31 ` Krzysztof Kozlowski
  2025-11-06 19:09   ` Krzysztof Kozlowski
  2025-11-06 16:31 ` [PATCH 4/6] crypto: ccp - Constify 'dev_vdata' member Krzysztof Kozlowski
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-06 16:31 UTC (permalink / raw)
  To: Olivia Mackall, Herbert Xu, Florian Fainelli,
	Broadcom internal kernel review list, Ray Jui, Scott Branden,
	Jesper Nilsson, Lars Persson, David S. Miller, Tom Lendacky,
	John Allen, Srujana Challa, Bharat Bhushan
  Cc: linux-crypto, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	linux-arm-kernel, Krzysztof Kozlowski

Driver's probe function matches against driver's of_device_id table, so
of_match_node() can be simplified with of_device_get_match_data().

This requires changing the enum used in the driver match data entries to
non-zero, to be able to recognize error case of
of_device_get_match_data().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/crypto/axis/artpec6_crypto.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/crypto/axis/artpec6_crypto.c b/drivers/crypto/axis/artpec6_crypto.c
index 75ee065da1ec..b0d45f5333ac 100644
--- a/drivers/crypto/axis/artpec6_crypto.c
+++ b/drivers/crypto/axis/artpec6_crypto.c
@@ -252,7 +252,7 @@ struct artpec6_crypto_dma_descriptors {
 };
 
 enum artpec6_crypto_variant {
-	ARTPEC6_CRYPTO,
+	ARTPEC6_CRYPTO = 1,
 	ARTPEC7_CRYPTO,
 };
 
@@ -2842,7 +2842,6 @@ MODULE_DEVICE_TABLE(of, artpec6_crypto_of_match);
 
 static int artpec6_crypto_probe(struct platform_device *pdev)
 {
-	const struct of_device_id *match;
 	enum artpec6_crypto_variant variant;
 	struct artpec6_crypto *ac;
 	struct device *dev = &pdev->dev;
@@ -2853,12 +2852,10 @@ static int artpec6_crypto_probe(struct platform_device *pdev)
 	if (artpec6_crypto_dev)
 		return -ENODEV;
 
-	match = of_match_node(artpec6_crypto_of_match, dev->of_node);
-	if (!match)
+	variant = of_device_get_match_data(dev);
+	if (!variant)
 		return -EINVAL;
 
-	variant = (enum artpec6_crypto_variant)match->data;
-
 	base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(base))
 		return PTR_ERR(base);

-- 
2.48.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 4/6] crypto: ccp - Constify 'dev_vdata' member
  2025-11-06 16:31 [PATCH 0/6] crypto/hwrng: Simplify with of_device_get_match_data() Krzysztof Kozlowski
                   ` (2 preceding siblings ...)
  2025-11-06 16:31 ` [PATCH 3/6] crypto: artpec6 " Krzysztof Kozlowski
@ 2025-11-06 16:31 ` Krzysztof Kozlowski
  2025-11-06 20:48   ` Tom Lendacky
  2025-11-06 16:31 ` [PATCH 5/6] crypto: ccp - Simplify with of_device_get_match_data() Krzysztof Kozlowski
  2025-11-06 16:31 ` [PATCH 6/6] crypto: cesa " Krzysztof Kozlowski
  5 siblings, 1 reply; 12+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-06 16:31 UTC (permalink / raw)
  To: Olivia Mackall, Herbert Xu, Florian Fainelli,
	Broadcom internal kernel review list, Ray Jui, Scott Branden,
	Jesper Nilsson, Lars Persson, David S. Miller, Tom Lendacky,
	John Allen, Srujana Challa, Bharat Bhushan
  Cc: linux-crypto, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	linux-arm-kernel, Krzysztof Kozlowski

sp_device->dev_vdata points to only const data (see 'static const struct
sp_dev_vdata dev_vdata'), so can be made pointer to const for code
safety.

Update also sp_get_acpi_version() function which returns this pointer to
'pointer to const' for code readability, even though it is not needed.

On the other hand, do not touch similar function sp_get_of_version()
because it will be immediately removed in next patches.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/crypto/ccp/sp-dev.h      | 2 +-
 drivers/crypto/ccp/sp-platform.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/ccp/sp-dev.h b/drivers/crypto/ccp/sp-dev.h
index 6f9d7063257d..1335a83fe052 100644
--- a/drivers/crypto/ccp/sp-dev.h
+++ b/drivers/crypto/ccp/sp-dev.h
@@ -95,7 +95,7 @@ struct sp_device {
 
 	struct device *dev;
 
-	struct sp_dev_vdata *dev_vdata;
+	const struct sp_dev_vdata *dev_vdata;
 	unsigned int ord;
 	char name[SP_MAX_NAME_LEN];
 
diff --git a/drivers/crypto/ccp/sp-platform.c b/drivers/crypto/ccp/sp-platform.c
index 3933cac1694d..de8a8183efdb 100644
--- a/drivers/crypto/ccp/sp-platform.c
+++ b/drivers/crypto/ccp/sp-platform.c
@@ -63,13 +63,13 @@ static struct sp_dev_vdata *sp_get_of_version(struct platform_device *pdev)
 	return NULL;
 }
 
-static struct sp_dev_vdata *sp_get_acpi_version(struct platform_device *pdev)
+static const struct sp_dev_vdata *sp_get_acpi_version(struct platform_device *pdev)
 {
 	const struct acpi_device_id *match;
 
 	match = acpi_match_device(sp_acpi_match, &pdev->dev);
 	if (match && match->driver_data)
-		return (struct sp_dev_vdata *)match->driver_data;
+		return (const struct sp_dev_vdata *)match->driver_data;
 
 	return NULL;
 }

-- 
2.48.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 5/6] crypto: ccp - Simplify with of_device_get_match_data()
  2025-11-06 16:31 [PATCH 0/6] crypto/hwrng: Simplify with of_device_get_match_data() Krzysztof Kozlowski
                   ` (3 preceding siblings ...)
  2025-11-06 16:31 ` [PATCH 4/6] crypto: ccp - Constify 'dev_vdata' member Krzysztof Kozlowski
@ 2025-11-06 16:31 ` Krzysztof Kozlowski
  2025-11-06 20:49   ` Tom Lendacky
  2025-11-06 16:31 ` [PATCH 6/6] crypto: cesa " Krzysztof Kozlowski
  5 siblings, 1 reply; 12+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-06 16:31 UTC (permalink / raw)
  To: Olivia Mackall, Herbert Xu, Florian Fainelli,
	Broadcom internal kernel review list, Ray Jui, Scott Branden,
	Jesper Nilsson, Lars Persson, David S. Miller, Tom Lendacky,
	John Allen, Srujana Challa, Bharat Bhushan
  Cc: linux-crypto, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	linux-arm-kernel, Krzysztof Kozlowski

Driver's probe function matches against driver's of_device_id table,
where each entry has non-NULL match data, so of_match_node() can be
simplified with of_device_get_match_data().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/crypto/ccp/sp-platform.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/crypto/ccp/sp-platform.c b/drivers/crypto/ccp/sp-platform.c
index de8a8183efdb..3f9843fa7782 100644
--- a/drivers/crypto/ccp/sp-platform.c
+++ b/drivers/crypto/ccp/sp-platform.c
@@ -52,17 +52,6 @@ static const struct of_device_id sp_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, sp_of_match);
 
-static struct sp_dev_vdata *sp_get_of_version(struct platform_device *pdev)
-{
-	const struct of_device_id *match;
-
-	match = of_match_node(sp_of_match, pdev->dev.of_node);
-	if (match && match->data)
-		return (struct sp_dev_vdata *)match->data;
-
-	return NULL;
-}
-
 static const struct sp_dev_vdata *sp_get_acpi_version(struct platform_device *pdev)
 {
 	const struct acpi_device_id *match;
@@ -123,7 +112,7 @@ static int sp_platform_probe(struct platform_device *pdev)
 		goto e_err;
 
 	sp->dev_specific = sp_platform;
-	sp->dev_vdata = pdev->dev.of_node ? sp_get_of_version(pdev)
+	sp->dev_vdata = pdev->dev.of_node ? of_device_get_match_data(&pdev->dev)
 					 : sp_get_acpi_version(pdev);
 	if (!sp->dev_vdata) {
 		ret = -ENODEV;

-- 
2.48.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 6/6] crypto: cesa - Simplify with of_device_get_match_data()
  2025-11-06 16:31 [PATCH 0/6] crypto/hwrng: Simplify with of_device_get_match_data() Krzysztof Kozlowski
                   ` (4 preceding siblings ...)
  2025-11-06 16:31 ` [PATCH 5/6] crypto: ccp - Simplify with of_device_get_match_data() Krzysztof Kozlowski
@ 2025-11-06 16:31 ` Krzysztof Kozlowski
  5 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-06 16:31 UTC (permalink / raw)
  To: Olivia Mackall, Herbert Xu, Florian Fainelli,
	Broadcom internal kernel review list, Ray Jui, Scott Branden,
	Jesper Nilsson, Lars Persson, David S. Miller, Tom Lendacky,
	John Allen, Srujana Challa, Bharat Bhushan
  Cc: linux-crypto, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	linux-arm-kernel, Krzysztof Kozlowski

Driver's probe function matches against driver's of_device_id table,
where each entry has non-NULL match data, so of_match_node() can be
simplified with of_device_get_match_data().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/crypto/marvell/cesa/cesa.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/marvell/cesa/cesa.c b/drivers/crypto/marvell/cesa/cesa.c
index 9c21f5d835d2..301bdf239e7d 100644
--- a/drivers/crypto/marvell/cesa/cesa.c
+++ b/drivers/crypto/marvell/cesa/cesa.c
@@ -420,7 +420,6 @@ static int mv_cesa_probe(struct platform_device *pdev)
 {
 	const struct mv_cesa_caps *caps = &orion_caps;
 	const struct mbus_dram_target_info *dram;
-	const struct of_device_id *match;
 	struct device *dev = &pdev->dev;
 	struct mv_cesa_dev *cesa;
 	struct mv_cesa_engine *engines;
@@ -433,11 +432,9 @@ static int mv_cesa_probe(struct platform_device *pdev)
 	}
 
 	if (dev->of_node) {
-		match = of_match_node(mv_cesa_of_match_table, dev->of_node);
-		if (!match || !match->data)
+		caps = of_device_get_match_data(dev);
+		if (!caps)
 			return -ENOTSUPP;
-
-		caps = match->data;
 	}
 
 	cesa = devm_kzalloc(dev, sizeof(*cesa), GFP_KERNEL);

-- 
2.48.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/6] crypto: artpec6 - Simplify with of_device_get_match_data()
  2025-11-06 16:31 ` [PATCH 3/6] crypto: artpec6 " Krzysztof Kozlowski
@ 2025-11-06 19:09   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-06 19:09 UTC (permalink / raw)
  To: Olivia Mackall, Herbert Xu, Florian Fainelli,
	Broadcom internal kernel review list, Ray Jui, Scott Branden,
	Jesper Nilsson, Lars Persson, David S. Miller, Tom Lendacky,
	John Allen, Srujana Challa, Bharat Bhushan
  Cc: linux-crypto, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	linux-arm-kernel

On 06/11/2025 17:31, Krzysztof Kozlowski wrote:
>  	struct device *dev = &pdev->dev;
> @@ -2853,12 +2852,10 @@ static int artpec6_crypto_probe(struct platform_device *pdev)
>  	if (artpec6_crypto_dev)
>  		return -ENODEV;
>  
> -	match = of_match_node(artpec6_crypto_of_match, dev->of_node);
> -	if (!match)
> +	variant = of_device_get_match_data(dev);

This needs cast for 32-bit builds like it was before. I will send v2.

> +	if (!variant)
>  		return -EINVAL;
>  
> -	variant = (enum artpec6_crypto_variant)match->data;



Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/6] hwrng: bcm2835 - Move MODULE_DEVICE_TABLE() to table definition
  2025-11-06 16:31 ` [PATCH 1/6] hwrng: bcm2835 - Move MODULE_DEVICE_TABLE() to table definition Krzysztof Kozlowski
@ 2025-11-06 20:34   ` Florian Fainelli
  0 siblings, 0 replies; 12+ messages in thread
From: Florian Fainelli @ 2025-11-06 20:34 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Olivia Mackall, Herbert Xu,
	Broadcom internal kernel review list, Ray Jui, Scott Branden,
	Jesper Nilsson, Lars Persson, David S. Miller, Tom Lendacky,
	John Allen, Srujana Challa, Bharat Bhushan
  Cc: linux-crypto, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	linux-arm-kernel

On 11/6/25 08:31, Krzysztof Kozlowski wrote:
> Convention is to place MODULE_DEVICE_TABLE() immediately after
> definition of the affected table, so one can easily spot missing such.
> There is on the other hand no benefits of putting MODULE_DEVICE_TABLE()
> far away.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/6] hwrng: bcm2835 - Simplify with of_device_get_match_data()
  2025-11-06 16:31 ` [PATCH 2/6] hwrng: bcm2835 - Simplify with of_device_get_match_data() Krzysztof Kozlowski
@ 2025-11-06 20:44   ` Florian Fainelli
  0 siblings, 0 replies; 12+ messages in thread
From: Florian Fainelli @ 2025-11-06 20:44 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Olivia Mackall, Herbert Xu,
	Broadcom internal kernel review list, Ray Jui, Scott Branden,
	Jesper Nilsson, Lars Persson, David S. Miller, Tom Lendacky,
	John Allen, Srujana Challa, Bharat Bhushan
  Cc: linux-crypto, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	linux-arm-kernel

On 11/6/25 08:31, Krzysztof Kozlowski wrote:
> Driver's probe function matches against driver's of_device_id table,
> where each entry has non-NULL match data, so of_match_node() can be
> simplified with of_device_get_match_data().
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/6] crypto: ccp - Constify 'dev_vdata' member
  2025-11-06 16:31 ` [PATCH 4/6] crypto: ccp - Constify 'dev_vdata' member Krzysztof Kozlowski
@ 2025-11-06 20:48   ` Tom Lendacky
  0 siblings, 0 replies; 12+ messages in thread
From: Tom Lendacky @ 2025-11-06 20:48 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Olivia Mackall, Herbert Xu,
	Florian Fainelli, Broadcom internal kernel review list, Ray Jui,
	Scott Branden, Jesper Nilsson, Lars Persson, David S. Miller,
	John Allen, Srujana Challa, Bharat Bhushan
  Cc: linux-crypto, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	linux-arm-kernel

On 11/6/25 10:31, Krzysztof Kozlowski wrote:
> sp_device->dev_vdata points to only const data (see 'static const struct
> sp_dev_vdata dev_vdata'), so can be made pointer to const for code
> safety.
> 
> Update also sp_get_acpi_version() function which returns this pointer to
> 'pointer to const' for code readability, even though it is not needed.
> 
> On the other hand, do not touch similar function sp_get_of_version()
> because it will be immediately removed in next patches.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Acked-by: Tom Lendacky <thomas.lendacky@amd.com>

> ---
>  drivers/crypto/ccp/sp-dev.h      | 2 +-
>  drivers/crypto/ccp/sp-platform.c | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/crypto/ccp/sp-dev.h b/drivers/crypto/ccp/sp-dev.h
> index 6f9d7063257d..1335a83fe052 100644
> --- a/drivers/crypto/ccp/sp-dev.h
> +++ b/drivers/crypto/ccp/sp-dev.h
> @@ -95,7 +95,7 @@ struct sp_device {
>  
>  	struct device *dev;
>  
> -	struct sp_dev_vdata *dev_vdata;
> +	const struct sp_dev_vdata *dev_vdata;
>  	unsigned int ord;
>  	char name[SP_MAX_NAME_LEN];
>  
> diff --git a/drivers/crypto/ccp/sp-platform.c b/drivers/crypto/ccp/sp-platform.c
> index 3933cac1694d..de8a8183efdb 100644
> --- a/drivers/crypto/ccp/sp-platform.c
> +++ b/drivers/crypto/ccp/sp-platform.c
> @@ -63,13 +63,13 @@ static struct sp_dev_vdata *sp_get_of_version(struct platform_device *pdev)
>  	return NULL;
>  }
>  
> -static struct sp_dev_vdata *sp_get_acpi_version(struct platform_device *pdev)
> +static const struct sp_dev_vdata *sp_get_acpi_version(struct platform_device *pdev)
>  {
>  	const struct acpi_device_id *match;
>  
>  	match = acpi_match_device(sp_acpi_match, &pdev->dev);
>  	if (match && match->driver_data)
> -		return (struct sp_dev_vdata *)match->driver_data;
> +		return (const struct sp_dev_vdata *)match->driver_data;
>  
>  	return NULL;
>  }
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 5/6] crypto: ccp - Simplify with of_device_get_match_data()
  2025-11-06 16:31 ` [PATCH 5/6] crypto: ccp - Simplify with of_device_get_match_data() Krzysztof Kozlowski
@ 2025-11-06 20:49   ` Tom Lendacky
  0 siblings, 0 replies; 12+ messages in thread
From: Tom Lendacky @ 2025-11-06 20:49 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Olivia Mackall, Herbert Xu,
	Florian Fainelli, Broadcom internal kernel review list, Ray Jui,
	Scott Branden, Jesper Nilsson, Lars Persson, David S. Miller,
	John Allen, Srujana Challa, Bharat Bhushan
  Cc: linux-crypto, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	linux-arm-kernel

On 11/6/25 10:31, Krzysztof Kozlowski wrote:
> Driver's probe function matches against driver's of_device_id table,
> where each entry has non-NULL match data, so of_match_node() can be
> simplified with of_device_get_match_data().
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Acked-by: Tom Lendacky <thomas.lendacky@amd.com>

> ---
>  drivers/crypto/ccp/sp-platform.c | 13 +------------
>  1 file changed, 1 insertion(+), 12 deletions(-)
> 
> diff --git a/drivers/crypto/ccp/sp-platform.c b/drivers/crypto/ccp/sp-platform.c
> index de8a8183efdb..3f9843fa7782 100644
> --- a/drivers/crypto/ccp/sp-platform.c
> +++ b/drivers/crypto/ccp/sp-platform.c
> @@ -52,17 +52,6 @@ static const struct of_device_id sp_of_match[] = {
>  };
>  MODULE_DEVICE_TABLE(of, sp_of_match);
>  
> -static struct sp_dev_vdata *sp_get_of_version(struct platform_device *pdev)
> -{
> -	const struct of_device_id *match;
> -
> -	match = of_match_node(sp_of_match, pdev->dev.of_node);
> -	if (match && match->data)
> -		return (struct sp_dev_vdata *)match->data;
> -
> -	return NULL;
> -}
> -
>  static const struct sp_dev_vdata *sp_get_acpi_version(struct platform_device *pdev)
>  {
>  	const struct acpi_device_id *match;
> @@ -123,7 +112,7 @@ static int sp_platform_probe(struct platform_device *pdev)
>  		goto e_err;
>  
>  	sp->dev_specific = sp_platform;
> -	sp->dev_vdata = pdev->dev.of_node ? sp_get_of_version(pdev)
> +	sp->dev_vdata = pdev->dev.of_node ? of_device_get_match_data(&pdev->dev)
>  					 : sp_get_acpi_version(pdev);
>  	if (!sp->dev_vdata) {
>  		ret = -ENODEV;
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-11-06 20:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-06 16:31 [PATCH 0/6] crypto/hwrng: Simplify with of_device_get_match_data() Krzysztof Kozlowski
2025-11-06 16:31 ` [PATCH 1/6] hwrng: bcm2835 - Move MODULE_DEVICE_TABLE() to table definition Krzysztof Kozlowski
2025-11-06 20:34   ` Florian Fainelli
2025-11-06 16:31 ` [PATCH 2/6] hwrng: bcm2835 - Simplify with of_device_get_match_data() Krzysztof Kozlowski
2025-11-06 20:44   ` Florian Fainelli
2025-11-06 16:31 ` [PATCH 3/6] crypto: artpec6 " Krzysztof Kozlowski
2025-11-06 19:09   ` Krzysztof Kozlowski
2025-11-06 16:31 ` [PATCH 4/6] crypto: ccp - Constify 'dev_vdata' member Krzysztof Kozlowski
2025-11-06 20:48   ` Tom Lendacky
2025-11-06 16:31 ` [PATCH 5/6] crypto: ccp - Simplify with of_device_get_match_data() Krzysztof Kozlowski
2025-11-06 20:49   ` Tom Lendacky
2025-11-06 16:31 ` [PATCH 6/6] crypto: cesa " Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®