]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
dm: cpu: Add a new get_count method to cpu uclass
authorBin Meng <bmeng.cn@gmail.com>
Wed, 17 Jun 2015 03:15:34 +0000 (11:15 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Wed, 9 Sep 2015 11:29:22 +0000 (13:29 +0200)
Introduce a new method 'get_count' in the UCLASS_CPU ops to get
the number of CPUs in the system.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
drivers/cpu/cpu-uclass.c
include/cpu.h

index d6be9d4dcf5cd534a9efb5627a91dfe405887065..a2814a8dcf5b0f7e04a8db6e8e14bdadffed16b4 100644 (file)
@@ -32,6 +32,16 @@ int cpu_get_info(struct udevice *dev, struct cpu_info *info)
        return ops->get_info(dev, info);
 }
 
+int cpu_get_count(struct udevice *dev)
+{
+       struct cpu_ops *ops = cpu_get_ops(dev);
+
+       if (!ops->get_count)
+               return -ENOSYS;
+
+       return ops->get_count(dev);
+}
+
 U_BOOT_DRIVER(cpu_bus) = {
        .name   = "cpu_bus",
        .id     = UCLASS_SIMPLE_BUS,
index 34c60bcbaa1d0edd814f1faec85f6b46a96780ff..bfb0db2e2c6dd96c5c52fa65edeb3a1bb9cfeb49 100644 (file)
@@ -58,6 +58,14 @@ struct cpu_ops {
         * @return 0 if OK, -ve on error
         */
        int (*get_info)(struct udevice *dev, struct cpu_info *info);
+
+       /**
+        * get_count() - Get number of CPUs
+        *
+        * @dev:        Device to check (UCLASS_CPU)
+        * @return CPU count if OK, -ve on error
+        */
+       int (*get_count)(struct udevice *dev);
 };
 
 #define cpu_get_ops(dev)        ((struct cpu_ops *)(dev)->driver->ops)
@@ -81,4 +89,12 @@ int cpu_get_desc(struct udevice *dev, char *buf, int size);
  */
 int cpu_get_info(struct udevice *dev, struct cpu_info *info);
 
+/**
+ * cpu_get_count() - Get number of CPUs
+ *
+ * @dev:       Device to check (UCLASS_CPU)
+ * @return CPU count if OK, -ve on error
+ */
+int cpu_get_count(struct udevice *dev);
+
 #endif