Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 4162
b: refs/heads/master
c: 184f6eb
h: refs/heads/master
v: v3
  • Loading branch information
Jeff Mahoney authored and Linus Torvalds committed Jul 6, 2005
1 parent a539321 commit 4983598
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b5bf5b6786ccfc9e0c8801291f463d92c8e0b423
refs/heads/master: 184f6eb8c46afc2a4aa6cb7c51ebc423c36d9c9d
71 changes: 71 additions & 0 deletions trunk/drivers/macintosh/macio_asic.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,82 @@ static int macio_device_resume(struct device * dev)
return 0;
}

static int macio_hotplug (struct device *dev, char **envp, int num_envp,
char *buffer, int buffer_size)
{
struct macio_dev * macio_dev;
struct of_device * of;
char *scratch, *compat;
int i = 0;
int length = 0;
int cplen, seen = 0;

if (!dev)
return -ENODEV;

macio_dev = to_macio_device(dev);
if (!macio_dev)
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;
++length;
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;
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);
while (compat && cplen > 0) {
int l;
envp[i++] = scratch;
length += scnprintf (scratch, buffer_size - length,
"OF_COMPATIBLE_%d=%s", seen, compat);
if ((buffer_size - length <= 0) || (i >= num_envp))
return -ENOMEM;
length++;
scratch += length;
l = strlen (compat) + 1;
compat += l;
cplen -= l;
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;
scratch += length;

envp[i] = NULL;

return 0;
}

extern struct device_attribute macio_dev_attrs[];

struct bus_type macio_bus_type = {
.name = "macio",
.match = macio_bus_match,
.hotplug = macio_hotplug,
.suspend = macio_device_suspend,
.resume = macio_device_resume,
.dev_attrs = macio_dev_attrs,
Expand Down

0 comments on commit 4983598

Please sign in to comment.