Re: device type in apple-mfi-fastcharfe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2022-04-07 at 12:40 +0200, Oliver Neukum wrote:
> Hi,
> 
> looking at this bug report:
> 
> https://bugzilla.kernel.org/show_bug.cgi?id=215799
> 
> I had an occasion to look at the way it registers the charger.
> In particular:
>  .type                   = POWER_SUPPLY_TYPE_BATTERY,
> 
> That seems kind of wrong. It does not contain a battery, does it? The
> type seems to confound user space. Is there some deeper reason? If
> not
> how about the attached patch? Regards Oliver

The "apple-mfi-fastcharge" driver gets registered for a lot of Apple
iOS devices plugged in through USB, and those devices definitely
contain a battery.

I'm going to hazard a guess that the script in question doesn't check
the power_supply "scope" property, which means it thinks any battery
plugged in to the machine is a battery that powers the machine. That's
not the case.

POWER_SUPPLY_TYPE_USB also seems to only be used by USB ports[1] that
are used to charge the machine itself (so a "system" scope), like the
USB port on a phone, not for devices connected through USB (of which
there are a lot).

[1]: Except for drivers/hid/wacom_sys.c, which looks incorrect
Benjamin, so this?

diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 066c567dbaa2..620fe74f5676 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -1777,7 +1777,7 @@ static int __wacom_initialize_battery(struct
wacom *wacom,
        bat_desc->get_property = wacom_battery_get_property;
        sprintf(battery->bat_name, "wacom_battery_%ld", n); 
        bat_desc->name = battery->bat_name;
-       bat_desc->type = POWER_SUPPLY_TYPE_USB;
+       bat_desc->type = POWER_SUPPLY_TYPE_BATTERY;
        bat_desc->use_for_apm = 0;
 
        ps_bat = devm_power_supply_register(dev, bat_desc, &psy_cfg);




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux