@@ -24,7 +24,7 @@ struct ufs_host {
24
24
void (* late_init )(struct ufs_hba * hba );
25
25
};
26
26
27
- enum {
27
+ enum intel_ufs_dsm_func_id {
28
28
INTEL_DSM_FNS = 0 ,
29
29
INTEL_DSM_RESET = 1 ,
30
30
};
@@ -42,6 +42,15 @@ static const guid_t intel_dsm_guid =
42
42
GUID_INIT (0x1A4832A0 , 0x7D03 , 0x43CA ,
43
43
0xB0 , 0x20 , 0xF6 , 0xDC , 0xD1 , 0x2A , 0x19 , 0x50 );
44
44
45
+ static bool __intel_dsm_supported (struct intel_host * host ,
46
+ enum intel_ufs_dsm_func_id fn )
47
+ {
48
+ return fn < 32 && fn >= 0 && (host -> dsm_fns & (1u << fn ));
49
+ }
50
+
51
+ #define INTEL_DSM_SUPPORTED (host , name ) \
52
+ __intel_dsm_supported(host, INTEL_DSM_##name)
53
+
45
54
static int __intel_dsm (struct intel_host * intel_host , struct device * dev ,
46
55
unsigned int fn , u32 * result )
47
56
{
@@ -71,7 +80,7 @@ static int __intel_dsm(struct intel_host *intel_host, struct device *dev,
71
80
static int intel_dsm (struct intel_host * intel_host , struct device * dev ,
72
81
unsigned int fn , u32 * result )
73
82
{
74
- if (fn > 31 || ! (intel_host -> dsm_fns & ( 1 << fn ) ))
83
+ if (! __intel_dsm_supported (intel_host , fn ))
75
84
return - EOPNOTSUPP ;
76
85
77
86
return __intel_dsm (intel_host , dev , fn , result );
@@ -300,7 +309,7 @@ static int ufs_intel_device_reset(struct ufs_hba *hba)
300
309
{
301
310
struct intel_host * host = ufshcd_get_variant (hba );
302
311
303
- if (host -> dsm_fns & INTEL_DSM_RESET ) {
312
+ if (INTEL_DSM_SUPPORTED ( host , RESET ) ) {
304
313
u32 result = 0 ;
305
314
int err ;
306
315
@@ -342,7 +351,7 @@ static int ufs_intel_common_init(struct ufs_hba *hba)
342
351
return - ENOMEM ;
343
352
ufshcd_set_variant (hba , host );
344
353
intel_dsm_init (host , hba -> dev );
345
- if (host -> dsm_fns & INTEL_DSM_RESET ) {
354
+ if (INTEL_DSM_SUPPORTED ( host , RESET ) ) {
346
355
if (hba -> vops -> device_reset )
347
356
hba -> caps |= UFSHCD_CAP_DEEPSLEEP ;
348
357
} else {
0 commit comments