Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 175031
b: refs/heads/master
c: c60e050
h: refs/heads/master
i:
  175029: c1ab235
  175027: 4471d35
  175023: b0bfe43
v: v3
  • Loading branch information
Magnus Damm authored and Greg Kroah-Hartman committed Dec 11, 2009
1 parent b2ce411 commit 637f7a2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 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: e16acb503b42ef241a9396de7c5a1614c74d8ca6
refs/heads/master: c60e0504c8e4fa14179d0687d80ef25148dd6dd4
29 changes: 22 additions & 7 deletions trunk/drivers/base/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ static __initdata LIST_HEAD(early_platform_device_list);
int __init early_platform_driver_register(struct early_platform_driver *epdrv,
char *buf)
{
unsigned long index;
char *tmp;
int n;

/* Simply add the driver to the end of the global list.
Expand All @@ -1019,13 +1019,28 @@ int __init early_platform_driver_register(struct early_platform_driver *epdrv,
if (buf && !strncmp(buf, epdrv->pdrv->driver.name, n)) {
list_move(&epdrv->list, &early_platform_driver_list);

if (!strcmp(buf, epdrv->pdrv->driver.name))
/* Allow passing parameters after device name */
if (buf[n] == '\0' || buf[n] == ',')
epdrv->requested_id = -1;
else if (buf[n] == '.' && strict_strtoul(&buf[n + 1], 10,
&index) == 0)
epdrv->requested_id = index;
else
epdrv->requested_id = EARLY_PLATFORM_ID_ERROR;
else {
epdrv->requested_id = simple_strtoul(&buf[n + 1],
&tmp, 10);

if (buf[n] != '.' || (tmp == &buf[n + 1])) {
epdrv->requested_id = EARLY_PLATFORM_ID_ERROR;
n = 0;
} else
n += strcspn(&buf[n + 1], ",") + 1;
}

if (buf[n] == ',')
n++;

if (epdrv->bufsize) {
memcpy(epdrv->buffer, &buf[n],
min_t(int, epdrv->bufsize, strlen(&buf[n]) + 1));
epdrv->buffer[epdrv->bufsize - 1] = '\0';
}
}

return 0;
Expand Down
20 changes: 15 additions & 5 deletions trunk/include/linux/platform_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ struct early_platform_driver {
struct platform_driver *pdrv;
struct list_head list;
int requested_id;
char *buffer;
int bufsize;
};

#define EARLY_PLATFORM_ID_UNSET -2
Expand All @@ -102,21 +104,29 @@ extern int early_platform_driver_probe(char *class_str,
int nr_probe, int user_only);
extern void early_platform_cleanup(void);

#define early_platform_init(class_string, platdrv) \
early_platform_init_buffer(class_string, platdrv, NULL, 0)

#ifndef MODULE
#define early_platform_init(class_string, platform_driver) \
#define early_platform_init_buffer(class_string, platdrv, buf, bufsiz) \
static __initdata struct early_platform_driver early_driver = { \
.class_str = class_string, \
.pdrv = platform_driver, \
.buffer = buf, \
.bufsize = bufsiz, \
.pdrv = platdrv, \
.requested_id = EARLY_PLATFORM_ID_UNSET, \
}; \
static int __init early_platform_driver_setup_func(char *buf) \
static int __init early_platform_driver_setup_func(char *buffer) \
{ \
return early_platform_driver_register(&early_driver, buf); \
return early_platform_driver_register(&early_driver, buffer); \
} \
early_param(class_string, early_platform_driver_setup_func)
#else /* MODULE */
#define early_platform_init(class_string, platform_driver)
#define early_platform_init_buffer(class_string, platdrv, buf, bufsiz) \
static inline char *early_platform_driver_setup_func(void) \
{ \
return bufsiz ? buf : NULL; \
}
#endif /* MODULE */

#endif /* _PLATFORM_DEVICE_H_ */

0 comments on commit 637f7a2

Please sign in to comment.