From 5c933238b98f5e3619bf880089a784dd561d3ac3 Mon Sep 17 00:00:00 2001 From: Alex Legg <alexlegg@google.com> Date: Tue, 30 Apr 2019 22:48:52 +0000 Subject: [PATCH] [ddk] Remove open_at device hook The DirectoryOpen handler will be removed along with resulting changes to devfs in a follow up CL. Change-Id: I37df4c6bdf2aba84575a5ab6b692b2da5f362185 --- .../fuchsia-ddk/fuchsia-ddk-sys/src/lib.rs | 2 -- garnet/public/rust/fuchsia-ddk/src/lib.rs | 12 ------- zircon/docs/ddk/advanced.md | 2 +- zircon/docs/ddk/device-ops.md | 33 ++++++------------- zircon/system/core/devmgr/devhost/api.cpp | 11 +++---- zircon/system/core/devmgr/devhost/core.cpp | 19 ++--------- zircon/system/core/devmgr/devhost/devhost.cpp | 6 +++- zircon/system/core/devmgr/devhost/devhost.h | 5 ++- .../system/core/devmgr/devhost/rpc-server.cpp | 2 +- zircon/system/core/devmgr/devhost/zx-device.h | 10 ++---- .../intel-hda/controller/intel-hda-codec.cpp | 1 - .../controller/intel-hda-controller.cpp | 2 -- zircon/system/dev/bus/virtio/ethernet.cpp | 1 - zircon/system/dev/bus/virtio/socket.cpp | 1 - .../dev/display/vim-display/vim-display.cpp | 1 - zircon/system/dev/test/mock-device/device.cpp | 12 ------- zircon/system/ulib/ddk/include/ddk/device.h | 21 +++--------- .../ddktl/include/ddktl/device-internal.h | 13 -------- .../system/ulib/ddktl/include/ddktl/device.h | 20 ----------- .../system/ulib/ddktl/test/device-tests.cpp | 16 --------- .../codec-utils/codec-driver-base.cpp | 1 - .../intel-hda/codec-utils/stream-base.cpp | 1 - 22 files changed, 35 insertions(+), 157 deletions(-) diff --git a/garnet/public/rust/fuchsia-ddk/fuchsia-ddk-sys/src/lib.rs b/garnet/public/rust/fuchsia-ddk/fuchsia-ddk-sys/src/lib.rs index 820e2d94209..16b14c4db2b 100644 --- a/garnet/public/rust/fuchsia-ddk/fuchsia-ddk-sys/src/lib.rs +++ b/garnet/public/rust/fuchsia-ddk/fuchsia-ddk-sys/src/lib.rs @@ -97,7 +97,6 @@ pub struct zx_protocol_device_t { pub get_protocol: Option<unsafe extern "C" fn (ctx: *mut u8, proto_id: u32, protocol: *mut u8) -> sys::zx_status_t>, pub open: Option<unsafe extern "C" fn (ctx: *mut u8, dev_out: *mut *mut zx_device_t, flags: u32) -> sys::zx_status_t>, - pub open_at: Option<unsafe extern "C" fn (ctx: *mut u8, dev_out: *mut *mut zx_device_t, path: *const c_char, flags: u32) -> sys::zx_status_t>, pub close: Option<unsafe extern "C" fn (ctx: *mut u8, flags: u32) -> sys::zx_status_t>, pub unbind: Option<unsafe extern "C" fn (ctx: *mut u8)>, pub release: Option<unsafe extern "C" fn (ctx: *mut u8)>, @@ -116,7 +115,6 @@ pub const DEFAULT_PROTOCOL_DEVICE: zx_protocol_device_t = zx_protocol_device_t { __version: DEVICE_OPS_VERSION, get_protocol: None, open: None, - open_at: None, close: None, unbind: None, release: None, diff --git a/garnet/public/rust/fuchsia-ddk/src/lib.rs b/garnet/public/rust/fuchsia-ddk/src/lib.rs index 591f8ff48f4..d0c3a197b7c 100644 --- a/garnet/public/rust/fuchsia-ddk/src/lib.rs +++ b/garnet/public/rust/fuchsia-ddk/src/lib.rs @@ -180,10 +180,6 @@ pub trait DeviceOps { Ok(None) } - fn open_at(&mut self, _path: &str, _flags: u32) -> Result<Option<Device>, Status> { - Err(Status::NOT_SUPPORTED) - } - fn close(&mut self, _flags: u32) -> Status { Status::OK } @@ -257,13 +253,6 @@ unsafe extern fn ddk_open(ctx: *mut u8, dev_out: *mut *mut sys::zx_device_t, fla open_result(ret, dev_out) } -unsafe extern fn ddk_open_at(ctx: *mut u8, dev_out: *mut *mut sys::zx_device_t, path: *const c_char, flags: u32) -> zsys::zx_status_t { - let context = ctx_borrow_mut_device_and_ops(ctx); - let path = CStr::from_ptr(path).to_str().unwrap(); - let ret = context.ops.open_at(path, flags); - open_result(ret, dev_out) -} - unsafe extern fn ddk_close(ctx: *mut u8, flags: u32) -> zsys::zx_status_t { let context = ctx_borrow_mut_device_and_ops(ctx); let ret = context.ops.close(flags); @@ -339,7 +328,6 @@ unsafe extern fn ddk_resume(ctx: *mut u8, flags: u32) -> zsys::zx_status_t { static mut DEVICE_OPS: sys::zx_protocol_device_t = sys::zx_protocol_device_t { get_protocol: Some(ddk_get_protocol), open: Some(ddk_open), - open_at: Some(ddk_open_at), close: Some(ddk_close), unbind: Some(ddk_unbind), release: Some(ddk_release), diff --git a/zircon/docs/ddk/advanced.md b/zircon/docs/ddk/advanced.md index c2f24e39a91..0b1112bcb87 100644 --- a/zircon/docs/ddk/advanced.md +++ b/zircon/docs/ddk/advanced.md @@ -95,7 +95,7 @@ We saw these in the `/dev/misc/demo-fifo` handler above. @@@ Notes only @@@ -This section is great for things like open_at(), talking about buffer management, +This section is great for things like talking about buffer management, threading, best practices, advanced options for device_add(), and so on. I think it can be somewhere between the man page ("printf is used to print a string and takes the following parameters") and an application note — I want to see diff --git a/zircon/docs/ddk/device-ops.md b/zircon/docs/ddk/device-ops.md index 31d253a7615..5c3e216c28b 100644 --- a/zircon/docs/ddk/device-ops.md +++ b/zircon/docs/ddk/device-ops.md @@ -34,25 +34,12 @@ A child created for return as an instance **must** be created with the zx_status_t (*open)(void* ctx, zx_device_t** dev_out, uint32_t flags); ``` -## open_at -DEPRECATED: See ZX-3277. -The open_at hook is called in the event that the open path to the device -contains segments after the device name itself. For example, if a device -exists as `/dev/misc/foo` and an attempt is made to `open("/dev/misc/foo/bar",...)`, -the open_at hook would be invoked with a *path* of `"bar"`. - -The default open_at implementation returns **ZX_ERR_NOT_SUPPORTED** - -``` -zx_status_t (*open_at)(void* ctx, zx_device_t** dev_out, const char* path, uint32_t flags); -``` - ## close -The close hook is called when a connection to a device is closed. These -calls will balance the calls to open or open_at. +The close hook is called when a connection to a device is closed. These +calls will balance the calls to open. -**Note:** If open or open_at return a **device instance**, the balancing close -hook that is called is the close hook on the **instance**, not the parent. +**Note:** If open returns a **device instance**, the balancing close hook +that is called is the close hook on the **instance**, not the parent. The default close implementation returns **ZX_OK**. ``` @@ -62,7 +49,7 @@ zx_status_t (*close)(void* ctx, uint32_t flags); ## unbind The unbind hook is called when the parent of this device is being removed (due to hot unplug, fatal error, etc). At the point unbind is called, it is not -possible for further open or open_at calls to occur, but io operations, etc +possible for further open calls to occur, but io operations, etc may continue until those client connections are closed. The driver should avoid further method calls to its parent device or any @@ -197,11 +184,11 @@ zx_status_t (*message)(void* ctx, fidl_msg_t* msg, fidl_txn_t* txn); #### Device State Bits ``` -#define DEV_STATE_READABLE DEVICE_SIGNAL_READABLE -#define DEV_STATE_WRITABLE DEVICE_SIGNAL_WRITABLE -#define DEV_STATE_ERROR DEVICE_SIGNAL_ERROR -#define DEV_STATE_HANGUP DEVICE_SIGNAL_HANGUP -#define DEV_STATE_OOB DEVICE_SIGNAL_OOB +#define DEV_STATE_READABLE ZX_USER_SIGNAL_0 +#define DEV_STATE_WRITABLE ZX_USER_SIGNAL_2 +#define DEV_STATE_ERROR ZX_USER_SIGNAL_3 +#define DEV_STATE_HANGUP ZX_USER_SIGNAL_4 +#define DEV_STATE_OOB ZX_USER_SIGNAL_1 ``` #### device_state_set diff --git a/zircon/system/core/devmgr/devhost/api.cpp b/zircon/system/core/devmgr/devhost/api.cpp index 843abd84b37..48b62dec341 100644 --- a/zircon/system/core/devmgr/devhost/api.cpp +++ b/zircon/system/core/devmgr/devhost/api.cpp @@ -103,7 +103,7 @@ __EXPORT zx_status_t device_add_from_driver(zx_driver_t* drv, zx_device_t* paren } if (dev && client_remote.is_valid()) { - // This needs to be called outside the ApiAutoLock, as device_open_at will be called + // This needs to be called outside the ApiAutoLock, as device_open will be called devhost_device_connect(dev, ZX_FS_RIGHT_READABLE | ZX_FS_RIGHT_WRITABLE, std::move(client_remote)); @@ -221,14 +221,13 @@ zx_status_t device_unbind(const fbl::RefPtr<zx_device_t>& dev) { return devhost_device_unbind(dev); } -zx_status_t device_open_at(const fbl::RefPtr<zx_device_t>& dev, fbl::RefPtr<zx_device_t>* out, - const char* path, uint32_t flags) { +zx_status_t device_open(const fbl::RefPtr<zx_device_t>& dev, fbl::RefPtr<zx_device_t>* out, + uint32_t flags) { ApiAutoLock lock; - return devhost_device_open_at(dev, out, path, flags); + return devhost_device_open(dev, out, flags); } -// This function is intended to consume the reference produced by -// device_open_at() +// This function is intended to consume the reference produced by device_open() zx_status_t device_close(fbl::RefPtr<zx_device_t> dev, uint32_t flags) { ApiAutoLock lock; return devhost_device_close(std::move(dev), flags); diff --git a/zircon/system/core/devmgr/devhost/core.cpp b/zircon/system/core/devmgr/devhost/core.cpp index f9a587c3538..e29908a5486 100644 --- a/zircon/system/core/devmgr/devhost/core.cpp +++ b/zircon/system/core/devmgr/devhost/core.cpp @@ -66,10 +66,6 @@ static zx_status_t default_open(void* ctx, zx_device_t** out, uint32_t flags) { return ZX_OK; } -static zx_status_t default_open_at(void* ctx, zx_device_t** out, const char* path, uint32_t flags) { - return ZX_ERR_NOT_SUPPORTED; -} - static zx_status_t default_close(void* ctx, uint32_t flags) { return ZX_OK; } @@ -118,7 +114,6 @@ static zx_status_t default_message(void* ctx, fidl_msg_t* msg, fidl_txn_t* txn) zx_protocol_device_t device_default_ops = []() { zx_protocol_device_t ops = {}; ops.open = default_open; - ops.open_at = default_open_at; ops.close = default_close; ops.unbind = default_unbind; ops.release = default_release; @@ -142,9 +137,6 @@ static zx_protocol_device_t device_invalid_ops = []() { zx_protocol_device_t ops = {}; ops.open = +[](void* ctx, zx_device_t**, uint32_t) -> zx_status_t { device_invalid_fatal(ctx); }; - ops.open_at = +[](void* ctx, zx_device_t**, const char*, uint32_t) -> zx_status_t { - device_invalid_fatal(ctx); - }; ops.close = +[](void* ctx, uint32_t) -> zx_status_t { device_invalid_fatal(ctx); }; ops.unbind = +[](void* ctx) { device_invalid_fatal(ctx); }; ops.release = +[](void* ctx) { device_invalid_fatal(ctx); }; @@ -528,9 +520,8 @@ zx_status_t devhost_device_unbind(const fbl::RefPtr<zx_device_t>& dev) REQ_DM_LO return ZX_OK; } -zx_status_t devhost_device_open_at(const fbl::RefPtr<zx_device_t>& dev, - fbl::RefPtr<zx_device_t>* out, const char* path, - uint32_t flags) REQ_DM_LOCK { +zx_status_t devhost_device_open(const fbl::RefPtr<zx_device_t>& dev, fbl::RefPtr<zx_device_t>* out, + uint32_t flags) REQ_DM_LOCK { if (dev->flags & DEV_FLAG_DEAD) { printf("device open: %p(%s) is dead!\n", dev.get(), dev->name); return ZX_ERR_BAD_STATE; @@ -540,11 +531,7 @@ zx_status_t devhost_device_open_at(const fbl::RefPtr<zx_device_t>& dev, zx_device_t* opened_dev = nullptr; { ApiAutoRelock relock; - if (path) { - r = dev->OpenAtOp(&opened_dev, path, flags); - } else { - r = dev->OpenOp(&opened_dev, flags); - } + r = dev->OpenOp(&opened_dev, flags); } if (r < 0) { new_ref.reset(); diff --git a/zircon/system/core/devmgr/devhost/devhost.cpp b/zircon/system/core/devmgr/devhost/devhost.cpp index bef9e0a1898..da6d7022a65 100644 --- a/zircon/system/core/devmgr/devhost/devhost.cpp +++ b/zircon/system/core/devmgr/devhost/devhost.cpp @@ -351,8 +351,12 @@ struct DevhostRpcReadContext { static zx_status_t fidl_devcoord_connection_directory_open(void* ctx, uint32_t flags, uint32_t mode, const char* path_data, size_t path_size, zx_handle_t object) { - auto conn = static_cast<DeviceControllerConnection*>(ctx); zx::channel c(object); + if (path_size != 1 && path_data[0] != '.') { + log(ERROR, "devhost: Tried to open path '%.*s'\n", static_cast<int>(path_size), path_data); + return ZX_OK; + } + auto conn = static_cast<DeviceControllerConnection*>(ctx); return devhost_device_connect(conn->dev, flags, path_data, path_size, std::move(c)); } diff --git a/zircon/system/core/devmgr/devhost/devhost.h b/zircon/system/core/devmgr/devhost/devhost.h index d4d14edc447..1455f7743ca 100644 --- a/zircon/system/core/devmgr/devhost/devhost.h +++ b/zircon/system/core/devmgr/devhost/devhost.h @@ -138,9 +138,8 @@ zx_status_t devhost_device_unbind(const fbl::RefPtr<zx_device_t>& dev) REQ_DM_LO zx_status_t devhost_device_create(zx_driver_t* drv, const char* name, void* ctx, const zx_protocol_device_t* ops, fbl::RefPtr<zx_device_t>* out) REQ_DM_LOCK; -zx_status_t devhost_device_open_at(const fbl::RefPtr<zx_device_t>& dev, - fbl::RefPtr<zx_device_t>* out, const char* path, - uint32_t flags) REQ_DM_LOCK; +zx_status_t devhost_device_open(const fbl::RefPtr<zx_device_t>& dev, fbl::RefPtr<zx_device_t>* out, + uint32_t flags) REQ_DM_LOCK; zx_status_t devhost_device_close(fbl::RefPtr<zx_device_t> dev, uint32_t flags) REQ_DM_LOCK; zx_status_t devhost_device_suspend(const fbl::RefPtr<zx_device_t>& dev, uint32_t flags) REQ_DM_LOCK; void devhost_device_destroy(zx_device_t* dev) REQ_DM_LOCK; diff --git a/zircon/system/core/devmgr/devhost/rpc-server.cpp b/zircon/system/core/devmgr/devhost/rpc-server.cpp index ead3d34f2e5..0eef7e4a551 100644 --- a/zircon/system/core/devmgr/devhost/rpc-server.cpp +++ b/zircon/system/core/devmgr/devhost/rpc-server.cpp @@ -110,7 +110,7 @@ static zx_status_t devhost_get_handles(zx::channel rh, const fbl::RefPtr<zx_devi newconn->flags = flags; fbl::RefPtr<zx_device_t> new_dev; - r = device_open_at(dev, &new_dev, path, flags); + r = device_open(dev, &new_dev, flags); if (r != ZX_OK) { fprintf(stderr, "devhost_get_handles(%p:%s) open path='%s', r=%d\n", dev.get(), dev->name, path ? path : "", r); diff --git a/zircon/system/core/devmgr/devhost/zx-device.h b/zircon/system/core/devmgr/devhost/zx-device.h index 4cba836a787..26152085fc3 100644 --- a/zircon/system/core/devmgr/devhost/zx-device.h +++ b/zircon/system/core/devmgr/devhost/zx-device.h @@ -39,10 +39,6 @@ struct zx_device : fbl::RefCountedUpgradeable<zx_device>, fbl::Recyclable<zx_dev return Dispatch(ops->open, ZX_OK, dev_out, flags); } - zx_status_t OpenAtOp(zx_device_t** dev_out, const char* path, uint32_t flags) { - return Dispatch(ops->open_at, ZX_ERR_NOT_SUPPORTED, dev_out, path, flags); - } - zx_status_t CloseOp(uint32_t flags) { return Dispatch(ops->close, ZX_OK, flags); } @@ -209,8 +205,8 @@ private: zx_status_t device_bind(const fbl::RefPtr<zx_device_t>& dev, const char* drv_libname); zx_status_t device_unbind(const fbl::RefPtr<zx_device_t>& dev); -zx_status_t device_open_at(const fbl::RefPtr<zx_device_t>& dev, fbl::RefPtr<zx_device_t>* out, - const char* path, uint32_t flags); +zx_status_t device_open(const fbl::RefPtr<zx_device_t>& dev, fbl::RefPtr<zx_device_t>* out, + uint32_t flags); // Note that device_close() is intended to consume a reference (logically, the -// one created by device_open_at). +// one created by device_open). zx_status_t device_close(fbl::RefPtr<zx_device_t> dev, uint32_t flags); diff --git a/zircon/system/dev/audio/intel-hda/controller/intel-hda-codec.cpp b/zircon/system/dev/audio/intel-hda/controller/intel-hda-codec.cpp index 127b9b967e5..a22b0d5f378 100644 --- a/zircon/system/dev/audio/intel-hda/controller/intel-hda-codec.cpp +++ b/zircon/system/dev/audio/intel-hda/controller/intel-hda-codec.cpp @@ -53,7 +53,6 @@ zx_protocol_device_t IntelHDACodec::CODEC_DEVICE_THUNKS = { .version = DEVICE_OPS_VERSION, .get_protocol = nullptr, .open = nullptr, - .open_at = nullptr, .close = nullptr, .unbind = nullptr, .release = nullptr, diff --git a/zircon/system/dev/audio/intel-hda/controller/intel-hda-controller.cpp b/zircon/system/dev/audio/intel-hda/controller/intel-hda-controller.cpp index 53d19493419..83dc818eede 100644 --- a/zircon/system/dev/audio/intel-hda/controller/intel-hda-controller.cpp +++ b/zircon/system/dev/audio/intel-hda/controller/intel-hda-controller.cpp @@ -47,7 +47,6 @@ zx_protocol_device_t IntelHDAController::CONTROLLER_DEVICE_THUNKS = { return DEV(ctx)->DeviceGetProtocol(proto_id, protocol); }, .open = nullptr, - .open_at = nullptr, .close = nullptr, .unbind = [](void* ctx) { DEV(ctx)->DeviceShutdown(); }, .release = [](void* ctx) { DEV(ctx)->DeviceRelease(); }, @@ -341,7 +340,6 @@ zx_protocol_device_t IntelHDAController::ROOT_DEVICE_THUNKS = { .version = DEVICE_OPS_VERSION, .get_protocol = nullptr, .open = nullptr, - .open_at = nullptr, .close = nullptr, .unbind = nullptr, .release = [](void* ctx) { DEV(ctx)->RootDeviceRelease(); }, diff --git a/zircon/system/dev/bus/virtio/ethernet.cpp b/zircon/system/dev/bus/virtio/ethernet.cpp index 96cc7af84ba..40d3d6e9293 100644 --- a/zircon/system/dev/bus/virtio/ethernet.cpp +++ b/zircon/system/dev/bus/virtio/ethernet.cpp @@ -74,7 +74,6 @@ zx_protocol_device_t kDeviceOps = { DEVICE_OPS_VERSION, nullptr, // get_protocol nullptr, // open - nullptr, // openat nullptr, // close virtio_net_unbind, virtio_net_release, diff --git a/zircon/system/dev/bus/virtio/socket.cpp b/zircon/system/dev/bus/virtio/socket.cpp index a5f0dacf48d..27a37543d22 100644 --- a/zircon/system/dev/bus/virtio/socket.cpp +++ b/zircon/system/dev/bus/virtio/socket.cpp @@ -108,7 +108,6 @@ static zx_protocol_device_t kDeviceOps = { DEVICE_OPS_VERSION, nullptr, // get_protocol nullptr, // open - nullptr, // openat nullptr, // close virtio_net_unbind, virtio_net_release, diff --git a/zircon/system/dev/display/vim-display/vim-display.cpp b/zircon/system/dev/display/vim-display/vim-display.cpp index 7d9ad2aed36..66b9eb9afd2 100644 --- a/zircon/system/dev/display/vim-display/vim-display.cpp +++ b/zircon/system/dev/display/vim-display/vim-display.cpp @@ -716,7 +716,6 @@ static zx_protocol_device_t main_device_proto = { .version = DEVICE_OPS_VERSION, .get_protocol = display_get_protocol, .open = nullptr, - .open_at = nullptr, .close = nullptr, .unbind = display_unbind, .release = display_release, diff --git a/zircon/system/dev/test/mock-device/device.cpp b/zircon/system/dev/test/mock-device/device.cpp index 7f3e5e53c47..00529345d1f 100644 --- a/zircon/system/dev/test/mock-device/device.cpp +++ b/zircon/system/dev/test/mock-device/device.cpp @@ -39,7 +39,6 @@ public: void DdkRelease(); zx_status_t DdkGetProtocol(uint32_t proto_id, void* out); zx_status_t DdkOpen(zx_device_t** dev_out, uint32_t flags); - zx_status_t DdkOpenAt(zx_device_t** dev_out, const char* path, uint32_t flags); zx_status_t DdkClose(uint32_t flags); void DdkUnbind(); zx_status_t DdkRead(void* buf, size_t count, zx_off_t off, size_t* actual); @@ -228,17 +227,6 @@ zx_status_t MockDevice::DdkOpen(zx_device_t** dev_out, uint32_t flags) { return ctx.hook_status; } -zx_status_t MockDevice::DdkOpenAt(zx_device_t** dev_out, const char* path, uint32_t flags) { - fbl::Array<const fuchsia_device_mock_Action> actions; - zx_status_t status = OpenAtHook(controller_, ConstructHookInvocation(), fbl::StringPiece(path), - flags, &actions); - ZX_ASSERT(status == ZX_OK); - ProcessActionsContext ctx(controller_, true, this, zxdev()); - status = ProcessActions(std::move(actions), &ctx); - ZX_ASSERT(status == ZX_OK); - return ctx.hook_status; -} - zx_status_t MockDevice::DdkClose(uint32_t flags) { fbl::Array<const fuchsia_device_mock_Action> actions; zx_status_t status = CloseHook(controller_, ConstructHookInvocation(), flags, &actions); diff --git a/zircon/system/ulib/ddk/include/ddk/device.h b/zircon/system/ulib/ddk/include/ddk/device.h index ddee6cdee31..e8807a85aef 100644 --- a/zircon/system/ulib/ddk/include/ddk/device.h +++ b/zircon/system/ulib/ddk/include/ddk/device.h @@ -82,23 +82,12 @@ typedef struct zx_protocol_device { // zx_status_t (*open)(void* ctx, zx_device_t** dev_out, uint32_t flags); - //@ ## open_at - // DEPRECATED: See ZX-3277. - // The open_at hook is called in the event that the open path to the device - // contains segments after the device name itself. For example, if a device - // exists as `/dev/misc/foo` and an attempt is made to `open("/dev/misc/foo/bar",...)`, - // the open_at hook would be invoked with a *path* of `"bar"`. - // - // The default open_at implementation returns **ZX_ERR_NOT_SUPPORTED** - // - zx_status_t (*open_at)(void* ctx, zx_device_t** dev_out, const char* path, uint32_t flags); - //@ ## close - // The close hook is called when a connection to a device is closed. These - // calls will balance the calls to open or open_at. + // The close hook is called when a connection to a device is closed. These + // calls will balance the calls to open. // - // **Note:** If open or open_at return a **device instance**, the balancing close - // hook that is called is the close hook on the **instance**, not the parent. + // **Note:** If open returns a **device instance**, the balancing close hook + // that is called is the close hook on the **instance**, not the parent. // // The default close implementation returns **ZX_OK**. zx_status_t (*close)(void* ctx, uint32_t flags); @@ -106,7 +95,7 @@ typedef struct zx_protocol_device { //@ ## unbind // The unbind hook is called when the parent of this device is being removed (due // to hot unplug, fatal error, etc). At the point unbind is called, it is not - // possible for further open or open_at calls to occur, but io operations, etc + // possible for further open calls to occur, but io operations, etc // may continue until those client connections are closed. // // The driver should avoid further method calls to its parent device or any diff --git a/zircon/system/ulib/ddktl/include/ddktl/device-internal.h b/zircon/system/ulib/ddktl/include/ddktl/device-internal.h index e65e730f1d2..1e7b9c2d71b 100644 --- a/zircon/system/ulib/ddktl/include/ddktl/device-internal.h +++ b/zircon/system/ulib/ddktl/include/ddktl/device-internal.h @@ -171,19 +171,6 @@ constexpr void CheckOpenable() { "'zx_status_t DdkOpen(zx_device_t**, uint32_t)'."); } -DECLARE_HAS_MEMBER_FN(has_ddk_open_at, DdkOpenAt); - -template <typename D> -constexpr void CheckOpenAtable() { - static_assert(has_ddk_open_at<D>::value, - "OpenAtable classes must implement DdkOpenAt"); - static_assert( - std::is_same<decltype(&D::DdkOpenAt), - zx_status_t (D::*)(zx_device_t**, const char*, uint32_t)>::value, - "DdkOpenAt must be a public non-static member function with signature " - "'zx_status_t DdkOpenAt(zx_device_t**, const char*, uint32_t)'."); -} - DECLARE_HAS_MEMBER_FN(has_ddk_close, DdkClose); template <typename D> diff --git a/zircon/system/ulib/ddktl/include/ddktl/device.h b/zircon/system/ulib/ddktl/include/ddktl/device.h index 73f11065405..279f308d8ed 100644 --- a/zircon/system/ulib/ddktl/include/ddktl/device.h +++ b/zircon/system/ulib/ddktl/include/ddktl/device.h @@ -38,10 +38,6 @@ // | ddk::Openable | zx_status_t DdkOpen(zx_device_t** dev_out, | // | | uint32_t flags) | // | | | -// | ddk::OpenAtable | zx_status_t DdkOpenAt(zx_device_t** dev_out, | -// | | const char* path, | -// | | uint32_t flags) | -// | | | // | ddk::Closable | zx_status_t DdkClose(uint32_t flags) | // | | | // | ddk::Unbindable | void DdkUnbind() | @@ -157,21 +153,6 @@ private: } }; -template <typename D> -class OpenAtable : public base_mixin { -protected: - static constexpr void InitOp(zx_protocol_device_t* proto) { - internal::CheckOpenAtable<D>(); - proto->open_at = OpenAt; - } - -private: - static zx_status_t OpenAt(void* ctx, zx_device_t** dev_out, const char* path, - uint32_t flags) { - return static_cast<D*>(ctx)->DdkOpenAt(dev_out, path, flags); - } -}; - template <typename D> class Closable : public base_mixin { protected: @@ -444,7 +425,6 @@ template <class D> using FullDevice = Device<D, GetProtocolable, Openable, - OpenAtable, Closable, Unbindable, Readable, diff --git a/zircon/system/ulib/ddktl/test/device-tests.cpp b/zircon/system/ulib/ddktl/test/device-tests.cpp index 8a71d044d8f..e5fcbd2548a 100644 --- a/zircon/system/ulib/ddktl/test/device-tests.cpp +++ b/zircon/system/ulib/ddktl/test/device-tests.cpp @@ -41,12 +41,6 @@ zx_status_t DdkOpen(zx_device_t** dev_out, uint32_t flags) { } END_SUCCESS_CASE -BEGIN_SUCCESS_CASE(OpenAtable) -zx_status_t DdkOpenAt(zx_device_t** dev_out, const char* path, uint32_t flags) { - return ZX_OK; -} -END_SUCCESS_CASE - BEGIN_SUCCESS_CASE(Closable) zx_status_t DdkClose(uint32_t flags) { return ZX_OK; @@ -136,11 +130,6 @@ struct TestDispatch : public ddk::FullDevice<TestDispatch> { return ZX_OK; } - zx_status_t DdkOpenAt(zx_device_t** dev_out, const char* path, uint32_t flags) { - open_at_called = true; - return ZX_OK; - } - zx_status_t DdkClose(uint32_t flags) { close_called = true; return ZX_OK; @@ -192,7 +181,6 @@ struct TestDispatch : public ddk::FullDevice<TestDispatch> { bool get_protocol_called = false; bool open_called = false; - bool open_at_called = false; bool close_called = false; bool unbind_called = false; bool release_called = false; @@ -218,7 +206,6 @@ static bool test_dispatch() { auto ops = dev->GetDeviceOps(); EXPECT_EQ(ZX_OK, ops->get_protocol(ctx, 0, nullptr), ""); EXPECT_EQ(ZX_OK, ops->open(ctx, nullptr, 0), ""); - EXPECT_EQ(ZX_OK, ops->open_at(ctx, nullptr, "", 0), ""); EXPECT_EQ(ZX_OK, ops->close(ctx, 0), ""); ops->unbind(ctx); ops->release(ctx); @@ -232,7 +219,6 @@ static bool test_dispatch() { EXPECT_TRUE(dev->get_protocol_called, ""); EXPECT_TRUE(dev->open_called, ""); - EXPECT_TRUE(dev->open_at_called, ""); EXPECT_TRUE(dev->close_called, ""); EXPECT_TRUE(dev->unbind_called, ""); EXPECT_TRUE(dev->release_called, ""); @@ -337,7 +323,6 @@ BEGIN_TEST_CASE(ddktl_device) RUN_NAMED_TEST("No mixins", do_test<TestNone>); RUN_NAMED_TEST("ddk::GetProtocolable", do_test<TestGetProtocolable>); RUN_NAMED_TEST("ddk::Openable", do_test<TestOpenable>); -RUN_NAMED_TEST("ddk::OpenAtable", do_test<TestOpenAtable>); RUN_NAMED_TEST("ddk::Closable", do_test<TestClosable>); RUN_NAMED_TEST("ddk::Unbindable", do_test<TestUnbindable>); RUN_NAMED_TEST("ddk::Readable", do_test<TestReadable>); @@ -353,7 +338,6 @@ RUN_NAMED_TEST("Method dispatch test", test_dispatch); #if TEST_WILL_NOT_COMPILE || 0 RUN_NAMED_TEST("FailNoDdkGetProtocol", do_test<TestNotGetProtocolable>); RUN_NAMED_TEST("FailNoDdkOpen", do_test<TestNotOpenable>); -RUN_NAMED_TEST("FailNoDdkOpenAt", do_test<TestNotOpenAtable>); RUN_NAMED_TEST("FailNoDdkClose", do_test<TestNotClosable>); RUN_NAMED_TEST("FailNoDdkUnbind", do_test<TestNotUnbindable>); RUN_NAMED_TEST("FailNoDdkRelease", do_test<TestNotReleasable>); diff --git a/zircon/system/ulib/intel-hda/codec-utils/codec-driver-base.cpp b/zircon/system/ulib/intel-hda/codec-utils/codec-driver-base.cpp index 8ef17301fba..00937b95725 100644 --- a/zircon/system/ulib/intel-hda/codec-utils/codec-driver-base.cpp +++ b/zircon/system/ulib/intel-hda/codec-utils/codec-driver-base.cpp @@ -38,7 +38,6 @@ zx_protocol_device_t IntelHDACodecDriverBase::CODEC_DEVICE_THUNKS = { .version = DEVICE_OPS_VERSION, .get_protocol = nullptr, .open = nullptr, - .open_at = nullptr, .close = nullptr, .unbind = nullptr, .release = [](void* ctx) { DEV(ctx)->DeviceRelease(); }, diff --git a/zircon/system/ulib/intel-hda/codec-utils/stream-base.cpp b/zircon/system/ulib/intel-hda/codec-utils/stream-base.cpp index 2d45032f304..7f4d99b11a5 100644 --- a/zircon/system/ulib/intel-hda/codec-utils/stream-base.cpp +++ b/zircon/system/ulib/intel-hda/codec-utils/stream-base.cpp @@ -33,7 +33,6 @@ zx_protocol_device_t IntelHDAStreamBase::STREAM_DEVICE_THUNKS = { .version = DEVICE_OPS_VERSION, .get_protocol = nullptr, .open = nullptr, - .open_at = nullptr, .close = nullptr, .unbind = nullptr, .release = nullptr, -- GitLab