board: phytec: phytec_som_detection: Add missing assignment
PATCH 1/2 board: phytec: phytec_som_detection: Add missing assignment
Assign the return value of snprintf (total length) to a variable to properly check if the string has the correct length.
Currently, this variable is always zero and the length check after snprintf will always fail.
--- board/phytec/common/phytec_som_detection.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
board/phytec/common/phytec_som_detection.c +2 -2
@@ -346,8 +346,8 @@ static int phytec_get_part_number(struct phytec_eeprom_data *data,return 0 ; }if (api2->som_type <=3 ) { -snprintf (part,PHYTEC_PART_NUMBER_MAX_LEN +1 ,"%s.%s" , - product_name, api2->bom_rev); + len =snprintf (part,PHYTEC_PART_NUMBER_MAX_LEN +1 ,"%s.%s" , + product_name, api2->bom_rev);if (len !=PHYTEC_PART_NUMBER_KSP_LEN )return -EINVAL ;return 0 ;
Signature · 1 line
2.25.1
PATCH 2/2 board: phytec: phytec_som_detection: Add support for phyFLEX
phyFLEX are SoMs based on the FPSC standard.
Add addition "SOM types" for the phyFLEX modules base on the FPSC Gamma specifiction. These modules come in four differnt variants; prototypes (PT), standard product (SP), KSP (KP) and KSM (KM).
--- board/phytec/common/phytec_som_detection.c | 38 ++++++++++++++++++++-- board/phytec/common/phytec_som_detection.h | 8 +++-- 2 files changed, 41 insertions(+), 5 deletions(-)
board/phytec/common/phytec_som_detection.c +35 -3
@@ -308,14 +308,24 @@ static int phytec_get_product_name(struct phytec_eeprom_data *data,case 7 : som_type =1 ;break ; +case 8 : +case 9 : +case 10 : +case 11 : + som_type =SOM_TYPE_PFL_G ; +break ;default :pr_err ("%s: Invalid SOM type: %i\n" , __func__, api2->som_type);return -EINVAL ; }; - len =snprintf (product,PHYTEC_PRODUCT_NAME_MAX_LEN +1 ,"%s-%03u" , +const char *fmt = (som_type ==SOM_TYPE_PFL_G ) ?"%s-%02u" :"%s-%03u" ; + + len =snprintf (product,PHYTEC_PRODUCT_NAME_MAX_LEN +1 , fmt, phytec_som_type_str[som_type], api2->som_no); -if (len !=PHYTEC_PRODUCT_NAME_STD_LEN ) +if (som_type !=SOM_TYPE_PFL_G && len !=PHYTEC_PRODUCT_NAME_PCX_LEN ) +return -EINVAL ; +if (som_type ==SOM_TYPE_PFL_G && len !=PHYTEC_PRODUCT_NAME_PFL_LEN )return -EINVAL ;return 0 ; }
@@ -327,6 +337,7 @@ static int phytec_get_part_number(struct phytec_eeprom_data *data,struct phytec_api2_data *api2;unsigned int ksp_type;int res, len; +char *variant ="SP" ;if (!data->valid || data->payload.api_rev <PHYTEC_API_REV2 )return -EINVAL ;
@@ -341,7 +352,7 @@ static int phytec_get_part_number(struct phytec_eeprom_data *data, len =snprintf (part,PHYTEC_PART_NUMBER_MAX_LEN +1 ,"%s-%s.%s" , product_name, api2->opt, api2->bom_rev); -if (len <PHYTEC_PART_NUMBER_STD_LEN ) +if (len <PHYTEC_PART_NUMBER_PCX_LEN )return -EINVAL ;return 0 ; }
@@ -353,6 +364,27 @@ static int phytec_get_part_number(struct phytec_eeprom_data *data,return 0 ; } +if (api2->som_type >=8 && api2->som_type <=11 ) { +switch (api2->som_type) { +case 8 : + variant ="PT" ; +break ; +case 10 : + variant ="KP" ; +break ; +case 11 : + variant ="KM" ; +break ; + } + + len =snprintf (part,PHYTEC_PART_NUMBER_MAX_LEN +1 , +"%s-%s%03u.%s" , product_name, variant, + api2->ksp_no, api2->bom_rev); +if (len !=PHYTEC_PART_NUMBER_PFL_LEN ) +return -EINVAL ; +return 0 ; + } +switch (api2->som_type) {case 4 : ksp_type =3 ;
board/phytec/common/phytec_som_detection.h +6 -2
@@ -18,10 +18,12 @@#define PHYTEC_GET_OPTION (option) \ (((option) > '9') ? (option) - 'A' + 10 : (option) - '0') -#define PHYTEC_PRODUCT_NAME_STD_LEN 7 // PCx-000 +#define PHYTEC_PRODUCT_NAME_PCX_LEN 7 // PCx-000 +#define PHYTEC_PRODUCT_NAME_PFL_LEN 8 // PFL-x-00#define PHYTEC_PRODUCT_NAME_KSP_LEN 8 // KSP-0000#define PHYTEC_PRODUCT_NAME_MAX_LEN PHYTEC_PRODUCT_NAME_KSP_LEN -#define PHYTEC_PART_NUMBER_STD_LEN 11 // PCx-000-\w{1,17}.Ax +#define PHYTEC_PART_NUMBER_PCX_LEN 11 // PCx-000-\w{1,17}.Ax +#define PHYTEC_PART_NUMBER_PFL_LEN 17 // PFL-x-00-xx000.Ax#define PHYTEC_PART_NUMBER_KSP_LEN 11 // KSP-0000.Ax#define PHYTEC_PART_NUMBER_STD_KSP_LEN 16 // PCx-000-KSx00.Ax#define PHYTEC_PART_NUMBER_MAX_LEN PHYTEC_PRODUCT_NAME_MAX_LEN + 21
@@ -38,6 +40,7 @@ enum phytec_som_type_str {SOM_TYPE_PCL ,SOM_TYPE_KSM ,SOM_TYPE_KSP , + SOM_TYPE_PFL_G, }; static const char * const phytec_som_type_str[] = {
@@ -45,6 +48,7 @@ static const char * const phytec_som_type_str[] = {"PCL" ,"KSM" ,"KSP" , + "PFL-G", }; struct phytec_api0_data {
Signature · 1 line
2.25.1
Re: [Upstream] [PATCH 2/2] board: phytec: phytec_som_detection: Add support for phyFLEX
Hello Daniel,
Am Montag, dem 10.11.2025 um 05:52 -0800 schrieb Daniel Schultz:
Quoted 4 lines
phyFLEX are SoMs based on the FPSC standard.
Add addition "SOM types" for the phyFLEX modules base on the FPSC Gamma specifiction. These modules come in four differnt
here are typos in the commit message s/specifiction/specification and s/differnt/different
besides that it looks good.
Quoted 135 lines
variants; prototypes (PT), standard product (SP), KSP (KP) and KSM (KM).
Signed-off-by Daniel Schultz <[email protected]>---
board/phytec/common/phytec_som_detection.c | 38
++++++++++++++++++++--
board/phytec/common/phytec_som_detection.h | 8 +++--2 files changed, 41 insertions(+), 5 deletions(-)board/phytec/common/phytec_som_detection.c +0
-0@@ -308,14 +308,24 @@ static int phytec_get_product_name(struct phytec_eeprom_data *data,case 7:
som_type = 1;
break;
+ case 8:
+ case 9:
+ case 10:
+ case 11:
+ som_type =SOM_TYPE_PFL_G;
+ break;
default:
pr_err("%s: Invalid SOM type: %i\n",__func__, api2-Quoted 1 line
som_type);return
-EINVAL;
};
- len = snprintf(product,PHYTEC_PRODUCT_NAME_MAX_LEN+ 1, "%s- %03u",
+ const char *fmt = (som_type==SOM_TYPE_PFL_G) ? "%s-%02u" :
"%s-%03u";
+
+ len =snprintf(product, PHYTEC_PRODUCT_NAME_MAX_LEN + 1, fmt, phytec_som_type_str[som_type], api2->som_no); - if (len !=PHYTEC_PRODUCT_NAME_STD_LEN)
+ if (som_type!=SOM_TYPE_PFL_G&& len !=PHYTEC_PRODUCT_NAME_PCX_LEN)
+ return-EINVAL;
+ if (som_type==SOM_TYPE_PFL_G&& len !=PHYTEC_PRODUCT_NAME_PFL_LEN)
return-EINVAL;
return 0;
}board/phytec/common/phytec_som_detection.c +1
-0@@ -327,6 +337,7 @@ static int phytec_get_part_number(struct phytec_eeprom_data *data, struct phytec_api2_data *api2; unsigned int ksp_type; int res, len; + char *variant = "SP";
if (!data->valid ||data->payload.api_rev<PHYTEC_API_REV2) return-EINVAL;board/phytec/common/phytec_som_detection.c +1
-1@@ -341,7 +352,7 @@ static int phytec_get_part_number(structphytec_eeprom_data *data, len = snprintf(part, PHYTEC_PART_NUMBER_MAX_LEN + 1, "%s-%s.%s", product_name, api2->opt, api2->bom_rev); - if (len < PHYTEC_PART_NUMBER_STD_LEN) + if (len < PHYTEC_PART_NUMBER_PCX_LEN) return -EINVAL; return 0;}
board/phytec/common/phytec_som_detection.c +0
-0@@ -353,6 +364,27 @@ static int phytec_get_part_number(struct phytec_eeprom_data *data, return 0; }
+ if (api2->som_type>= 8 &&api2->som_type<= 11) { + switch (api2->som_type) {
+ case 8:
+ variant = "PT";
+ break;
+ case 10:
+ variant = "KP";
+ break;
+ case 11:
+ variant = "KM";
+ break;
+ }board/phytec/common/phytec_som_detection.c +9
-0+ + len = snprintf(part, PHYTEC_PART_NUMBER_MAX_LEN + 1, + "%s-%s%03u.%s", product_name, variant, + api2->ksp_no, api2->bom_rev); + if (len != PHYTEC_PART_NUMBER_PFL_LEN) + return -EINVAL; + return 0; + } +switch (
api2->som_type) {
case 4:
ksp_type = 3;board/phytec/common/phytec_som_detection.h +0
-0@@ -18,10 +18,12 @@ #define PHYTEC_GET_OPTION(option) \ (((option) > '9') ? (option) - 'A' + 10 : (option) - '0')board/phytec/common/phytec_som_detection.h +2
-1-#define PHYTEC_PRODUCT_NAME_STD_LEN 7 // PCx-000 +#define PHYTEC_PRODUCT_NAME_PCX_LEN 7 // PCx-000 +#define PHYTEC_PRODUCT_NAME_PFL_LEN 8 // PFL-x-00#define PHYTEC_PRODUCT_NAME_KSP_LEN 8 // KSP-0000 #define PHYTEC_PRODUCT_NAME_MAX_LEN PHYTEC_PRODUCT_NAME_KSP_LEN -#define PHYTEC_PART_NUMBER_STD_LEN 11 // PCx-000- \w{1,17}.Ax
+#define PHYTEC_PART_NUMBER_PCX_LEN 11 // PCx-000- \w{1,17}.Ax
+#define PHYTEC_PART_NUMBER_PFL_LEN 17 // PFL-x-00-xx000.Ax #define PHYTEC_PART_NUMBER_KSP_LEN 11 // KSP-0000.Ax #define PHYTEC_PART_NUMBER_STD_KSP_LEN 16 // PCx-000-KSx00.Ax #define PHYTEC_PART_NUMBER_MAX_LEN PHYTEC_PRODUCT_NAME_MAX_LEN + 21board/phytec/common/phytec_som_detection.h +1
-0@@ -38,6 +40,7 @@ enum phytec_som_type_str { SOM_TYPE_PCL, SOM_TYPE_KSM, SOM_TYPE_KSP, + SOM_TYPE_PFL_G, };
static const char * const phytec_som_type_str[] = {board/phytec/common/phytec_som_detection.h +1
-0@@ -45,6 +48,7 @@ static const char * const phytec_som_type_str[] = { "PCL", "KSM", "KSP", + "PFL-G", };
structphytec_api0_data{
Signature · 5 lines
PHYTEC Messtechnik GmbH | Barcelona-Allee 1 | 55129 Mainz, Germany Geschäftsführer: Dipl.-Ing. Michael Mitezki, Dipl.-Ing. Bodo Huber, Dipl.-Ing. (FH) Markus Lickes | Handelsregister Mainz HRB 4656 | Finanzamt Mainz | St.Nr. 26/665/00608, DE 149059855
Re: [Upstream] [PATCH 2/2] board: phytec: phytec_som_detection: Add support for phyFLEX
In reply to Daniel SchultzHi Daniel,
the phyFLEX-AM62Lx is not upstream yet but since our som detection is in sync with upstream:
Quoted 141 lines · Daniel Schultz
phyFLEX are SoMs based on the FPSC standard.
Add addition "SOM types" for the phyFLEX modules base on the FPSC Gamma specifiction. These modules come in four differnt variants; prototypes (PT), standard product (SP), KSP (KP) and KSM (KM).
Signed-off-by Daniel Schultz <[email protected]>---
board/phytec/common/phytec_som_detection.c | 38
++++++++++++++++++++--
board/phytec/common/phytec_som_detection.h | 8 +++--2 files changed, 41 insertions(+), 5 deletions(-)board/phytec/common/phytec_som_detection.c +0
-0@@ -308,14 +308,24 @@ static int phytec_get_product_name(struct phytec_eeprom_data *data,case 7:
som_type= 1;
break;board/phytec/common/phytec_som_detection.c +6
-0+case 8 : +case 9 : +case 10 : +case 11 : + som_type =SOM_TYPE_PFL_G ; +break ;default:
pr_err("%s: Invalid SOM type: %i\n",__func__, api2-Quoted 1 line
som_type);return
-EINVAL;
};board/phytec/common/phytec_som_detection.c +0
-1- len = snprintf(product, PHYTEC_PRODUCT_NAME_MAX_LEN + 1,"%s-%03u",
board/phytec/common/phytec_som_detection.c +1
-0+ const char *fmt = (som_type == SOM_TYPE_PFL_G) ? "%s-%02u" :"%s-%03u";
board/phytec/common/phytec_som_detection.c +2
-0+ + len = snprintf(product, PHYTEC_PRODUCT_NAME_MAX_LEN + 1,fmt,
phytec_som_type_str[som_type],api2->som_no);board/phytec/common/phytec_som_detection.c +1
-1-if (len !=PHYTEC_PRODUCT_NAME_STD_LEN ) + if (som_type != SOM_TYPE_PFL_G && len !=
PHYTEC_PRODUCT_NAME_PCX_LEN)board/phytec/common/phytec_som_detection.c +2
-0+return -EINVAL ; + if (som_type == SOM_TYPE_PFL_G && len !=
PHYTEC_PRODUCT_NAME_PFL_LEN)
return-EINVAL;
return 0;
}board/phytec/common/phytec_som_detection.c +1
-0@@ -327,6 +337,7 @@ static int phytec_get_part_number(struct phytec_eeprom_data *data, struct phytec_api2_data *api2; unsigned int ksp_type; int res, len; +char *variant ="SP" ;
if (!data->valid ||data->payload.api_rev<PHYTEC_API_REV2) return-EINVAL;board/phytec/common/phytec_som_detection.c +1
-1@@ -341,7 +352,7 @@ static int phytec_get_part_number(structphytec_eeprom_data *data, len = snprintf(part, PHYTEC_PART_NUMBER_MAX_LEN + 1, "%s-%s.%s", product_name, api2->opt, api2->bom_rev); -if (len <PHYTEC_PART_NUMBER_STD_LEN ) +if (len <PHYTEC_PART_NUMBER_PCX_LEN ) return -EINVAL; return 0;}
board/phytec/common/phytec_som_detection.c +0
-0@@ -353,6 +364,27 @@ static int phytec_get_part_number(struct phytec_eeprom_data *data, return 0; }board/phytec/common/phytec_som_detection.c +15
-0+if (api2->som_type >=8 && api2->som_type <=11 ) { +switch (api2->som_type) { +case 8 : + variant ="PT" ; +break ; +case 10 : + variant ="KP" ; +break ; +case 11 : + variant ="KM" ; +break ; + } + + len = snprintf(part, PHYTEC_PART_NUMBER_MAX_LEN + 1, + "%s-%s%03u.%s", product_name,variant,
board/phytec/common/phytec_som_detection.c +6
-0+ api2->ksp_no, api2->bom_rev); +if (len !=PHYTEC_PART_NUMBER_PFL_LEN ) +return -EINVAL ; +return 0 ; + } +switch (
api2->som_type) {
case 4:
ksp_type= 3;board/phytec/common/phytec_som_detection.h +0
-0@@ -18,10 +18,12 @@ #define PHYTEC_GET_OPTION(option) \ (((option) > '9') ? (option) - 'A' + 10 : (option) - '0')board/phytec/common/phytec_som_detection.h +2
-1-#define PHYTEC_PRODUCT_NAME_STD_LEN 7 // PCx-000 +#define PHYTEC_PRODUCT_NAME_PCX_LEN 7 // PCx-000 +#define PHYTEC_PRODUCT_NAME_PFL_LEN 8 // PFL-x-00#define
PHYTEC_PRODUCT_NAME_KSP_LEN8 // KSP-0000
#definePHYTEC_PRODUCT_NAME_MAX_LENPHYTEC_PRODUCT_NAME_KSP_LEN
-#definePHYTEC_PART_NUMBER_STD_LEN11 // PCx-000-
\w{1,17}.Ax
+#definePHYTEC_PART_NUMBER_PCX_LEN11 // PCx-000-
\w{1,17}.Ax
+#definePHYTEC_PART_NUMBER_PFL_LEN17 // PFL-x-00-xx000.Ax
#definePHYTEC_PART_NUMBER_KSP_LEN11 // KSP-0000.Ax
#definePHYTEC_PART_NUMBER_STD_KSP_LEN16 // PCx-000-KSx00.Ax
#definePHYTEC_PART_NUMBER_MAX_LENPHYTEC_PRODUCT_NAME_MAX_LEN
+ 21board/phytec/common/phytec_som_detection.h +1
-0@@ -38,6 +40,7 @@ enum phytec_som_type_str { SOM_TYPE_PCL, SOM_TYPE_KSM, SOM_TYPE_KSP, + SOM_TYPE_PFL_G, };
static const char * const phytec_som_type_str[] = {board/phytec/common/phytec_som_detection.h +1
-0@@ -45,6 +48,7 @@ static const char * const phytec_som_type_str[] = { "PCL", "KSM", "KSP", + "PFL-G", };
structphytec_api0_data{