Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys convert more KM_NOSLEEP to KM_SLEEP and remove code to h...



details:   https://anonhg.NetBSD.org/src/rev/4b6f00827236
branches:  trunk
changeset: 455332:4b6f00827236
user:      chs <chs%NetBSD.org@localhost>
date:      Tue Oct 15 00:13:52 2019 +0000

description:
convert more KM_NOSLEEP to KM_SLEEP and remove code to handle failures.

diffstat:

 sys/arch/ia64/ia64/sapic.c       |   7 ++-----
 sys/arch/sparc64/dev/ldc.c       |  14 +++-----------
 sys/arch/x86/x86/cpu_ucode_amd.c |  17 ++++-------------
 sys/dev/acpi/sdhc_acpi.c         |  11 +++--------
 sys/dev/ata/ata.c                |  12 +++---------
 sys/dev/dm/dm_target_linear.c    |   8 +++-----
 sys/dev/dm/dm_target_snapshot.c  |  19 ++++++-------------
 sys/dev/dm/dm_target_stripe.c    |   9 ++++-----
 sys/dev/gpio/gpio.c              |   8 +++-----
 sys/dev/marvell/if_mvxpe.c       |   8 +++-----
 sys/dev/marvell/mvxpsec.c        |  16 +++-------------
 11 files changed, 37 insertions(+), 92 deletions(-)

diffs (truncated from 411 to 300 lines):

diff -r 5e96ad006d4b -r 4b6f00827236 sys/arch/ia64/ia64/sapic.c
--- a/sys/arch/ia64/ia64/sapic.c        Mon Oct 14 22:59:15 2019 +0000
+++ b/sys/arch/ia64/ia64/sapic.c        Tue Oct 15 00:13:52 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sapic.c,v 1.2 2012/10/27 17:29:03 chs Exp $    */
+/*     $NetBSD: sapic.c,v 1.3 2019/10/15 00:13:52 chs Exp $    */
 /*-
  * Copyright (c) 2001 Doug Rabson
  * All rights reserved.
@@ -144,10 +144,7 @@
        struct sapic *sa;
        u_int i;
 
-       sa = kmem_zalloc(sizeof(struct sapic), KM_NOSLEEP);
-       if (sa == NULL)
-               return NULL;
-
+       sa = kmem_zalloc(sizeof(struct sapic), KM_SLEEP);
        sa->sa_id = id;
        sa->sa_base = base;
        sa->sa_registers = IA64_PHYS_TO_RR6(address);
diff -r 5e96ad006d4b -r 4b6f00827236 sys/arch/sparc64/dev/ldc.c
--- a/sys/arch/sparc64/dev/ldc.c        Mon Oct 14 22:59:15 2019 +0000
+++ b/sys/arch/sparc64/dev/ldc.c        Tue Oct 15 00:13:52 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ldc.c,v 1.5 2019/10/01 18:00:07 chs Exp $      */
+/*     $NetBSD: ldc.c,v 1.6 2019/10/15 00:13:52 chs Exp $      */
 /*     $OpenBSD: ldc.c,v 1.12 2015/03/21 18:02:58 kettenis Exp $       */
 /*
  * Copyright (c) 2009 Mark Kettenis
@@ -604,10 +604,7 @@
 #if OPENBSD_BUSDMA
        int nsegs;
 #endif
-       lm = kmem_zalloc(sizeof(struct ldc_map), KM_NOSLEEP);
-       if (lm == NULL)
-               return NULL;
-
+       lm = kmem_zalloc(sizeof(struct ldc_map), KM_SLEEP);
        size = roundup(nentries * sizeof(struct ldc_map_slot), PAGE_SIZE);
 
 #if OPENBSD_BUSDMA
@@ -634,9 +631,7 @@
                goto unmap;
        }
 #else
-       va = (vaddr_t)kmem_zalloc(size, KM_NOSLEEP);
-       if (va == 0)
-               goto free;
+       va = (vaddr_t)kmem_zalloc(size, KM_SLEEP);
 #endif
        lm->lm_slot = (struct ldc_map_slot *)va;
        lm->lm_nentries = nentries;
@@ -650,9 +645,6 @@
        bus_dmamem_free(t, &lm->lm_seg, 1);
 destroy:
        bus_dmamap_destroy(t, lm->lm_map);
-#else
-free:
-       kmem_free(lm, sizeof(struct ldc_map));
 #endif
        return (NULL);
 }
diff -r 5e96ad006d4b -r 4b6f00827236 sys/arch/x86/x86/cpu_ucode_amd.c
--- a/sys/arch/x86/x86/cpu_ucode_amd.c  Mon Oct 14 22:59:15 2019 +0000
+++ b/sys/arch/x86/x86/cpu_ucode_amd.c  Tue Oct 15 00:13:52 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_ucode_amd.c,v 1.9 2019/01/27 02:08:39 pgoyette Exp $ */
+/* $NetBSD: cpu_ucode_amd.c,v 1.10 2019/10/15 00:13:52 chs Exp $ */
 /*
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_amd.c,v 1.9 2019/01/27 02:08:39 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_amd.c,v 1.10 2019/10/15 00:13:52 chs Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_xen.h"
@@ -263,16 +263,8 @@
                return EINVAL;
        }
 
-       mc.mc_amd = kmem_zalloc(sizeof(*mc.mc_amd), KM_NOSLEEP);
-       if (mc.mc_amd == NULL)
-               return ENOMEM;
-
-       mc.mc_amd->ect = kmem_alloc(mc.mc_mpbuf->mpb_len, KM_NOSLEEP);
-       if (mc.mc_amd->ect == NULL) {
-               error = ENOMEM;
-               goto err0;
-       }
-
+       mc.mc_amd = kmem_zalloc(sizeof(*mc.mc_amd), KM_SLEEP);
+       mc.mc_amd->ect = kmem_alloc(mc.mc_mpbuf->mpb_len, KM_SLEEP);
        memcpy(mc.mc_amd->ect, mc.mc_mpbuf->mpb_data, mc.mc_mpbuf->mpb_len);
        mc.mc_amd->ect_size = mc.mc_mpbuf->mpb_len;
 
@@ -307,7 +299,6 @@
 
 err1:
        kmem_free(mc.mc_amd->ect, mc.mc_amd->ect_size);
-err0:
        kmem_free(mc.mc_amd, sizeof(*mc.mc_amd));
        return error;
 }
diff -r 5e96ad006d4b -r 4b6f00827236 sys/dev/acpi/sdhc_acpi.c
--- a/sys/dev/acpi/sdhc_acpi.c  Mon Oct 14 22:59:15 2019 +0000
+++ b/sys/dev/acpi/sdhc_acpi.c  Tue Oct 15 00:13:52 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sdhc_acpi.c,v 1.7 2018/11/17 07:06:25 kre Exp $        */
+/*     $NetBSD: sdhc_acpi.c,v 1.8 2019/10/15 00:13:52 chs Exp $        */
 
 /*
  * Copyright (c) 2016 Kimihiro Nonaka <nonaka%NetBSD.org@localhost>
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sdhc_acpi.c,v 1.7 2018/11/17 07:06:25 kre Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc_acpi.c,v 1.8 2019/10/15 00:13:52 chs Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -188,11 +188,7 @@
                goto unmap;
        }
 
-       sc->sc.sc_host = kmem_zalloc(sizeof(struct sdhc_host *), KM_NOSLEEP);
-       if (sc->sc.sc_host == NULL) {
-               aprint_error_dev(self, "couldn't alloc memory\n");
-               goto intr_disestablish;
-       }
+       sc->sc.sc_host = kmem_zalloc(sizeof(struct sdhc_host *), KM_SLEEP);
 
        /* Enable DMA transfer */
        sc->sc.sc_flags |= SDHC_FLAG_USE_DMA;
