From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.forwardemail.net (smtp.forwardemail.net [121.127.44.66]) (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 50F0439FCA7 for ; Fri, 8 May 2026 23:06:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=121.127.44.66 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778281599; cv=none; b=beZf5HwaIZjWYuoRTSq+5kl29RJWlZhzIiDWFlokCrH+kG2s2AQI/ImR4ONK9mTIvwgPa5t1nQiXTC4jqHu7uvHAm7cHR09dp4Mhrngxb7229WF+odIegHGvCORk2t0u/jAxjR37aAODsjbKo7JQ/4AqDYeItqs7Iva3Bh06ww8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778281599; c=relaxed/simple; bh=t85JgM7KjwXDhuHHWszBT9YbwgD4puLOXW4SOvK3YkE=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=N8ZNiliSMGREkAWgq6WUHkD7sFcazLsVUURkmhoei3CTXNPxazIgs+h98SYIPG15LlWIGG2hNsCGZqOgKX4S5S1FDYyqhgUzNTCCNTLvyEye0F7QQVapFhKXlveaLfBe/+WFMPZ8HQRIwubtDiscw8GjqBUizwNjuHqghvwWKN8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ubuntu.com; spf=pass smtp.mailfrom=fe-bounces.ubuntu.com; dkim=pass (2048-bit key) header.d=ubuntu.com header.i=@ubuntu.com header.b=dnhJgd3b; arc=none smtp.client-ip=121.127.44.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ubuntu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fe-bounces.ubuntu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ubuntu.com header.i=@ubuntu.com header.b="dnhJgd3b" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ubuntu.com; h=In-Reply-To: References: To: From: Subject: Cc: Message-Id: Date: Content-Type: Content-Transfer-Encoding: Mime-Version; q=dns/txt; s=fe-953a8a3ca9; t=1778281596; bh=q2RkdA8XgRewXeIJWKjEFH8X9QpIWC1TGFtAoUA+NC0=; b=dnhJgd3bj5vKoS98ZpwuBbJDZSg8VBVJl2aSZMoKtG6AcAmsq/kyja/uFeImpEdhAv+0I4rI4 td08ilsiUkIqgJInw4cHQeOHmJouRRqQgkgk4Bub/oEQMahofIZp9gjhLLYRJVd6LOC5ey2x0rj qZCO3OmwII0TOTO/o2eAbWCEwZwi09xitZQgsL+magDoRU3sGOs1DYJBGS2ZA0njzWrC55aTwoZ 8Sftx8Wp/rWdUOY8KLDNaspGgLclIz5bKT+UF3u7WND+sWuO5ZuPswpDIdhivNRbDPsKYS82RNV hazGfaUfDpX/QYLrV0Pc9a2Bz72pzLAh5E+iOAXBDKOA== X-Forward-Email-ID: 69fe6c7947f0cc71ba90f8e4 X-Forward-Email-Sender: rfc822; jpeisach@ubuntu.com, smtp.forwardemail.net, 121.127.44.66 X-Forward-Email-Version: 2.7.7 X-Forward-Email-Website: https://forwardemail.net X-Complaints-To: abuse@forwardemail.net X-Report-Abuse: abuse@forwardemail.net X-Report-Abuse-To: abuse@forwardemail.net 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; format=Flowed Date: Fri, 08 May 2026 19:06:31 -0400 Message-Id: Cc: , , , , Subject: Re: [PATCH v3] phy: apple: atc: Fix typec switch/mux leak on unbind From: "Joshua Peisach" To: "David Carlier" , , , , , , , X-Mailer: aerc 0.21.0 References: <20260507163746.108086-1-devnexen@gmail.com> <20260508201958.30060-1-devnexen@gmail.com> In-Reply-To: <20260508201958.30060-1-devnexen@gmail.com> On Fri May 8, 2026 at 4:19 PM EDT, David Carlier wrote: > drivers/phy/apple/atc.c | 27 ++++++++++++++++++++++----- > 1 file changed, 22 insertions(+), 5 deletions(-) > > diff --git a/drivers/phy/apple/atc.c b/drivers/phy/apple/atc.c > index e9d106f135c5..4156fabad742 100644 > --- a/drivers/phy/apple/atc.c > +++ b/drivers/phy/apple/atc.c > @@ -628,9 +628,6 @@ struct apple_atcphy { > =20 > struct reset_controller_dev rcdev; > =20 > - struct typec_switch *sw; > - struct typec_mux *mux; > - > struct mutex lock; > }; > =20 > @@ -2066,15 +2063,25 @@ static int atcphy_sw_set(struct typec_switch_dev = *sw, enum typec_orientation ori > return 0; > } > =20 > +static void atcphy_typec_switch_unregister(void *data) > +{ > + typec_switch_unregister(data); > +} > + > static int atcphy_probe_switch(struct apple_atcphy *atcphy) > { > + struct typec_switch_dev *sw; > struct typec_switch_desc sw_desc =3D { > .drvdata =3D atcphy, > .fwnode =3D atcphy->dev->fwnode, > .set =3D atcphy_sw_set, > }; > =20 > - return PTR_ERR_OR_ZERO(typec_switch_register(atcphy->dev, &sw_desc)); > + sw =3D typec_switch_register(atcphy->dev, &sw_desc); > + if (IS_ERR(sw)) > + return PTR_ERR(sw); > + > + return devm_add_action_or_reset(atcphy->dev, atcphy_typec_switch_unregi= ster, sw); > } > =20 > static int atcphy_mux_set(struct typec_mux_dev *mux, struct typec_mux_st= ate *state) > @@ -2146,15 +2153,25 @@ static int atcphy_mux_set(struct typec_mux_dev *m= ux, struct typec_mux_state *sta > return atcphy_configure(atcphy, target_mode); > } > =20 > +static void atcphy_typec_mux_unregister(void *data) > +{ > + typec_mux_unregister(data); > +} > + > static int atcphy_probe_mux(struct apple_atcphy *atcphy) > { > + struct typec_mux_dev *mux; > struct typec_mux_desc mux_desc =3D { > .drvdata =3D atcphy, > .fwnode =3D atcphy->dev->fwnode, > .set =3D atcphy_mux_set, > }; > =20 > - return PTR_ERR_OR_ZERO(typec_mux_register(atcphy->dev, &mux_desc)); > + mux =3D typec_mux_register(atcphy->dev, &mux_desc); > + if (IS_ERR(mux)) > + return PTR_ERR(mux); > + > + return devm_add_action_or_reset(atcphy->dev, atcphy_typec_mux_unregiste= r, mux); > } > =20 > static int atcphy_load_tunables(struct apple_atcphy *atcphy) Looks okay. Ran it on M1 MBP, no issues as far as I can tell. Tested-by: Joshua Peisach