Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 101605
b: refs/heads/master
c: 09e67ca
h: refs/heads/master
i:
  101603: 840c85e
v: v3
  • Loading branch information
Stephen Rothwell authored and Paul Mackerras committed May 16, 2008
1 parent 966cff3 commit b6fbb8a
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 51 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: 7bc228b1ef71f395aeb89bdf81bf95556b08b374
refs/heads/master: 09e67ca2c523544e6b38aa570a5f62a0cf20b87b
48 changes: 0 additions & 48 deletions trunk/arch/powerpc/kernel/of_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,54 +89,6 @@ struct of_device *of_device_alloc(struct device_node *np,
}
EXPORT_SYMBOL(of_device_alloc);

ssize_t of_device_get_modalias(struct of_device *ofdev,
char *str, ssize_t len)
{
const char *compat;
int cplen, i;
ssize_t tsize, csize, repend;

/* Name & Type */
csize = snprintf(str, len, "of:N%sT%s",
ofdev->node->name, ofdev->node->type);

/* Get compatible property if any */
compat = of_get_property(ofdev->node, "compatible", &cplen);
if (!compat)
return csize;

/* Find true end (we tolerate multiple \0 at the end */
for (i=(cplen-1); i>=0 && !compat[i]; i--)
cplen--;
if (!cplen)
return csize;
cplen++;

/* Check space (need cplen+1 chars including final \0) */
tsize = csize + cplen;
repend = tsize;

if (csize>=len) /* @ the limit, all is already filled */
return tsize;

if (tsize>=len) { /* limit compat list */
cplen = len-csize-1;
repend = len;
}

/* Copy and do char replacement */
memcpy(&str[csize+1], compat, cplen);
for (i=csize; i<repend; i++) {
char c = str[i];
if (c=='\0')
str[i] = 'C';
else if (c==' ')
str[i] = '_';
}

return tsize;
}

int of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
{
struct of_device *ofdev;
Expand Down
48 changes: 48 additions & 0 deletions trunk/drivers/of/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,51 @@ void of_device_unregister(struct of_device *ofdev)
device_unregister(&ofdev->dev);
}
EXPORT_SYMBOL(of_device_unregister);

ssize_t of_device_get_modalias(struct of_device *ofdev,
char *str, ssize_t len)
{
const char *compat;
int cplen, i;
ssize_t tsize, csize, repend;

/* Name & Type */
csize = snprintf(str, len, "of:N%sT%s",
ofdev->node->name, ofdev->node->type);

/* Get compatible property if any */
compat = of_get_property(ofdev->node, "compatible", &cplen);
if (!compat)
return csize;

/* Find true end (we tolerate multiple \0 at the end */
for (i = (cplen - 1); i >= 0 && !compat[i]; i--)
cplen--;
if (!cplen)
return csize;
cplen++;

/* Check space (need cplen+1 chars including final \0) */
tsize = csize + cplen;
repend = tsize;

if (csize >= len) /* @ the limit, all is already filled */
return tsize;

if (tsize >= len) { /* limit compat list */
cplen = len - csize - 1;
repend = len;
}

/* Copy and do char replacement */
memcpy(&str[csize + 1], compat, cplen);
for (i = csize; i < repend; i++) {
char c = str[i];
if (c == '\0')
str[i] = 'C';
else if (c == ' ')
str[i] = '_';
}

return tsize;
}
2 changes: 0 additions & 2 deletions trunk/include/asm-powerpc/of_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ extern struct of_device *of_device_alloc(struct device_node *np,
const char *bus_id,
struct device *parent);

extern ssize_t of_device_get_modalias(struct of_device *ofdev,
char *str, ssize_t len);
extern int of_device_uevent(struct device *dev,
struct kobj_uevent_env *env);

Expand Down
3 changes: 3 additions & 0 deletions trunk/include/linux/of_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ static inline void of_device_free(struct of_device *dev)
of_release_dev(&dev->dev);
}

extern ssize_t of_device_get_modalias(struct of_device *ofdev,
char *str, ssize_t len);

#endif /* _LINUX_OF_DEVICE_H */

0 comments on commit b6fbb8a

Please sign in to comment.