All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] spi: stm32: disable device mode with st,stm32f4-spi compatible
@ 2023-06-27 12:39 ` Valentin Caron
  0 siblings, 0 replies; 12+ messages in thread
From: Valentin Caron @ 2023-06-27 12:39 UTC (permalink / raw)
  To: Mark Brown
  Cc: Krzysztof Kozlowski, Alexandre Torgue, Alain Volmat, linux-spi,
	linux-stm32, linux-arm-kernel, linux-kernel, Valentin Caron

STM32 SPI driver is not capable to handle device mode with stm32f4 soc.
Stop probing if this case happens, and print an error with involved
compatible.

Signed-off-by: Valentin Caron <valentin.caron@foss.st.com>
---
Changes since v1:
- Replace of_match_device()->data by of_device_get_match_data()

 drivers/spi/spi-stm32.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 6d10fa4ab783..0de56441f72e 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -238,6 +238,7 @@ struct stm32_spi;
  * @baud_rate_div_min: minimum baud rate divisor
  * @baud_rate_div_max: maximum baud rate divisor
  * @has_fifo: boolean to know if fifo is used for driver
+ * @has_device_mode: is this compatible capable to switch on device mode
  * @flags: compatible specific SPI controller flags used at registration time
  */
 struct stm32_spi_cfg {
@@ -259,6 +260,7 @@ struct stm32_spi_cfg {
 	unsigned int baud_rate_div_min;
 	unsigned int baud_rate_div_max;
 	bool has_fifo;
+	bool has_device_mode;
 	u16 flags;
 };
 
@@ -1750,6 +1752,7 @@ static const struct stm32_spi_cfg stm32f4_spi_cfg = {
 	.baud_rate_div_min = STM32F4_SPI_BR_DIV_MIN,
 	.baud_rate_div_max = STM32F4_SPI_BR_DIV_MAX,
 	.has_fifo = false,
+	.has_device_mode = false,
 	.flags = SPI_MASTER_MUST_TX,
 };
 
@@ -1774,6 +1777,7 @@ static const struct stm32_spi_cfg stm32h7_spi_cfg = {
 	.baud_rate_div_min = STM32H7_SPI_MBR_DIV_MIN,
 	.baud_rate_div_max = STM32H7_SPI_MBR_DIV_MAX,
 	.has_fifo = true,
+	.has_device_mode = true,
 };
 
 static const struct of_device_id stm32_spi_of_match[] = {
@@ -1798,8 +1802,16 @@ static int stm32_spi_probe(struct platform_device *pdev)
 	struct device_node *np = pdev->dev.of_node;
 	bool device_mode;
 	int ret;
+	const char *compatible =
+		of_match_device(pdev->dev.driver->of_match_table, &pdev->dev)->compatible;
+	const struct stm32_spi_cfg *cfg = (const struct stm32_spi_cfg *)
+		of_device_get_match_data(&pdev->dev);
 
 	device_mode = of_property_read_bool(np, "spi-slave");
+	if (!cfg->has_device_mode && device_mode) {
+		dev_err(&pdev->dev, "spi-slave not yet supported with %s\n", compatible);
+		return -EPERM;
+	}
 
 	if (device_mode)
 		ctrl = devm_spi_alloc_slave(&pdev->dev, sizeof(struct stm32_spi));
@@ -1817,9 +1829,7 @@ static int stm32_spi_probe(struct platform_device *pdev)
 	spi->device_mode = device_mode;
 	spin_lock_init(&spi->lock);
 
-	spi->cfg = (const struct stm32_spi_cfg *)
-		of_match_device(pdev->dev.driver->of_match_table,
-				&pdev->dev)->data;
+	spi->cfg = cfg;
 
 	spi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
 	if (IS_ERR(spi->base))
-- 
2.25.1


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

* [PATCH v2] spi: stm32: disable device mode with st,stm32f4-spi compatible
@ 2023-06-27 12:39 ` Valentin Caron
  0 siblings, 0 replies; 12+ messages in thread
From: Valentin Caron @ 2023-06-27 12:39 UTC (permalink / raw)
  To: Mark Brown
  Cc: Krzysztof Kozlowski, Alexandre Torgue, Alain Volmat, linux-spi,
	linux-stm32, linux-arm-kernel, linux-kernel, Valentin Caron

