Driver core: keep PHYSDEV for old struct class_device

Class-devices created by "struct class_device" are going to be replaced
by "struct device". Keep the deprecated PHYSDEV* variables for the already
"deprecated" struct class_device" devices.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Kay Sievers 2007-05-01 13:46:26 +02:00 committed by Greg Kroah-Hartman
parent adfdebceac
commit 2c7afd125c
2 changed files with 27 additions and 42 deletions

View file

@ -369,36 +369,6 @@ char *make_class_name(const char *name, struct kobject *kobj)
return class_name;
}
static int deprecated_class_uevent(char **envp, int num_envp, int *cur_index,
char *buffer, int buffer_size,
int *cur_len,
struct class_device *class_dev)
{
struct device *dev = class_dev->dev;
char *path;
if (!dev)
return 0;
/* add device, backing this class device (deprecated) */
path = kobject_get_path(&dev->kobj, GFP_KERNEL);
add_uevent_var(envp, num_envp, cur_index, buffer, buffer_size,
cur_len, "PHYSDEVPATH=%s", path);
kfree(path);
if (dev->bus)
add_uevent_var(envp, num_envp, cur_index,
buffer, buffer_size, cur_len,
"PHYSDEVBUS=%s", dev->bus->name);
if (dev->driver)
add_uevent_var(envp, num_envp, cur_index,
buffer, buffer_size, cur_len,
"PHYSDEVDRIVER=%s", dev->driver->name);
return 0;
}
static int make_deprecated_class_device_links(struct class_device *class_dev)
{
char *class_name;
@ -430,11 +400,6 @@ static void remove_deprecated_class_device_links(struct class_device *class_dev)
kfree(class_name);
}
#else
static inline int deprecated_class_uevent(char **envp, int num_envp,
int *cur_index, char *buffer,
int buffer_size, int *cur_len,
struct class_device *class_dev)
{ return 0; }
static inline int make_deprecated_class_device_links(struct class_device *cd)
{ return 0; }
static void remove_deprecated_class_device_links(struct class_device *cd)
@ -445,15 +410,13 @@ static int class_uevent(struct kset *kset, struct kobject *kobj, char **envp,
int num_envp, char *buffer, int buffer_size)
{
struct class_device *class_dev = to_class_dev(kobj);
struct device *dev = class_dev->dev;
int i = 0;
int length = 0;
int retval = 0;
pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id);
deprecated_class_uevent(envp, num_envp, &i, buffer, buffer_size,
&length, class_dev);
if (MAJOR(class_dev->devt)) {
add_uevent_var(envp, num_envp, &i,
buffer, buffer_size, &length,
@ -464,6 +427,26 @@ static int class_uevent(struct kset *kset, struct kobject *kobj, char **envp,
"MINOR=%u", MINOR(class_dev->devt));
}
if (dev) {
const char *path = kobject_get_path(&dev->kobj, GFP_KERNEL);
if (path) {
add_uevent_var(envp, num_envp, &i,
buffer, buffer_size, &length,
"PHYSDEVPATH=%s", path);
kfree(path);
}
if (dev->bus)
add_uevent_var(envp, num_envp, &i,
buffer, buffer_size, &length,
"PHYSDEVBUS=%s", dev->bus->name);
if (dev->driver)
add_uevent_var(envp, num_envp, &i,
buffer, buffer_size, &length,
"PHYSDEVDRIVER=%s", dev->driver->name);
}
/* terminate, set to next free slot, shrink available space */
envp[i] = NULL;
envp = &envp[i];

View file

@ -180,10 +180,12 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, char **envp,
const char *path;
path = kobject_get_path(&parent->kobj, GFP_KERNEL);
add_uevent_var(envp, num_envp, &i,
buffer, buffer_size, &length,
"PHYSDEVPATH=%s", path);
kfree(path);
if (path) {
add_uevent_var(envp, num_envp, &i,
buffer, buffer_size, &length,
"PHYSDEVPATH=%s", path);
kfree(path);
}
add_uevent_var(envp, num_envp, &i,
buffer, buffer_size, &length,