-static struct sysfs_device *get_sysfs_device(struct sysfs_class_device *class_dev)
-{
- struct sysfs_device *sysfs_device;
- struct sysfs_class_device *class_dev_parent;
- int loop;
- int retval;
- char filename[SYSFS_PATH_MAX + 6];
-
- /* FIXME!!! */
- /* This is needed here as we can easily out-race the placement of the
- * device symlink by the kernel. The call to sleep(1); will be removed
- * once libsysfs can be queried for sysfs_get_classdev_device()
- * multiple times and have it return the proper information when the
- * class device really shows up. For now, we live with the time
- * delay...
- */
-// sleep(1);
- loop = 10;
- while (loop--) {
- struct stat buf;
-
- strcpy(filename, class_dev->path);
- strcat(filename, "/device");
- dbg("looking for '%s'", filename);
- retval = stat(filename, &buf);
- if (!retval)
- break;
-#if 0
- /* bah, let's go backwards up a level to see if the device is there,
- * as block partitions don't point to the physical device. Need to fix that
- * up in the kernel...
- */
- if (strcmp(class_dev->classname, SYSFS_BLOCK_NAME) == 0) {
- if (isdigit(class_dev->path[strlen(class_dev->path)-1])) {
- char *temp = strrchr(filename, '/');
- if (temp) {
- *temp = 0x00;
- temp = strrchr(filename, '/');
- if (temp) {
- *temp = 0x00;
- strcat(filename, "/device");
- dbg("looking for '%s'", filename);
- retval = stat(filename, &buf);
- if (!retval)
- break;
- }
- }
+ /* check for matching place of device */
+ if (dev->place[0] != '\0') {
+ dbg("check " FIELD_PLACE);
+ if (match_place(dev, class_dev, sysfs_device) != 0) {
+ dbg(FIELD_PLACE " is not matching");
+ goto try_parent;
+ } else {
+ dbg(FIELD_PLACE " matches");