您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ udev_device_get_parent函数代码示例

51自学网 2021-06-03 09:05:48
  C++
这篇教程C++ udev_device_get_parent函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中udev_device_get_parent函数的典型用法代码示例。如果您正苦于以下问题:C++ udev_device_get_parent函数的具体用法?C++ udev_device_get_parent怎么用?C++ udev_device_get_parent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了udev_device_get_parent函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: names_pci

static int names_pci(struct udev_device *dev, struct netnames *names) {        struct udev_device *parent;        assert(dev);        assert(names);        parent = udev_device_get_parent(dev);        /* there can only ever be one virtio bus per parent device, so we can           safely ignore any virtio buses. see           <http://lists.linuxfoundation.org/pipermail/virtualization/2015-August/030331.html> */        while (parent && streq_ptr("virtio", udev_device_get_subsystem(parent)))                parent = udev_device_get_parent(parent);        if (!parent)                return -ENOENT;        /* check if our direct parent is a PCI device with no other bus in-between */        if (streq_ptr("pci", udev_device_get_subsystem(parent))) {                names->type = NET_PCI;                names->pcidev = parent;        } else {                names->pcidev = udev_device_get_parent_with_subsystem_devtype(dev, "pci", NULL);                if (!names->pcidev)                        return -ENOENT;        }        dev_pci_onboard(dev, names);        dev_pci_slot(dev, names);        return 0;}
开发者ID:BenjaminLefoul,项目名称:systemd,代码行数:30,


示例2: qDebug

void Storage::checkDevice(int fd) {    PowerManagerLock* powerLock = PowerManager::getNewLock(this);    powerLock->activate();    qDebug() << Q_FUNC_INFO << "FD: "<< fd;    struct udev_device *dev;    dev = udev_monitor_receive_device(udev_monitor);    if (dev)    {        QString device = udev_device_get_devnode(dev);        QString path = udev_device_get_devpath(dev);        QString action = udev_device_get_action(dev);        QString devtype = udev_device_get_devtype(dev);        QString sysname("/dev/");        sysname += QString(udev_device_get_sysname(dev));        QString parent = udev_device_get_devpath( udev_device_get_parent (dev));        if (sysname.contains(QRegExp("mmcblk[0-9]//d*"))  || sysname.contains(QRegExp("mmcblk[0-9]")))        {            qDebug() << "Got " << path << ":" << action;            qDebug() << "    Got Device";            qDebug() << "    Node: " <<  udev_device_get_devnode(dev);            qDebug() << "    Subsystem: "<< udev_device_get_subsystem(dev);            qDebug() << "    Devtype: " << devtype;            qDebug() << "    Action: " << action;            qDebug() << "    Sysname: " << sysname;            qDebug() << "    sysnum: " << udev_device_get_sysnum (dev);            qDebug() << "    parent: " << parent;            processRemovableUdevEvents(devtype, path, sysname, action);        }        udev_device_unref(dev);    }    delete powerLock;}
开发者ID:bq,项目名称:cervantes,代码行数:34,


示例3: assert_return_errno

/** * udev_device_get_parent_with_subsystem_devtype: * @udev_device: udev device to start searching from * @subsystem: the subsystem of the device * @devtype: the type (DEVTYPE) of the device * * Find the next parent device, with a matching subsystem and devtype * value, and fill in information from the sys device and the udev * database entry. * * If devtype is #NULL, only subsystem is checked, and any devtype will * match. * * Returned device is not referenced. It is attached to the child * device, and will be cleaned up when the child device is cleaned up. * * It can be called as many times as needed, without caring about * references. * * Returns: a new udev device, or #NULL if no matching parent exists. **/_public_ struct udev_device *udev_device_get_parent_with_subsystem_devtype(struct udev_device *udev_device, const char *subsystem, const char *devtype){        sd_device *parent;        int r;        assert_return_errno(udev_device, NULL, EINVAL);        /* this relies on the fact that finding the subdevice of a parent or the           parent of a subdevice commute */        /* first find the correct sd_device */        r = sd_device_get_parent_with_subsystem_devtype(udev_device->device, subsystem, devtype, &parent);        if (r < 0) {                errno = -r;                return NULL;        }        /* then walk the chain of udev_device parents until the correspanding           one is found */        while ((udev_device = udev_device_get_parent(udev_device))) {                if (udev_device->device == parent)                        return udev_device;        }        errno = ENOENT;        return NULL;}
开发者ID:AOSC-Dev,项目名称:systemd,代码行数:48,


