> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/man/man9/bus_child_present.9.md).

# bus\_child\_present.9

`bus_child_present` — 询问总线驱动程序此设备是否仍然实际存在

## 名称

`bus_child_present`

## 概要

```c
#include <sys/param.h>
#include <sys/bus.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>

int
bus_child_present(device_t dev)
```

## 描述

`bus_child_present` 函数请求 `dev` 的父设备驱动程序检查 `dev` 所代表的硬件此时是否仍然可以物理访问。虽然可访问的概念因总线而异，但通常不可访问的硬件无法通过 `bus_space*` 方法访问，而该方法原本用于访问设备。

这不询问"此设备是否有子设备？"的问题，该问题可通过 [device\_get\_children(9)](/man/man9/device_get_children.9.md) 更好地回答。

## 返回值

零返回值表示设备不在系统中。非零返回值表示设备在系统中，或者设备状态无法确定。

## 实例

以下是示例代码。仅在 [dc(4)](/man/man4/dc.4.md) 设备实际存在时才调用 stop。

```c
device_t dev;
dc_softc *sc;
sc = device_get_softc(dev);
if (bus_child_present(dev))
	dc_stop(sc);
```

## 参见

[device(9)](/man/man9/device.9.md), [driver(9)](/man/man9/driver.9.md)

## 作者

本手册页由 Warner Losh <imp@FreeBSD.org> 编写。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/man/man9/bus_child_present.9.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
