Beispiel #1
0
// Parent returns the parent Device, or nil if the receiver has no parent Device
func (d *Device) Parent() *Device {
	d.lock()
	defer d.unlock()
	ptr := C.udev_device_get_parent(d.ptr)
	if ptr != nil {
		C.udev_device_ref(ptr)
	}
	return d.u.newDevice(ptr)
}
Beispiel #2
0
// ParentWithSubsystemDevtype returns the parent Device with the given subsystem and devtype,
// or nil if the receiver has no such parent device
func (d *Device) ParentWithSubsystemDevtype(subsystem, devtype string) *Device {
	d.lock()
	defer d.unlock()
	ss, dt := C.CString(subsystem), C.CString(devtype)
	defer freeCharPtr(ss)
	defer freeCharPtr(dt)
	ptr := C.udev_device_get_parent_with_subsystem_devtype(d.ptr, ss, dt)
	if ptr != nil {
		C.udev_device_ref(ptr)
	}
	return d.u.newDevice(ptr)
}