@@ -299,9 +299,17 @@ static int firehose_configure_response_parser(xmlNode *node, void *data, bool *r
299299}
300300
301301static int firehose_send_configure (struct qdl_device * qdl , size_t payload_size ,
302- bool skip_storage_init , const char * storage ,
302+ bool skip_storage_init ,
303+ enum qdl_storage_type storage ,
303304 size_t * max_payload_size )
304305{
306+ static const char * const memory_names [] = {
307+ [QDL_STORAGE_EMMC ] = "emmc" ,
308+ [QDL_STORAGE_NAND ] = "nand" ,
309+ [QDL_STORAGE_UFS ] = "ufs" ,
310+ [QDL_STORAGE_NVME ] = "nvme" ,
311+ [QDL_STORAGE_SPINOR ] = "spinor" ,
312+ };
305313 xmlNode * root ;
306314 xmlNode * node ;
307315 xmlDoc * doc ;
@@ -311,7 +319,7 @@ static int firehose_send_configure(struct qdl_device *qdl, size_t payload_size,
311319 xmlDocSetRootElement (doc , root );
312320
313321 node = xmlNewChild (root , NULL , (xmlChar * )"configure" , NULL );
314- xml_setpropf (node , "MemoryName" , storage );
322+ xml_setpropf (node , "MemoryName" , memory_names [ storage ] );
315323 xml_setpropf (node , "MaxPayloadSizeToTargetInBytes" , "%lu" , payload_size );
316324 xml_setpropf (node , "verbose" , "%d" , 0 );
317325 xml_setpropf (node , "ZLPAwareHost" , "%d" , 1 );
@@ -324,7 +332,7 @@ static int firehose_send_configure(struct qdl_device *qdl, size_t payload_size,
324332}
325333
326334static int firehose_try_configure (struct qdl_device * qdl , bool skip_storage_init ,
327- const char * storage )
335+ enum qdl_storage_type storage )
328336{
329337 size_t max_sector_size ;
330338 size_t sector_sizes [] = { 512 , 4096 };
@@ -359,7 +367,7 @@ static int firehose_try_configure(struct qdl_device *qdl, bool skip_storage_init
359367
360368 ux_debug ("accepted max payload size: %zu\n" , qdl -> max_payload_size );
361369
362- if (strcmp ( storage , "nand" ) ) {
370+ if (storage != QDL_STORAGE_NAND ) {
363371 max_sector_size = sector_sizes [ARRAY_SIZE (sector_sizes ) - 1 ];
364372 buf = malloc (max_sector_size );
365373 memset (& op , 0 , sizeof (op ));
@@ -560,7 +568,7 @@ static int firehose_program(struct qdl_device *qdl, struct program *program, int
560568
561569 vip_transfer_clear_status (qdl );
562570 }
563- n = qdl_write (qdl , buf , chunk_size * sector_size , 10000 );
571+ n = qdl_write (qdl , buf , chunk_size * sector_size , 30000 );
564572 if (n < 0 ) {
565573 ux_err ("USB write failed for data chunk\n" );
566574 ret = firehose_read (qdl , 30000 , firehose_generic_parser , NULL );
@@ -929,7 +937,7 @@ static int firehose_reset(struct qdl_device *qdl)
929937
930938static int firehose_detect_and_configure (struct qdl_device * qdl ,
931939 bool skip_storage_init ,
932- const char * storage ,
940+ enum qdl_storage_type storage ,
933941 unsigned int timeout_s )
934942{
935943 struct timeval timeout = { .tv_sec = timeout_s };
@@ -962,7 +970,7 @@ int firehose_provision(struct qdl_device *qdl)
962970{
963971 int ret ;
964972
965- ret = firehose_detect_and_configure (qdl , true, "ufs" , 5 );
973+ ret = firehose_detect_and_configure (qdl , true, QDL_STORAGE_UFS , 5 );
966974 if (ret )
967975 return ret ;
968976
@@ -980,7 +988,7 @@ int firehose_provision(struct qdl_device *qdl)
980988
981989}
982990
983- int firehose_run (struct qdl_device * qdl , const char * storage )
991+ int firehose_run (struct qdl_device * qdl , enum qdl_storage_type storage )
984992{
985993 bool multiple ;
986994 int bootable ;
0 commit comments