Ashley Barnes scored his first goal in more than a year as Burnley beat Wolves 2-1 to move three points clear of the Premier League relegation zone.