diff options
author | Hans Petter Selasky <hselasky@FreeBSD.org> | 2017-02-22 20:24:09 +0000 |
---|---|---|
committer | Hans Petter Selasky <hselasky@FreeBSD.org> | 2017-02-22 20:24:09 +0000 |
commit | 72ebbe00b336a35509cc4f5aa0b17fb311a8a1f4 (patch) | |
tree | 86084c18d74efa0c9aa4c52910dd5284e97d38aa /sys/compat/linuxkpi/common/include/linux | |
parent | 1cdefd084d6e5aca88b1647d24fd3b02866865b6 (diff) | |
download | src-72ebbe00b336a35509cc4f5aa0b17fb311a8a1f4.tar.gz src-72ebbe00b336a35509cc4f5aa0b17fb311a8a1f4.zip |
Convert magic values into macros in the LinuxKPI scatterlist
implementation.
Suggested by: cem @
MFC after: 1 week
Sponsored by: Mellanox Technologies
Notes
Notes:
svn path=/head/; revision=314109
Diffstat (limited to 'sys/compat/linuxkpi/common/include/linux')
-rw-r--r-- | sys/compat/linuxkpi/common/include/linux/scatterlist.h | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/scatterlist.h b/sys/compat/linuxkpi/common/include/linux/scatterlist.h index 85442ab0c22e..125b1acb7a33 100644 --- a/sys/compat/linuxkpi/common/include/linux/scatterlist.h +++ b/sys/compat/linuxkpi/common/include/linux/scatterlist.h @@ -38,12 +38,15 @@ struct scatterlist { unsigned long page_link; +#define SG_PAGE_LINK_CHAIN 0x1UL +#define SG_PAGE_LINK_LAST 0x2UL +#define SG_PAGE_LINK_MASK 0x3UL unsigned int offset; unsigned int length; dma_addr_t address; }; -CTASSERT((sizeof(struct scatterlist) & 0x3) == 0); +CTASSERT((sizeof(struct scatterlist) & SG_PAGE_LINK_MASK) == 0); struct sg_table { struct scatterlist *sgl; @@ -65,10 +68,10 @@ struct sg_page_iter { #define SG_MAGIC 0x87654321UL -#define sg_is_chain(sg) ((sg)->page_link & 0x01) -#define sg_is_last(sg) ((sg)->page_link & 0x02) +#define sg_is_chain(sg) ((sg)->page_link & SG_PAGE_LINK_CHAIN) +#define sg_is_last(sg) ((sg)->page_link & SG_PAGE_LINK_LAST) #define sg_chain_ptr(sg) \ - ((struct scatterlist *) ((sg)->page_link & ~0x03)) + ((struct scatterlist *) ((sg)->page_link & ~SG_PAGE_LINK_MASK)) #define sg_dma_address(sg) (sg)->address #define sg_dma_len(sg) (sg)->length @@ -86,7 +89,7 @@ typedef void (sg_free_fn) (struct scatterlist *, unsigned int); static inline void sg_assign_page(struct scatterlist *sg, struct page *page) { - unsigned long page_link = sg->page_link & 0x3; + unsigned long page_link = sg->page_link & SG_PAGE_LINK_MASK; sg->page_link = page_link | (unsigned long)page; } @@ -103,7 +106,7 @@ sg_set_page(struct scatterlist *sg, struct page *page, unsigned int len, static inline struct page * sg_page(struct scatterlist *sg) { - return ((struct page *)((sg)->page_link & ~0x3)); + return ((struct page *)((sg)->page_link & ~SG_PAGE_LINK_MASK)); } static inline void @@ -138,14 +141,15 @@ sg_chain(struct scatterlist *prv, unsigned int prv_nents, sg->offset = 0; sg->length = 0; - sg->page_link = ((unsigned long)sgl | 0x01) & ~0x02; + sg->page_link = ((unsigned long)sgl | + SG_PAGE_LINK_CHAIN) & ~SG_PAGE_LINK_LAST; } static inline void sg_mark_end(struct scatterlist *sg) { - sg->page_link |= 0x02; - sg->page_link &= ~0x01; + sg->page_link |= SG_PAGE_LINK_LAST; + sg->page_link &= ~SG_PAGE_LINK_CHAIN; } static inline void |