diff --git a/src/Device.zig b/src/Device.zig index 6ffeb20..6215d2f 100644 --- a/src/Device.zig +++ b/src/Device.zig @@ -151,7 +151,7 @@ pub fn getDeviceInfo(self: Device, io: std.Io) !DeviceInfo { ); switch (rc) { .success => { - return DeviceInfo.init(self.minor, &info); + return .init(self, &info); }, .failure => |e| { log.warn("problem: {s}", .{@tagName(e)}); diff --git a/src/DeviceInfo.zig b/src/DeviceInfo.zig index 0ee1ca1..dca675c 100644 --- a/src/DeviceInfo.zig +++ b/src/DeviceInfo.zig @@ -12,8 +12,8 @@ const ioctl = @import("ioctl.zig"); const Device = @import("Device.zig"); -/// The minor device number used to access the hidraw device. -minor: linux.dev_t, +/// The hidraw device. +device: Device, /// The bus type. bustype: ioctl.BUS, @@ -24,9 +24,9 @@ vendor: u16, /// The product ID. product: u16, -pub fn init(minor: linux.dev_t, info: *const ioctl.hidraw_devinfo) DeviceInfo { +pub fn init(device: Device, info: *const ioctl.hidraw_devinfo) DeviceInfo { return .{ - .minor = minor, + .device = device, .bustype = info.bustype, .vendor = info.vendor, .product = info.product, diff --git a/src/DeviceInfoIterator.zig b/src/DeviceInfoIterator.zig index 41623f4..2204b1c 100644 --- a/src/DeviceInfoIterator.zig +++ b/src/DeviceInfoIterator.zig @@ -21,7 +21,7 @@ pub fn next(self: *DeviceInfoIterator, io: std.Io) !?DeviceInfo { while (self.index < 64) { defer self.index += 1; const device = Device.open(io, self.index) catch continue; - defer device.close(io); + errdefer device.close(io); return device.getDeviceInfo(io) catch continue; } return null;