All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 1/6] dm: cpu: Add a new get_count method to cpu uclass
@ 2015-06-13 10:11 Bin Meng
  2015-06-15 20:45 ` Simon Glass
  0 siblings, 1 reply; 4+ messages in thread
From: Bin Meng @ 2015-06-13 10:11 UTC (permalink / raw)
  To: u-boot

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>

---

Changes in v3:
- Drop patches already applied and rebase on u-boot-x86/master
- New patch to add a new get_count method to cpu uclass

Changes in v2: None

 drivers/cpu/cpu-uclass.c | 10 ++++++++++
 include/cpu.h            | 18 ++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/drivers/cpu/cpu-uclass.c b/drivers/cpu/cpu-uclass.c
index d6be9d4..8efb17c 100644
--- a/drivers/cpu/cpu-uclass.c
+++ b/drivers/cpu/cpu-uclass.c
@@ -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, int *count)
+{
+	struct cpu_ops *ops = cpu_get_ops(dev);
+
+	if (!ops->get_count)
+		return -ENOSYS;
+
+	return ops->get_count(dev, count);
+}
+
 U_BOOT_DRIVER(cpu_bus) = {
 	.name	= "cpu_bus",
 	.id	= UCLASS_SIMPLE_BUS,
diff --git a/include/cpu.h b/include/cpu.h
index 34c60bc..6fd735d 100644
--- a/include/cpu.h
+++ b/include/cpu.h
@@ -58,6 +58,15 @@ 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)
+	 * @count:	Returns CPU count
+	 * @return 0 if OK, -ve on error
+	 */
+	int (*get_count)(struct udevice *dev, int *count);
 };
 
 #define cpu_get_ops(dev)        ((struct cpu_ops *)(dev)->driver->ops)
@@ -81,4 +90,13 @@ 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)
+ * @count:	Returns CPU count
+ * @return 0 if OK, -ve on error
+ */
+int cpu_get_count(struct udevice *dev, int *count);
+
 #endif
-- 
1.8.2.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v3 1/6] dm: cpu: Add a new get_count method to cpu uclass
  2015-06-13 10:11 [U-Boot] [PATCH v3 1/6] dm: cpu: Add a new get_count method to cpu uclass Bin Meng
@ 2015-06-15 20:45 ` Simon Glass
  2015-06-16  0:19   ` Bin Meng
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Glass @ 2015-06-15 20:45 UTC (permalink / raw)
  To: u-boot

Hi Bin,

On 13 June 2015 at 04:11, Bin Meng <bmeng.cn@gmail.com> wrote:
>
> 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>
>
> ---
>
> Changes in v3:
> - Drop patches already applied and rebase on u-boot-x86/master
> - New patch to add a new get_count method to cpu uclass
>
> Changes in v2: None
>
>  drivers/cpu/cpu-uclass.c | 10 ++++++++++
>  include/cpu.h            | 18 ++++++++++++++++++
>  2 files changed, 28 insertions(+)
>
> diff --git a/drivers/cpu/cpu-uclass.c b/drivers/cpu/cpu-uclass.c
> index d6be9d4..8efb17c 100644
> --- a/drivers/cpu/cpu-uclass.c
> +++ b/drivers/cpu/cpu-uclass.c
> @@ -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, int *count)

Can we please return count and avoid the 'count' parameter? We can use
-ve for errors.

> +{
> +       struct cpu_ops *ops = cpu_get_ops(dev);
> +
> +       if (!ops->get_count)
> +               return -ENOSYS;
> +
> +       return ops->get_count(dev, count);
> +}
> +
>  U_BOOT_DRIVER(cpu_bus) = {
>         .name   = "cpu_bus",
>         .id     = UCLASS_SIMPLE_BUS,
> diff --git a/include/cpu.h b/include/cpu.h
> index 34c60bc..6fd735d 100644
> --- a/include/cpu.h
> +++ b/include/cpu.h
> @@ -58,6 +58,15 @@ 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)
> +        * @count:      Returns CPU count
> +        * @return 0 if OK, -ve on error
> +        */
> +       int (*get_count)(struct udevice *dev, int *count);
>  };
>
>  #define cpu_get_ops(dev)        ((struct cpu_ops *)(dev)->driver->ops)
> @@ -81,4 +90,13 @@ 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)
> + * @count:     Returns CPU count
> + * @return 0 if OK, -ve on error
> + */
> +int cpu_get_count(struct udevice *dev, int *count);
> +
>  #endif
> --
> 1.8.2.1
>

Regards,
Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v3 1/6] dm: cpu: Add a new get_count method to cpu uclass
  2015-06-15 20:45 ` Simon Glass
