Skip to content

Commit

Permalink
lib/scatterlist: use sg_phys() helper
Browse files Browse the repository at this point in the history
This shorten the length of code in horizential direction, therefore is
easier to read.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Sui Jingfeng <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
suijingfeng authored and akpm00 committed Nov 6, 2024
1 parent 2f07b65 commit e01caa2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/scatterlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,14 +474,14 @@ int sg_alloc_append_table_from_pages(struct sg_append_table *sgt_append,
return -EOPNOTSUPP;

if (sgt_append->prv) {
unsigned long next_pfn = (page_to_phys(sg_page(sgt_append->prv)) +
sgt_append->prv->offset + sgt_append->prv->length) / PAGE_SIZE;
unsigned long next_pfn;

if (WARN_ON(offset))
return -EINVAL;

/* Merge contiguous pages into the last SG */
prv_len = sgt_append->prv->length;
next_pfn = (sg_phys(sgt_append->prv) + prv_len) / PAGE_SIZE;
if (page_to_pfn(pages[0]) == next_pfn) {
last_pg = pfn_to_page(next_pfn - 1);
while (n_pages && pages_are_mergeable(pages[0], last_pg)) {
Expand Down

0 comments on commit e01caa2

Please sign in to comment.