示例4: udev_device_get_udev

static struct udev_device *handle_scsi_iscsi(struct udev_device *parent, char **path){	struct udev *udev  = udev_device_get_udev(parent);	struct udev_device *transportdev;	struct udev_device *sessiondev = NULL;	const char *target;	char *connname;	struct udev_device *conndev = NULL;	const char *addr;	const char *port;	/* find iscsi session */	transportdev = parent;	while (1) {		transportdev = udev_device_get_parent(transportdev);		if (transportdev == NULL)			return NULL;		if (strncmp(udev_device_get_sysname(transportdev), "session", 7) == 0)			break;	}	if (transportdev == NULL)		return NULL;	/* find iscsi session device */	sessiondev = udev_device_new_from_subsystem_sysname(udev, "iscsi_session", udev_device_get_sysname(transportdev));	if (sessiondev == NULL)		return NULL;	target = udev_device_get_sysattr_value(sessiondev, "targetname");	if (target == NULL) {		parent = NULL;		goto out;	}	if (asprintf(&connname, "connection%s:0", udev_device_get_sysnum(transportdev)) < 0) {		parent = NULL;		goto out;	}	conndev = udev_device_new_from_subsystem_sysname(udev, "iscsi_connection", connname);	free(connname);	if (conndev == NULL) {		parent = NULL;		goto out;	}	addr = udev_device_get_sysattr_value(conndev, "persistent_address");	port = udev_device_get_sysattr_value(conndev, "persistent_port");	if (addr == NULL || port == NULL) {		parent = NULL;		goto out;	}	path_prepend(path, "ip-%s:%s-iscsi-%s-lun-%s", addr, port, target, udev_device_get_sysnum(parent));out:	udev_device_unref(sessiondev);	udev_device_unref(conndev);	return parent;}
开发者ID:Lingvorn,项目名称:udev,代码行数:56,


示例5: names_pci

static int names_pci(struct udev_device *dev, struct netnames *names) {        struct udev_device *parent;        static int do_virtio = -1;        if (do_virtio < 0) {                _cleanup_free_ char *value = NULL;                int n = 0;                do_virtio = 0;                if (get_proc_cmdline_key("net.ifnames", NULL) > 0)                        do_virtio = 1;                else if (get_proc_cmdline_key("net.ifnames=", &value) > 0) {                        safe_atoi(value, &n);                        if (n > 0)                                do_virtio = 1;                }        }        parent = udev_device_get_parent(dev);        /* there can only ever be one virtio bus per parent device, so we can           safely ignore any virtio buses. see           <http://lists.linuxfoundation.org/pipermail/virtualization/2015-August/030331.html> */        if (do_virtio > 0)                while (parent && streq_ptr("virtio", udev_device_get_subsystem(parent)))                        parent = udev_device_get_parent(parent);        if (!parent)                return -ENOENT;        /* check if our direct parent is a PCI device with no other bus in-between */        if (streq_ptr("pci", udev_device_get_subsystem(parent))) {                names->type = NET_PCI;                names->pcidev = parent;        } else {                names->pcidev = udev_device_get_parent_with_subsystem_devtype(dev, "pci", NULL);                if (!names->pcidev)                        return -ENOENT;        }        dev_pci_onboard(dev, names);        dev_pci_slot(dev, names);        return 0;}
开发者ID:f0,项目名称:systemd-rhel,代码行数:42,


示例6: getParent

UdevDevice UdevDevice::getParent(void)	{	/* Get the parent device: */	udev_device* parent=udev_device_get_parent(device);		/* The parent device is not supposed to be unref'ed, so let's explicitly ref it here so that a later unref won't destroy it: */	if(parent!=0)		udev_device_ref(parent);		return UdevDevice(parent);	}
开发者ID:Doc-Ok,项目名称:OpticalTracking,代码行数:11,


示例7: read_usb_vudc_device

