Well I have got the same problem with a Moto X 2013, with Android 5.1.
I cannot say if it is related to a software update.
It started with some freezing of the Camera App and then the back side Camera disappeared completely (no longer possible to switch and the flash cannot be used anymore).
It tends to be OK with the front camera (selfie), once the other one is ignored.
I have considered both hardware and software.
With software most of all the tricks given within forum have been attempted: emptying cache, wiping, even reinitialization of the phone - nothing worked.
With hardware:
-squeezing the phone on the back side has given the illusion it could be effective (the back camera was restored, but only for some minutes).
-I changed the flash (I anticipated something wrong in it could impact on the camera behaviour)
-I changed the camera itself for a new one.
Well each time something is changed on the hardware (open the phone, disconnect) makes the camera recognized again when powering up the phone, but an action as simple as switching to the front camera, or exiting software makes it hang.
Hanging of the back camera goes with hanging of the flash application.
I suspect the things are linked to some native sofware issues; however everything appears updated and really I don't know how to fix it. The version of the camera software is 5.011.17. Or it is hardware not concerning camera devices.
Also running the phone with only the back camera (front camera and flash unplugged) produced freezing after being recognized.
Now I am attempting with a third party software camera. I don't know if it can be a solution.
We don't see so much comments within forums about these issues over the last year. Out of hope?
Thanks for your help.