@ 2015-06-16  0:19   ` Bin Meng
  2015-06-16 22:10     ` Simon Glass
  0 siblings, 1 reply; 4+ messages in thread
From: Bin Meng @ 2015-06-16  0:19 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Tue, Jun 16, 2015 at 4:45 AM, Simon Glass <sjg@chromium.org> wrote:
> Hi Bin,
>
> On 13 June 2015 at 04:11, Bin Meng <bmeng.cn@gmail.com> wrote:
>>
>> 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>
>>
>> ---
>>
>> Changes in v3:
>> - Drop patches already applied and rebase on u-boot-x86/master
>> - New patch to add a new get_count method to cpu uclass
>>
>> Changes in v2: None
>>
>>  drivers/cpu/cpu-uclass.c | 10 ++++++++++
>>  include/cpu.h            | 18 ++++++++++++++++++
>>  2 files changed, 28 insertions(+)
>>
>> diff --git a/drivers/cpu/cpu-uclass.c b/drivers/cpu/cpu-uclass.c
>> index d6be9d4..8efb17c 100644
>> --- a/drivers/cpu/cpu-uclass.c
>> +++ b/drivers/cpu/cpu-uclass.c
>> @@ -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, int *count)
>
> Can we please return count and avoid the 'count' parameter? We can use
> -ve for errors.
>

Yes, but I was wondering that if it looks inconsistent to other two
cpu ops? (or maybe other dm driver ops?)

>> +{
>> +       struct cpu_ops *ops = cpu_get_ops(dev);
>> +
>> +       if (!ops->get_count)
>> +               return -ENOSYS;
>> +
>> +       return ops->get_count(dev, count);
>> +}
>> +
>>  U_BOOT_DRIVER(cpu_bus) = {
>>         .name   = "cpu_bus",
>>         .id     = UCLASS_SIMPLE_BUS,
>> diff --git a/include/cpu.h b/include/cpu.h
>> index 34c60bc..6fd735d 100644
>> --- a/include/cpu.h
>> +++ b/include/cpu.h
>> @@ -58,6 +58,15 @@ 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)
>> +        * @count:      Returns CPU count
>> +        * @return 0 if OK, -ve on error
>> +        */
>> +       int (*get_count)(struct udevice *dev, int *count);
>>  };
>>
>>  #define cpu_get_ops(dev)        ((struct cpu_ops *)(dev)->driver->ops)
>> @@ -81,4 +90,13 @@ 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)
>> + * @count:     Returns CPU count
>> + * @return 0 if OK, -ve on error
>> + */
>> +int cpu_get_count(struct udevice *dev, int *count);
>> +
>>  #endif
>> --

Regards,
Bin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v3 1/6] dm: cpu: Add a new get_count method to cpu uclass
  2015-06-16  0:19   ` Bin Meng
@ 2015-06-16 22:10     ` Simon Glass
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Glass @ 2015-06-16 22:10 UTC (permalink / raw)
  To: u-boot

Hi Bin,

On 15 June 2015 at 18:19, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Simon,
>
> On Tue, Jun 16, 2015 at 4:45 AM, Simon Glass <sjg@chromium.org> wrote:
>> Hi Bin,
>>
>> On 13 June 2015 at 04:11, Bin Meng <bmeng.cn@gmail.com> wrote:
>>>
>>> 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>
>>>
>>> ---
>>>
>>> Changes in v3:
>>> - Drop patches already applied and rebase on u-boot-x86/master
>>> - New patch to add a new get_count method to cpu uclass
>>>
>>> Changes in v2: None
>>>
>>>  drivers/cpu/cpu-uclass.c | 10 ++++++++++
>>>  include/cpu.h            | 18 ++++++++++++++++++
>>>  2 files changed, 28 insertions(+)
>>>
>>> diff --git a/drivers/cpu/cpu-uclass.c b/drivers/cpu/cpu-uclass.c
>>> index d6be9d4..8efb17c 100644
>>> --- a/drivers/cpu/cpu-uclass.c
>>> +++ b/drivers/cpu/cpu-uclass.c
>>> @@ -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, int *count)
>>
>> Can we please return count and avoid the 'count' parameter? We can use
>> -ve for errors.
>>
>
> Yes, but I was wondering that if it looks inconsistent to other two
> cpu ops? (or maybe other dm driver ops?)

I think that if the return value needs to be a postive int, then we
should just use the return value. In other cases perhaps not. It is
slightly more efficient and a little easier to read.

Regards,
Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-06-16 22:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-13 10:11 [U-Boot] [PATCH v3 1/6] dm: cpu: Add a new get_count method to cpu uclass Bin Meng
2015-06-15 20:45 ` Simon Glass
2015-06-16  0:19   ` Bin Meng
2015-06-16 22:10     ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.