Skip to content

Commit c03aef8

Browse files
committed
PM: hibernate: Extra cleanup of comments in swap handling code
Continue recent cleanups of comments in the swap handling code. Unify the use of white space in the comments, drop some unuseful comments outside function bodies, and move some other comments into function bodies. No functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/5943864.DvuYhMxLoT@rafael.j.wysocki
1 parent 8e2d57e commit c03aef8

1 file changed

Lines changed: 33 additions & 48 deletions

File tree

kernel/power/swap.c

Lines changed: 33 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,18 @@ static bool clean_pages_on_read;
4646
static bool clean_pages_on_decompress;
4747

4848
/*
49-
* The swap map is a data structure used for keeping track of each page
50-
* written to a swap partition. It consists of many swap_map_page
51-
* structures that contain each an array of MAP_PAGE_ENTRIES swap entries.
52-
* These structures are stored on the swap and linked together with the
53-
* help of the .next_swap member.
49+
* The swap map is a data structure used for keeping track of each page
50+
* written to a swap partition. It consists of many swap_map_page structures
51+
* that contain each an array of MAP_PAGE_ENTRIES swap entries. These
52+
* structures are stored on the swap and linked together with the help of the
53+
* .next_swap member.
5454
*
55-
* The swap map is created during suspend. The swap map pages are
56-
* allocated and populated one at a time, so we only need one memory
57-
* page to set up the entire structure.
55+
* The swap map is created during suspend. The swap map pages are allocated and
56+
* populated one at a time, so we only need one memory page to set up the entire
57+
* structure.
5858
*
59-
* During resume we pick up all swap_map_page structures into a list.
59+
* During resume we pick up all swap_map_page structures into a list.
6060
*/
61-
6261
#define MAP_PAGE_ENTRIES (PAGE_SIZE / sizeof(sector_t) - 1)
6362

