From: krw Date: Sun, 30 Jun 2024 12:03:17 +0000 (+0000) Subject: Use howmany() to calculate how many prpl entries are needed to describe a X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=4e79e4854bc868e1c0eb5932716a31a881d14e33;p=openbsd Use howmany() to calculate how many prpl entries are needed to describe a hibernate i/o. Use of howmany() suggested by jmatthew@, ok jmatthew@ --- diff --git a/sys/dev/ic/nvme.c b/sys/dev/ic/nvme.c index fe8764b0323..62299a4de62 100644 --- a/sys/dev/ic/nvme.c +++ b/sys/dev/ic/nvme.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nvme.c,v 1.117 2024/06/04 20:31:35 krw Exp $ */ +/* $OpenBSD: nvme.c,v 1.118 2024/06/30 12:03:17 krw Exp $ */ /* * Copyright (c) 2014 David Gwynne @@ -1799,7 +1799,7 @@ nvme_hibernate_io(dev_t dev, daddr_t blkno, vaddr_t addr, size_t size, page_bus_phys = page_phys; htolem64(&isqe->entry.prp[1], page_bus_phys + offsetof(struct nvme_hibernate_page, prpl)); - for (i = 1; i < (size / my->sc->sc_mps); i++) { + for (i = 1; i < howmany(size, my->sc->sc_mps); i++) { htolem64(&my->prpl[i - 1], data_bus_phys + (i * my->sc->sc_mps)); }