Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/gpio use l->l_cred since it is available.
details: https://anonhg.NetBSD.org/src/rev/a4aa2787f275
branches: trunk
changeset: 1023666:a4aa2787f275
user: christos <christos%NetBSD.org@localhost>
date: Tue Sep 21 14:36:34 2021 +0000
description:
use l->l_cred since it is available.
diffstat:
sys/arch/i386/isa/cmos.c | 6 ++--
sys/dev/gpio/gpio.c | 61 ++++++++++++++++++++++-------------------------
2 files changed, 32 insertions(+), 35 deletions(-)
diffs (217 lines):
diff -r 6b111dc51d7f -r a4aa2787f275 sys/arch/i386/isa/cmos.c
--- a/sys/arch/i386/isa/cmos.c Tue Sep 21 14:30:15 2021 +0000
+++ b/sys/arch/i386/isa/cmos.c Tue Sep 21 14:36:34 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cmos.c,v 1.12 2015/08/20 14:40:16 christos Exp $ */
+/* $NetBSD: cmos.c,v 1.13 2021/09/21 14:36:34 christos Exp $ */
/*
* Copyright (C) 2003 JONE System Co., Inc.
@@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cmos.c,v 1.12 2015/08/20 14:40:16 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cmos.c,v 1.13 2021/09/21 14:36:34 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -124,7 +124,7 @@
cmos_open(dev_t dev, int flags, int ifmt, struct lwp *l)
{
- return kauth_authorize_machdep(kauth_cred_get(),
+ return kauth_authorize_machdep(l->l_cred,
KAUTH_MACHDEP_NVRAM, NULL, NULL, NULL, NULL);
}
diff -r 6b111dc51d7f -r a4aa2787f275 sys/dev/gpio/gpio.c
--- a/sys/dev/gpio/gpio.c Tue Sep 21 14:30:15 2021 +0000
+++ b/sys/dev/gpio/gpio.c Tue Sep 21 14:36:34 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gpio.c,v 1.67 2021/08/09 20:49:09 andvar Exp $ */
+/* $NetBSD: gpio.c,v 1.68 2021/09/21 14:38:51 christos Exp $ */
/* $OpenBSD: gpio.c,v 1.6 2006/01/14 12:33:49 grange Exp $ */
/*
@@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.67 2021/08/09 20:49:09 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.68 2021/09/21 14:38:51 christos Exp $");
/*
* General Purpose Input/Output framework.
@@ -88,7 +88,7 @@
#ifdef COMPAT_50
/* Old API */
static int gpio_ioctl_oapi(struct gpio_softc *, u_long, void *, int,
- kauth_cred_t);
+ struct lwp *);
#endif
CFATTACH_DECL3_NEW(gpio, sizeof(struct gpio_softc),
@@ -690,7 +690,6 @@
#endif
device_t dv;
cfdata_t cf;
- kauth_cred_t cred;
int locs[GPIOCF_NLOCS];
int error, pin, value, flags, npins;
@@ -703,13 +702,11 @@
return EBUSY;
}
- cred = kauth_cred_get();
-
switch (cmd) {
case GPIOINFO:
info = data;
- if (!kauth_authorize_device(cred, KAUTH_DEVICE_GPIO_PINSET,
- NULL, NULL, NULL, NULL))
+ if (!kauth_authorize_device(l->l_cred,
+ KAUTH_DEVICE_GPIO_PINSET, NULL, NULL, NULL, NULL))
info->gpio_npins = sc->sc_npins;
else {
for (pin = npins = 0; pin < sc->sc_npins; pin++)
@@ -729,8 +726,8 @@
return EINVAL;
if (!(sc->sc_pins[pin].pin_flags & GPIO_PIN_SET) &&
- kauth_authorize_device(cred, KAUTH_DEVICE_GPIO_PINSET,
- NULL, NULL, NULL, NULL))
+ kauth_authorize_device(l->l_cred,
+ KAUTH_DEVICE_GPIO_PINSET, NULL, NULL, NULL, NULL))
return EPERM;
/* return read value */
@@ -759,8 +756,8 @@
return EBUSY;
if (!(sc->sc_pins[pin].pin_flags & GPIO_PIN_SET) &&
- kauth_authorize_device(cred, KAUTH_DEVICE_GPIO_PINSET,
- NULL, NULL, NULL, NULL))
+ kauth_authorize_device(l->l_cred,
+ KAUTH_DEVICE_GPIO_PINSET, NULL, NULL, NULL, NULL))
return EPERM;
value = req->gp_value;
@@ -791,8 +788,8 @@
return EBUSY;
if (!(sc->sc_pins[pin].pin_flags & GPIO_PIN_SET) &&
- kauth_authorize_device(cred, KAUTH_DEVICE_GPIO_PINSET,
- NULL, NULL, NULL, NULL))
+ kauth_authorize_device(l->l_cred,
+ KAUTH_DEVICE_GPIO_PINSET, NULL, NULL, NULL, NULL))
return EPERM;
value = (sc->sc_pins[pin].pin_state == GPIO_PIN_LOW ?
@@ -818,8 +815,8 @@
*/
attach = data;
#endif
- if (kauth_authorize_device(cred, KAUTH_DEVICE_GPIO_PINSET,
- NULL, NULL, NULL, NULL))
+ if (kauth_authorize_device(l->l_cred,
+ KAUTH_DEVICE_GPIO_PINSET, NULL, NULL, NULL, NULL))
return EPERM;
/* do not try to attach if the pins are already mapped */
@@ -878,8 +875,8 @@
mutex_exit(&sc->sc_mtx);
return error;
case GPIOSET:
- if (kauth_authorize_device(cred, KAUTH_DEVICE_GPIO_PINSET,
- NULL, NULL, NULL, NULL))
+ if (kauth_authorize_device(l->l_cred,
+ KAUTH_DEVICE_GPIO_PINSET, NULL, NULL, NULL, NULL))
return EPERM;
set = data;
@@ -935,8 +932,8 @@
}
break;
case GPIOUNSET:
- if (kauth_authorize_device(cred, KAUTH_DEVICE_GPIO_PINSET,
- NULL, NULL, NULL, NULL))
+ if (kauth_authorize_device(l->l_cred,
+ KAUTH_DEVICE_GPIO_PINSET, NULL, NULL, NULL, NULL))
return EPERM;
set = data;
@@ -965,7 +962,7 @@
#ifdef COMPAT_50
/* Try the old API */
DPRINTF(("%s: trying the old API\n", device_xname(sc->sc_dev)));
- return gpio_ioctl_oapi(sc, cmd, data, flag, cred);
+ return gpio_ioctl_oapi(sc, cmd, data, flag, l);
#else
return ENOTTY;
#endif
@@ -976,7 +973,7 @@
#ifdef COMPAT_50
static int
gpio_ioctl_oapi(struct gpio_softc *sc, u_long cmd, void *data, int flag,
- kauth_cred_t cred)
+ struct lwp *l)
{
gpio_chipset_tag_t gc;
struct gpio_pin_op *op;
@@ -998,8 +995,8 @@
return EINVAL;
if (!(sc->sc_pins[pin].pin_flags & GPIO_PIN_SET) &&
- kauth_authorize_device(cred, KAUTH_DEVICE_GPIO_PINSET,
- NULL, NULL, NULL, NULL))
+ kauth_authorize_device(l->l_cred,
+ KAUTH_DEVICE_GPIO_PINSET, NULL, NULL, NULL, NULL))
return EPERM;
/* return read value */
@@ -1020,8 +1017,8 @@
return EBUSY;
if (!(sc->sc_pins[pin].pin_flags & GPIO_PIN_SET) &&
- kauth_authorize_device(cred, KAUTH_DEVICE_GPIO_PINSET,
- NULL, NULL, NULL, NULL))
+ kauth_authorize_device(l->l_cred,
+ KAUTH_DEVICE_GPIO_PINSET, NULL, NULL, NULL, NULL))
return EPERM;
value = op->gp_value;
@@ -1049,8 +1046,8 @@
return EBUSY;
if (!(sc->sc_pins[pin].pin_flags & GPIO_PIN_SET) &&
- kauth_authorize_device(cred, KAUTH_DEVICE_GPIO_PINSET,
- NULL, NULL, NULL, NULL))
+ kauth_authorize_device(l->l_cred,
+ KAUTH_DEVICE_GPIO_PINSET, NULL, NULL, NULL, NULL))
return EPERM;
value = (sc->sc_pins[pin].pin_state == GPIO_PIN_LOW ?
@@ -1064,8 +1061,8 @@
case GPIOPINCTL:
ctl = data;
- if (kauth_authorize_device(cred, KAUTH_DEVICE_GPIO_PINSET,
- NULL, NULL, NULL, NULL))
+ if (kauth_authorize_device(l->l_cred,
+ KAUTH_DEVICE_GPIO_PINSET, NULL, NULL, NULL, NULL))
return EPERM;
pin = ctl->gp_pin;
@@ -1092,8 +1089,8 @@
case GPIODETACH50:
/* FALLTHOUGH */
case GPIODETACH:
- if (kauth_authorize_device(cred, KAUTH_DEVICE_GPIO_PINSET,
- NULL, NULL, NULL, NULL))
+ if (kauth_authorize_device(l->l_cred,
+ KAUTH_DEVICE_GPIO_PINSET, NULL, NULL, NULL, NULL))
return EPERM;
error = 0;
Home |
Main Index |
Thread Index |
Old Index