Skip to content

Commit 7b487be

Browse files
cris-masudeep-holla
authored andcommitted
firmware: arm_scmi: quirk: Fix CLOCK_DESCRIBE_RATES triplet
Convert an existing quirk in CLOCK_DESCRIBE_RATES parsing to the new quirk framework. This is a sort of a peculiar quirk since it matches any platform and any firmware. Signed-off-by: Cristian Marussi <[email protected]> Message-Id: <[email protected]> Signed-off-by: Sudeep Holla <[email protected]>
1 parent 487c407 commit 7b487be

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

drivers/firmware/arm_scmi/clock.c

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "protocols.h"
1313
#include "notify.h"
14+
#include "quirks.h"
1415

1516
/* Updated only after ALL the mandatory features for that version are merged */
1617
#define SCMI_PROTOCOL_SUPPORTED_VERSION 0x30000
@@ -429,6 +430,23 @@ static void iter_clk_describe_prepare_message(void *message,
429430
msg->rate_index = cpu_to_le32(desc_index);
430431
}
431432

433+
#define QUIRK_OUT_OF_SPEC_TRIPLET \
434+
({ \
435+
/* \
436+
* A known quirk: a triplet is returned but num_returned != 3 \
437+
* Check for a safe payload size and fix. \
438+
*/ \
439+
if (st->num_returned != 3 && st->num_remaining == 0 && \
440+
st->rx_len == sizeof(*r) + sizeof(__le32) * 2 * 3) { \
441+
st->num_returned = 3; \
442+
st->num_remaining = 0; \
443+
} else { \
444+
dev_err(p->dev, \
445+
"Cannot fix out-of-spec reply !\n"); \
446+
return -EPROTO; \
447+
} \
448+
})
449+
432450
static int
433451
iter_clk_describe_update_state(struct scmi_iterator_state *st,
434452
const void *response, void *priv)
@@ -450,19 +468,8 @@ iter_clk_describe_update_state(struct scmi_iterator_state *st,
450468
p->clk->name, st->num_returned, st->num_remaining,
451469
st->rx_len);
452470

453-
/*
454-
* A known quirk: a triplet is returned but num_returned != 3
455-
* Check for a safe payload size and fix.
456-
*/
457-
if (st->num_returned != 3 && st->num_remaining == 0 &&
458-
st->rx_len == sizeof(*r) + sizeof(__le32) * 2 * 3) {
459-
st->num_returned = 3;
460-
st->num_remaining = 0;
461-
} else {
462-
dev_err(p->dev,
463-
"Cannot fix out-of-spec reply !\n");
464-
return -EPROTO;
465-
}
471+
SCMI_QUIRK(clock_rates_triplet_out_of_spec,
472+
QUIRK_OUT_OF_SPEC_TRIPLET);
466473
}
467474

468475
return 0;

drivers/firmware/arm_scmi/quirks.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ struct scmi_quirk {
169169
__DEFINE_SCMI_QUIRK_ENTRY(_qn, _ven, _sub, _impl, ##__VA_ARGS__)
170170

171171
/* Global Quirks Definitions */
172+
DEFINE_SCMI_QUIRK(clock_rates_triplet_out_of_spec, NULL, NULL, NULL);
172173

173174
/*
174175
* Quirks Pointers Array
@@ -177,6 +178,7 @@ struct scmi_quirk {
177178
* defined quirks descriptors.
178179
*/
179180
static struct scmi_quirk *scmi_quirks_table[] = {
181+
__DECLARE_SCMI_QUIRK_ENTRY(clock_rates_triplet_out_of_spec),
180182
NULL
181183
};
182184

drivers/firmware/arm_scmi/quirks.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,7 @@ static inline void scmi_quirks_enable(struct device *dev, const char *vend,
4545

4646
#endif /* CONFIG_ARM_SCMI_QUIRKS */
4747

48+
/* Quirk delarations */
49+
DECLARE_SCMI_QUIRK(clock_rates_triplet_out_of_spec);
50+
4851
#endif /* _SCMI_QUIRKS_H */

0 commit comments

Comments
 (0)