6463
/*
@@ -89,10 +88,8 @@ struct swap_map_page_list {
8988
};
9089

9190
/*
92-
* The swap_map_handle structure is used for handling swap in
93-
* a file-alike way
91+
* The swap_map_handle structure is used for handling swap in a file-alike way.
9492
*/
95-
9693
struct swap_map_handle {
9794
struct swap_map_page *cur;
9895
struct swap_map_page_list *maps;
@@ -117,10 +114,9 @@ struct swsusp_header {
117114
static struct swsusp_header *swsusp_header;
118115

119116
/*
120-
* The following functions are used for tracing the allocated
121-
* swap pages, so that they can be freed in case of an error.
117+
* The following functions are used for tracing the allocated swap pages, so
118+
* that they can be freed in case of an error.
122119
*/
123-
124120
struct swsusp_extent {
125121
struct rb_node node;
126122
unsigned long start;
@@ -170,15 +166,14 @@ static int swsusp_extents_insert(unsigned long swap_offset)
170166
return 0;
171167
}
172168

173-
/*
174-
* alloc_swapdev_block - allocate a swap page and register that it has
175-
* been allocated, so that it can be freed in case of an error.
176-
*/
177-
178169
sector_t alloc_swapdev_block(int swap)
179170
{
180171
unsigned long offset;
181172

173+
/*
174+
* Allocate a swap page and register that it has been allocated, so that
175+
* it can be freed in case of an error.
176+
*/
182177
offset = swp_offset(get_swap_page_of_type(swap));
183178
if (offset) {
184179
if (swsusp_extents_insert(offset))
@@ -189,16 +184,14 @@ sector_t alloc_swapdev_block(int swap)
189184
return 0;
190185
}
191186

192-
/*
193-
* free_all_swap_pages - free swap pages allocated for saving image data.
194-
* It also frees the extents used to register which swap entries had been
195-
* allocated.
196-
*/
197-
198187
void free_all_swap_pages(int swap)
199188
{
200189
struct rb_node *node;
201190

191+
/*
192+
* Free swap pages allocated for saving image data. It also frees the
193+
* extents used to register which swap entries had been allocated.
194+
*/
202195
while ((node = swsusp_extents.rb_node)) {
203196
struct swsusp_extent *ext;
204197

@@ -303,6 +296,7 @@ static int hib_wait_io(struct hib_bio_batch *hb)
303296
/*
304297
* Saving part
305298
*/
299+
306300
static int mark_swapfiles(struct swap_map_handle *handle, unsigned int flags)
307301
{
308302
int error;
@@ -615,9 +609,6 @@ static void free_crc_data(struct crc_data *crc)
615609
kfree(crc);
616610
}
617611

618-
/*
619-
* CRC32 update function that runs in its own thread.
620-
*/
621612
static int crc32_threadfn(void *data)
622613
{
623614
struct crc_data *d = data;
@@ -642,6 +633,7 @@ static int crc32_threadfn(void *data)
642633
}
643634
return 0;
644635
}
636+
645637
/*
646638
* Structure used for data compression.
647639
*/
@@ -663,9 +655,6 @@ struct cmp_data {
663655
/* Indicates the image size after compression */
664656
static atomic64_t compressed_size = ATOMIC_INIT(0);
665657

666-
/*
667-
* Compression function that runs in its own thread.
668-
*/
669658
static int compress_threadfn(void *data)
670659
{
671660
struct cmp_data *d = data;
@@ -936,15 +925,15 @@ static int enough_swap(unsigned int nr_pages)
936925
}
937926

938927
/**
939-
* swsusp_write - Write entire image and metadata.
940-
* @flags: flags to pass to the "boot" kernel in the image header
928+
* swsusp_write - Write entire image and metadata.
929+
* @flags: flags to pass to the "boot" kernel in the image header
941930
*
942-
* It is important _NOT_ to umount filesystems at this point. We want
943-
* them synced (in case something goes wrong) but we DO not want to mark
944-
* filesystem clean: it is not. (And it does not matter, if we resume
945-
* correctly, we'll mark system clean, anyway.)
931+
* It is important _NOT_ to umount filesystems at this point. We want them
932+
* synced (in case something goes wrong) but we DO not want to mark filesystem
933+
* clean: it is not. (And it does not matter, if we resume correctly, we'll mark
934+
* system clean, anyway.)
946935
*
947-
* Return: 0 on success, negative error code on failure.
936+
* Return: 0 on success, negative error code on failure.
948937
*/
949938
int swsusp_write(unsigned int flags)
950939
{
@@ -988,8 +977,8 @@ int swsusp_write(unsigned int flags)
988977
}
989978

990979
/*
991-
* The following functions allow us to read data using a swap map
992-
* in a file-like way.
980+
* The following functions allow us to read data using a swap map in a file-like
981+
* way.
993982
*/
994983

995984
static void release_swap_reader(struct swap_map_handle *handle)
@@ -1161,9 +1150,6 @@ struct dec_data {
11611150
unsigned char cmp[CMP_SIZE]; /* compressed buffer */
11621151
};
11631152

1164-
/*
1165-
* Decompression function that runs in its own thread.
1166-
*/
11671153
static int decompress_threadfn(void *data)
11681154
{
11691155
struct dec_data *d = data;
@@ -1618,7 +1604,6 @@ int swsusp_check(bool exclusive)
16181604
/**
16191605
* swsusp_close - close resume device.
16201606
*/
1621-
16221607
void swsusp_close(void)
16231608
{
16241609
if (IS_ERR(hib_resume_bdev_file)) {
@@ -1630,9 +1615,9 @@ void swsusp_close(void)
16301615
}
16311616

16321617
/**
1633-
* swsusp_unmark - Unmark swsusp signature in the resume device
1618+
* swsusp_unmark - Unmark swsusp signature in the resume device
16341619
*
1635-
* Return: 0 on success, negative error code on failure.
1620+
* Return: 0 on success, negative error code on failure.
16361621
*/
16371622
#ifdef CONFIG_SUSPEND
16381623
int swsusp_unmark(void)

0 commit comments

Comments
 (0)