whitelist -> permitlist

This commit is contained in:
thorpej 2020-07-07 16:14:23 +00:00
parent 1d895808a5
commit e161d68a32
3 changed files with 26 additions and 25 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: x86_autoconf.c,v 1.82 2020/05/02 16:44:36 bouyer Exp $ */
/* $NetBSD: x86_autoconf.c,v 1.83 2020/07/07 16:14:23 thorpej Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: x86_autoconf.c,v 1.82 2020/05/02 16:44:36 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: x86_autoconf.c,v 1.83 2020/07/07 16:14:23 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -569,24 +569,24 @@ device_register(device_t dev, void *aux)
*/
if (device_is_a(dev, "iic") &&
device_is_a(dev->dv_parent, "imcsmb")) {
static const char *imcsmb_device_whitelist[] = {
static const char *imcsmb_device_permitlist[] = {
"spdmem",
"sdtemp",
NULL,
};
prop_array_t whitelist = prop_array_create();
prop_array_t permitlist = prop_array_create();
prop_dictionary_t props = device_properties(dev);
int i;
for (i = 0; imcsmb_device_whitelist[i] != NULL; i++) {
for (i = 0; imcsmb_device_permitlist[i] != NULL; i++) {
prop_string_t pstr = prop_string_create_cstring_nocopy(
imcsmb_device_whitelist[i]);
(void) prop_array_add(whitelist, pstr);
imcsmb_device_permitlist[i]);
(void) prop_array_add(permitlist, pstr);
prop_object_release(pstr);
}
(void) prop_dictionary_set(props,
I2C_PROP_INDIRECT_DEVICE_WHITELIST,
whitelist);
I2C_PROP_INDIRECT_DEVICE_PERMITLIST,
permitlist);
(void) prop_dictionary_set_cstring_nocopy(props,
I2C_PROP_INDIRECT_PROBE_STRATEGY,
I2C_PROBE_STRATEGY_NONE);

View File

@ -1,4 +1,4 @@
/* $NetBSD: i2c.c,v 1.74 2020/06/12 03:32:30 thorpej Exp $ */
/* $NetBSD: i2c.c,v 1.75 2020/07/07 16:14:23 thorpej Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@ -40,7 +40,7 @@
#endif
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.74 2020/06/12 03:32:30 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.75 2020/07/07 16:14:23 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -207,29 +207,30 @@ iic_probe_smbus_receive_byte(struct iic_softc *sc,
}
static bool
iic_indirect_driver_is_whitelisted(struct iic_softc *sc, cfdata_t cf)
iic_indirect_driver_is_permitted(struct iic_softc *sc, cfdata_t cf)
{
prop_object_iterator_t iter;
prop_array_t whitelist;
prop_array_t permitlist;
prop_string_t pstr;
prop_type_t ptype;
bool rv = false;
whitelist = prop_dictionary_get(device_properties(sc->sc_dev),
I2C_PROP_INDIRECT_DEVICE_WHITELIST);
if (whitelist == NULL) {
/* No whitelist -> everything allowed */
permitlist = prop_dictionary_get(device_properties(sc->sc_dev),
I2C_PROP_INDIRECT_DEVICE_PERMITLIST);
if (permitlist == NULL) {
/* No permitlist -> everything allowed */
return (true);
}
if ((ptype = prop_object_type(whitelist)) != PROP_TYPE_ARRAY) {
if ((ptype = prop_object_type(permitlist)) != PROP_TYPE_ARRAY) {
aprint_error_dev(sc->sc_dev,
"invalid property type (%d) for '%s'; must be array (%d)\n",
ptype, I2C_PROP_INDIRECT_DEVICE_WHITELIST, PROP_TYPE_ARRAY);
ptype, I2C_PROP_INDIRECT_DEVICE_PERMITLIST,
PROP_TYPE_ARRAY);
return (false);
}
iter = prop_array_iterator(whitelist);
iter = prop_array_iterator(permitlist);
while ((pstr = prop_object_iterator_next(iter)) != NULL) {
if (prop_string_equals_string(pstr, cf->cf_name)) {
rv = true;
@ -253,9 +254,9 @@ iic_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
/*
* Before we do any more work, consult the allowed-driver
* white-list for this bus (if any).
* permit-list for this bus (if any).
*/
if (iic_indirect_driver_is_whitelisted(sc, cf) == false)
if (iic_indirect_driver_is_permitted(sc, cf) == false)
return (0);
/* default to "quick write". */

View File

@ -1,4 +1,4 @@
/* $NetBSD: i2cvar.h,v 1.19 2019/12/22 23:23:32 thorpej Exp $ */
/* $NetBSD: i2cvar.h,v 1.20 2020/07/07 16:14:23 thorpej Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@ -61,8 +61,8 @@
#define I2C_PROBE_STRATEGY_NONE \
"none"
#define I2C_PROP_INDIRECT_DEVICE_WHITELIST \
"i2c-indirect-device-whitelist"
#define I2C_PROP_INDIRECT_DEVICE_PERMITLIST \
"i2c-indirect-device-permitlist"
/* value is a prop_array of prop_strings */
struct ic_intr_list {