lib: sbi: Optimize probe of srst/susp
No need to do a fully comprehensive count, just find a supported reset or suspend type Signed-off-by: Xiang W <wxjstz@126.com> Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
parent
8b952d4fcd
commit
767b5fc418
|
@ -50,7 +50,7 @@ static int sbi_ecall_srst_handler(unsigned long extid, unsigned long funcid,
|
||||||
|
|
||||||
static int sbi_ecall_srst_probe(unsigned long extid, unsigned long *out_val)
|
static int sbi_ecall_srst_probe(unsigned long extid, unsigned long *out_val)
|
||||||
{
|
{
|
||||||
u32 type, count = 0;
|
u32 type;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* At least one standard reset types should be supported by
|
* At least one standard reset types should be supported by
|
||||||
|
@ -59,11 +59,13 @@ static int sbi_ecall_srst_probe(unsigned long extid, unsigned long *out_val)
|
||||||
|
|
||||||
for (type = 0; type <= SBI_SRST_RESET_TYPE_LAST; type++) {
|
for (type = 0; type <= SBI_SRST_RESET_TYPE_LAST; type++) {
|
||||||
if (sbi_system_reset_supported(type,
|
if (sbi_system_reset_supported(type,
|
||||||
SBI_SRST_RESET_REASON_NONE))
|
SBI_SRST_RESET_REASON_NONE)) {
|
||||||
count++;
|
*out_val = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*out_val = (count) ? 1 : 0;
|
*out_val = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,18 +25,20 @@ static int sbi_ecall_susp_handler(unsigned long extid, unsigned long funcid,
|
||||||
|
|
||||||
static int sbi_ecall_susp_probe(unsigned long extid, unsigned long *out_val)
|
static int sbi_ecall_susp_probe(unsigned long extid, unsigned long *out_val)
|
||||||
{
|
{
|
||||||
u32 type, count = 0;
|
u32 type;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* At least one suspend type should be supported by the
|
* At least one suspend type should be supported by the
|
||||||
* platform for the SBI SUSP extension to be usable.
|
* platform for the SBI SUSP extension to be usable.
|
||||||
*/
|
*/
|
||||||
for (type = 0; type <= SBI_SUSP_SLEEP_TYPE_LAST; type++) {
|
for (type = 0; type <= SBI_SUSP_SLEEP_TYPE_LAST; type++) {
|
||||||
if (sbi_system_suspend_supported(type))
|
if (sbi_system_suspend_supported(type)) {
|
||||||
count++;
|
*out_val = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*out_val = count ? 1 : 0;
|
*out_val = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue