A C function for returning the address of the calling function
Didn't totally work
After porting the code to gnu C style, it only &quot;sort of&quot; worked for me.  I was able to have foo() print that it was called from bar() or baz().  However, if foo() was called directly from main(), then it crashed when trying to find its caller.  That's probably because on my system (Cygwin 32-bit, using Gnu C compiler), main() doesn't have a caller on the stack.
Clobbered register
It's not safe to write to ebx without pushing it on the stack and popping it off later.  ebx is considered non-volatile, which means that a function must preserve its value.  If you don't, then the calling function will be affected because its local variable may be stored in ebx, for example.  You can safely use eax, ecx, and edx though, because they are all considered volatile registers (i.e. you are allowed to clobber them).  So you should change your ebx accesses to ecx instead.
Not portable
Your asm statement assumes that the compiler will insert these lines at the top of the function:
    pushl   %ebp
    movl    %esp, %ebp

That may be what your compiler does, but it's not a certainty.  For example, with my GNU C compiler, it normally outputs the above code.  But with the -O2 option, it does this instead:
    subl    $28, %esp

If you want to make sure that you get the function prologue you need, you should write the whole thing in assembly and include the prologue/epilogue you require.