Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 133442
b: refs/heads/master
c: 57fee4a
h: refs/heads/master
v: v3
  • Loading branch information
Eric Miao authored and Greg Kroah-Hartman committed Mar 24, 2009
1 parent daec078 commit 63acaed
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 71b3e0c1ad90f28e34c105069175cbd4edb43dfa
refs/heads/master: 57fee4a58fe802272742caae248872c392a60670
23 changes: 22 additions & 1 deletion trunk/drivers/base/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,25 @@ static int platform_uevent(struct device *dev, struct kobj_uevent_env *env)
{
struct platform_device *pdev = to_platform_device(dev);

add_uevent_var(env, "MODALIAS=platform:%s", pdev->name);
add_uevent_var(env, "MODALIAS=%s%s", PLATFORM_MODULE_PREFIX,
(pdev->id_entry) ? pdev->id_entry->name : pdev->name);
return 0;
}

static const struct platform_device_id *platform_match_id(
struct platform_device_id *id,
struct platform_device *pdev)
{
while (id->name[0]) {
if (strcmp(pdev->name, id->name) == 0) {
pdev->id_entry = id;
return id;
}
id++;
}
return NULL;
}

/**
* platform_match - bind platform device to platform driver.
* @dev: device.
Expand All @@ -604,7 +619,13 @@ static int platform_uevent(struct device *dev, struct kobj_uevent_env *env)
static int platform_match(struct device *dev, struct device_driver *drv)
{
struct platform_device *pdev = to_platform_device(dev);
struct platform_driver *pdrv = to_platform_driver(drv);

/* match against the id table first */
if (pdrv->id_table)
return platform_match_id(pdrv->id_table, pdev) != NULL;

/* fall-back to driver name match */
return (strcmp(pdev->name, drv->name) == 0);
}

Expand Down
9 changes: 9 additions & 0 deletions trunk/include/linux/mod_devicetable.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,4 +454,13 @@ struct dmi_system_id {

#define DMI_MATCH(a, b) { a, b }

#define PLATFORM_NAME_SIZE 20
#define PLATFORM_MODULE_PREFIX "platform:"

struct platform_device_id {
char name[PLATFORM_NAME_SIZE];
kernel_ulong_t driver_data
__attribute__((aligned(sizeof(kernel_ulong_t))));
};

#endif /* LINUX_MOD_DEVICETABLE_H */
6 changes: 6 additions & 0 deletions trunk/include/linux/platform_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@
#define _PLATFORM_DEVICE_H_

#include <linux/device.h>
#include <linux/mod_devicetable.h>

struct platform_device {
const char * name;
int id;
struct device dev;
u32 num_resources;
struct resource * resource;

struct platform_device_id *id_entry;
};

#define platform_get_device_id(pdev) ((pdev)->id_entry)

#define to_platform_device(x) container_of((x), struct platform_device, dev)

extern int platform_device_register(struct platform_device *);
Expand Down Expand Up @@ -56,6 +61,7 @@ struct platform_driver {
int (*resume_early)(struct platform_device *);
int (*resume)(struct platform_device *);
struct device_driver driver;
struct platform_device_id *id_table;
};

extern int platform_driver_register(struct platform_driver *);
Expand Down
12 changes: 12 additions & 0 deletions trunk/scripts/mod/file2alias.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,14 @@ static int do_dmi_entry(const char *filename, struct dmi_system_id *id,
strcat(alias, ":");
return 1;
}

static int do_platform_entry(const char *filename,
struct platform_device_id *id, char *alias)
{
sprintf(alias, PLATFORM_MODULE_PREFIX "%s", id->name);
return 1;
}

/* Ignore any prefix, eg. some architectures prepend _ */
static inline int sym_is(const char *symbol, const char *name)
{
Expand Down Expand Up @@ -849,6 +857,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
do_table(symval, sym->st_size,
sizeof(struct dmi_system_id), "dmi",
do_dmi_entry, mod);
else if (sym_is(symname, "__mod_platform_device_table"))
do_table(symval, sym->st_size,
sizeof(struct platform_device_id), "platform",
do_platform_entry, mod);
free(zeros);
}

Expand Down

0 comments on commit 63acaed

Please sign in to comment.