All of lore.kernel.org
 help / color / mirror / Atom feed
From: "José Expósito" <jose.exposito89@gmail.com>
To: jikos@kernel.org
Cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"José Expósito" <jose.exposito89@gmail.com>
Subject: [PATCH v2 5/5] HID: magicmouse: report battery status
Date: Sat, 22 May 2021 20:06:11 +0200	[thread overview]
Message-ID: <20210522180611.314300-5-jose.exposito89@gmail.com> (raw)
In-Reply-To: <20210522180611.314300-1-jose.exposito89@gmail.com>

Report the battery charging status for the Apple Magic Mouse 2
and the Apple Magic Trackpad 2.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
 drivers/hid/hid-magicmouse.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index 53e8a10f0551..4085b6698f2c 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -155,6 +155,7 @@ static enum power_supply_property magicmouse_ps_props[] = {
 	POWER_SUPPLY_PROP_PRESENT,
 	POWER_SUPPLY_PROP_SCOPE,
 	POWER_SUPPLY_PROP_CAPACITY,
+	POWER_SUPPLY_PROP_STATUS,
 };
 
 static bool magicmouse_can_report_battery(struct magicmouse_sc *msc)
@@ -229,6 +230,15 @@ static int magicmouse_battery_get_property(struct power_supply *psy,
 
 		val->intval = msc->battery.capacity;
 		break;
+	case POWER_SUPPLY_PROP_STATUS:
+		if (msc->input->id.vendor == BT_VENDOR_ID_APPLE) {
+			val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
+		} else { /* USB_VENDOR_ID_APPLE */
+			val->intval = (msc->battery.capacity == 100) ?
+				      POWER_SUPPLY_STATUS_FULL :
+				      POWER_SUPPLY_STATUS_CHARGING;
+		}
+		break;
 	default:
 		ret = -EINVAL;
 		break;
-- 
2.25.1


  parent reply	other threads:[~2021-05-22 18:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-22 18:06 [PATCH v2 1/5] HID: magicmouse: register power supply José Expósito
2021-05-22 18:06 ` [PATCH v2 2/5] HID: magicmouse: report battery capacity over bluetooth José Expósito
2021-05-22 18:06 ` [PATCH v2 3/5] HID: magicmouse: Magic Trackpad 2 USB battery capacity José Expósito
2021-05-22 18:06 ` [PATCH v2 4/5] HID: magicmouse: Magic Mouse " José Expósito
2021-05-22 18:06 ` José Expósito [this message]
2021-06-24 13:33 ` [PATCH v2 1/5] HID: magicmouse: register power supply Jiri Kosina
2021-06-25 17:08   ` José Expósito
2021-07-28  9:35     ` Jiri Kosina
2021-07-28  9:58       ` José Expósito
2021-07-28 10:04         ` Jiri Kosina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210522180611.314300-5-jose.exposito89@gmail.com \
    --to=jose.exposito89@gmail.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.