From 293fc00622d830d19d388458bc8774c17cb97ef9 Mon Sep 17 00:00:00 2001 From: haad Date: Mon, 4 Jan 2010 00:12:22 +0000 Subject: Indent files remove unnecessary blank lines, white spaces and KNFize code. --- sys/dev/dm/dm_dev.c | 209 ++++++++++++++++++++++++---------------------------- 1 file changed, 98 insertions(+), 111 deletions(-) (limited to 'sys/dev/dm/dm_dev.c') diff --git a/sys/dev/dm/dm_dev.c b/sys/dev/dm/dm_dev.c index dc1b50ce9f9..bf6f6465c7d 100644 --- a/sys/dev/dm/dm_dev.c +++ b/sys/dev/dm/dm_dev.c @@ -1,4 +1,4 @@ -/* $NetBSD: dm_dev.c,v 1.7 2009/12/29 23:37:48 haad Exp $ */ +/* $NetBSD: dm_dev.c,v 1.8 2010/01/04 00:19:08 haad Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -41,9 +41,9 @@ #include "netbsd-dm.h" #include "dm.h" -static dm_dev_t* dm_dev_lookup_name(const char *); -static dm_dev_t* dm_dev_lookup_uuid(const char *); -static dm_dev_t* dm_dev_lookup_minor(int); +static dm_dev_t *dm_dev_lookup_name(const char *); +static dm_dev_t *dm_dev_lookup_uuid(const char *); +static dm_dev_t *dm_dev_lookup_minor(int); static struct dm_dev_head dm_dev_list = TAILQ_HEAD_INITIALIZER(dm_dev_list); @@ -52,90 +52,88 @@ kmutex_t dm_dev_mutex; /* dm_dev_mutex must be holdby caller before using disable_dev. */ __inline static void -disable_dev(dm_dev_t *dmv) +disable_dev(dm_dev_t * dmv) { - TAILQ_REMOVE(&dm_dev_list, dmv, next_devlist); - mutex_enter(&dmv->dev_mtx); - mutex_exit(&dm_dev_mutex); - while(dmv->ref_cnt != 0) - cv_wait(&dmv->dev_cv, &dmv->dev_mtx); - mutex_exit(&dmv->dev_mtx); -} - + TAILQ_REMOVE(&dm_dev_list, dmv, next_devlist); + mutex_enter(&dmv->dev_mtx); + mutex_exit(&dm_dev_mutex); + while (dmv->ref_cnt != 0) + cv_wait(&dmv->dev_cv, &dmv->dev_mtx); + mutex_exit(&dmv->dev_mtx); +} /* - * Generic function used to lookup dm_dev_t. Calling with dm_dev_name + * Generic function used to lookup dm_dev_t. Calling with dm_dev_name * and dm_dev_uuid NULL is allowed. */ -dm_dev_t* +dm_dev_t * dm_dev_lookup(const char *dm_dev_name, const char *dm_dev_uuid, - int dm_dev_minor) + int dm_dev_minor) { dm_dev_t *dmv; - + dmv = NULL; mutex_enter(&dm_dev_mutex); - - /* KASSERT(dm_dev_name != NULL && dm_dev_uuid != NULL && dm_dev_minor > 0); */ + + /* KASSERT(dm_dev_name != NULL && dm_dev_uuid != NULL && dm_dev_minor + * > 0); */ if (dm_dev_minor > 0) - if ((dmv = dm_dev_lookup_minor(dm_dev_minor)) != NULL){ + if ((dmv = dm_dev_lookup_minor(dm_dev_minor)) != NULL) { dm_dev_busy(dmv); mutex_exit(&dm_dev_mutex); return dmv; } - - if (dm_dev_name != NULL) - if ((dmv = dm_dev_lookup_name(dm_dev_name)) != NULL){ + if (dm_dev_name != NULL) + if ((dmv = dm_dev_lookup_name(dm_dev_name)) != NULL) { dm_dev_busy(dmv); mutex_exit(&dm_dev_mutex); - return dmv; + return dmv; } - if (dm_dev_uuid != NULL) - if ((dmv = dm_dev_lookup_uuid(dm_dev_uuid)) != NULL){ + if ((dmv = dm_dev_lookup_uuid(dm_dev_uuid)) != NULL) { dm_dev_busy(dmv); mutex_exit(&dm_dev_mutex); return dmv; } - mutex_exit(&dm_dev_mutex); - return NULL; + mutex_exit(&dm_dev_mutex); + return NULL; } - + /* * Lookup device with its minor number. */ -static dm_dev_t* +static dm_dev_t * dm_dev_lookup_minor(int dm_dev_minor) { dm_dev_t *dmv; - - TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist){ + + TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist) { if (dm_dev_minor == dmv->minor) return dmv; } - + return NULL; } - /* * Lookup device with it's device name. */ -static dm_dev_t* +static dm_dev_t * dm_dev_lookup_name(const char *dm_dev_name) { dm_dev_t *dmv; - int dlen; int slen; + int dlen; + int slen; slen = strlen(dm_dev_name); if (slen == 0) return NULL; - - TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist){ + + TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist) { dlen = strlen(dmv->name); - - if(slen != dlen) + + if (slen != dlen) continue; if (strncmp(dm_dev_name, dmv->name, slen) == 0) @@ -144,62 +142,59 @@ dm_dev_lookup_name(const char *dm_dev_name) return NULL; } - /* * Lookup device with it's device uuid. Used mostly by LVM2tools. */ -static dm_dev_t* +static dm_dev_t * dm_dev_lookup_uuid(const char *dm_dev_uuid) { dm_dev_t *dmv; size_t len; - + len = 0; len = strlen(dm_dev_uuid); - + if (len == 0) return NULL; - TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist){ + TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist) { if (strlen(dmv->uuid) != len) continue; - + if (strncmp(dm_dev_uuid, dmv->uuid, strlen(dmv->uuid)) == 0) return dmv; } return NULL; } - /* * Insert new device to the global list of devices. */ int -dm_dev_insert(dm_dev_t *dev) +dm_dev_insert(dm_dev_t * dev) { dm_dev_t *dmv; int r; dmv = NULL; r = 0; - + KASSERT(dev != NULL); mutex_enter(&dm_dev_mutex); if (((dmv = dm_dev_lookup_uuid(dev->uuid)) == NULL) && ((dmv = dm_dev_lookup_name(dev->name)) == NULL) && - ((dmv = dm_dev_lookup_minor(dev->minor)) == NULL)){ + ((dmv = dm_dev_lookup_minor(dev->minor)) == NULL)) { TAILQ_INSERT_TAIL(&dm_dev_list, dev, next_devlist); - + } else r = EEXIST; - - mutex_exit(&dm_dev_mutex); + + mutex_exit(&dm_dev_mutex); return r; } - -#ifdef notyet +#ifdef notyet /* * Lookup device with its minor number. */ @@ -207,16 +202,16 @@ int dm_dev_test_minor(int dm_dev_minor) { dm_dev_t *dmv; - + mutex_enter(&dm_dev_mutex); - TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist){ - if (dm_dev_minor == dmv->minor){ + TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist) { + if (dm_dev_minor == dmv->minor) { mutex_exit(&dm_dev_mutex); return 1; } } mutex_exit(&dm_dev_mutex); - + return 0; } #endif @@ -231,45 +226,42 @@ dm_dev_t * dm_dev_detach(device_t devt) { dm_dev_t *dmv; - + mutex_enter(&dm_dev_mutex); - TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist){ - if (devt == dmv->devt){ + TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist) { + if (devt == dmv->devt) { disable_dev(dmv); return dmv; } } mutex_exit(&dm_dev_mutex); - + return NULL; } - -/* - * Remove device selected with dm_dev from global list of devices. +/* + * Remove device selected with dm_dev from global list of devices. */ -dm_dev_t* +dm_dev_t * dm_dev_rem(const char *dm_dev_name, const char *dm_dev_uuid, - int dm_dev_minor) -{ + int dm_dev_minor) +{ dm_dev_t *dmv; dmv = NULL; - + mutex_enter(&dm_dev_mutex); - + if (dm_dev_minor > 0) - if ((dmv = dm_dev_lookup_minor(dm_dev_minor)) != NULL){ + if ((dmv = dm_dev_lookup_minor(dm_dev_minor)) != NULL) { disable_dev(dmv); return dmv; } - - if (dm_dev_name != NULL) - if ((dmv = dm_dev_lookup_name(dm_dev_name)) != NULL){ + if (dm_dev_name != NULL) + if ((dmv = dm_dev_lookup_name(dm_dev_name)) != NULL) { disable_dev(dmv); return dmv; } - if (dm_dev_uuid != NULL) - if ((dmv = dm_dev_lookup_name(dm_dev_uuid)) != NULL){ + if ((dmv = dm_dev_lookup_name(dm_dev_uuid)) != NULL) { disable_dev(dmv); return dmv; } @@ -277,10 +269,9 @@ dm_dev_rem(const char *dm_dev_name, const char *dm_dev_uuid, return NULL; } - /* * Destroy all devices created in device-mapper. Remove all tables - * free all allocated memmory. + * free all allocated memmory. */ int dm_dev_destroy(void) @@ -288,10 +279,10 @@ dm_dev_destroy(void) dm_dev_t *dmv; mutex_enter(&dm_dev_mutex); - while (TAILQ_FIRST(&dm_dev_list) != NULL){ + while (TAILQ_FIRST(&dm_dev_list) != NULL) { dmv = TAILQ_FIRST(&dm_dev_list); - + TAILQ_REMOVE(&dm_dev_list, TAILQ_FIRST(&dm_dev_list), next_devlist); @@ -299,7 +290,7 @@ dm_dev_destroy(void) while (dmv->ref_cnt != 0) cv_wait(&dmv->dev_cv, &dmv->dev_mtx); - + /* Destroy active table first. */ dm_table_destroy(&dmv->table_head, DM_TABLE_ACTIVE); @@ -311,36 +302,34 @@ dm_dev_destroy(void) mutex_exit(&dmv->dev_mtx); mutex_destroy(&dmv->dev_mtx); cv_destroy(&dmv->dev_cv); - - (void)kmem_free(dmv, sizeof(dm_dev_t)); + + (void) kmem_free(dmv, sizeof(dm_dev_t)); } mutex_exit(&dm_dev_mutex); mutex_destroy(&dm_dev_mutex); - return 0; + return 0; } - /* * Allocate new device entry. */ -dm_dev_t* +dm_dev_t * dm_dev_alloc(void) { dm_dev_t *dmv; - + dmv = kmem_zalloc(sizeof(dm_dev_t), KM_SLEEP); - - if(dmv != NULL) + + if (dmv != NULL) dmv->diskp = kmem_zalloc(sizeof(struct disk), KM_SLEEP); - + return dmv; } - /* * Freed device entry. */ int -dm_dev_free(dm_dev_t *dmv) +dm_dev_free(dm_dev_t * dmv) { KASSERT(dmv != NULL); @@ -348,33 +337,32 @@ dm_dev_free(dm_dev_t *dmv) mutex_destroy(&dmv->diskp_mtx); cv_destroy(&dmv->dev_cv); - if(dmv->diskp != NULL) - (void)kmem_free(dmv->diskp, sizeof(struct disk)); - - (void)kmem_free(dmv, sizeof(dm_dev_t)); - + if (dmv->diskp != NULL) + (void) kmem_free(dmv->diskp, sizeof(struct disk)); + + (void) kmem_free(dmv, sizeof(dm_dev_t)); + return 0; } void -dm_dev_busy(dm_dev_t *dmv) +dm_dev_busy(dm_dev_t * dmv) { mutex_enter(&dmv->dev_mtx); dmv->ref_cnt++; mutex_exit(&dmv->dev_mtx); -} +} void -dm_dev_unbusy(dm_dev_t *dmv) +dm_dev_unbusy(dm_dev_t * dmv) { KASSERT(dmv->ref_cnt != 0); - + mutex_enter(&dmv->dev_mtx); if (--dmv->ref_cnt == 0) cv_broadcast(&dmv->dev_cv); mutex_exit(&dmv->dev_mtx); } - /* * Return prop_array of dm_targer_list dictionaries. */ @@ -384,14 +372,14 @@ dm_dev_prop_list(void) dm_dev_t *dmv; prop_array_t dev_array; prop_dictionary_t dev_dict; - + dev_array = prop_array_create(); - + mutex_enter(&dm_dev_mutex); - + TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist) { - dev_dict = prop_dictionary_create(); - + dev_dict = prop_dictionary_create(); + prop_dictionary_set_cstring(dev_dict, DM_DEV_NAME, dmv->name); prop_dictionary_set_uint32(dev_dict, DM_DEV_DEV, dmv->minor); @@ -399,17 +387,16 @@ dm_dev_prop_list(void) prop_object_release(dev_dict); } - mutex_exit(&dm_dev_mutex); + mutex_exit(&dm_dev_mutex); return dev_array; } - /* * Initialize global device mutex. */ int dm_dev_init(void) { - TAILQ_INIT(&dm_dev_list); /* initialize global dev list */ + TAILQ_INIT(&dm_dev_list); /* initialize global dev list */ mutex_init(&dm_dev_mutex, MUTEX_DEFAULT, IPL_NONE); return 0; } -- cgit Bump kernel version to avoid module mismatch. Welcome to 7.99.38 ! 2016-01-25earm (iyonix and zaurus) don't have cpu_counter.hchristos 2016-01-25spell empty.christos 2016-01-25Handle also the earm{ev,hf}...christos 2016-01-25Map "earm" to armv5martin 2016-01-24Remove hf and eb. Rin Okuyamachristos 2016-01-24Grr. arm is different.christos 2016-01-24Instead of hard-coding who has cpu counters why don't you look for them?christos 2015-09-10Evil hack to ensure dtrace lockstat module builds on arm.riz 2015-03-08dtrace syscall for linux32christos 2015-03-08non working glue.christos 2015-03-07Add syscall provider build glue, unhooked.christos 2014-09-18Per the wiki roadmap, rename the three dtrace modules to havewiz a "dtrace_" prefix. amd64 build tested, other set list changes done the same way. 2014-03-05Tidy up Makefile of cyclic and dtrace modules to support ARMozaki-r 2012-12-02adapt the cyclic module and profile dtrace provider to netbsd.chs for now, just hook the cyclic callback into hardclock(). 2012-12-02remove unneeded include dirs.chs 2010-12-14Disable errors reported by unknown pragmas in dtrace module.haad 2010-03-13Include ../../Makefile.inc now that it works.christos 2010-03-13now that I've fixed Makefile.inc, include it.christos 2010-03-12DTrace: Add the Function Boundary Trace (FBT) provider moduile. Thisdarran module instruments every function in the kernel with entry and exit probes. These probes are true zero-effect probes in that they don't exist in the code until they are enabled. The probes are enabled by directly patching the function entry and exit points to make jumps into the dtrace framework. This gives us over 29,000 trace points in the kernel. 2010-03-10DTrace: fix a build problem for the SDT provider.darran 2010-03-01DTrace: Add an SDT (Statically Defined Tracing) provider framework, anddarran implement most of the proc provider. Adds proc:::create, exec, exec_success, exec_faillure, signal_send, signal_discard, signal_handle, lwp_create, lwp_start, lwp_exit. 2010-02-21DTrace: add the dtrace module.darran