@@ -215,7 +211,6 @@
        if (sc->sc.sc_host != NULL)
                kmem_free(sc->sc.sc_host, sizeof(struct sdhc_host *));
        sc->sc.sc_host = NULL;
-intr_disestablish:
        if (sc->sc_ih != NULL)
                acpi_intr_disestablish(sc->sc_ih);
        sc->sc_ih = NULL;
diff -r 5e96ad006d4b -r 4b6f00827236 sys/dev/ata/ata.c
--- a/sys/dev/ata/ata.c Mon Oct 14 22:59:15 2019 +0000
+++ b/sys/dev/ata/ata.c Tue Oct 15 00:13:52 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ata.c,v 1.150 2019/08/21 04:51:41 msaitoh Exp $        */
+/*     $NetBSD: ata.c,v 1.151 2019/10/15 00:13:53 chs Exp $    */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.150 2019/08/21 04:51:41 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.151 2019/10/15 00:13:53 chs Exp $");
 
 #include "opt_ata.h"
 
@@ -750,14 +750,8 @@
                atabus_free_drives(chp);
        if (chp->ch_drive == NULL) {
                chp->ch_drive = kmem_zalloc(
-                   sizeof(struct ata_drive_datas) * ndrives, KM_NOSLEEP);
+                   sizeof(struct ata_drive_datas) * ndrives, KM_SLEEP);
        }
