Re: [PATCH 1/2] board: phytec: common: phytec_som_detection: Add phytec_get_som_type

2024-03-04 Thread Benjamin Hahn
On 04.03.24 15:42, Fabio Estevam wrote:
> On Mon, Mar 4, 2024 at 9:31 AM Benjamin Hahn  wrote:
>> Add a function that gets the som_type from the EEPROM.
>> Add an enum for the som_type.
>>
>> Signed-off-by: Benjamin Hahn 
> Your series does not even build:
>
> board/phytec/common/phytec_som_detection.c: In function ‘phytec_get_som_type’:
> board/phytec/common/phytec_som_detection.c:210:18: error: ‘struct
> phytec_eeprom_data’ has no member named ‘valid’
>210 | if (!data->valid || data->data.api_rev < PHYTEC_API_REV2)
>|  ^~
> board/phytec/common/phytec_som_detection.c:210:39: error: ‘union
> ’ has no member named ‘api_rev’
>210 | if (!data->valid || data->data.api_rev < PHYTEC_API_REV2)
>|   ^
> board/phytec/common/phytec_som_detection.c:213:26: error: ‘union
> ’ has no member named ‘data’
>213 | return data->data.data.data_api2.som_type;
>|  ^
> board/phytec/common/phytec_som_detection.c:214:1: warning: control
> reaches end of non-void function [-Wreturn-type]
>214 | }
>| ^

Oh, I'm very sorry about that. Seems like I made some mistakes when 
porting the patches to upstream.

I sent a v2, where I fixed them.

Benjamin



Re: [PATCH 1/2] board: phytec: common: phytec_som_detection: Add phytec_get_som_type

2024-03-04 Thread Fabio Estevam
On Mon, Mar 4, 2024 at 9:31 AM Benjamin Hahn  wrote:
>
> Add a function that gets the som_type from the EEPROM.
> Add an enum for the som_type.
>
> Signed-off-by: Benjamin Hahn 

Your series does not even build:

board/phytec/common/phytec_som_detection.c: In function ‘phytec_get_som_type’:
board/phytec/common/phytec_som_detection.c:210:18: error: ‘struct
phytec_eeprom_data’ has no member named ‘valid’
  210 | if (!data->valid || data->data.api_rev < PHYTEC_API_REV2)
  |  ^~
board/phytec/common/phytec_som_detection.c:210:39: error: ‘union
’ has no member named ‘api_rev’
  210 | if (!data->valid || data->data.api_rev < PHYTEC_API_REV2)
  |   ^
board/phytec/common/phytec_som_detection.c:213:26: error: ‘union
’ has no member named ‘data’
  213 | return data->data.data.data_api2.som_type;
  |  ^
board/phytec/common/phytec_som_detection.c:214:1: warning: control
reaches end of non-void function [-Wreturn-type]
  214 | }
  | ^


[PATCH 1/2] board: phytec: common: phytec_som_detection: Add phytec_get_som_type

2024-03-04 Thread Benjamin Hahn
Add a function that gets the som_type from the EEPROM.
Add an enum for the som_type.

Signed-off-by: Benjamin Hahn 
---
 board/phytec/common/phytec_som_detection.c | 10 ++
 board/phytec/common/phytec_som_detection.h |  8 
 2 files changed, 18 insertions(+)

diff --git a/board/phytec/common/phytec_som_detection.c 
b/board/phytec/common/phytec_som_detection.c
index c73bf9721b2f..eaf7659c051d 100644
--- a/board/phytec/common/phytec_som_detection.c
+++ b/board/phytec/common/phytec_som_detection.c
@@ -203,6 +203,16 @@ u8 __maybe_unused phytec_get_rev(struct phytec_eeprom_data 
*data)
return api2->pcb_rev;
 }
 
+u8 __maybe_unused phytec_get_som_type(struct phytec_eeprom_data *data)
+{
+   if (!data)
+   data = _data;
+   if (!data->valid || data->data.api_rev < PHYTEC_API_REV2)
+   return PHYTEC_EEPROM_INVAL;
+
+   return data->data.data.data_api2.som_type;
+}
+
 #else
 
 inline int phytec_eeprom_data_setup(struct phytec_eeprom_data *data,
diff --git a/board/phytec/common/phytec_som_detection.h 
b/board/phytec/common/phytec_som_detection.h
index 11009240875c..c0f0c57a6123 100644
--- a/board/phytec/common/phytec_som_detection.h
+++ b/board/phytec/common/phytec_som_detection.h
@@ -19,6 +19,13 @@ enum {
PHYTEC_API_REV2,
 };
 
+enum phytec_som_type_str {
+   PCM = 0,
+   PCL,
+   KSM,
+   KSP,
+};
+
 static const char * const phytec_som_type_str[] = {
"PCM",
"PCL",
@@ -67,5 +74,6 @@ void __maybe_unused phytec_print_som_info(struct 
phytec_eeprom_data *data);
 
 char * __maybe_unused phytec_get_opt(struct phytec_eeprom_data *data);
 u8 __maybe_unused phytec_get_rev(struct phytec_eeprom_data *data);
+u8 __maybe_unused phytec_get_som_type(struct phytec_eeprom_data *data);
 
 #endif /* _PHYTEC_SOM_DETECTION_H */

-- 
2.34.1