mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp@gmail.com>
To: Bastien Nocera <hadess@hadess.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 12/12] usb: apple-mfi-fastcharge: Simplify match and property_is_writeable
Date: Sat,  5 Dec 2026 18:44:56 -0800	[thread overview]
Message-ID: <7be74b3b899167a181d41b1c32da6099602c02b4.1796524906.git.rosenp@gmail.com> (raw)
In-Reply-To: <cover.1796524906.git.rosenp@gmail.com>

Check the 0x12nn product ID range with a mask on a u16, matching the
type of the descriptor field, and reduce property_is_writeable() to a
single comparison.

No functional change.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/usb/misc/apple-mfi-fastcharge.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/misc/apple-mfi-fastcharge.c b/drivers/usb/misc/apple-mfi-fastcharge.c
index f6355db6ec99..41eb0d56f9e0 100644
--- a/drivers/usb/misc/apple-mfi-fastcharge.c
+++ b/drivers/usb/misc/apple-mfi-fastcharge.c
@@ -154,12 +154,7 @@ static int apple_mfi_fc_set_property(struct power_supply *psy,
 static int apple_mfi_fc_property_is_writeable(struct power_supply *psy,
 					      enum power_supply_property psp)
 {
-	switch (psp) {
-	case POWER_SUPPLY_PROP_CHARGE_TYPE:
-		return 1;
-	default:
-		return 0;
-	}
+	return psp == POWER_SUPPLY_PROP_CHARGE_TYPE;
 }
 
 static const enum power_supply_property apple_mfi_fc_properties[] = {
@@ -169,11 +164,10 @@ static const enum power_supply_property apple_mfi_fc_properties[] = {
 
 static bool mfi_fc_match(struct usb_device *udev)
 {
-	int idProduct;
+	u16 idProduct = le16_to_cpu(udev->descriptor.idProduct);
 
-	idProduct = le16_to_cpu(udev->descriptor.idProduct);
 	/* See comment above mfi_fc_id_table[] */
-	return (idProduct >= 0x1200 && idProduct <= 0x12ff);
+	return (idProduct & 0xff00) == 0x1200;
 }
 
 static int mfi_fc_probe(struct usb_device *udev)
-- 
2.56.1


      parent reply	other threads:[~2026-12-06  2:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-06  2:44 [PATCH 00/12] usb: apple-mfi-fastcharge: Fixes and cleanups Rosen Penev
2026-12-06  2:44 ` [PATCH 01/12] usb: apple-mfi-fastcharge: Convert to devm resources Rosen Penev
2026-12-06  2:44 ` [PATCH 02/12] usb: apple-mfi-fastcharge: Use pm_runtime_resume_and_get() Rosen Penev
2026-12-06  2:44 ` [PATCH 03/12] usb: apple-mfi-fastcharge: Fix usb_control_msg() return check and timeout Rosen Penev
2026-12-06  2:44 ` [PATCH 04/12] usb: apple-mfi-fastcharge: Use POWER_SUPPLY_TYPE_USB instead of BATTERY Rosen Penev
2026-12-06  2:44 ` [PATCH 05/12] usb: apple-mfi-fastcharge: Constify power_supply_property array Rosen Penev
2026-12-06  2:44 ` [PATCH 06/12] usb: apple-mfi-fastcharge: Use topology-based device name Rosen Penev
2026-12-06  2:44 ` [PATCH 07/12] usb: apple-mfi-fastcharge: Restore charge current on resume Rosen Penev
2026-12-06  2:44 ` [PATCH 08/12] usb: apple-mfi-fastcharge: Serialize charge_type access with a mutex Rosen Penev
2026-12-06  2:44 ` [PATCH 09/12] usb: apple-mfi-fastcharge: Configure runtime PM autosuspend Rosen Penev
2026-12-06  2:44 ` [PATCH 10/12] usb: apple-mfi-fastcharge: Name the vendor power request Rosen Penev
2026-12-06  2:44 ` [PATCH 11/12] usb: apple-mfi-fastcharge: Rename battery variables to psy Rosen Penev
2026-12-06  2:44 ` Rosen Penev [this message]

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=7be74b3b899167a181d41b1c32da6099602c02b4.1796524906.git.rosenp@gmail.com \
    --to=rosenp@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hadess@hadess.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®