[hbbtv/youtubetv] Fixed hanup bug and segmentation fault on 3rd-party images.
[vuplus_openembedded] / recipes / linux / linux-efika-2.6.20 / 0016-macintosh-Use-the-new-of_device-common-uevent-handler.txt
1 From 2507b27c0841752a6f419439896fcb089fa4a5ba Mon Sep 17 00:00:00 2001
2 From: Sylvain Munaut <tnt@246tNt.com>
3 Date: Sat, 23 Dec 2006 23:13:56 +0100
4 Subject: [PATCH] [PATCH] macintosh: Use the new of_device common uevent handler
5
6 The generation of the uevent is now common to all bus using
7 of_device.
8
9 Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
10 ---
11  drivers/macintosh/macio_asic.c |   98 +---------------------------------------
12  1 files changed, 1 insertions(+), 97 deletions(-)
13
14 diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
15 index d562160..e851266 100644
16 --- a/drivers/macintosh/macio_asic.c
17 +++ b/drivers/macintosh/macio_asic.c
18 @@ -134,108 +134,12 @@ static int macio_device_resume(struct device * dev)
19         return 0;
20  }
21  
22 -static int macio_uevent(struct device *dev, char **envp, int num_envp,
23 -                          char *buffer, int buffer_size)
24 -{
25 -       struct macio_dev * macio_dev;
26 -       struct of_device * of;
27 -       char *scratch;
28 -       const char *compat, *compat2;
29 -
30 -       int i = 0;
31 -       int length, cplen, cplen2, seen = 0;
32 -
33 -       if (!dev)
34 -               return -ENODEV;
35 -
36 -       macio_dev = to_macio_device(dev);
37 -       if (!macio_dev)
38 -               return -ENODEV;
39 -
40 -       of = &macio_dev->ofdev;
41 -
42 -       /* stuff we want to pass to /sbin/hotplug */
43 -       envp[i++] = scratch = buffer;
44 -       length = scnprintf (scratch, buffer_size, "OF_NAME=%s", of->node->name);
45 -       ++length;
46 -       buffer_size -= length;
47 -       if ((buffer_size <= 0) || (i >= num_envp))
48 -               return -ENOMEM;
49 -       scratch += length;
50 -
51 -       envp[i++] = scratch;
52 -       length = scnprintf (scratch, buffer_size, "OF_TYPE=%s", of->node->type);
53 -       ++length;
54 -       buffer_size -= length;
55 -       if ((buffer_size <= 0) || (i >= num_envp))
56 -               return -ENOMEM;
57 -       scratch += length;
58 -
59 -        /* Since the compatible field can contain pretty much anything
60 -         * it's not really legal to split it out with commas. We split it
61 -         * up using a number of environment variables instead. */
62 -
63 -       compat = get_property(of->node, "compatible", &cplen);
64 -       compat2 = compat;
65 -       cplen2= cplen;
66 -       while (compat && cplen > 0) {
67 -                envp[i++] = scratch;
68 -               length = scnprintf (scratch, buffer_size,
69 -                                    "OF_COMPATIBLE_%d=%s", seen, compat);
70 -               ++length;
71 -               buffer_size -= length;
72 -               if ((buffer_size <= 0) || (i >= num_envp))
73 -                       return -ENOMEM;
74 -               scratch += length;
75 -               length = strlen (compat) + 1;
76 -               compat += length;
77 -               cplen -= length;
78 -               seen++;
79 -       }
80 -
81 -       envp[i++] = scratch;
82 -       length = scnprintf (scratch, buffer_size, "OF_COMPATIBLE_N=%d", seen);
83 -       ++length;
84 -       buffer_size -= length;
85 -       if ((buffer_size <= 0) || (i >= num_envp))
86 -               return -ENOMEM;
87 -       scratch += length;
88 -
89 -       envp[i++] = scratch;
90 -       length = scnprintf (scratch, buffer_size, "MODALIAS=of:N%sT%s",
91 -                       of->node->name, of->node->type);
92 -       /* overwrite '\0' */
93 -       buffer_size -= length;
94 -       if ((buffer_size <= 0) || (i >= num_envp))
95 -               return -ENOMEM;
96 -       scratch += length;
97 -
98 -       if (!compat2) {
99 -               compat2 = "";
100 -               cplen2 = 1;
101 -       }
102 -       while (cplen2 > 0) {
103 -               length = snprintf (scratch, buffer_size, "C%s", compat2);
104 -               buffer_size -= length;
105 -               if (buffer_size <= 0)
106 -                       return -ENOMEM;
107 -               scratch += length;
108 -               length = strlen (compat2) + 1;
109 -               compat2 += length;
110 -               cplen2 -= length;
111 -       }
112 -
113 -       envp[i] = NULL;
114 -
115 -       return 0;
116 -}
117 -
118  extern struct device_attribute macio_dev_attrs[];
119  
120  struct bus_type macio_bus_type = {
121         .name   = "macio",
122         .match  = macio_bus_match,
123 -       .uevent = macio_uevent,
124 +       .uevent = of_device_uevent,
125         .probe  = macio_device_probe,
126         .remove = macio_device_remove,
127         .shutdown = macio_device_shutdown,
128 -- 
129 1.4.4.2
130