From nobody Fri Jul 24 23:30:38 2026 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 869D425B0AE for ; Wed, 22 Jul 2026 05:36:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784698605; cv=none; b=ErJui5oQGPBalJAbL1XbvIHq2itpJec4erLfIwBRXQ5UgqjezZ6vj1tcjp7CuvHwAVBBVdodZrafd95TEhWgLVVGXaaL4PhlhvLsG666UhpmNbbKL/H0VjTzCBI1xI3kQfiBRpjMguAFDiJutb1gpzL1XeOtVcWi7oMY+W/RItg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784698605; c=relaxed/simple; bh=hqGhStuKD9ywvE0eqxuCRvlqQbRDWnjRzCP77fRnr1k=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=WbOYpsvwJggqUgYjKgfSwv62zsdxFsl4HTVBEm0Y0W/Bbxh9hNzSXuab9gCIm1yIR5RNo0/G9b+svjbhQsjDMlVra3vzrl5+tlx5UUDcP2xVRRTFpm9SxBvkOyuOiNYOS6P5t03Z2oSVOZj4OwMj7/eOOxtx5vR2FE8zzu3hrkc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BF8qqUTc; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BF8qqUTc" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-47f8773ce8dso69109f8f.0 for ; Tue, 21 Jul 2026 22:36:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784698602; x=1785303402; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=JUYQkb6kcmG18ceKspm+XxEQfizEv7MsjrgrMep9zgE=; b=BF8qqUTcNunWvkKwOYfa4HLb8F2Xo/FrN26F7IUwuu81E8kaBeynw8bWWxSvX0IsCB yqsK/v/S100B5FDAsX/wYKAacoKVEtWDIEU9X+JhZAkaeJpcZoff0nlarSPNlWrVd4LH ocVvoFYANq1o+89SqNviPPcSCvx1YRjwRTnhHuslkPgnxgeEnjZBnQwyKKqD/s9/+K8o /M8bN7kt6jd6YK+4stSQMG8x0WaAg0nURVh+LNMtetFMoWwhc8hb+mEwgwEuwjpq9Us3 AWA/+IxZ8NKCh9I2Xc52tjT4pZi5tF5nEyx2YbcYpspxQUapi2SWdyDH3W6B6l1JY/9b 9mjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784698602; x=1785303402; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=JUYQkb6kcmG18ceKspm+XxEQfizEv7MsjrgrMep9zgE=; b=NDuB3NvY7qUVPds8crsPWXkXaMCEbTfOzTf2m1mzk7XVEYZuGpmImNLaBDOPZDnFO0 cwAbTynf94wrsZdqIv7jTKLhKPIXhPrPnEHIMS53YfwS3qeAqbl7vBRRhiC/9gWtMyl+ fUjw8ZfSTZXXpuqgeDzf6Ui9LCIbJd1zuopyRr5w0+D6AS/X+zCU7QximEfUMlfNEKzM Q/BqeE65niyhWKJo9APm4f/vdAGYnZILg6L+RuNUCSh3jNQPkOmzufPEWHjJrcq/VsUl 0ifJRM403yUca2Bmc2NAz7jQ6P0WTdUFTgHSca6DpncAShLhlA8nevpQzYEarAFoUT60 I+Vg== X-Forwarded-Encrypted: i=1; AHgh+RorIoriboCvfCXY0OO7AbOLSOjBmIsUko9rvx5zhpbVzwt8omSnZdEYyGmubRUgUA23YlkLhp7JVuk3WOw=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3p8ZUMAfnsq042hWo8r6sxnf1H2E1Vfi2PYQsDo6xwbykwQw5 ZPXP3FAsAoJDIZlC89iCVQBFMMgezF8Rtlpi13WIxSZvQo0gRPPAzd2h X-Gm-Gg: AR+sD10zbt0OdF3/mEc89f/Fu5XhmcqLLQr3vpJ5tkYoXkThGH9Dt11JSJmS0NUNBh6 4mkSju/RMuJiBC1HUP0QLZG0I5gOZY06LlcCu3p6Gh3kl48l4ubrfYfs6JwY0T/tJY/WTooJvSD p1wHPGAzUDmUXBdc9xf3yFxTWW8So9MyWM3mfYh8Uq63oO4jJxzdzsfKgaVLaTz8lXWkBYC2Z6N Ca3zxJD1JR/zXlruJNjiJLbpVw+F0lwiulRBE8cC2j25xYdD5IbUGkMYaoayT48Eq9UBxs/SyaJ O/g2LFFkjuJyd8KbpmjXzmBE/xV7nltNd8L+pYXRMEoA5W7dyVZnhWmBqpNb58afs0fXWrsg2mk 8FQOBCal3EDy+TsM+nGZG2HtfE6NSqckZdybD0JtVBFgkv461swCg4q45QSYAgoJOydVZWaDAWg xgMigpaWjFXSP/Z0ZIePuZjsc= X-Received: by 2002:adf:e18e:0:b0:47e:12d9:1c79 with SMTP id ffacd0b85a97d-47f622ffc75mr25483573f8f.27.1784698601513; Tue, 21 Jul 2026 22:36:41 -0700 (PDT) Received: from localhost.localdomain ([95.43.220.235]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f85c532d4sm2477933f8f.22.2026.07.21.22.36.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2026 22:36:41 -0700 (PDT) From: Ivaylo Dimitrov To: Vinod Koul , Neil Armstrong , Johan Hovold Cc: linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Ivaylo Dimitrov Subject: [PATCH] phy: omap-usb2: add explicit PHY comparator API Date: Wed, 22 Jul 2026 08:36:18 +0300 Message-Id: <20260722053618.602702-1-ivo.g.dimitrov.75@gmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The existing omap_usb2_set_comparator() API locates the OMAP USB2 PHY instance by calling usb_get_phy(USB_PHY_TYPE_USB2), assuming there is a single USB2 PHY registered in the system. This assumption no longer holds on systems with multiple USB2 PHY providers. In such cases, the global lookup may return a different USB2 PHY instance, causing the OMAP driver to perform an invalid container_of() conversion when accessing its private data. Introduce omap_usb2_set_phy_comparator(), allowing callers to explicitly specify the OMAP USB2 PHY instance to associate with a phy_companion. The new helper validates that the supplied USB PHY is an OMAP USB2 PHY before accessing its private data. The existing omap_usb2_set_comparator() API is kept unchanged for existing users. Signed-off-by: Ivaylo Dimitrov --- drivers/phy/ti/phy-omap-usb2.c | 32 ++++++++++++++++++++++++++++++++ include/linux/phy/omap_usb.h | 7 +++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/phy/ti/phy-omap-usb2.c b/drivers/phy/ti/phy-omap-usb2.c index 1eb252604441..ac31b693fce7 100644 --- a/drivers/phy/ti/phy-omap-usb2.c +++ b/drivers/phy/ti/phy-omap-usb2.c @@ -70,6 +70,8 @@ struct omap_usb { =20 #define phy_to_omapusb(x) container_of((x), struct omap_usb, phy) =20 +static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host); + struct usb_phy_data { const char *label; u8 flags; @@ -113,6 +115,36 @@ int omap_usb2_set_comparator(struct phy_companion *com= parator) } EXPORT_SYMBOL_GPL(omap_usb2_set_comparator); =20 +/** + * omap_usb2_set_phy_comparator() - associate a comparator with an OMAP US= B2 PHY + * + * @omap_phy: OMAP USB2 PHY instance + * @comparator: companion PHY providing comparator operations + * + * The phy companion driver should call this API with the companion PHY + * implementation containing the callbacks required by @omap_phy. + * + * For use by phy companion drivers. + */ +int omap_usb2_set_phy_comparator(struct usb_phy *omap_phy, + struct phy_companion *comparator) +{ + struct omap_usb *phy; + + if (!omap_phy) + return -EINVAL; + + if (WARN_ON(!omap_phy->otg || + omap_phy->otg->set_host !=3D omap_usb_set_host)) + return -EINVAL; + + phy =3D phy_to_omapusb(omap_phy); + phy->comparator =3D comparator; + + return 0; +} +EXPORT_SYMBOL_GPL(omap_usb2_set_phy_comparator); + static int omap_usb_set_vbus(struct usb_otg *otg, bool enabled) { struct omap_usb *phy =3D phy_to_omapusb(otg->usb_phy); diff --git a/include/linux/phy/omap_usb.h b/include/linux/phy/omap_usb.h index e23b52df93ec..96f9792c6ce6 100644 --- a/include/linux/phy/omap_usb.h +++ b/include/linux/phy/omap_usb.h @@ -15,11 +15,18 @@ =20 #if defined(CONFIG_OMAP_USB2) || defined(CONFIG_OMAP_USB2_MODULE) extern int omap_usb2_set_comparator(struct phy_companion *comparator); +extern int omap_usb2_set_phy_comparator(struct usb_phy *omap_phy, + struct phy_companion *comparator); #else static inline int omap_usb2_set_comparator(struct phy_companion *comparato= r) { return -ENODEV; } +static inline int omap_usb2_set_phy_comparator(struct usb_phy *omap_phy, + struct phy_companion *comparator) +{ + return -ENODEV; +} #endif =20 #endif /* __DRIVERS_OMAP_USB_H */ --=20 2.39.5