Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add device_attached_to_iattr(), which return true if the...
details: https://anonhg.NetBSD.org/src/rev/db9ac5a69078
branches: trunk
changeset: 951516:db9ac5a69078
user: thorpej <thorpej%NetBSD.org@localhost>
date: Thu Feb 04 23:29:16 2021 +0000
description:
Add device_attached_to_iattr(), which return true if the device
attached to the specified interface attribute.
diffstat:
sys/kern/subr_device.c | 26 +++++++++++++++++++++++---
sys/sys/device.h | 3 ++-
2 files changed, 25 insertions(+), 4 deletions(-)
diffs (70 lines):
diff -r a7f74950c07e -r db9ac5a69078 sys/kern/subr_device.c
--- a/sys/kern/subr_device.c Thu Feb 04 22:55:36 2021 +0000
+++ b/sys/kern/subr_device.c Thu Feb 04 23:29:16 2021 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: subr_device.c,v 1.4 2021/01/28 15:53:46 thorpej Exp $ */
+/* $NetBSD: subr_device.c,v 1.5 2021/02/04 23:29:16 thorpej Exp $ */
/*
- * Copyright (c) 2006 The NetBSD Foundation, Inc.
+ * Copyright (c) 2006, 2021 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_device.c,v 1.4 2021/01/28 15:53:46 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_device.c,v 1.5 2021/02/04 23:29:16 thorpej Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -39,6 +39,7 @@
/*
* Accessor functions for the device_t type.
*/
+
devclass_t
device_class(device_t dev)
{
@@ -182,3 +183,22 @@
return strcmp(dev->dv_cfdriver->cd_name, dname) == 0;
}
+
+/*
+ * device_attached_to_iattr:
+ *
+ * Returns true if the device attached to the specified interface
+ * attribute.
+ */
+bool
+device_attached_to_iattr(device_t dev, const char *iattr)
+{
+ cfdata_t cfdata = device_cfdata(dev);
+ const struct cfparent *pspec;
+
+ if (cfdata == NULL || (pspec = cfdata->cf_pspec) == NULL) {
+ return false;
+ }
+
+ return strcmp(pspec->cfp_iattr, iattr) == 0;
+}
diff -r a7f74950c07e -r db9ac5a69078 sys/sys/device.h
--- a/sys/sys/device.h Thu Feb 04 22:55:36 2021 +0000
+++ b/sys/sys/device.h Thu Feb 04 23:29:16 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: device.h,v 1.164 2021/01/27 04:54:08 thorpej Exp $ */
+/* $NetBSD: device.h,v 1.165 2021/02/04 23:29:16 thorpej Exp $ */
/*
* Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -544,6 +544,7 @@
void (*)(device_t, devactive_t));
bool device_is_a(device_t, const char *);
+bool device_attached_to_iattr(device_t, const char *);
device_t device_find_by_xname(const char *);
device_t device_find_by_driver_unit(const char *, int);
Home |
Main Index |
Thread Index |
Old Index