Configure postgresql recovery again to be slave
Assuming you are using streaming replication, "no latency".
If you can stop writes or stay on the new master B, some steps below can be reduced

If you stop writes, before you failover back to old master A, it could be a master without any issues, most of the times.

But as you have mentioned that you have writes on the new master B after failing over to it, you will have to


resynchronize the old master A as a standby, using pg_start_backup-rsync-pg_stop_backup (and of course recovery.conf) 
promote A using the trigger file, etc
restart B as a standby of A
if it doesn't start (due to continuous writes), you'll have to rsync it again as listed above


I would love to hear if there are other options :)