* [PATCH] power_supply: add "unknown" in power supply type
@ 2011-12-01 7:08 Kim, Milo
2012-01-04 4:51 ` Anton Vorontsov
0 siblings, 1 reply; 2+ messages in thread
From: Kim, Milo @ 2011-12-01 7:08 UTC (permalink / raw)
To: Anton Vorontsov; +Cc: linux-kernel@vger.kernel.org, dwmw2@infradead.org
Hi, Anton
For the default value of power supply type, "unknown" is added.
With default prop value, supply type property can be displayed as default - "Unknown".
And union propval is set to zero.
Then no data abort exception even if the propval is not updated by xxx_get_property().
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
---
drivers/power/power_supply_sysfs.c | 4 +++-
include/linux/power_supply.h | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
index 58cc490..6250686 100644
--- a/drivers/power/power_supply_sysfs.c
+++ b/drivers/power/power_supply_sysfs.c
@@ -42,7 +42,7 @@ static ssize_t power_supply_show_property(struct device *dev,
struct device_attribute *attr,
char *buf) {
static char *type_text[] = {
- "Battery", "UPS", "Mains", "USB",
+ "Unknown", "Battery", "UPS", "Mains", "USB",
"USB_DCP", "USB_CDP", "USB_ACA"
};
static char *status_text[] = {
@@ -67,6 +67,8 @@ static ssize_t power_supply_show_property(struct device *dev,
const ptrdiff_t off = attr - power_supply_attrs;
union power_supply_propval value;
+ memset(&value, 0, sizeof(value));
+
if (off == POWER_SUPPLY_PROP_TYPE)
value.intval = psy->type;
else
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 204c18d..9c83e04 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -123,7 +123,8 @@ enum power_supply_property {
};
enum power_supply_type {
- POWER_SUPPLY_TYPE_BATTERY = 0,
+ POWER_SUPPLY_TYPE_UNKNOWN = 0,
+ POWER_SUPPLY_TYPE_BATTERY,
POWER_SUPPLY_TYPE_UPS,
POWER_SUPPLY_TYPE_MAINS,
POWER_SUPPLY_TYPE_USB, /* Standard Downstream Port */
--
1.7.4.1
Best Regards
Milo (Woogyom) Kim
Texas Instruments Incorporated
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] power_supply: add "unknown" in power supply type
2011-12-01 7:08 [PATCH] power_supply: add "unknown" in power supply type Kim, Milo
@ 2012-01-04 4:51 ` Anton Vorontsov
0 siblings, 0 replies; 2+ messages in thread
From: Anton Vorontsov @ 2012-01-04 4:51 UTC (permalink / raw)
To: Kim, Milo; +Cc: linux-kernel@vger.kernel.org, dwmw2@infradead.org
On Wed, Nov 30, 2011 at 11:08:33PM -0800, Kim, Milo wrote:
> Hi, Anton
>
> For the default value of power supply type, "unknown" is added.
> With default prop value, supply type property can be displayed as default - "Unknown".
Applied, thanks!
> And union propval is set to zero.
> Then no data abort exception even if the propval is not updated by xxx_get_property().
Why it is not updated in the first place (assuming get_property() returned
success)?.. Driver should be fixed then... I dropped this change.
In any case, if we want this change, it should be a separate patch.
Thanks!
> Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
> ---
> drivers/power/power_supply_sysfs.c | 4 +++-
> include/linux/power_supply.h | 3 ++-
> 2 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
> index 58cc490..6250686 100644
> --- a/drivers/power/power_supply_sysfs.c
> +++ b/drivers/power/power_supply_sysfs.c
> @@ -42,7 +42,7 @@ static ssize_t power_supply_show_property(struct device *dev,
> struct device_attribute *attr,
> char *buf) {
> static char *type_text[] = {
> - "Battery", "UPS", "Mains", "USB",
> + "Unknown", "Battery", "UPS", "Mains", "USB",
> "USB_DCP", "USB_CDP", "USB_ACA"
> };
> static char *status_text[] = {
> @@ -67,6 +67,8 @@ static ssize_t power_supply_show_property(struct device *dev,
> const ptrdiff_t off = attr - power_supply_attrs;
> union power_supply_propval value;
>
> + memset(&value, 0, sizeof(value));
> +
> if (off == POWER_SUPPLY_PROP_TYPE)
> value.intval = psy->type;
> else
> diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
> index 204c18d..9c83e04 100644
> --- a/include/linux/power_supply.h
> +++ b/include/linux/power_supply.h
> @@ -123,7 +123,8 @@ enum power_supply_property {
> };
>
> enum power_supply_type {
> - POWER_SUPPLY_TYPE_BATTERY = 0,
> + POWER_SUPPLY_TYPE_UNKNOWN = 0,
> + POWER_SUPPLY_TYPE_BATTERY,
> POWER_SUPPLY_TYPE_UPS,
> POWER_SUPPLY_TYPE_MAINS,
> POWER_SUPPLY_TYPE_USB, /* Standard Downstream Port */
> --
> 1.7.4.1
>
>
> Best Regards
>
> Milo (Woogyom) Kim
> Texas Instruments Incorporated
--
Anton Vorontsov
Email: cbouatmailru@gmail.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-01-04 4:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-01 7:08 [PATCH] power_supply: add "unknown" in power supply type Kim, Milo
2012-01-04 4:51 ` Anton Vorontsov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox