Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp734523lqo; Fri, 10 May 2024 13:13:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVUhoW/gz0rMDmknKgcnx1Nf38MdV3n3Kwc3YZ06MQNYJoCb4jm2/U+6rq/OnVmwTBAZpQnWg5lydjjnlrXqBvxkDClXgciotUHzZyvPw== X-Google-Smtp-Source: AGHT+IFhot/5GjEWCVuwP4aczhrp8zvVSXGJOfB63YSoBJbWhZGDwF2sRTNZxe4+5rS7O3CnS1KJ X-Received: by 2002:a05:620a:50:b0:792:bf2e:2e55 with SMTP id af79cd13be357-792c75ffaacmr403517685a.47.1715372022527; Fri, 10 May 2024 13:13:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715372022; cv=pass; d=google.com; s=arc-20160816; b=Un7Rnrxqt4CKDdcNogwRN31hYbM+v3yDv0k5YSDuPTxir4k7mIyQ06nQo716ZnC0xC X1CHiQPw8RHB/1KoxQlC/WeFBUlDwavtOc3yVQfeXFMJwgR5xfMsrH2c1jMgK6+FFGjl uM44X9iTDcOXebmiwLGU7+bjCcKQ4vrDyB9fyvChKUc6i9ejKpS4qRjHbd6mP/B3mqq5 W5pa910Nku8h7XdsyV7k2MnfrFVKXzfWPD3DbRZdCZVHDh3oTXZQUgoW/d/TuQGYrPPy Ku9kDjU3grxamvA3fl475zRC8PurgQAhfj0ybxoLVme3u8wLYwRxD5j300OT6Uo1dxhy T+oQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=LSLd4C6RWuRDc53VYjutUDg53I6/Zy/8sBQNs3K9WZo=; fh=q/ssmfy29w5paDWHQwtYsoMIrUtnyYe5tt8u3V7SzZs=; b=K4WsVj3jCzbV8JNQT1IOVv7pUiQF/QHO1NQNYlLY9u0m1fg8eZutObKJmOTi0yw/dx Xgkj9suRYfAhw6x5ekMfDc3P4D5y3xYj1+2uyON5Vx2Utgq4i3d3doZH70JYoDJKWlST Oh/KX3fb4n9JsnUlr0n+5to1ljqBqSo3WI19fHqoyBPGthSrGWiAJ9erlRai4MFC/NHC H0ZnmZFBOne2xQDov8j+CMNtDWHPWC2Ri1EyHKd9h91L5IvRgQONBTnLJ4GjF6uctHiX UC5GrP+/FaIOmdpWb/20Ra8YULrRIMoqLg0YRVOVZ+sb5r9cJVGNkQwa4YpMDMGD9Jss GtKQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=3hc1OM+7; arc=pass (i=1 spf=pass spfdomain=flex--jthies.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-176160-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176160-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-792bf33ad9esi423754285a.424.2024.05.10.13.13.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 13:13:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176160-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=3hc1OM+7; arc=pass (i=1 spf=pass spfdomain=flex--jthies.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-176160-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176160-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 34DF81C225C1 for ; Fri, 10 May 2024 20:13:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3CC3D4D58A; Fri, 10 May 2024 20:13:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="3hc1OM+7" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 EDC114CB4E for ; Fri, 10 May 2024 20:13:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715372001; cv=none; b=SJbutzGDQd3tmWjC9kYdIbK2fT4CVK1mGJZJKiv0Cmgj6IXC942J+T7A6wqXG6MgrWDAgCYmnxBPc8djWyM4xCG2xmPDHcZNEfTeztsaE9W+4OWR7hn9SjkUxkulc6L6oKwcSB6rYbF9ci+J1MtxGcza1028VwrjwLFFCXHUQXg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715372001; c=relaxed/simple; bh=xQ2rEgQNzAAGgb7mqu13QJRWKCJLNrN/kv/VNptS1jg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=EGXbcsty+8oVc8/nTxpP5gQZxW6wXBkx/JK1IUf8DeloJ1lmRFyw7fNP9Gr2wiWiNYnPmux9i4V1HyxzhbmI2Kjnokvf/L3Fwi1Zvl94/8tqXRGK2W3ibxsV+Ei8WRbb9d4JTdp7A6eYmICVV5Kjqkkjnre+zlUwJchQmTQjxqI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jthies.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=3hc1OM+7; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jthies.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-de60cd96bf3so5192050276.0 for ; Fri, 10 May 2024 13:13:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715371997; x=1715976797; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=LSLd4C6RWuRDc53VYjutUDg53I6/Zy/8sBQNs3K9WZo=; b=3hc1OM+7SaX/wGre2uA9snQ9GWdp08+vioF0MXI96Ee1wzU0E7FNqDiEcXvMC1+cbY 5v7ddYzaxF3ep6fnzWmYGpvOrcPJuYPaV7++86nQ6V7DXonYBTuQDQgt7aPsnYCLaWIz 80QDoSMiGFOLkDtZgRUrscyfzPNBQgfnMncpNps6YXj2wnDLxj5rfBGlwNnVypkF72jl fxvkVvNUCfB+DVv3mHOU59HbPkl5+EIv8RuclWw5KyTV7QRsSpRFDZ9qLGLTGGgcKq0m GAwj6FuSBCt0fDui56SmFUTILwr/sRzvzq0fOMY6gDaG6YtJ4csORezGZQSwjSsQ+iaz NNYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715371997; x=1715976797; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LSLd4C6RWuRDc53VYjutUDg53I6/Zy/8sBQNs3K9WZo=; b=HfXpwIQeTBfqI58bOrs8HoxTj4mRqaLHgZBXnRbET+6oCDd2hoTrocfBiyYWOXsa7X 2r3tI6yvqWABHgq3TNqt/QuIqfWHAwfDqQqStTQHTQokjJg2aiKpwFxqMpWlHezX/arl vkuh28MR3Tmhs72Sh4PiZjBk00domcjzCSCjUNo2D7v3GlVMWQjY0mSd6N2rcN4mtsSP Jjc7AbLdiwPzbRsruTJCEZaAEN04yGsvn2Hw/fhKGEo3AAAnOIQYxO/hBuNWBvB6Am2u mUfhGq2/ZXUOER98It7NMVWL/jFb2/KscAQWI2Mc2H8q80gK0jwu4cVf96MCBEqDHmYN LiUg== X-Forwarded-Encrypted: i=1; AJvYcCWmcrK7rUVjdwqMFhPGqJffYgWtMtZDwHeAjzAVg5Wuv/D0NEI/UsgVILEVlctt7AoLqG35yrAS4fWBeKu7QReJoLWQsG6vEKPZNbip X-Gm-Message-State: AOJu0Yxd4Dgqb5OYuRDTg8Oe/XJmdd5HsT9OUvI5/d0L96hr386DlTi3 9aTr87It4yaoXcrRHHtOgTtxSpw5bal0wNdbbFiUdtSE6NfgQK8o0QxI75AoHgT6OQgKk/2NAxW fZw== X-Received: from jthies.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:23db]) (user=jthies job=sendgmr) by 2002:a05:6902:c0e:b0:dda:c4ec:7db5 with SMTP id 3f1490d57ef6-dee4e57a059mr1072074276.4.1715371997051; Fri, 10 May 2024 13:13:17 -0700 (PDT) Date: Fri, 10 May 2024 20:12:42 +0000 In-Reply-To: <20240510201244.2968152-1-jthies@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240510201244.2968152-1-jthies@google.com> X-Mailer: git-send-email 2.45.0.118.g7fe29c98d7-goog Message-ID: <20240510201244.2968152-3-jthies@google.com> Subject: [PATCH v5 2/4] usb: typec: Update sysfs when setting ops From: Jameson Thies To: heikki.krogerus@linux.intel.com, linux-usb@vger.kernel.org Cc: jthies@google.com, pmalani@chromium.org, bleung@google.com, abhishekpandit@chromium.org, andersson@kernel.org, dmitry.baryshkov@linaro.org, fabrice.gasnier@foss.st.com, gregkh@linuxfoundation.org, hdegoede@redhat.com, neil.armstrong@linaro.org, rajaram.regupathy@intel.com, saranya.gopal@intel.com, linux-kernel@vger.kernel.org, Benson Leung Content-Type: text/plain; charset="UTF-8" From: Abhishek Pandit-Subedi When adding altmode ops, update the sysfs group so that visibility is also recalculated. Reviewed-by: Heikki Krogerus Reviewed-by: Benson Leung Signed-off-by: Abhishek Pandit-Subedi Signed-off-by: Jameson Thies --- Changes in V5: - Fixed signed off by line order. Changes in V4: - None. Changes in V3: - None. Changes in V2: - None. drivers/usb/typec/altmodes/displayport.c | 2 +- drivers/usb/typec/class.c | 18 +++++++++++++++++- drivers/usb/typec/ucsi/displayport.c | 2 +- include/linux/usb/typec.h | 3 +++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c index 596cd4806018b..92cc1b1361208 100644 --- a/drivers/usb/typec/altmodes/displayport.c +++ b/drivers/usb/typec/altmodes/displayport.c @@ -746,7 +746,7 @@ int dp_altmode_probe(struct typec_altmode *alt) dp->alt = alt; alt->desc = "DisplayPort"; - alt->ops = &dp_altmode_ops; + typec_altmode_set_ops(alt, &dp_altmode_ops); if (plug) { plug->desc = "Displayport"; diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 9610e647a8d48..9262fcd4144f8 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -467,6 +467,22 @@ static const struct attribute_group *typec_altmode_groups[] = { NULL }; +/** + * typec_altmode_set_ops - Set ops for altmode + * @adev: Handle to the alternate mode + * @ops: Ops for the alternate mode + * + * After setting ops, attribute visiblity needs to be refreshed if the alternate + * mode can be activated. + */ +void typec_altmode_set_ops(struct typec_altmode *adev, + const struct typec_altmode_ops *ops) +{ + adev->ops = ops; + sysfs_update_group(&adev->dev.kobj, &typec_altmode_group); +} +EXPORT_SYMBOL_GPL(typec_altmode_set_ops); + static int altmode_id_get(struct device *dev) { struct ida *ids; @@ -2317,7 +2333,7 @@ void typec_port_register_altmodes(struct typec_port *port, continue; } - alt->ops = ops; + typec_altmode_set_ops(alt, ops); typec_altmode_set_drvdata(alt, drvdata); altmodes[index] = alt; index++; diff --git a/drivers/usb/typec/ucsi/displayport.c b/drivers/usb/typec/ucsi/displayport.c index d9d3c91125ca8..eb7b8d6e47d00 100644 --- a/drivers/usb/typec/ucsi/displayport.c +++ b/drivers/usb/typec/ucsi/displayport.c @@ -337,7 +337,7 @@ struct typec_altmode *ucsi_register_displayport(struct ucsi_connector *con, dp->con = con; dp->alt = alt; - alt->ops = &ucsi_displayport_ops; + typec_altmode_set_ops(alt, &ucsi_displayport_ops); typec_altmode_set_drvdata(alt, dp); return alt; diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h index b35b427561ab5..549275f8ac1b3 100644 --- a/include/linux/usb/typec.h +++ b/include/linux/usb/typec.h @@ -167,6 +167,9 @@ struct typec_port *typec_altmode2port(struct typec_altmode *alt); void typec_altmode_update_active(struct typec_altmode *alt, bool active); +void typec_altmode_set_ops(struct typec_altmode *alt, + const struct typec_altmode_ops *ops); + enum typec_plug_index { TYPEC_PLUG_SOP_P, TYPEC_PLUG_SOP_PP, -- 2.45.0.118.g7fe29c98d7-goog