-       if (chp->ch_drive == NULL) {
-           aprint_error_dev(chp->ch_atac->atac_dev,
-               "can't alloc drive array\n");
-           chp->ch_ndrives = 0;
-           return ENOMEM;
-       };
        for (i = 0; i < ndrives; i++) {
                chp->ch_drive[i].chnl_softc = chp;
                chp->ch_drive[i].drive = i;
diff -r 5e96ad006d4b -r 4b6f00827236 sys/dev/dm/dm_target_linear.c
--- a/sys/dev/dm/dm_target_linear.c     Mon Oct 14 22:59:15 2019 +0000
+++ b/sys/dev/dm/dm_target_linear.c     Tue Oct 15 00:13:52 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target_linear.c,v 1.17 2018/01/05 14:22:05 christos Exp $      */
+/*        $NetBSD: dm_target_linear.c,v 1.18 2019/10/15 00:13:53 chs Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.17 2018/01/05 14:22:05 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.18 2019/10/15 00:13:53 chs Exp $");
 
 /*
  * This file implements initial version of device-mapper dklinear target.
@@ -111,9 +111,7 @@
 
        aprint_debug("Linear target status function called\n");
 
-       if ((params = kmem_alloc(DM_MAX_PARAMS_SIZE, KM_NOSLEEP)) == NULL)
-               return NULL;
-
+       params = kmem_alloc(DM_MAX_PARAMS_SIZE, KM_SLEEP);
        aprint_normal("%s %" PRIu64, tlc->pdev->name, tlc->offset);
        snprintf(params, DM_MAX_PARAMS_SIZE, "%s %" PRIu64,
            tlc->pdev->name, tlc->offset);
diff -r 5e96ad006d4b -r 4b6f00827236 sys/dev/dm/dm_target_snapshot.c
--- a/sys/dev/dm/dm_target_snapshot.c   Mon Oct 14 22:59:15 2019 +0000
+++ b/sys/dev/dm/dm_target_snapshot.c   Tue Oct 15 00:13:52 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target_snapshot.c,v 1.19 2018/01/05 14:22:05 christos Exp $      */
+/*        $NetBSD: dm_target_snapshot.c,v 1.20 2019/10/15 00:13:53 chs Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.19 2018/01/05 14:22:05 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.20 2019/10/15 00:13:53 chs Exp $");
 
 /*
  * 1. Suspend my_data to temporarily stop any I/O while the snapshot is being
@@ -223,9 +223,7 @@
        if ((dmp_snap = dm_pdev_insert(argv[0])) == NULL)
                return ENOENT;
 
-       if ((tsc = kmem_alloc(sizeof(*tsc), KM_NOSLEEP)) == NULL)
-               return 1;
-
+       tsc = kmem_alloc(sizeof(*tsc), KM_SLEEP);
        tsc->tsc_persistent_dev = 0;
 
        /* There is now cow device for nonpersistent snapshot devices */
@@ -285,8 +283,7 @@
        /* length of names + count of chars + spaces and null char */
        prm_len = strlen(tsc->tsc_snap_dev->name) + cow_len + count + 5;
 
-       if ((params = kmem_alloc(prm_len, KM_NOSLEEP)) == NULL)
-               return NULL;
+       params = kmem_alloc(prm_len, KM_SLEEP);
 
        printf("%s %s %s %" PRIu64 "\n", tsc->tsc_snap_dev->name,
            tsc->tsc_cow_dev->name, tsc->tsc_persistent_dev ? "p" : "n",
@@ -411,10 +408,7 @@
        if ((dmp_real = dm_pdev_insert(params)) == NULL)
                return ENOENT;
 
-       if ((tsoc = kmem_alloc(sizeof(dm_target_snapshot_origin_config_t), KM_NOSLEEP))
-           == NULL)
-               return 1;
-
+       tsoc = kmem_alloc(sizeof(dm_target_snapshot_origin_config_t), KM_SLEEP);
        tsoc->tsoc_real_dev = dmp_real;
 
        dmv->dev_type = DM_SNAPSHOT_ORIG_DEV;
@@ -448,8 +442,7 @@
 
        printf("real_dev name %s\n", tsoc->tsoc_real_dev->name);
 
-       if ((params = kmem_alloc(prm_len, KM_NOSLEEP)) == NULL)
-               return NULL;
+       params = kmem_alloc(prm_len, KM_SLEEP);
 
        printf("%s\n", tsoc->tsoc_real_dev->name);
 
diff -r 5e96ad006d4b -r 4b6f00827236 sys/dev/dm/dm_target_stripe.c
--- a/sys/dev/dm/dm_target_stripe.c     Mon Oct 14 22:59:15 2019 +0000
+++ b/sys/dev/dm/dm_target_stripe.c     Tue Oct 15 00:13:52 2019 +0000
@@ -1,4 +1,4 @@
-/*$NetBSD: dm_target_stripe.c,v 1.23 2018/01/05 14:22:26 christos Exp $*/
+/*$NetBSD: dm_target_stripe.c,v 1.24 2019/10/15 00:13:53 chs Exp $*/
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.23 2018/01/05 14:22:26 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.24 2019/10/15 00:13:53 chs Exp $");
 
 /*
  * This file implements initial version of device-mapper stripe target.
@@ -158,8 +158,7 @@
        printf("Stripe target chunk size %s number of stripes %s\n",
            argv[1], argv[0]);
 
-       if ((tsc = kmem_alloc(sizeof(*tsc), KM_NOSLEEP)) == NULL)
-               return ENOMEM;
+       tsc = kmem_alloc(sizeof(*tsc), KM_SLEEP);
 
        /* Initialize linked list for striping devices */
        TAILQ_INIT(&tsc->stripe_devs);
@@ -174,7 +173,7 @@



Home | Main Index | Thread Index | Old Index