staticint read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev){	const char *path, *name;	char filepath[SYSFS_PATH_MAX];	struct usb_device_descriptor descr;	unsigned i;	FILE *fd = NULL;	struct udev_device *plat;	const char *speed;	int ret = 0;	plat = udev_device_get_parent(sdev);	path = udev_device_get_syspath(plat);	snprintf(filepath, SYSFS_PATH_MAX, "%s/%s",		 path, VUDC_DEVICE_DESCR_FILE);	fd = fopen(filepath, "r");	if (!fd)		return -1;	ret = fread((char *) &descr, sizeof(descr), 1, fd);	if (ret < 0)		return -1;	fclose(fd);	copy_descr_attr(dev, &descr, bDeviceClass);	copy_descr_attr(dev, &descr, bDeviceSubClass);	copy_descr_attr(dev, &descr, bDeviceProtocol);	copy_descr_attr(dev, &descr, bNumConfigurations);	copy_descr_attr16(dev, &descr, idVendor);	copy_descr_attr16(dev, &descr, idProduct);	copy_descr_attr16(dev, &descr, bcdDevice);	strncpy(dev->path, path, SYSFS_PATH_MAX);	dev->speed = USB_SPEED_UNKNOWN;	speed = udev_device_get_sysattr_value(sdev, "current_speed");	if (speed) {		for (i = 0; i < ARRAY_SIZE(speed_names); i++) {			if (!strcmp(speed_names[i].name, speed)) {				dev->speed = speed_names[i].speed;				break;			}		}	}	/* Only used for user output, little sense to output them in general */	dev->bNumInterfaces = 0;	dev->bConfigurationValue = 0;	dev->busnum = 0;	name = udev_device_get_sysname(plat);	strncpy(dev->busid, name, SYSFS_BUS_ID_SIZE);	return 0;}
开发者ID:513855417,项目名称:linux,代码行数:54,


示例8: Device

Device Device::parent() const{    if (!d)        return Device();    struct udev_device *p = udev_device_get_parent(d->udev);    if (!p)        return Device();    return Device(new DevicePrivate(p));}
开发者ID:gustavosbarreto,项目名称:libqsolid,代码行数:12,


示例9: dri2_get_driver_for_fd

char *dri2_get_driver_for_fd(int fd){   struct udev *udev;   struct udev_device *device, *parent;   const char *pci_id;   char *driver = NULL;   int vendor_id, chip_id, i, j;   udev = udev_new();   device = dri2_udev_device_new_from_fd(udev, fd);   if (device == NULL)      return NULL;   parent = udev_device_get_parent(device);   if (parent == NULL) {      _eglLog(_EGL_WARNING, "DRI2: could not get parent device");      goto out;   }   pci_id = udev_device_get_property_value(parent, "PCI_ID");   if (pci_id == NULL ||       sscanf(pci_id, "%x:%x", &vendor_id, &chip_id) != 2) {      _eglLog(_EGL_WARNING, "EGL-DRI2: malformed or no PCI ID");      goto out;   }   for (i = 0; driver_map[i].driver; i++) {      if (vendor_id != driver_map[i].vendor_id)         continue;      if (driver_map[i].num_chips_ids == -1) {         driver = strdup(driver_map[i].driver);         _eglLog(_EGL_DEBUG, "pci id for %d: %04x:%04x, driver %s",                 fd, vendor_id, chip_id, driver);         goto out;      }      for (j = 0; j < driver_map[i].num_chips_ids; j++)         if (driver_map[i].chip_ids[j] == chip_id) {            driver = strdup(driver_map[i].driver);            _eglLog(_EGL_DEBUG, "pci id for %d: %04x:%04x, driver %s",                    fd, vendor_id, chip_id, driver);            goto out;         }   }out:   udev_device_unref(device);   udev_unref(udev);   return driver;}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:52,


示例10: libudev_get_pci_id_for_fd

