Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3698305pxv; Mon, 26 Jul 2021 09:39:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznP2ghA1kG/84Ald5F0zUfp3KVG1I93cwpW8YTLIDrwT3JHtSqTjs3cRR1XwZE/bfGa8Mm X-Received: by 2002:a5e:d918:: with SMTP id n24mr15838300iop.173.1627317576676; Mon, 26 Jul 2021 09:39:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627317576; cv=none; d=google.com; s=arc-20160816; b=gTVvfF1lhITmMA+3tXVTbdVCf3fkvxhuKnuYXRizyxGuKvSjqLojbDT4H2oeq7eACw VErU7bvnMzxWWGQiiuaKfbzeEbNLhoG0VOsWsofcnvtuRw2PNAJ7j+1lAZfJyYudanvu H8OYFNaTD+R54f/aEf27GGfbN1yEPxSSnIxh3A2TwEA0GfTodJ4ptxTa3XwsdWeCkWZD vajJ/hAMTfM7pyXMeUE3TYvfwXZCu/v5fK91N/DzAHaOwvT8Okq6EfBvIMZjMavOCQbV y0xof68yNBAPsyNlQrsRRWGbk8ClE5iIHTiOdTZnn9wgLCIyUKo/63Kwpd95Ghcl83Sc q2UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RxrAodUsoUNWd19CFZswfloSG/ufhGbxA28bN5hhWO0=; b=uhBL2gbPEz11uCmSkShVwQWS+vSZjeTFpBmDZwDASV8RHkNrB98PWf6q9Y1e8J3IzE ADozwXkQt4O4qXat93tlusfw8h1XHHroIfA/poahKekxvzTGsGnJ7gr8579jpo5apHAn 1PaJeMdwNJC7uZ+TZuIdCieYAGPjr8EjYGfxI3Np6LSJT8yxi8hJ8/6WhPflFuEBk/Ja 4y2xM6Hf5VT8ekhwXgRz7Ive6mECipzRbrvyR/EM3g7TxBkeabMzjO8VlIfaAdiODHWf rf/vjAUvb+Ajhym0+HedFYTMyweZp+alk5T/0OMTXKo3nyQqEJ1nZFG9n6T/NqkkUORh hmeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ARFV8N1i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w11si335271ill.114.2021.07.26.09.39.25; Mon, 26 Jul 2021 09:39:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ARFV8N1i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239981AbhGZPyp (ORCPT + 99 others); Mon, 26 Jul 2021 11:54:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:51332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235092AbhGZPeF (ORCPT ); Mon, 26 Jul 2021 11:34:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DDECF6056B; Mon, 26 Jul 2021 16:14:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627316067; bh=MIRtdigQjRd10/NGJnkLyqs1dc1KSlw2sbuL0WPp5i0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ARFV8N1igqQpLinFQYRpm4e+6QZxjZ+t7ruZGfgJ+cysNgCK1fM/dKltRCtD2KyaQ jqEQkdgR2AWQvqXedEenJbEe8LEZD6kryv+ya0VvcmgefYmjNRCdlMxDooEx3urwxR 5qYKm8AnFYnAQ3DfU+h5I1tSwh7W1hhjaC4vP0V0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amelie Delaunay Subject: [PATCH 5.13 174/223] usb: typec: stusb160x: register role switch before interrupt registration Date: Mon, 26 Jul 2021 17:39:26 +0200 Message-Id: <20210726153851.887066028@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153846.245305071@linuxfoundation.org> References: <20210726153846.245305071@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Amelie Delaunay commit 86762ad4abcc549deb7a155c8e5e961b9755bcf0 upstream. During interrupt registration, attach state is checked. If attached, then the Type-C state is updated with typec_set_xxx functions and role switch is set with usb_role_switch_set_role(). If the usb_role_switch parameter is error or null, the function simply returns 0. So, to update usb_role_switch role if a device is attached before the irq is registered, usb_role_switch must be registered before irq registration. Fixes: da0cb6310094 ("usb: typec: add support for STUSB160x Type-C controller family") Cc: stable Signed-off-by: Amelie Delaunay Link: https://lore.kernel.org/r/20210716120718.20398-2-amelie.delaunay@foss.st.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/stusb160x.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/drivers/usb/typec/stusb160x.c +++ b/drivers/usb/typec/stusb160x.c @@ -739,10 +739,6 @@ static int stusb160x_probe(struct i2c_cl typec_set_pwr_opmode(chip->port, chip->pwr_opmode); if (client->irq) { - ret = stusb160x_irq_init(chip, client->irq); - if (ret) - goto port_unregister; - chip->role_sw = fwnode_usb_role_switch_get(fwnode); if (IS_ERR(chip->role_sw)) { ret = PTR_ERR(chip->role_sw); @@ -752,6 +748,10 @@ static int stusb160x_probe(struct i2c_cl ret); goto port_unregister; } + + ret = stusb160x_irq_init(chip, client->irq); + if (ret) + goto role_sw_put; } else { /* * If Source or Dual power role, need to enable VDD supply @@ -775,6 +775,9 @@ static int stusb160x_probe(struct i2c_cl return 0; +role_sw_put: + if (chip->role_sw) + usb_role_switch_put(chip->role_sw); port_unregister: typec_unregister_port(chip->port); all_reg_disable: