diff options
| author | rkujawa <rkujawa@NetBSD.org> | 2013-10-15 10:27:55 +0000 |
|---|---|---|
| committer | rkujawa <rkujawa@NetBSD.org> | 2013-10-15 10:27:55 +0000 |
| commit | ac522f5bb5e78e38ce54b53ec64c3a342ef8e178 (patch) | |
| tree | 477ca86507202f9d37119ecbd8dc4b6dd369bfd2 /sys/dev | |
| parent | 14544937a3037191db4b5c0dee563f6bd2a9f1e6 (diff) | |
Simplify sysctl handling.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/i2c/mcp980x.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/sys/dev/i2c/mcp980x.c b/sys/dev/i2c/mcp980x.c index 8a9a25d9b02..097e2cf8758 100644 --- a/sys/dev/i2c/mcp980x.c +++ b/sys/dev/i2c/mcp980x.c @@ -1,4 +1,4 @@ -/* $NetBSD: mcp980x.c,v 1.2 2013/10/15 10:18:49 rkujawa Exp $ */ +/* $NetBSD: mcp980x.c,v 1.3 2013/10/15 10:27:55 rkujawa Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mcp980x.c,v 1.2 2013/10/15 10:18:49 rkujawa Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mcp980x.c,v 1.3 2013/10/15 10:27:55 rkujawa Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -308,25 +308,24 @@ sysctl_mcp980x_res(SYSCTLFN_ARGS) { struct sysctlnode node = *rnode; struct mcp980x_softc *sc = node.sysctl_data; - int newres; + int newres, err; + + node.sysctl_data = &sc->sc_res; + if ((err = (sysctl_lookup(SYSCTLFN_CALL(&node)))) != 0) + return err; if (newp) { - node.sysctl_data = &sc->sc_res; - if (sysctl_lookup(SYSCTLFN_CALL(&node)) == 0) { - newres = *(int *)node.sysctl_data; - if (newres > MCP980X_CONFIG_ADC_RES_12BIT) - return EINVAL; - sc->sc_res = (uint8_t) newres; - mcp980x_resolution_set(sc, sc->sc_res); - return 0; - } + newres = *(int *)node.sysctl_data; + if (newres > MCP980X_CONFIG_ADC_RES_12BIT) + return EINVAL; + sc->sc_res = (uint8_t) newres; + mcp980x_resolution_set(sc, sc->sc_res); + return 0; } else { sc->sc_res = mcp980x_resolution_get(sc); - node.sysctl_data = &sc->sc_res; node.sysctl_size = 4; - return (sysctl_lookup(SYSCTLFN_CALL(&node))); } - return EINVAL; + return err; } |
