ibmebus: Use of_device_uevent()
PATCH 1/1 ibmebus: Use of_device_uevent()
This patch replaces ibmebus_uevent() by Sylvain's generic function.
---
ibmebus.c | 37 +++---------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-)
arch/powerpc/kernel/ibmebus.c +3 -34
@@ -372,41 +372,10 @@ static int ibmebus_bus_match(struct devireturn 0 ; } -static int ibmebus_uevent (struct device *dev,char **envp,int num_envp, -char *buffer,int buffer_size) -{ -const struct ibmebus_dev *ebus_dev =to_ibmebus_dev (dev); -char *name, *cp, *loc_code; -int length; - -if (!num_envp) -return -ENOMEM ; - -if (!ebus_dev->ofdev.node) -return -ENODEV ; - - name = (char *)get_property (ebus_dev->ofdev.node,"name" ,NULL ); - cp = (char *)get_property (ebus_dev->ofdev.node,"compatible" ,NULL ); - loc_code = (char *)get_property (ebus_dev->ofdev.node, -"ibm,loc-code" ,NULL ); -if (!(name && cp && loc_code)) -return -ENODEV ; - - envp[0 ] = buffer; - length =scnprintf (buffer, buffer_size, -"MODALIAS=ibmebus:T%s:S%s:L%s" , - name, cp, loc_code); -if (buffer_size - length <=0 ) -return -ENOMEM ; - envp[1 ] =NULL ; - -return 0 ; -} -struct bus_type ibmebus_bus_type = { - .name ="ibmebus" , - .uevent = ibmebus_uevent, - .match = ibmebus_bus_match, + .name ="ibmebus" , + .uevent = of_device_uevent, + .match = ibmebus_bus_match, };EXPORT_SYMBOL (ibmebus_bus_type);
arch/powerpc/kernel/ibmebus.c static int ibmebus_bus_match(struct devi · line 380
Quoted 12 lines · Hoang-Nam Nguyen
This patch replaces
ibmebus_uevent()by Sylvain's generic function.struct
bus_typeibmebus_bus_type= {arch/powerpc/kernel/ibmebus.c +3
-3- .name = "ibmebus", - .uevent = ibmebus_uevent, - .match = ibmebus_bus_match, + .name = "ibmebus", + .uevent = of_device_uevent, + .match = ibmebus_bus_match, };EXPORT_SYMBOL (ibmebus_bus_type);
Doesn't that oops when called with the fake parent device ?
Either you do a wrapper that test for it (that's what I did when I posted the patch).
Or, an even better approach is to add this
+ if (!ebus_dev->ofdev.node)
+ return -ENODEV;
inside the code of of_device_uevent itself.
Sylvain
Sylvain Munaut <[email protected]> wrote on 17.02.2007 04:36:01:
Quoted 1 line
Doesn't that oops when called with the fake parent device ?
I should stop posting patches after 12 hours of work ,)
Quoted 6 lines
Or, an even better approach is to add this
(quoted diff) +2
-0+ if (!ebus_dev->ofdev.node) + return -ENODEV;inside the code of
of_device_ueventitself.
Nice! Patch will follow.
Thanks again,
Joachim
---
Joachim Fenkes -- eHCA Linux Driver Developer and Hardware Tamer extraordinaire
IBM Deutschland Entwicklung GmbH -- Dept. 3627 (I/O Firmware Development
2)
Schoenaicher Strasse 220 -- 71032 Boeblingen -- Germany eMail: [email protected] -- Phone: +49 7031 16 1239
Vorsitzender des Aufsichtsrats: Johann Weihen -- Geschäftsführung:
Herbert Kircher
Sitz der Gesellschaft: Böblingen -- Registergericht: Amtsgericht Stuttgart, HRB 243294