Skip to content

Commit 5eaed68

Browse files
Max Gurtovoyaxboe
authored andcommitted
block: use symbolic constants for t10_pi type
Replace all hard-coded values with T10_PI_TYPES to make the code more readable. Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Max Gurtovoy <maxg@mellanox.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 7ad67ca commit 5eaed68

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

‎block/t10-pi.c‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static __be16 t10_pi_ip_fn(void *data, unsigned int len)
2727
* tag.
2828
*/
2929
static blk_status_t t10_pi_generate(struct blk_integrity_iter *iter,
30-
csum_fn *fn, unsigned int type)
30+
csum_fn *fn, enum t10_dif_type type)
3131
{
3232
unsigned int i;
3333

@@ -37,7 +37,7 @@ static blk_status_t t10_pi_generate(struct blk_integrity_iter *iter,
3737
pi->guard_tag = fn(iter->data_buf, iter->interval);
3838
pi->app_tag = 0;
3939

40-
if (type == 1)
40+
if (type == T10_PI_TYPE1_PROTECTION)
4141
pi->ref_tag = cpu_to_be32(lower_32_bits(iter->seed));
4242
else
4343
pi->ref_tag = 0;
@@ -51,7 +51,7 @@ static blk_status_t t10_pi_generate(struct blk_integrity_iter *iter,
5151
}
5252

5353
static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter,
54-
csum_fn *fn, unsigned int type)
54+
csum_fn *fn, enum t10_dif_type type)
5555
{
5656
unsigned int i;
5757

@@ -60,8 +60,8 @@ static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter,
6060
__be16 csum;
6161

6262
switch (type) {
63-
case 1:
64-
case 2:
63+
case T10_PI_TYPE1_PROTECTION:
64+
case T10_PI_TYPE2_PROTECTION:
6565
if (pi->app_tag == T10_PI_APP_ESCAPE)
6666
goto next;
6767

@@ -74,7 +74,7 @@ static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter,
7474
return BLK_STS_PROTECTION;
7575
}
7676
break;
77-
case 3:
77+
case T10_PI_TYPE3_PROTECTION:
7878
if (pi->app_tag == T10_PI_APP_ESCAPE &&
7979
pi->ref_tag == T10_PI_REF_ESCAPE)
8080
goto next;
@@ -102,42 +102,42 @@ static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter,
102102

103103
static blk_status_t t10_pi_type1_generate_crc(struct blk_integrity_iter *iter)
104104
{
105-
return t10_pi_generate(iter, t10_pi_crc_fn, 1);
105+
return t10_pi_generate(iter, t10_pi_crc_fn, T10_PI_TYPE1_PROTECTION);
106106
}
107107

108108
static blk_status_t t10_pi_type1_generate_ip(struct blk_integrity_iter *iter)
109109
{
110-
return t10_pi_generate(iter, t10_pi_ip_fn, 1);
110+
return t10_pi_generate(iter, t10_pi_ip_fn, T10_PI_TYPE1_PROTECTION);
111111
}
112112

113113
static blk_status_t t10_pi_type1_verify_crc(struct blk_integrity_iter *iter)
114114
{
115-
return t10_pi_verify(iter, t10_pi_crc_fn, 1);
115+
return t10_pi_verify(iter, t10_pi_crc_fn, T10_PI_TYPE1_PROTECTION);
116116
}
117117

118118
static blk_status_t t10_pi_type1_verify_ip(struct blk_integrity_iter *iter)
119119
{
120-
return t10_pi_verify(iter, t10_pi_ip_fn, 1);
120+
return t10_pi_verify(iter, t10_pi_ip_fn, T10_PI_TYPE1_PROTECTION);
121121
}
122122

123123
static blk_status_t t10_pi_type3_generate_crc(struct blk_integrity_iter *iter)
124124
{
125-
return t10_pi_generate(iter, t10_pi_crc_fn, 3);
125+
return t10_pi_generate(iter, t10_pi_crc_fn, T10_PI_TYPE3_PROTECTION);
126126
}
127127

128128
static blk_status_t t10_pi_type3_generate_ip(struct blk_integrity_iter *iter)
129129
{
130-
return t10_pi_generate(iter, t10_pi_ip_fn, 3);
130+
return t10_pi_generate(iter, t10_pi_ip_fn, T10_PI_TYPE3_PROTECTION);
131131
}
132132

133133
static blk_status_t t10_pi_type3_verify_crc(struct blk_integrity_iter *iter)
134134
{
135-
return t10_pi_verify(iter, t10_pi_crc_fn, 3);
135+
return t10_pi_verify(iter, t10_pi_crc_fn, T10_PI_TYPE3_PROTECTION);
136136
}
137137

138138
static blk_status_t t10_pi_type3_verify_ip(struct blk_integrity_iter *iter)
139139
{
140-
return t10_pi_verify(iter, t10_pi_ip_fn, 3);
140+
return t10_pi_verify(iter, t10_pi_ip_fn, T10_PI_TYPE3_PROTECTION);
141141
}
142142

143143
const struct blk_integrity_profile t10_pi_type1_crc = {

0 commit comments

Comments
 (0)