STM32 SPI driver is not capable to handle device mode with stm32f4 soc.
Stop probing if this case happens, and print an error with involved
compatible.

Signed-off-by: Valentin Caron <valentin.caron@foss.st.com>
---
Changes since v1:
- Replace of_match_device()->data by of_device_get_match_data()

 drivers/spi/spi-stm32.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 6d10fa4ab783..0de56441f72e 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -238,6 +238,7 @@ struct stm32_spi;
  * @baud_rate_div_min: minimum baud rate divisor
  * @baud_rate_div_max: maximum baud rate divisor
  * @has_fifo: boolean to know if fifo is used for driver
+ * @has_device_mode: is this compatible capable to switch on device mode
  * @flags: compatible specific SPI controller flags used at registration time
  */
 struct stm32_spi_cfg {
@@ -259,6 +260,7 @@ struct stm32_spi_cfg {
 	unsigned int baud_rate_div_min;
 	unsigned int baud_rate_div_max;
 	bool has_fifo;
+	bool has_device_mode;
 	u16 flags;
 };
 
@@ -1750,6 +1752,7 @@ static const struct stm32_spi_cfg stm32f4_spi_cfg = {
 	.baud_rate_div_min = STM32F4_SPI_BR_DIV_MIN,
 	.baud_rate_div_max = STM32F4_SPI_BR_DIV_MAX,
 	.has_fifo = false,
+	.has_device_mode = false,
 	.flags = SPI_MASTER_MUST_TX,
 };
 
@@ -1774,6 +1777,7 @@ static const struct stm32_spi_cfg stm32h7_spi_cfg = {
 	.baud_rate_div_min = STM32H7_SPI_MBR_DIV_MIN,
 	.baud_rate_div_max = STM32H7_SPI_MBR_DIV_MAX,
 	.has_fifo = true,
+	.has_device_mode = true,
 };
 
 static const struct of_device_id stm32_spi_of_match[] = {
@@ -1798,8 +1802,16 @@ static int stm32_spi_probe(struct platform_device *pdev)
 	struct device_node *np = pdev->dev.of_node;
 	bool device_mode;
 	int ret;
+	const char *compatible =
+		of_match_device(pdev->dev.driver->of_match_table, &pdev->dev)->compatible;
+	const struct stm32_spi_cfg *cfg = (const struct stm32_spi_cfg *)
+		of_device_get_match_data(&pdev->dev);
 
 	device_mode = of_property_read_bool(np, "spi-slave");
+	if (!cfg->has_device_mode && device_mode) {
+		dev_err(&pdev->dev, "spi-slave not yet supported with %s\n", compatible);
+		return -EPERM;
+	}
 
 	if (device_mode)
 		ctrl = devm_spi_alloc_slave(&pdev->dev, sizeof(struct stm32_spi));
@@ -1817,9 +1829,7 @@ static int stm32_spi_probe(struct platform_device *pdev)
 	spi->device_mode = device_mode;
 	spin_lock_init(&spi->lock);
 
-	spi->cfg = (const struct stm32_spi_cfg *)
-		of_match_device(pdev->dev.driver->of_match_table,
-				&pdev->dev)->data;
+	spi->cfg = cfg;
 
 	spi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
 	if (IS_ERR(spi->base))
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2] spi: stm32: disable device mode with st,stm32f4-spi compatible
  2023-06-27 12:39 ` Valentin Caron
@ 2023-06-27 13:39   ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2023-06-27 13:39 UTC (permalink / raw)
  To: Valentin Caron, Mark Brown
  Cc: Krzysztof Kozlowski, Alexandre Torgue, Alain Volmat, linux-spi,
	linux-stm32, linux-arm-kernel, linux-kernel

On 27/06/2023 14:39, Valentin Caron wrote:
> STM32 SPI driver is not capable to handle device mode with stm32f4 soc.
> Stop probing if this case happens, and print an error with involved
> compatible.
> 

...

>  
>  static const struct of_device_id stm32_spi_of_match[] = {
> @@ -1798,8 +1802,16 @@ static int stm32_spi_probe(struct platform_device *pdev)
>  	struct device_node *np = pdev->dev.of_node;
>  	bool device_mode;
>  	int ret;
> +	const char *compatible =
> +		of_match_device(pdev->dev.driver->of_match_table, &pdev->dev)->compatible;

The goal was to replace it, so drop it.

> +	const struct stm32_spi_cfg *cfg = (const struct stm32_spi_cfg *)

Why do you need the cast? To drop the const? Are you sure it is really
needed?

> +		of_device_get_match_data(&pdev->dev);
Best regards,
Krzysztof


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

* Re: [PATCH v2] spi: stm32: disable device mode with st,stm32f4-spi compatible
@ 2023-06-27 13:39   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2023-06-27 13:39 UTC (permalink / raw)
  To: Valentin Caron, Mark Brown
  Cc: Krzysztof Kozlowski, Alexandre Torgue, Alain Volmat, linux-spi,
	linux-stm32, linux-arm-kernel, linux-kernel

On 27/06/2023 14:39, Valentin Caron wrote:
> STM32 SPI driver is not capable to handle device mode with stm32f4 soc.
> Stop probing if this case happens, and print an error with involved
> compatible.
> 

...

>  
>  static const struct of_device_id stm32_spi_of_match[] = {
> @@ -1798,8 +1802,16 @@ static int stm32_spi_probe(struct platform_device *pdev)
>  	struct device_node *np = pdev->dev.of_node;
>  	bool device_mode;
>  	int ret;
> +	const char *compatible =
> +		of_match_device(pdev->dev.driver->of_match_table, &pdev->dev)->compatible;

The goal was to replace it, so drop it.

> +	const struct stm32_spi_cfg *cfg = (const struct stm32_spi_cfg *)

Why do you need the cast? To drop the const? Are you sure it is really
needed?

> +		of_device_get_match_data(&pdev->dev);
Best regards,
Krzysztof


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2] spi: stm32: disable device mode with st,stm32f4-spi compatible
  2023-06-27 13:39   ` Krzysztof Kozlowski
@ 2023-06-28 16:21     ` Valentin CARON
  -1 siblings, 0 replies; 12+ messages in thread
From: Valentin CARON @ 2023-06-28 16:21 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Mark Brown
  Cc: Krzysztof Kozlowski, Alexandre Torgue, Alain Volmat, linux-spi,
	linux-stm32, linux-arm-kernel, linux-kernel

Hi,

On 6/27/23 15:39, Krzysztof Kozlowski wrote:
> On 27/06/2023 14:39, Valentin Caron wrote:
>> STM32 SPI driver is not capable to handle device mode with stm32f4 soc.
>> Stop probing if this case happens, and print an error with involved
>> compatible.
>>
> ...
>
>>   
>>   static const struct of_device_id stm32_spi_of_match[] = {
>> @@ -1798,8 +1802,16 @@ static int stm32_spi_probe(struct platform_device *pdev)
>>   	struct device_node *np = pdev->dev.of_node;
>>   	bool device_mode;
>>   	int ret;
>> +	const char *compatible =
>> +		of_match_device(pdev->dev.driver->of_match_table, &pdev->dev)->compatible;
> The goal was to replace it, so drop it.
Is is still needed for dev_err, so I can't
 > dev_err(&pdev->dev, "spi-slave not yet supported with %s\n", 
compatible);
>
>> +	const struct stm32_spi_cfg *cfg = (const struct stm32_spi_cfg *)
> Why do you need the cast? To drop the const? Are you sure it is really
> needed?
Effectively, this cast is useless, I will drop it.
>> +		of_device_get_match_data(&pdev->dev);
> Best regards,
> Krzysztof

Thanks,
Valentin


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

* Re: [PATCH v2] spi: stm32: disable device mode with st,stm32f4-spi compatible
@ 2023-06-28 16:21     ` Valentin CARON
  0 siblings, 0 replies; 12+ messages in thread
From: Valentin CARON @ 2023-06-28 16:21 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Mark Brown
  Cc: Krzysztof Kozlowski, Alexandre Torgue, Alain Volmat, linux-spi,
	linux-stm32, linux-arm-kernel, linux-kernel

Hi,

On 6/27/23 15:39, Krzysztof Kozlowski wrote:
> On 27/06/2023 14:39, Valentin Caron wrote:
>> STM32 SPI driver is not capable to handle device mode with stm32f4 soc.
>> Stop probing if this case happens, and print an error with involved
>> compatible.
>>
> ...
>
>>   
>>   static const struct of_device_id stm32_spi_of_match[] = {
>> @@ -1798,8 +1802,16 @@ static int stm32_spi_probe(struct platform_device *pdev)
>>   	struct device_node *np = pdev->dev.of_node;
>>   	bool device_mode;
>>   	int ret;
>> +	const char *compatible =
>> +		of_match_device(pdev->dev.driver->of_match_table, &pdev->dev)->compatible;
> The goal was to replace it, so drop it.
Is is still needed for dev_err, so I can't
 > dev_err(&pdev->dev, "spi-slave not yet supported with %s\n", 
compatible);
>
>> +	const struct stm32_spi_cfg *cfg = (const struct stm32_spi_cfg *)
> Why do you need the cast? To drop the const? Are you sure it is really
> needed?
Effectively, this cast is useless, I will drop it.
>> +		of_device_get_match_data(&pdev->dev);
> Best regards,
> Krzysztof

Thanks,
Valentin


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2] spi: stm32: disable device mode with st,stm32f4-spi compatible
  2023-06-28 16:21     ` Valentin CARON
@ 2023-07-01  8:09       ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-01  8:09 UTC (permalink / raw)
  To: Valentin CARON, Mark Brown
  Cc: Krzysztof Kozlowski, Alexandre Torgue, Alain Volmat, linux-spi,
	linux-stm32, linux-arm-kernel, linux-kernel

On 28/06/2023 18:21, Valentin CARON wrote:
> Hi,
> 
> On 6/27/23 15:39, Krzysztof Kozlowski wrote:
>> On 27/06/2023 14:39, Valentin Caron wrote:
>>> STM32 SPI driver is not capable to handle device mode with stm32f4 soc.
>>> Stop probing if this case happens, and print an error with involved
>>> compatible.
>>>
>> ...
>>
>>>   
>>>   static const struct of_device_id stm32_spi_of_match[] = {
>>> @@ -1798,8 +1802,16 @@ static int stm32_spi_probe(struct platform_device *pdev)
>>>   	struct device_node *np = pdev->dev.of_node;
>>>   	bool device_mode;
>>>   	int ret;
>>> +	const char *compatible =
>>> +		of_match_device(pdev->dev.driver->of_match_table, &pdev->dev)->compatible;
>> The goal was to replace it, so drop it.
> Is is still needed for dev_err, so I can't

Why do you need it for dev_err? Isn't it entirely redundant?

Best regards,
Krzysztof


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

* Re: [PATCH v2] spi: stm32: disable device mode with st,stm32f4-spi compatible
@ 2023-07-01  8:09       ` Krzysztof Kozlowski
  0 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-01  8:09 UTC (permalink / raw)
  To: Valentin CARON, Mark Brown
  Cc: Krzysztof Kozlowski, Alexandre Torgue, Alain Volmat, linux-spi,
	linux-stm32, linux-arm-kernel, linux-kernel

On 28/06/2023 18:21, Valentin CARON wrote:
> Hi,
> 
> On 6/27/23 15:39, Krzysztof Kozlowski wrote:
>> On 27/06/2023 14:39, Valentin Caron wrote:
>>> STM32 SPI driver is not capable to handle device mode with stm32f4 soc.
>>> Stop probing if this case happens, and print an error with involved
>>> compatible.
>>>
>> ...
>>
>>>   
>>>   static const struct of_device_id stm32_spi_of_match[] = {
>>> @@ -1798,8 +1802,16 @@ static int stm32_spi_probe(struct platform_device *pdev)
>>>   	struct device_node *np = pdev->dev.of_node;
>>>   	bool device_mode;
>>>   	int ret;
>>> +	const char *compatible =
>>> +		of_match_device(pdev->dev.driver->of_match_table, &pdev->dev)->compatible;
>> The goal was to replace it, so drop it.
> Is is still needed for dev_err, so I can't

Why do you need it for dev_err? Isn't it entirely redundant?

Best regards,
Krzysztof


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2] spi: stm32: disable device mode with st,stm32f4-spi compatible
  2023-07-01  8:09       ` Krzysztof Kozlowski
@ 2023-07-05 17:16         ` Valentin CARON
  -1 siblings, 0 replies; 12+ messages in thread
From: Valentin CARON @ 2023-07-05 17:16 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Mark Brown
  Cc: Krzysztof Kozlowski, Alexandre Torgue, Alain Volmat, linux-spi,
	linux-stm32, linux-arm-kernel, linux-kernel

Hi, Krzysztof

On 7/1/23 10:09, Krzysztof Kozlowski wrote:
> On 28/06/2023 18:21, Valentin CARON wrote:
>> Hi,
>>
>> On 6/27/23 15:39, Krzysztof Kozlowski wrote:
>>> On 27/06/2023 14:39, Valentin Caron wrote:
>>>> STM32 SPI driver is not capable to handle device mode with stm32f4 soc.
>>>> Stop probing if this case happens, and print an error with involved
>>>> compatible.
>>>>
>>> ...
>>>
>>>>    
>>>>    static const struct of_device_id stm32_spi_of_match[] = {
>>>> @@ -1798,8 +1802,16 @@ static int stm32_spi_probe(struct platform_device *pdev)
>>>>    	struct device_node *np = pdev->dev.of_node;
>>>>    	bool device_mode;
>>>>    	int ret;
>>>> +	const char *compatible =
>>>> +		of_match_device(pdev->dev.driver->of_match_table, &pdev->dev)->compatible;
>>> The goal was to replace it, so drop it.
>> Is is still needed for dev_err, so I can't
> Why do you need it for dev_err? Isn't it entirely redundant?
>
> Best regards,
> Krzysztof
>
Only to have a clearer error message. To let know to user that spi 
device is not available on this device.

Right now, there is only one compatible where spi device can't be 
enable. So I could use a static message. But this is not the best if a 
new compatible is added.

Regards,
Valentin

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

* Re: [PATCH v2] spi: stm32: disable device mode with st,stm32f4-spi compatible
@ 2023-07-05 17:16         ` Valentin CARON
  0 siblings, 0 replies; 12+ messages in thread
From: Valentin CARON @ 2023-07-05 17:16 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Mark Brown
  Cc: Krzysztof Kozlowski, Alexandre Torgue, Alain Volmat, linux-spi,
	linux-stm32, linux-arm-kernel, linux-kernel

Hi, Krzysztof

On 7/1/23 10:09, Krzysztof Kozlowski wrote:
> On 28/06/2023 18:21, Valentin CARON wrote:
>> Hi,
>>
>> On 6/27/23 15:39, Krzysztof Kozlowski wrote:
>>> On 27/06/2023 14:39, Valentin Caron wrote:
>>>> STM32 SPI driver is not capable to handle device mode with stm32f4 soc.
>>>> Stop probing if this case happens, and print an error with involved
>>>> compatible.
>>>>
>>> ...
>>>
>>>>    
>>>>    static const struct of_device_id stm32_spi_of_match[] = {
>>>> @@ -1798,8 +1802,16 @@ static int stm32_spi_probe(struct platform_device *pdev)
>>>>    	struct device_node *np = pdev->dev.of_node;
>>>>    	bool device_mode;
>>>>    	int ret;
>>>> +	const char *compatible =
>>>> +		of_match_device(pdev->dev.driver->of_match_table, &pdev->dev)->compatible;
>>> The goal was to replace it, so drop it.
>> Is is still needed for dev_err, so I can't
> Why do you need it for dev_err? Isn't it entirely redundant?
>
> Best regards,
> Krzysztof
>
Only to have a clearer error message. To let know to user that spi 
device is not available on this device.

Right now, there is only one compatible where spi device can't be 
enable. So I could use a static message. But this is not the best if a 
new compatible is added.

Regards,
Valentin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2] spi: stm32: disable device mode with st,stm32f4-spi compatible
  2023-07-05 17:16         ` Valentin CARON
@ 2023-07-06  6:08           ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-06  6:08 UTC (permalink / raw)
  To: Valentin CARON, Mark Brown
  Cc: Krzysztof Kozlowski, Alexandre Torgue, Alain Volmat, linux-spi,
	linux-stm32, linux-arm-kernel, linux-kernel

On 05/07/2023 19:16, Valentin CARON wrote:
> Hi, Krzysztof
> 
> On 7/1/23 10:09, Krzysztof Kozlowski wrote:
>> On 28/06/2023 18:21, Valentin CARON wrote:
>>> Hi,
>>>
>>> On 6/27/23 15:39, Krzysztof Kozlowski wrote:
>>>> On 27/06/2023 14:39, Valentin Caron wrote:
>>>>> STM32 SPI driver is not capable to handle device mode with stm32f4 soc.
>>>>> Stop probing if this case happens, and print an error with involved
>>>>> compatible.
>>>>>
>>>> ...
>>>>
>>>>>    
>>>>>    static const struct of_device_id stm32_spi_of_match[] = {
>>>>> @@ -1798,8 +1802,16 @@ static int stm32_spi_probe(struct platform_device *pdev)
>>>>>    	struct device_node *np = pdev->dev.of_node;
>>>>>    	bool device_mode;
>>>>>    	int ret;
>>>>> +	const char *compatible =
>>>>> +		of_match_device(pdev->dev.driver->of_match_table, &pdev->dev)->compatible;
>>>> The goal was to replace it, so drop it.
>>> Is is still needed for dev_err, so I can't
>> Why do you need it for dev_err? Isn't it entirely redundant?
>>
>> Best regards,
>> Krzysztof
>>
> Only to have a clearer error message. To let know to user that spi 
> device is not available on this device.

It's obvious from the probe error.

> Right now, there is only one compatible where spi device can't be 
> enable. So I could use a static message. But this is not the best if a 
> new compatible is added.

It does not make sense. Compatible changes here nothing. It does not
matter whether your driver supports one or two devices. Not mentioning
that errors are printed with device ID.

Drop this code, it's entirely useless.

Best regards,
Krzysztof


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

* Re: [PATCH v2] spi: stm32: disable device mode with st,stm32f4-spi compatible
@ 2023-07-06  6:08           ` Krzysztof Kozlowski
  0 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-06  6:08 UTC (permalink / raw)
  To: Valentin CARON, Mark Brown
  Cc: Krzysztof Kozlowski, Alexandre Torgue, Alain Volmat, linux-spi,
	linux-stm32, linux-arm-kernel, linux-kernel

On 05/07/2023 19:16, Valentin CARON wrote:
> Hi, Krzysztof
> 
> On 7/1/23 10:09, Krzysztof Kozlowski wrote:
>> On 28/06/2023 18:21, Valentin CARON wrote:
>>> Hi,
>>>
>>> On 6/27/23 15:39, Krzysztof Kozlowski wrote:
>>>> On 27/06/2023 14:39, Valentin Caron wrote:
>>>>> STM32 SPI driver is not capable to handle device mode with stm32f4 soc.
>>>>> Stop probing if this case happens, and print an error with involved
>>>>> compatible.
>>>>>
>>>> ...
>>>>
>>>>>    
>>>>>    static const struct of_device_id stm32_spi_of_match[] = {
>>>>> @@ -1798,8 +1802,16 @@ static int stm32_spi_probe(struct platform_device *pdev)
>>>>>    	struct device_node *np = pdev->dev.of_node;
>>>>>    	bool device_mode;
>>>>>    	int ret;
>>>>> +	const char *compatible =
>>>>> +		of_match_device(pdev->dev.driver->of_match_table, &pdev->dev)->compatible;
>>>> The goal was to replace it, so drop it.
>>> Is is still needed for dev_err, so I can't
>> Why do you need it for dev_err? Isn't it entirely redundant?
>>
>> Best regards,
>> Krzysztof
>>
> Only to have a clearer error message. To let know to user that spi 
> device is not available on this device.

It's obvious from the probe error.

> Right now, there is only one compatible where spi device can't be 
> enable. So I could use a static message. But this is not the best if a 
> new compatible is added.

It does not make sense. Compatible changes here nothing. It does not
matter whether your driver supports one or two devices. Not mentioning
that errors are printed with device ID.

Drop this code, it's entirely useless.

Best regards,
Krzysztof


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2023-07-06  6:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-27 12:39 [PATCH v2] spi: stm32: disable device mode with st,stm32f4-spi compatible Valentin Caron
2023-06-27 12:39 ` Valentin Caron
2023-06-27 13:39 ` Krzysztof Kozlowski
2023-06-27 13:39   ` Krzysztof Kozlowski
2023-06-28 16:21   ` Valentin CARON
2023-06-28 16:21     ` Valentin CARON
2023-07-01  8:09     ` Krzysztof Kozlowski
2023-07-01  8:09       ` Krzysztof Kozlowski
2023-07-05 17:16       ` Valentin CARON
2023-07-05 17:16         ` Valentin CARON
2023-07-06  6:08         ` Krzysztof Kozlowski
2023-07-06  6:08           ` Krzysztof Kozlowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.