static intlibudev_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id){   struct udev *udev = NULL;   struct udev_device *device = NULL, *parent;   const char *pci_id;   UDEV_SYMBOL(struct udev *, udev_new, (void));   UDEV_SYMBOL(struct udev_device *, udev_device_get_parent,               (struct udev_device *));   UDEV_SYMBOL(const char *, udev_device_get_property_value,               (struct udev_device *, const char *));   UDEV_SYMBOL(struct udev_device *, udev_device_unref,               (struct udev_device *));   UDEV_SYMBOL(struct udev *, udev_unref, (struct udev *));   *chip_id = -1;   if (dlsym_failed)      return 0;   udev = udev_new();   device = udev_device_new_from_fd(udev, fd);   if (!device)      goto out;   parent = udev_device_get_parent(device);   if (parent == NULL) {      log_(_LOADER_WARNING, "MESA-LOADER: could not get parent device/n");      goto out;   }   pci_id = udev_device_get_property_value(parent, "PCI_ID");   if (pci_id == NULL) {      log_(_LOADER_INFO, "MESA-LOADER: no PCI ID/n");      *chip_id = -1;      goto out;   } else if (sscanf(pci_id, "%x:%x", vendor_id, chip_id) != 2) {      log_(_LOADER_WARNING, "MESA-LOADER: malformed PCI ID/n");      *chip_id = -1;      goto out;   }out:   if (device)      udev_device_unref(device);   if (udev)      udev_unref(udev);   return (*chip_id >= 0);}
开发者ID:ashmew2,项目名称:kolibriosSVN,代码行数:50,


示例11: get_serial_modem_device

/* * Here we try to find the "modem device". * * In this variant we identify the "modem device" as simply the device * that has the OFONO_DRIVER property.  If the device node doesn't * have this property itself, then we do a brute force search for it * through the device hierarchy. * */static struct udev_device* get_serial_modem_device(struct udev_device *dev){	const char* driver;	while (dev) {		driver = udev_device_get_property_value(dev, "OFONO_DRIVER");		if (driver)			return dev;		dev = udev_device_get_parent(dev);	}	return NULL;}
开发者ID:endocode,项目名称:ofono,代码行数:23,


示例12: udev_prop_value

const char *udev_prop_value(struct udev_device *device,		const char *prop_name){	struct udev_device *parent;	const char *prop_value = NULL;	parent = device;	while (parent && !prop_value) {		prop_value = udev_device_get_property_value(parent, prop_name);		parent = udev_device_get_parent(parent);	}	return prop_value;}
开发者ID:libratbag,项目名称:libratbag,代码行数:15,


示例13: while

static struct udev_device *skip_subsystem(struct udev_device *dev, const char *subsys){	struct udev_device *parent = dev;	while (parent != NULL) {		const char *subsystem;		subsystem = udev_device_get_subsystem(parent);		if (subsystem == NULL || strcmp(subsystem, subsys) != 0)			break;		dev = parent;		parent = udev_device_get_parent(parent);	}	return dev;}
开发者ID:Lingvorn,项目名称:udev,代码行数:15,


示例14: names_ccw

static int names_ccw(struct  udev_device *dev, struct netnames *names) {        struct udev_device *cdev;        const char *bus_id;        size_t bus_id_len;        int rc;        assert(dev);        assert(names);        /* Retrieve the associated CCW device */        cdev = udev_device_get_parent(dev);        if (!cdev)                return -ENOENT;        /* Network devices are always grouped CCW devices */        if (!streq_ptr("ccwgroup", udev_device_get_subsystem(cdev)))                return -ENOENT;        /* Retrieve bus-ID of the grouped CCW device.  The bus-ID uniquely         * identifies the network device on the Linux on System z channel         * subsystem.  Note that the bus-ID contains lowercase characters.         */        bus_id = udev_device_get_sysname(cdev);        if (!bus_id)                return -ENOENT;        /* Check the length of the bus-ID.  Rely on that the kernel provides         * a correct bus-ID; alternatively, improve this check and parse and         * verify each bus-ID part...         */        bus_id_len = strlen(bus_id);        if (!bus_id_len || bus_id_len < 8 || bus_id_len > 9)                return -EINVAL;        /* Strip leading zeros from the bus id for aesthetic purposes. This         * keeps the ccw names stable, yet much shorter in general case of         * bus_id 0.0.0600 -> 600. This is similar to e.g. how PCI domain is         * not prepended when it is zero.         */        bus_id += strspn(bus_id, ".0");        /* Store the CCW bus-ID for use as network device name */        rc = snprintf(names->ccw_group, sizeof(names->ccw_group), "c%s", bus_id);        if (rc >= 0 && rc < (int)sizeof(names->ccw_group))                names->type = NET_CCWGROUP;        return 0;}
开发者ID:BenjaminLefoul,项目名称:systemd,代码行数:47,


