Keep your devices in a well-cushioned compartment of your bag. You can buy a cushioned laptop sleeve if needed. You should isolate them from any rough, sharp, or metallic object to prevent any risk of damage. You can also put some tape on the exposed battery terminals to eliminate the risk of short-circuiting.