@@ -65,16 +65,18 @@ struct sg_table {
65
65
*/
66
66
67
67
#define SG_MAGIC 0x87654321
68
+ #define SG_CHAIN 0x01UL
69
+ #define SG_END 0x02UL
68
70
69
71
/*
70
72
* We overload the LSB of the page pointer to indicate whether it's
71
73
* a valid sg entry, or whether it points to the start of a new scatterlist.
72
74
* Those low bits are there for everyone! (thanks mason :-)
73
75
*/
74
- #define sg_is_chain (sg ) ((sg)->page_link & 0x01 )
75
- #define sg_is_last (sg ) ((sg)->page_link & 0x02 )
76
+ #define sg_is_chain (sg ) ((sg)->page_link & SG_CHAIN )
77
+ #define sg_is_last (sg ) ((sg)->page_link & SG_END )
76
78
#define sg_chain_ptr (sg ) \
77
- ((struct scatterlist *) ((sg)->page_link & ~0x03 ))
79
+ ((struct scatterlist *) ((sg)->page_link & ~(SG_CHAIN | SG_END) ))
78
80
79
81
/**
80
82
* sg_assign_page - Assign a given page to an SG entry
@@ -88,13 +90,13 @@ struct sg_table {
88
90
**/
89
91
static inline void sg_assign_page (struct scatterlist * sg , struct page * page )
90
92
{
91
- unsigned long page_link = sg -> page_link & 0x3 ;
93
+ unsigned long page_link = sg -> page_link & ( SG_CHAIN | SG_END ) ;
92
94
93
95
/*
94
96
* In order for the low bit stealing approach to work, pages
95
97
* must be aligned at a 32-bit boundary as a minimum.
96
98
*/
97
- BUG_ON ((unsigned long ) page & 0x03 );
99
+ BUG_ON ((unsigned long ) page & ( SG_CHAIN | SG_END ) );
98
100
#ifdef CONFIG_DEBUG_SG
99
101
BUG_ON (sg -> sg_magic != SG_MAGIC );
100
102
BUG_ON (sg_is_chain (sg ));
@@ -130,7 +132,7 @@ static inline struct page *sg_page(struct scatterlist *sg)
130
132
BUG_ON (sg -> sg_magic != SG_MAGIC );
131
133
BUG_ON (sg_is_chain (sg ));
132
134
#endif
133
- return (struct page * )((sg )-> page_link & ~0x3 );
135
+ return (struct page * )((sg )-> page_link & ~( SG_CHAIN | SG_END ) );
134
136
}
135
137
136
138
/**
@@ -178,7 +180,8 @@ static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents,
178
180
* Set lowest bit to indicate a link pointer, and make sure to clear
179
181
* the termination bit if it happens to be set.
180
182
*/
181
- prv [prv_nents - 1 ].page_link = ((unsigned long ) sgl | 0x01 ) & ~0x02 ;
183
+ prv [prv_nents - 1 ].page_link = ((unsigned long ) sgl | SG_CHAIN )
184
+ & ~SG_END ;
182
185
}
183
186
184
187
/**
@@ -198,8 +201,8 @@ static inline void sg_mark_end(struct scatterlist *sg)
198
201
/*
199
202
* Set termination bit, clear potential chain bit
200
203
*/
201
- sg -> page_link |= 0x02 ;
202
- sg -> page_link &= ~0x01 ;
204
+ sg -> page_link |= SG_END ;
205
+ sg -> page_link &= ~SG_CHAIN ;
203
206
}
204
207
205
208
/**
@@ -215,7 +218,7 @@ static inline void sg_unmark_end(struct scatterlist *sg)
215
218
#ifdef CONFIG_DEBUG_SG
216
219
BUG_ON (sg -> sg_magic != SG_MAGIC );
217
220
#endif
218
- sg -> page_link &= ~0x02 ;
221
+ sg -> page_link &= ~SG_END ;
219
222
}
220
223
221
224
/**
0 commit comments