chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[PATCH] remove historical SYSFS_attr="value" format
[elogind.git]
/
udev_sysfs.c
diff --git
a/udev_sysfs.c
b/udev_sysfs.c
index 886e9f403b9fce5527f520fc46ff51ce7b254e5f..1953dd777542c0cbb83db8fa8e56603b447503f9 100644
(file)
--- a/
udev_sysfs.c
+++ b/
udev_sysfs.c
@@
-28,14
+28,13
@@
#include <errno.h>
#include <sys/stat.h>
#include <errno.h>
#include <sys/stat.h>
-#include "l
ogging
.h"
+#include "l
ibsysfs/sysfs/libsysfs
.h"
#include "udev_version.h"
#include "udev_sysfs.h"
#include "udev_version.h"
#include "udev_sysfs.h"
-#include "libsysfs/sysfs/libsysfs.h"
+#include "udev_lib.h"
+#include "logging.h"
-/* list of subsystem specific files
- * NULL if there is no file to wait for
- */
+/* list of subsystem specific files, NULL if there is no file to wait for */
static struct subsystem_file {
char *subsystem;
char *file;
static struct subsystem_file {
char *subsystem;
char *file;
@@
-204,6
+203,13
@@
static int class_device_expect_no_device_link(struct sysfs_class_device *class_d
struct class_device *classdevice;
int len;
struct class_device *classdevice;
int len;
+ /* the kernel may tell us what to wait for */
+ if (kernel_release_satisfactory(2,6,10) > 0)
+ if (getenv("PHYSDEVPATH") == NULL) {
+ dbg("the kernel says, that there is no physical device for '%s'", class_dev->path);
+ return 1;
+ }
+
for (classdevice = class_device; classdevice->subsystem != NULL; classdevice++) {
if (strcmp(class_dev->classname, classdevice->subsystem) == 0) {
/* see if no device in this class is expected to have a device-link */
for (classdevice = class_device; classdevice->subsystem != NULL; classdevice++) {
if (strcmp(class_dev->classname, classdevice->subsystem) == 0) {
/* see if no device in this class is expected to have a device-link */
@@
-229,12
+235,13
@@
static int class_device_expect_no_device_link(struct sysfs_class_device *class_d
return 0;
}
return 0;
}
-/* skip waiting for the bus */
+/* skip waiting for the bus
of the devices device
*/
static int class_device_expect_no_bus(struct sysfs_class_device *class_dev)
{
static char *devices_without_bus[] = {
"scsi_host",
"i2c-adapter",
static int class_device_expect_no_bus(struct sysfs_class_device *class_dev)
{
static char *devices_without_bus[] = {
"scsi_host",
"i2c-adapter",
+ "i2c-dev",
NULL
};
char **device;
NULL
};
char **device;
@@
-249,14
+256,14
@@
static int class_device_expect_no_bus(struct sysfs_class_device *class_dev)
return 0;
}
return 0;
}
-/* wait for
the bus and for a bus
specific file to show up */
-int wait_for_
bu
s_device(struct sysfs_device *devices_dev,
+/* wait for
a devices device
specific file to show up */
+int wait_for_
device
s_device(struct sysfs_device *devices_dev,
const char **error)
{
const char **error)
{
- static struct
bus
_file {
+ static struct
device
_file {
char *bus;
char *file;
char *bus;
char *file;
- }
bus
_files[] = {
+ }
device
_files[] = {
{ .bus = "scsi", .file = "vendor" },
{ .bus = "usb", .file = "idVendor" },
{ .bus = "usb", .file = "iInterface" },
{ .bus = "scsi", .file = "vendor" },
{ .bus = "usb", .file = "idVendor" },
{ .bus = "usb", .file = "iInterface" },
@@
-271,9
+278,16
@@
int wait_for_bus_device(struct sysfs_device *devices_dev,
{ .bus = "ieee1394", .file = "address" },
{ NULL, NULL }
};
{ .bus = "ieee1394", .file = "address" },
{ NULL, NULL }
};
- struct
bus_file *bus
file;
+ struct
device_file *device
file;
int loop;
int loop;
+ /* the kernel may tell us what to wait for */
+ if (kernel_release_satisfactory(2,6,10) > 0)
+ if (getenv("PHYSDEVBUS") == NULL) {
+ dbg("the kernel says, that there is no bus for '%s'", devices_dev->path);
+ return 0;
+ }
+
/* wait for the bus device link to the devices device */
loop = WAIT_MAX_SECONDS * WAIT_LOOP_PER_SECOND;
while (--loop) {
/* wait for the bus device link to the devices device */
loop = WAIT_MAX_SECONDS * WAIT_LOOP_PER_SECOND;
while (--loop) {
@@
-290,22
+304,22
@@
int wait_for_bus_device(struct sysfs_device *devices_dev,
}
dbg("bus device link found for bus '%s'", devices_dev->bus);
}
dbg("bus device link found for bus '%s'", devices_dev->bus);
- /* wait for a bus specific file to show up */
+ /* wait for a bus
device
specific file to show up */
loop = WAIT_MAX_SECONDS * WAIT_LOOP_PER_SECOND;
while (--loop) {
int found_bus_type = 0;
loop = WAIT_MAX_SECONDS * WAIT_LOOP_PER_SECOND;
while (--loop) {
int found_bus_type = 0;
- for (
busfile = bus_files; busfile->bus != NULL; bus
file++) {
- if (strcmp(devices_dev->bus,
bus
file->bus) == 0) {
+ for (
devicefile = device_files; devicefile->bus != NULL; device
file++) {
+ if (strcmp(devices_dev->bus,
device
file->bus) == 0) {
char filename[SYSFS_PATH_MAX];
struct stat stats;
found_bus_type = 1;
char filename[SYSFS_PATH_MAX];
struct stat stats;
found_bus_type = 1;
- snprintf(filename, SYSFS_PATH_MAX-1, "%s/%s", devices_dev->path,
bus
file->file);
- dbg("looking at bus '%s' for specific file '%s'", devices_dev->bus, filename);
+ snprintf(filename, SYSFS_PATH_MAX-1, "%s/%s", devices_dev->path,
device
file->file);
+ dbg("looking at bus '%s'
device
for specific file '%s'", devices_dev->bus, filename);
if (stat(filename, &stats) == 0) {
if (stat(filename, &stats) == 0) {
- dbg("bus '%s'
specific file '%s' found", devices_dev->bus, bus
file->file);
+ dbg("bus '%s'
device specific file '%s' found", devices_dev->bus, device
file->file);
return 0;
}
}
return 0;
}
}
@@
-320,14
+334,14
@@
int wait_for_bus_device(struct sysfs_device *devices_dev,
usleep(1000 * 1000 / WAIT_LOOP_PER_SECOND);
}
usleep(1000 * 1000 / WAIT_LOOP_PER_SECOND);
}
- dbg("error: getting
bus '%s' specific file '%s'", devices_dev->bus, bus
file->file);
+ dbg("error: getting
'%s' device specific file '%s'", devices_dev->bus, device
file->file);
if (error)
if (error)
- *error = "bus specific file unavailable";
+ *error = "bus
device
specific file unavailable";
return -1;
}
return -1;
}
-struct sysfs_class_device *
open_class_device_wait
(const char *path)
+struct sysfs_class_device *
wait_class_device_open
(const char *path)
{
struct sysfs_class_device *class_dev;
int loop;
{
struct sysfs_class_device *class_dev;
int loop;
@@
-357,7
+371,7
@@
int wait_for_class_device(struct sysfs_class_device *class_dev,
/* skip devices without devices-link */
if (class_device_expect_no_device_link(class_dev)) {
dbg("no device symlink expected for '%s', ", class_dev->name);
/* skip devices without devices-link */
if (class_device_expect_no_device_link(class_dev)) {
dbg("no device symlink expected for '%s', ", class_dev->name);
- return
-ENODEV
;
+ return
0
;
}
/* the symlink may be on the parent device */
}
/* the symlink may be on the parent device */
@@
-387,16
+401,16
@@
int wait_for_class_device(struct sysfs_class_device *class_dev,
}
dbg("device symlink found pointing to '%s'", devices_dev->path);
}
dbg("device symlink found pointing to '%s'", devices_dev->path);
- /* wait for the
bus valu
e */
+ /* wait for the
devices devic
e */
if (class_device_expect_no_bus(class_dev)) {
dbg("no bus device expected for '%s', ", class_dev->classname);
return 0;
if (class_device_expect_no_bus(class_dev)) {
dbg("no bus device expected for '%s', ", class_dev->classname);
return 0;
- } else {
- return wait_for_bus_device(devices_dev, error);
}
}
+
+ return wait_for_devices_device(devices_dev, error);
}
}
-struct sysfs_device *
open_devices_device_wait
(const char *path)
+struct sysfs_device *
wait_devices_device_open
(const char *path)
{
struct sysfs_device *devices_dev;
int loop;
{
struct sysfs_device *devices_dev;
int loop;