示例15: linux_get_pciid_from_fd

static intlinux_get_pciid_from_fd(int fd, unsigned *vendor_id, unsigned *chip_id){	struct udev *udev;	struct udev_device *device;	struct udev_device *parent;	const char *pci_id;	struct stat buffer;	int ret;	ret = fstat(fd, &buffer);	if (ret)		return -EINVAL;	if (!S_ISCHR(buffer.st_mode))		return -EINVAL;	udev = udev_new();	if (!udev)		return -ENOMEM;	device = udev_device_new_from_devnum(udev, 'c', buffer.st_rdev);	if (!device)		goto err_free_udev;	parent = udev_device_get_parent(device);	if (!parent)		goto err_free_device;	pci_id = udev_device_get_property_value(parent, "PCI_ID");	if (!pci_id)		goto err_free_device;	if (sscanf(pci_id, "%x:%x", vendor_id, chip_id) != 2)		goto err_free_device;	udev_device_unref(device);	udev_unref(udev);	return 0;err_free_device:	udev_device_unref(device);err_free_udev:	udev_unref(udev);	return -EINVAL;}
开发者ID:alexzeitgeist,项目名称:YT2,代码行数:47,


示例16: dri2_get_driver_for_fd

char *dri2_get_driver_for_fd(int fd){   struct udev *udev;   struct udev_device *device, *parent;   const char *pci_id;   char *driver = NULL;   int vendor_id, chip_id, i, j;   udev = udev_new();   device = dri2_udev_device_new_from_fd(udev, fd);   if (device == NULL)      return NULL;   parent = udev_device_get_parent(device);   if (parent == NULL) {      goto out;   }   pci_id = udev_device_get_property_value(parent, "PCI_ID");   if (pci_id == NULL ||       sscanf(pci_id, "%x:%x", &vendor_id, &chip_id) != 2) {      goto out;   }   for (i = 0; driver_map[i].driver; i++) {      if (vendor_id != driver_map[i].vendor_id)         continue;      if (driver_map[i].num_chips_ids == -1) {         driver = strdup(driver_map[i].driver);         goto out;      }      for (j = 0; j < driver_map[i].num_chips_ids; j++)         if (driver_map[i].chip_ids[j] == chip_id) {            driver = strdup(driver_map[i].driver);            goto out;         }   }out:   udev_device_unref(device);   udev_unref(udev);   return driver;}
开发者ID:axeldavy,项目名称:xf86-video-wlglamor,代码行数:46,


示例17: udev_builtin_hwdb_search

static int udev_builtin_hwdb_search(struct udev_device *dev, struct udev_device *srcdev,                                    const char *subsystem, const char *prefix,                                    const char *filter, bool test) {        struct udev_device *d;        char s[16];        bool last = false;        int r = 0;        assert(dev);        if (!srcdev)                srcdev = dev;        for (d = srcdev; d && !last; d = udev_device_get_parent(d)) {                const char *dsubsys;                const char *modalias = NULL;                dsubsys = udev_device_get_subsystem(d);                if (!dsubsys)                        continue;                /* look only at devices of a specific subsystem */                if (subsystem && !streq(dsubsys, subsystem))                        continue;                modalias = udev_device_get_property_value(d, "MODALIAS");                if (streq(dsubsys, "usb") && streq_ptr(udev_device_get_devtype(d), "usb_device")) {                        /* if the usb_device does not have a modalias, compose one */                        if (!modalias)                                modalias = modalias_usb(d, s, sizeof(s));                        /* avoid looking at any parent device, they are usually just a USB hub */                        last = true;                }                if (!modalias)                        continue;                r = udev_builtin_hwdb_lookup(dev, prefix, modalias, filter, test);                if (r > 0)                        break;        }        return r;}
开发者ID:jamespharvey20,项目名称:systemd,代码行数:46,


示例18: print_device_chain

