Default HTC One USB Host Mode Problem

hello, i need your help. everytime i plug my htc one to my computer it always turns to host mode and cannot charge. and when i plug it back to my wall charger, it cant charge anymore. i tried rebooting it, and it seems to get fixed. but when i plug it back to my computer, the same thing happens all over again. how do i fix this? can i have it replaced? it is still in warranty.