Custom module - find out the name of the field
OK. I ended up doing it a little differently:

In my field_widget_form function I added a hidden field. In this function it is possible to access the $field and therefore the name of the field using

$field['field_name'];

So I saved that value to the hidden form. Then when I trigger a function within that form it is able to access that value. So in my different function that relies on the machine_name of the field I actually access the value of the form that is set when the widget form is built.