static int print_device_chain(struct udev_device *device){        struct udev_device *device_parent;        const char *str;        printf("/n"               "Udevadm info starts with the device specified by the devpath and then/n"               "walks up the chain of parent devices. It prints for every device/n"               "found, all possible attributes in the udev rules key format./n"               "A rule to match, can be composed by the attributes of the device/n"               "and the attributes from one single parent device./n"               "/n");        printf("  looking at device '%s':/n", udev_device_get_devpath(device));        printf("    KERNEL==/"%s/"/n", udev_device_get_sysname(device));        str = udev_device_get_subsystem(device);        if (str == NULL)                str = "";        printf("    SUBSYSTEM==/"%s/"/n", str);        str = udev_device_get_driver(device);        if (str == NULL)                str = "";        printf("    DRIVER==/"%s/"/n", str);        print_all_attributes(device, "ATTR");        device_parent = device;        do {                device_parent = udev_device_get_parent(device_parent);                if (device_parent == NULL)                        break;                printf("  looking at parent device '%s':/n", udev_device_get_devpath(device_parent));                printf("    KERNELS==/"%s/"/n", udev_device_get_sysname(device_parent));                str = udev_device_get_subsystem(device_parent);                if (str == NULL)                        str = "";                printf("    SUBSYSTEMS==/"%s/"/n", str);                str = udev_device_get_driver(device_parent);                if (str == NULL)                        str = "";                printf("    DRIVERS==/"%s/"/n", str);                print_all_attributes(device_parent, "ATTRS");        } while (device_parent != NULL);        return 0;}
开发者ID:kwirk,项目名称:systemd,代码行数:45,


示例19: drm_open_matching

