dm: core: Add a way to count the devices in a uclass