Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 19399
b: refs/heads/master
c: e619978
h: refs/heads/master
i:
  19397: a0e87f1
  19395: 5f5f268
  19391: ee56e90
v: v3
  • Loading branch information
Olaf Hering authored and Linus Torvalds committed Feb 1, 2006
1 parent 6da2b20 commit 16d50e7
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 25 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: 39931e41becd6abeb2014747369d8b6392f5dbac
refs/heads/master: e61997881e0402aedbfad8696e369568a0583f14
72 changes: 48 additions & 24 deletions trunk/drivers/macintosh/macio_asic.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,9 @@ static int macio_uevent(struct device *dev, char **envp, int num_envp,
{
struct macio_dev * macio_dev;
struct of_device * of;
char *scratch, *compat;
char *scratch, *compat, *compat2;
int i = 0;
int length = 0;
int cplen, seen = 0;
int length, cplen, cplen2, seen = 0;

if (!dev)
return -ENODEV;
Expand All @@ -153,53 +152,78 @@ static int macio_uevent(struct device *dev, char **envp, int num_envp,
return -ENODEV;

of = &macio_dev->ofdev;
scratch = buffer;

/* stuff we want to pass to /sbin/hotplug */
envp[i++] = scratch;
length += scnprintf (scratch, buffer_size - length, "OF_NAME=%s",
of->node->name);
if ((buffer_size - length <= 0) || (i >= num_envp))
return -ENOMEM;
envp[i++] = scratch = buffer;
length = scnprintf (scratch, buffer_size, "OF_NAME=%s", of->node->name);
++length;
buffer_size -= length;
if ((buffer_size <= 0) || (i >= num_envp))
return -ENOMEM;
scratch += length;

envp[i++] = scratch;
length += scnprintf (scratch, buffer_size - length, "OF_TYPE=%s",
of->node->type);
if ((buffer_size - length <= 0) || (i >= num_envp))
return -ENOMEM;
length = scnprintf (scratch, buffer_size, "OF_TYPE=%s", of->node->type);
++length;
buffer_size -= length;
if ((buffer_size <= 0) || (i >= num_envp))
return -ENOMEM;
scratch += length;

/* Since the compatible field can contain pretty much anything
* it's not really legal to split it out with commas. We split it
* up using a number of environment variables instead. */

compat = (char *) get_property(of->node, "compatible", &cplen);
compat2 = compat;
cplen2= cplen;
while (compat && cplen > 0) {
int l;
envp[i++] = scratch;
length += scnprintf (scratch, buffer_size - length,
length = scnprintf (scratch, buffer_size,
"OF_COMPATIBLE_%d=%s", seen, compat);
if ((buffer_size - length <= 0) || (i >= num_envp))
++length;
buffer_size -= length;
if ((buffer_size <= 0) || (i >= num_envp))
return -ENOMEM;
length++;
scratch += length;
l = strlen (compat) + 1;
compat += l;
cplen -= l;
length = strlen (compat) + 1;
compat += length;
cplen -= length;
seen++;
}

envp[i++] = scratch;
length += scnprintf (scratch, buffer_size - length,
"OF_COMPATIBLE_N=%d", seen);
if ((buffer_size - length <= 0) || (i >= num_envp))
return -ENOMEM;
length = scnprintf (scratch, buffer_size, "OF_COMPATIBLE_N=%d", seen);
++length;
buffer_size -= length;
if ((buffer_size <= 0) || (i >= num_envp))
return -ENOMEM;
scratch += length;

envp[i++] = scratch;
length = scnprintf (scratch, buffer_size, "MODALIAS=of:N%sT%s",
of->node->name, of->node->type);
/* overwrite '\0' */
buffer_size -= length;
if ((buffer_size <= 0) || (i >= num_envp))
return -ENOMEM;
scratch += length;

if (!compat2) {
compat2 = "";
cplen2 = 1;
}
while (cplen2 > 0) {
length = snprintf (scratch, buffer_size, "C%s", compat2);
buffer_size -= length;
if (buffer_size <= 0)
return -ENOMEM;
scratch += length;
length = strlen (compat2) + 1;
compat2 += length;
cplen2 -= length;
}

envp[i] = NULL;

return 0;
Expand Down

0 comments on commit 16d50e7

Please sign in to comment.