Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/dm dm: Style cleanups (no functional changes)
details: https://anonhg.NetBSD.org/src/rev/d97320ede981
branches: trunk
changeset: 1005637:d97320ede981
user: tkusumi <tkusumi%NetBSD.org@localhost>
date: Sun Dec 15 14:39:42 2019 +0000
description:
dm: Style cleanups (no functional changes)
diffstat:
sys/dev/dm/device-mapper.c | 48 ++++++++++++----------------------------
sys/dev/dm/dm_dev.c | 25 ++++++++++-----------
sys/dev/dm/dm_ioctl.c | 31 +++++++------------------
sys/dev/dm/dm_pdev.c | 8 ++++--
sys/dev/dm/dm_table.c | 18 +++++++++-----
sys/dev/dm/dm_target.c | 23 ++++++++++---------
sys/dev/dm/dm_target_error.c | 10 +++++---
sys/dev/dm/dm_target_linear.c | 6 ++--
sys/dev/dm/dm_target_mirror.c | 10 +++++---
sys/dev/dm/dm_target_snapshot.c | 11 ++++-----
sys/dev/dm/dm_target_stripe.c | 8 +++---
sys/dev/dm/dm_target_zero.c | 12 +++++-----
12 files changed, 94 insertions(+), 116 deletions(-)
diffs (truncated from 1099 to 300 lines):
diff -r fd504dbd41d8 -r d97320ede981 sys/dev/dm/device-mapper.c
--- a/sys/dev/dm/device-mapper.c Sun Dec 15 14:21:34 2019 +0000
+++ b/sys/dev/dm/device-mapper.c Sun Dec 15 14:39:42 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: device-mapper.c,v 1.53 2019/12/15 10:12:45 tkusumi Exp $ */
+/* $NetBSD: device-mapper.c,v 1.54 2019/12/15 14:39:42 tkusumi Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -35,7 +35,6 @@
#include <sys/types.h>
#include <sys/param.h>
-
#include <sys/buf.h>
#include <sys/conf.h>
#include <sys/device.h>
@@ -236,7 +235,7 @@
{
/* Pseudo-device; always present. */
- return (1);
+ return 1;
}
/*
@@ -247,10 +246,8 @@
static void
dm_attach(device_t parent, device_t self, void *aux)
{
- return;
}
-
/*
* dm_detach:
*
@@ -291,6 +288,7 @@
static void
dm_doinit(void)
{
+
dm_target_init();
dm_dev_init();
dm_pdev_init();
@@ -303,12 +301,11 @@
int error;
error = config_cfattach_attach(dm_cd.cd_name, &dm_ca);
- if (error) {
+ if (error)
aprint_error("%s: unable to register cfattach\n",
dm_cd.cd_name);
- } else {
+ else
dm_doinit();
- }
}
#ifdef _MODULE
@@ -388,16 +385,14 @@
*/
static int
dm_cmd_to_fun(prop_dictionary_t dm_dict)
- {
+{
int i, r;
prop_string_t command;
- r = 0;
-
if ((command = prop_dictionary_get(dm_dict, DM_IOCTL_COMMAND)) == NULL)
return EINVAL;
- for(i = 0; cmd_fn[i].cmd != NULL; i++)
+ for (i = 0; cmd_fn[i].cmd != NULL; i++)
if (prop_string_equals_cstring(command, cmd_fn[i].cmd))
break;
@@ -412,9 +407,8 @@
aprint_debug("ioctl %s called %p\n", cmd_fn[i].cmd, cmd_fn[i].fn);
if (cmd_fn[i].fn == NULL)
return 0;
- r = cmd_fn[i].fn(dm_dict);
- return r;
+ return cmd_fn[i].fn(dm_dict);
}
/* Call apropriate ioctl handler function. */
@@ -469,7 +463,6 @@
dm_dev_unbusy(dmv);
break;
}
-
case DIOCGDISKINFO:
{
struct plistref *pref = (struct plistref *) data;
@@ -487,7 +480,6 @@
dm_dev_unbusy(dmv);
break;
}
-
case DIOCCACHESYNC:
{
dm_table_entry_t *table_en;
@@ -510,7 +502,6 @@
dm_dev_unbusy(dmv);
break;
}
-
case DIOCGSECTORSIZE:
{
u_int *valp = data;
@@ -528,7 +519,6 @@
dm_dev_unbusy(dmv);
break;
}
-
case DIOCGMEDIASIZE:
{
off_t *valp = data;
@@ -546,7 +536,6 @@
dm_dev_unbusy(dmv);
break;
}
-
default:
aprint_debug("unknown disk_ioctl called\n");
return ENOTTY;
@@ -563,7 +552,7 @@
dmstrategy(struct buf *bp)
{
dm_dev_t *dmv;
- dm_table_t *tbl;
+ dm_table_t *tbl;
dm_table_entry_t *table_en;
struct buf *nestbuf;
@@ -574,8 +563,6 @@
buf_start = bp->b_blkno * DEV_BSIZE;
buf_len = bp->b_bcount;
- tbl = NULL;
-
table_end = 0;
issued_len = 0;
@@ -620,9 +607,7 @@
* off by one error
*/
table_end = table_start + table_en->length * DEV_BSIZE;
-
start = MAX(table_start, buf_start);
-
end = MIN(table_end, buf_start + buf_len);
aprint_debug("----------------------------------------\n");
@@ -639,15 +624,11 @@
if (start < end) {
/* create nested buffer */
nestbuf = getiobuf(NULL, true);
-
nestiobuf_setup(bp, nestbuf, start - buf_start,
- (end - start));
-
+ end - start);
issued_len += end - start;
-
/* I need number of blocks. */
nestbuf->b_blkno = (start - table_start) / DEV_BSIZE;
-
table_en->target->strategy(table_en, nestbuf);
}
}
@@ -656,7 +637,7 @@
nestiobuf_done(bp, buf_len - issued_len, EINVAL);
mutex_enter(&dmv->diskp_mtx);
- disk_unbusy(dmv->diskp, buf_len, bp != NULL ? bp->b_flags & B_READ : 0);
+ disk_unbusy(dmv->diskp, buf_len, bp ? (bp->b_flags & B_READ) : 0);
mutex_exit(&dmv->diskp_mtx);
dm_table_release(&dmv->table_head, DM_TABLE_ACTIVE);
@@ -668,14 +649,14 @@
dmread(dev_t dev, struct uio *uio, int flag)
{
- return (physio(dmstrategy, NULL, dev, B_READ, dmminphys, uio));
+ return physio(dmstrategy, NULL, dev, B_READ, dmminphys, uio);
}
static int
dmwrite(dev_t dev, struct uio *uio, int flag)
{
- return (physio(dmstrategy, NULL, dev, B_WRITE, dmminphys, uio));
+ return physio(dmstrategy, NULL, dev, B_WRITE, dmminphys, uio);
}
static int
@@ -705,10 +686,11 @@
{
uint64_t numsec;
unsigned int secsize;
+ struct disk_geom *dg;
dm_table_disksize(head, &numsec, &secsize);
- struct disk_geom *dg = &disk->dk_geom;
+ dg = &disk->dk_geom;
memset(dg, 0, sizeof(*dg));
dg->dg_secperunit = numsec;
diff -r fd504dbd41d8 -r d97320ede981 sys/dev/dm/dm_dev.c
--- a/sys/dev/dm/dm_dev.c Sun Dec 15 14:21:34 2019 +0000
+++ b/sys/dev/dm/dm_dev.c Sun Dec 15 14:39:42 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_dev.c,v 1.15 2019/12/14 10:49:30 tkusumi Exp $ */
+/* $NetBSD: dm_dev.c,v 1.16 2019/12/15 14:39:42 tkusumi Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,11 +29,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_dev.c,v 1.15 2019/12/14 10:49:30 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_dev.c,v 1.16 2019/12/15 14:39:42 tkusumi Exp $");
#include <sys/types.h>
#include <sys/param.h>
-
#include <sys/disk.h>
#include <sys/disklabel.h>
#include <sys/ioctl.h>
@@ -47,8 +46,7 @@
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);
+static struct dm_dev_head dm_dev_list = TAILQ_HEAD_INITIALIZER(dm_dev_list);
static kmutex_t dm_dev_mutex;
@@ -56,6 +54,7 @@
__inline static void
disable_dev(dm_dev_t *dmv)
{
+
TAILQ_REMOVE(&dm_dev_list, dmv, next_devlist);
mutex_enter(&dmv->dev_mtx);
mutex_exit(&dm_dev_mutex);
@@ -74,9 +73,7 @@
{
dm_dev_t *dmv;
- dmv = NULL;
mutex_enter(&dm_dev_mutex);
-
/* KASSERT(dm_dev_name != NULL && dm_dev_uuid != NULL && dm_dev_minor
* > 0); */
if (dm_dev_minor > 0)
@@ -98,6 +95,7 @@
return dmv;
}
mutex_exit(&dm_dev_mutex);
+
return NULL;
}
@@ -109,10 +107,9 @@
{
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;
}
@@ -191,8 +188,8 @@
TAILQ_INSERT_TAIL(&dm_dev_list, dev, next_devlist);
} else
r = EEXIST;
+ mutex_exit(&dm_dev_mutex);
- mutex_exit(&dm_dev_mutex);
return r;
}
@@ -249,10 +246,8 @@
int dm_dev_minor)
{
dm_dev_t *dmv;
- dmv = NULL;
Home |
Main Index |
Thread Index |
Old Index