Sat Jun 27 13:53:10 2020 UTC ()
prop_dictionary_[sg]et_cstring{,_nocopy} -> prop_dictionary_[sg]et_string{,_nocopy}


(jmcneill)
diff -r1.271 -r1.272 src/sys/kern/subr_autoconf.c

cvs diff -r1.271 -r1.272 src/sys/kern/subr_autoconf.c (expand / switch to unified diff)

--- src/sys/kern/subr_autoconf.c 2020/05/25 21:05:01 1.271
+++ src/sys/kern/subr_autoconf.c 2020/06/27 13:53:10 1.272
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: subr_autoconf.c,v 1.271 2020/05/25 21:05:01 thorpej Exp $ */ 1/* $NetBSD: subr_autoconf.c,v 1.272 2020/06/27 13:53:10 jmcneill Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996, 2000 Christopher G. Demetriou 4 * Copyright (c) 1996, 2000 Christopher G. Demetriou
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -67,27 +67,27 @@ @@ -67,27 +67,27 @@
67 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 67 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 68 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 69 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 70 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 71 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 * SUCH DAMAGE. 72 * SUCH DAMAGE.
73 * 73 *
74 * from: Header: subr_autoconf.c,v 1.12 93/02/01 19:31:48 torek Exp (LBL) 74 * from: Header: subr_autoconf.c,v 1.12 93/02/01 19:31:48 torek Exp (LBL)
75 * 75 *
76 * @(#)subr_autoconf.c 8.3 (Berkeley) 5/17/94 76 * @(#)subr_autoconf.c 8.3 (Berkeley) 5/17/94
77 */ 77 */
78 78
79#include <sys/cdefs.h> 79#include <sys/cdefs.h>
80__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.271 2020/05/25 21:05:01 thorpej Exp $"); 80__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.272 2020/06/27 13:53:10 jmcneill Exp $");
81 81
82#ifdef _KERNEL_OPT 82#ifdef _KERNEL_OPT
83#include "opt_ddb.h" 83#include "opt_ddb.h"
84#include "drvctl.h" 84#include "drvctl.h"
85#endif 85#endif
86 86
87#include <sys/param.h> 87#include <sys/param.h>
88#include <sys/device.h> 88#include <sys/device.h>
89#include <sys/disklabel.h> 89#include <sys/disklabel.h>
90#include <sys/conf.h> 90#include <sys/conf.h>
91#include <sys/kauth.h> 91#include <sys/kauth.h>
92#include <sys/kmem.h> 92#include <sys/kmem.h>
93#include <sys/systm.h> 93#include <sys/systm.h>
@@ -558,33 +558,33 @@ devmon_report_device(device_t dev, bool  @@ -558,33 +558,33 @@ devmon_report_device(device_t dev, bool
558 const char *where; 558 const char *where;
559 device_t pdev = device_parent(dev); 559 device_t pdev = device_parent(dev);
560 560
561 /* If currently no drvctl device, just return */ 561 /* If currently no drvctl device, just return */
562 if (devmon_insert_vec == no_devmon_insert) 562 if (devmon_insert_vec == no_devmon_insert)
563 return; 563 return;
564 564
565 ev = prop_dictionary_create(); 565 ev = prop_dictionary_create();
566 if (ev == NULL) 566 if (ev == NULL)
567 return; 567 return;
568 568
569 what = (isattach ? "device-attach" : "device-detach"); 569 what = (isattach ? "device-attach" : "device-detach");
570 parent = (pdev == NULL ? "root" : device_xname(pdev)); 570 parent = (pdev == NULL ? "root" : device_xname(pdev));
571 if (prop_dictionary_get_cstring_nocopy(dict, "location", &where)) { 571 if (prop_dictionary_get_string(dict, "location", &where)) {
572 prop_dictionary_set_cstring(ev, "location", where); 572 prop_dictionary_set_string(ev, "location", where);
573 aprint_debug("ev: %s %s at %s in [%s]\n", 573 aprint_debug("ev: %s %s at %s in [%s]\n",
574 what, device_xname(dev), parent, where);  574 what, device_xname(dev), parent, where);
575 } 575 }
576 if (!prop_dictionary_set_cstring(ev, "device", device_xname(dev)) || 576 if (!prop_dictionary_set_string(ev, "device", device_xname(dev)) ||
577 !prop_dictionary_set_cstring(ev, "parent", parent)) { 577 !prop_dictionary_set_string(ev, "parent", parent)) {
578 prop_object_release(ev); 578 prop_object_release(ev);
579 return; 579 return;
580 } 580 }
581 581
582 if ((*devmon_insert_vec)(what, ev) != 0) 582 if ((*devmon_insert_vec)(what, ev) != 0)
583 prop_object_release(ev); 583 prop_object_release(ev);
584} 584}
585 585
586/* 586/*
587 * Add a cfdriver to the system. 587 * Add a cfdriver to the system.
588 */ 588 */
589int 589int
590config_cfdriver_attach(struct cfdriver *cd) 590config_cfdriver_attach(struct cfdriver *cd)
@@ -1444,32 +1444,32 @@ config_devalloc(const device_t parent, c @@ -1444,32 +1444,32 @@ config_devalloc(const device_t parent, c
1444 dev->dv_depth = 0; 1444 dev->dv_depth = 0;
1445 dev->dv_flags |= DVF_ACTIVE; /* always initially active */ 1445 dev->dv_flags |= DVF_ACTIVE; /* always initially active */
1446 if (locs) { 1446 if (locs) {
1447 KASSERT(parent); /* no locators at root */ 1447 KASSERT(parent); /* no locators at root */
1448 ia = cfiattr_lookup(cfdata_ifattr(cf), parent->dv_cfdriver); 1448 ia = cfiattr_lookup(cfdata_ifattr(cf), parent->dv_cfdriver);
1449 dev->dv_locators = 1449 dev->dv_locators =
1450 kmem_alloc(sizeof(int [ia->ci_loclen + 1]), KM_SLEEP); 1450 kmem_alloc(sizeof(int [ia->ci_loclen + 1]), KM_SLEEP);
1451 *dev->dv_locators++ = sizeof(int [ia->ci_loclen + 1]); 1451 *dev->dv_locators++ = sizeof(int [ia->ci_loclen + 1]);
1452 memcpy(dev->dv_locators, locs, sizeof(int [ia->ci_loclen])); 1452 memcpy(dev->dv_locators, locs, sizeof(int [ia->ci_loclen]));
1453 } 1453 }
1454 dev->dv_properties = prop_dictionary_create(); 1454 dev->dv_properties = prop_dictionary_create();
1455 KASSERT(dev->dv_properties != NULL); 1455 KASSERT(dev->dv_properties != NULL);
1456 1456
1457 prop_dictionary_set_cstring_nocopy(dev->dv_properties, 1457 prop_dictionary_set_string_nocopy(dev->dv_properties,
1458 "device-driver", dev->dv_cfdriver->cd_name); 1458 "device-driver", dev->dv_cfdriver->cd_name);
1459 prop_dictionary_set_uint16(dev->dv_properties, 1459 prop_dictionary_set_uint16(dev->dv_properties,
1460 "device-unit", dev->dv_unit); 1460 "device-unit", dev->dv_unit);
1461 if (parent != NULL) { 1461 if (parent != NULL) {
1462 prop_dictionary_set_cstring(dev->dv_properties, 1462 prop_dictionary_set_string(dev->dv_properties,
1463 "device-parent", device_xname(parent)); 1463 "device-parent", device_xname(parent));
1464 } 1464 }
1465 1465
1466 if (dev->dv_cfdriver->cd_attrs != NULL) 1466 if (dev->dv_cfdriver->cd_attrs != NULL)
1467 config_add_attrib_dict(dev); 1467 config_add_attrib_dict(dev);
1468 1468
1469 return dev; 1469 return dev;
1470} 1470}
1471 1471
1472/* 1472/*
1473 * Create an array of device attach attributes and add it 1473 * Create an array of device attach attributes and add it
1474 * to the device's dv_properties dictionary. 1474 * to the device's dv_properties dictionary.
1475 * 1475 *
@@ -1503,41 +1503,41 @@ config_add_attrib_dict(device_t dev) @@ -1503,41 +1503,41 @@ config_add_attrib_dict(device_t dev)
1503 int i, j; 1503 int i, j;
1504 const struct cfiattrdata *ci; 1504 const struct cfiattrdata *ci;
1505 prop_dictionary_t attr_dict, loc_dict; 1505 prop_dictionary_t attr_dict, loc_dict;
1506 prop_array_t attr_array, loc_array; 1506 prop_array_t attr_array, loc_array;
1507 1507
1508 if ((attr_array = prop_array_create()) == NULL) 1508 if ((attr_array = prop_array_create()) == NULL)
1509 return; 1509 return;
1510 1510
1511 for (i = 0; ; i++) { 1511 for (i = 0; ; i++) {
1512 if ((ci = dev->dv_cfdriver->cd_attrs[i]) == NULL) 1512 if ((ci = dev->dv_cfdriver->cd_attrs[i]) == NULL)
1513 break; 1513 break;
1514 if ((attr_dict = prop_dictionary_create()) == NULL) 1514 if ((attr_dict = prop_dictionary_create()) == NULL)
1515 break; 1515 break;
1516 prop_dictionary_set_cstring_nocopy(attr_dict, "attribute-name", 1516 prop_dictionary_set_string_nocopy(attr_dict, "attribute-name",
1517 ci->ci_name); 1517 ci->ci_name);
1518 1518
1519 /* Create an array of the locator names and defaults */ 1519 /* Create an array of the locator names and defaults */
1520 1520
1521 if (ci->ci_loclen != 0 && 1521 if (ci->ci_loclen != 0 &&
1522 (loc_array = prop_array_create()) != NULL) { 1522 (loc_array = prop_array_create()) != NULL) {
1523 for (j = 0; j < ci->ci_loclen; j++) { 1523 for (j = 0; j < ci->ci_loclen; j++) {
1524 loc_dict = prop_dictionary_create(); 1524 loc_dict = prop_dictionary_create();
1525 if (loc_dict == NULL) 1525 if (loc_dict == NULL)
1526 continue; 1526 continue;
1527 prop_dictionary_set_cstring_nocopy(loc_dict, 1527 prop_dictionary_set_string_nocopy(loc_dict,
1528 "loc-name", ci->ci_locdesc[j].cld_name); 1528 "loc-name", ci->ci_locdesc[j].cld_name);
1529 if (ci->ci_locdesc[j].cld_defaultstr != NULL) 1529 if (ci->ci_locdesc[j].cld_defaultstr != NULL)
1530 prop_dictionary_set_cstring_nocopy( 1530 prop_dictionary_set_string_nocopy(
1531 loc_dict, "default", 1531 loc_dict, "default",
1532 ci->ci_locdesc[j].cld_defaultstr); 1532 ci->ci_locdesc[j].cld_defaultstr);
1533 prop_array_set(loc_array, j, loc_dict); 1533 prop_array_set(loc_array, j, loc_dict);
1534 prop_object_release(loc_dict); 1534 prop_object_release(loc_dict);
1535 } 1535 }
1536 prop_dictionary_set_and_rel(attr_dict, "locators", 1536 prop_dictionary_set_and_rel(attr_dict, "locators",
1537 loc_array); 1537 loc_array);
1538 } 1538 }
1539 prop_array_add(attr_array, attr_dict); 1539 prop_array_add(attr_array, attr_dict);
1540 prop_object_release(attr_dict); 1540 prop_object_release(attr_dict);
1541 } 1541 }
1542 if (i == 0) 1542 if (i == 0)
1543 prop_object_release(attr_array); 1543 prop_object_release(attr_array);