diff mbox series

[13/14] PM: mm: cleanup swsusp_swap_check

Message ID 20200917165720.3285256-14-hch@lst.de
State Not Applicable
Delegated to: David Miller
Headers show
Series [01/14] block: move the NEED_PART_SCAN flag to struct gendisk | expand

Commit Message

Christoph Hellwig Sept. 17, 2020, 4:57 p.m. UTC
Use blkdev_get_by_dev instead of bdget + blkdev_get.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 kernel/power/swap.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Comments

Rafael J. Wysocki Sept. 18, 2020, 4:01 p.m. UTC | #1
On Thu, Sep 17, 2020 at 7:39 PM Christoph Hellwig <hch@lst.de> wrote:
>
> Use blkdev_get_by_dev instead of bdget + blkdev_get.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  kernel/power/swap.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/power/swap.c b/kernel/power/swap.c
> index 9d3ffbfe08dbf6..71385bedcc3a49 100644
> --- a/kernel/power/swap.c
> +++ b/kernel/power/swap.c
> @@ -343,12 +343,10 @@ static int swsusp_swap_check(void)
>                 return res;
>         root_swap = res;
>
> -       hib_resume_bdev = bdget(swsusp_resume_device);
> -       if (!hib_resume_bdev)
> -               return -ENOMEM;
> -       res = blkdev_get(hib_resume_bdev, FMODE_WRITE, NULL);
> -       if (res)
> -               return res;
> +       hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device, FMODE_WRITE,
> +                       NULL);
> +       if (IS_ERR(hib_resume_bdev))
> +               return PTR_ERR(hib_resume_bdev);
>
>         res = set_blocksize(hib_resume_bdev, PAGE_SIZE);
>         if (res < 0)
> --
> 2.28.0
>
Pavel Machek Sept. 19, 2020, 9:06 a.m. UTC | #2
On Thu 2020-09-17 18:57:19, Christoph Hellwig wrote:
> Use blkdev_get_by_dev instead of bdget + blkdev_get.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Acked-by: Pavel Machek <pavel@ucw.cz>
diff mbox series

Patch

diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 9d3ffbfe08dbf6..71385bedcc3a49 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -343,12 +343,10 @@  static int swsusp_swap_check(void)
 		return res;
 	root_swap = res;
 
-	hib_resume_bdev = bdget(swsusp_resume_device);
-	if (!hib_resume_bdev)
-		return -ENOMEM;
-	res = blkdev_get(hib_resume_bdev, FMODE_WRITE, NULL);
-	if (res)
-		return res;
+	hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device, FMODE_WRITE,
+			NULL);
+	if (IS_ERR(hib_resume_bdev))
+		return PTR_ERR(hib_resume_bdev);
 
 	res = set_blocksize(hib_resume_bdev, PAGE_SIZE);
 	if (res < 0)