@@ -358,15 +358,20 @@ static int scmi_sensor_update_intervals(const struct scmi_protocol_handle *ph,
358
358
return ph -> hops -> iter_response_run (iter );
359
359
}
360
360
361
+ struct scmi_apriv {
362
+ bool any_axes_support_extended_names ;
363
+ struct scmi_sensor_info * s ;
364
+ };
365
+
361
366
static void iter_axes_desc_prepare_message (void * message ,
362
367
const unsigned int desc_index ,
363
368
const void * priv )
364
369
{
365
370
struct scmi_msg_sensor_axis_description_get * msg = message ;
366
- const struct scmi_sensor_info * s = priv ;
371
+ const struct scmi_apriv * apriv = priv ;
367
372
368
373
/* Set the number of sensors to be skipped/already read */
369
- msg -> id = cpu_to_le32 (s -> id );
374
+ msg -> id = cpu_to_le32 (apriv -> s -> id );
370
375
msg -> axis_desc_index = cpu_to_le32 (desc_index );
371
376
}
372
377
@@ -393,12 +398,14 @@ iter_axes_desc_process_response(const struct scmi_protocol_handle *ph,
393
398
u32 attrh , attrl ;
394
399
struct scmi_sensor_axis_info * a ;
395
400
size_t dsize = SCMI_MSG_RESP_AXIS_DESCR_BASE_SZ ;
396
- struct scmi_sensor_info * s = priv ;
401
+ struct scmi_apriv * apriv = priv ;
397
402
const struct scmi_axis_descriptor * adesc = st -> priv ;
398
403
399
404
attrl = le32_to_cpu (adesc -> attributes_low );
405
+ if (SUPPORTS_EXTENDED_AXIS_NAMES (attrl ))
406
+ apriv -> any_axes_support_extended_names = true;
400
407
401
- a = & s -> axis [st -> desc_index + st -> loop_idx ];
408
+ a = & apriv -> s -> axis [st -> desc_index + st -> loop_idx ];
402
409
a -> id = le32_to_cpu (adesc -> id );
403
410
a -> extended_attrs = SUPPORTS_EXTEND_ATTRS (attrl );
404
411
@@ -444,10 +451,19 @@ iter_axes_extended_name_process_response(const struct scmi_protocol_handle *ph,
444
451
void * priv )
445
452
{
446
453
struct scmi_sensor_axis_info * a ;
447
- const struct scmi_sensor_info * s = priv ;
454
+ const struct scmi_apriv * apriv = priv ;
448
455
struct scmi_sensor_axis_name_descriptor * adesc = st -> priv ;
456
+ u32 axis_id = le32_to_cpu (adesc -> axis_id );
457
+
458
+ if (axis_id >= st -> max_resources )
459
+ return - EPROTO ;
449
460
450
- a = & s -> axis [st -> desc_index + st -> loop_idx ];
461
+ /*
462
+ * Pick the corresponding descriptor based on the axis_id embedded
463
+ * in the reply since the list of axes supporting extended names
464
+ * can be a subset of all the axes.
465
+ */
466
+ a = & apriv -> s -> axis [axis_id ];
451
467
strscpy (a -> name , adesc -> name , SCMI_MAX_STR_SIZE );
452
468
st -> priv = ++ adesc ;
453
469
@@ -458,21 +474,36 @@ static int
458
474
scmi_sensor_axis_extended_names_get (const struct scmi_protocol_handle * ph ,
459
475
struct scmi_sensor_info * s )
460
476
{
477
+ int ret ;
461
478
void * iter ;
462
479
struct scmi_iterator_ops ops = {
463
480
.prepare_message = iter_axes_desc_prepare_message ,
464
481
.update_state = iter_axes_extended_name_update_state ,
465
482
.process_response = iter_axes_extended_name_process_response ,
466
483
};
484
+ struct scmi_apriv apriv = {
485
+ .any_axes_support_extended_names = false,
486
+ .s = s ,
487
+ };
467
488
468
489
iter = ph -> hops -> iter_response_init (ph , & ops , s -> num_axis ,
469
490
SENSOR_AXIS_NAME_GET ,
470
491
sizeof (struct scmi_msg_sensor_axis_description_get ),
471
- s );
492
+ & apriv );
472
493
if (IS_ERR (iter ))
473
494
return PTR_ERR (iter );
474
495
475
- return ph -> hops -> iter_response_run (iter );
496
+ /*
497
+ * Do not cause whole protocol initialization failure when failing to
498
+ * get extended names for axes.
499
+ */
500
+ ret = ph -> hops -> iter_response_run (iter );
501
+ if (ret )
502
+ dev_warn (ph -> dev ,
503
+ "Failed to get axes extended names for %s (ret:%d).\n" ,
504
+ s -> name , ret );
505
+
506
+ return 0 ;
476
507
}
477
508
478
509
static int scmi_sensor_axis_description (const struct scmi_protocol_handle * ph ,
@@ -486,6 +517,10 @@ static int scmi_sensor_axis_description(const struct scmi_protocol_handle *ph,
486
517
.update_state = iter_axes_desc_update_state ,
487
518
.process_response = iter_axes_desc_process_response ,
488
519
};
520
+ struct scmi_apriv apriv = {
521
+ .any_axes_support_extended_names = false,
522
+ .s = s ,
523
+ };
489
524
490
525
s -> axis = devm_kcalloc (ph -> dev , s -> num_axis ,
491
526
sizeof (* s -> axis ), GFP_KERNEL );
@@ -495,15 +530,16 @@ static int scmi_sensor_axis_description(const struct scmi_protocol_handle *ph,
495
530
iter = ph -> hops -> iter_response_init (ph , & ops , s -> num_axis ,
496
531
SENSOR_AXIS_DESCRIPTION_GET ,
497
532
sizeof (struct scmi_msg_sensor_axis_description_get ),
498
- s );
533
+ & apriv );
499
534
if (IS_ERR (iter ))
500
535
return PTR_ERR (iter );
501
536
502
537
ret = ph -> hops -> iter_response_run (iter );
503
538
if (ret )
504
539
return ret ;
505
540
506
- if (PROTOCOL_REV_MAJOR (version ) >= 0x3 )
541
+ if (PROTOCOL_REV_MAJOR (version ) >= 0x3 &&
542
+ apriv .any_axes_support_extended_names )
507
543
ret = scmi_sensor_axis_extended_names_get (ph , s );
508
544
509
545
return ret ;
0 commit comments