/** Open the first DRM device matching the criteria */int drm_open_matching(const char *pci_glob, int flags, int *vendor_id, int *device_id){	struct udev *udev;	struct udev_enumerate *e;	struct udev_device *device, *parent;        struct udev_list_entry *entry;	const char *pci_id, *path;        char *tmp;	int fd;        *vendor_id = 0;        *device_id = 0;        	udev = udev_new();	if (udev == NULL) {		fprintf(stderr, "failed to initialize udev context/n");                return -1;		//abort();	}	fd = -1;	e = udev_enumerate_new(udev);	udev_enumerate_add_match_subsystem(e, "drm");        udev_enumerate_scan_devices(e);        udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) {		path = udev_list_entry_get_name(entry);		device = udev_device_new_from_syspath(udev, path);		parent = udev_device_get_parent(device);		/* Filter out KMS output devices. */		if (strcmp(udev_device_get_subsystem(parent), "pci") != 0)			continue;		pci_id = udev_device_get_property_value(parent, "PCI_ID");		if (fnmatch(pci_glob, pci_id, 0) != 0)			continue;		fd = open(udev_device_get_devnode(device), O_RDWR);		if (fd < 0)			continue;		if ((flags & DRM_TEST_MASTER) && !is_master(fd)) {			close(fd);			fd = -1;			continue;		}		break;	}
开发者ID:bjsnider,项目名称:vaapi,代码行数:46,


示例20: get_sysfs_pg83

static intget_sysfs_pg83(struct path *pp, unsigned char *buff, int buflen){	struct udev_device *parent = pp->udev;	while (parent) {		const char *subsys = udev_device_get_subsystem(parent);		if (subsys && !strncmp(subsys, "scsi", 4))			break;		parent = udev_device_get_parent(parent);	}	if (!parent || sysfs_get_vpd(parent, 0x83, buff, buflen) <= 0) {		PRINT_DEBUG("failed to read sysfs vpd pg83/n");		return -1;	}	return 0;}
开发者ID:liujun01203,项目名称:multipath-tools,代码行数:18,


示例21: names_pci

static int names_pci(struct udev_device *dev, struct netnames *names) {        struct udev_device *parent;        parent = udev_device_get_parent(dev);        if (!parent)                return -ENOENT;        /* check if our direct parent is a PCI device with no other bus in-between */        if (streq_ptr("pci", udev_device_get_subsystem(parent))) {                names->type = NET_PCI;                names->pcidev = parent;        } else {                names->pcidev = udev_device_get_parent_with_subsystem_devtype(dev, "pci", NULL);                if (!names->pcidev)                        return -ENOENT;        }        dev_pci_onboard(dev, names);        dev_pci_slot(dev, names);        return 0;}
开发者ID:fest3er,项目名称:eudev,代码行数:19,


示例22: get_ncontrollers

static int get_ncontrollers(void){	struct dirent **namelist;	struct udev_device *platform;	int n;	platform = udev_device_get_parent(vhci_driver->hc_device);	if (platform == NULL)		return -1;	n = scandir(udev_device_get_syspath(platform), &namelist, vhci_hcd_filter, NULL);	if (n < 0)		err("scandir failed");	else {		for (int i = 0; i < n; i++)			free(namelist[i]);		free(namelist);	}	return n;}
开发者ID:mdamt,项目名称:linux,代码行数:21,


示例23: names_ccw

static int names_ccw(struct  udev_device *dev, struct netnames *names) {        struct udev_device *cdev;        const char *bus_id;        size_t bus_id_len;        int rc;        assert(dev);        assert(names);        /* Retrieve the associated CCW device */        cdev = udev_device_get_parent(dev);        if (!cdev)                return -ENOENT;        /* Network devices are always grouped CCW devices */        if (!streq_ptr("ccwgroup", udev_device_get_subsystem(cdev)))                return -ENOENT;        /* Retrieve bus-ID of the grouped CCW device.  The bus-ID uniquely         * identifies the network device on the Linux on System z channel         * subsystem.  Note that the bus-ID contains lowercase characters.         */        bus_id = udev_device_get_sysname(cdev);        if (!bus_id)                return -ENOENT;        /* Check the length of the bus-ID.  Rely on that the kernel provides         * a correct bus-ID; alternatively, improve this check and parse and         * verify each bus-ID part...         */        bus_id_len = strlen(bus_id);        if (!bus_id_len || bus_id_len < 8 || bus_id_len > 9)                return -EINVAL;        /* Store the CCW bus-ID for use as network device name */        rc = snprintf(names->ccw_group, sizeof(names->ccw_group), "ccw%s", bus_id);        if (rc >= 0 && rc < (int)sizeof(names->ccw_group))                names->type = NET_CCWGROUP;        return 0;}
开发者ID:lnykryn,项目名称:systemd,代码行数:40,


示例24: find_drm_pci_id

static booleanfind_drm_pci_id(struct pipe_loader_drm_device *ddev){   struct udev *udev = NULL;   struct udev_device *parent, *device = NULL;   struct stat stat;   const char *pci_id;   if (fstat(ddev->fd, &stat) < 0)      goto fail;   udev = udev_new();   if (!udev)      goto fail;   device = udev_device_new_from_devnum(udev, 'c', stat.st_rdev);   if (!device)      goto fail;   parent = udev_device_get_parent(device);   if (!parent)      goto fail;   pci_id = udev_device_get_property_value(parent, "PCI_ID");   if (!pci_id ||       sscanf(pci_id, "%x:%x", &ddev->base.u.pci.vendor_id,              &ddev->base.u.pci.chip_id) != 2)      goto fail;   return TRUE;  fail:   if (device)      udev_device_unref(device);   if (udev)      udev_unref(udev);   return FALSE;}
开发者ID:Forzaferrarileo,项目名称:mesa,代码行数:39,


示例25: get_baud_rate

static unsigned int get_baud_rate(int fd){	struct stat st;	unsigned int baudrate = 19200;	int id;	struct udev *udev;	struct udev_device *device, *parent;	const char *attr_id = NULL;	if (fstat(fd, &st) == -1)		return 0;	udev = udev_new();	device = udev_device_new_from_devnum(udev, 'c', st.st_rdev);	parent = device;	while (parent) {		attr_id = udev_device_get_sysattr_value(parent, "id");		if (attr_id &&				(strncmp(attr_id, "WACf", 4) == 0 || strncmp(attr_id, "FUJ", 3) == 0))			break;		parent = udev_device_get_parent(parent);	}	/* Devices up to WACf007 are 19200, newer devices are 38400. FUJ	   devices are all 19200 */	if (attr_id && sscanf(attr_id, "WACf%x", &id) == 1 && id >= 0x8)		baudrate = 38400;	if (device)		udev_device_unref(device);	udev_unref(udev);	return baudrate;}
开发者ID:jigpu,项目名称:xf86-input-wacom,代码行数:36,



注:本文中的udev_device_get_parent函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ udev_device_get_parent_with_subsystem_devtype函数代码示例
C++ udev_device_get_devnode函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。