From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796225587; b=FKH7byaFFtpESXOspsp3AW0H76rZTfeKDkFGILQcZrqcb3NwThY2Q0+As0V9tHt6aPp1 u32729/OYushfslkN64vlJXZraYMlI6DepzkEIWwWbccsLZXTfYKa25sZPmu32yRoFsgQ 21W2clDhV7OcenzEEpUGI3uMGo73HC8f58107pRF7Q4Slo3jd1vLKo4V/n1CvAJMhX60E 8UTC2/RvaSuFNxtNvbUICidEzY9DkuwKOSUw0ZIoZXk4wqWF08pNR4UVFLP5a8A72PZsk 04gaU+1cZK3z4YPkxH7kdj1dz+BuBLyaP/6JSl0gKar3GwBnyODuzDaYVQMjcxhKGiw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796225587; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; bh=jZzbQ0N3p5RvJsg5tTstTqQsjYjXelAC6Xu5hEoc9k0=; b=geriMMVlVzCKQ3TkLEwb6baLcEZ6t0y2Gy2+cPfdHpns6xmc+ePeRHAhd+lE+n2At/HZ Ro08gByAH/Hxoco4V0ubShS9e3Ed/YkdB70jYD5+oBClMhX2wxP90td4Zf0+OpnZk8cDB wDnxMtO5UgVIWmmE7KkJidKVsgVvqIsL5hOWU5kYr1AMn0P70wC6aRFP+kIy04ug/i9vy aNMihMQty17juV+0hZwxBVmQ4P0J+cApepf11B8btswdngBPVoMtBq0e5I7raZsYo6kLB EF/ryuyx3xdAhDQQAULag3Smq++hSaE3CQ42wxqkj/LD19I+kzFOOhey0Y+kE9i7mnw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Vi2Bwb7T; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66AC0606A32D for ; Wed, 2 Dec 2026 15:33:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 66AC0606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Vi2Bwb7T DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796225586; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jZzbQ0N3p5RvJsg5tTstTqQsjYjXelAC6Xu5hEoc9k0=; b=Vi2Bwb7T80z3vqym075+BTK6bkK+GyDiLuRtdkyU6Yn6OBF+dl7yEpOu6BAujtFiD8JKb1 6cXOyD2mUqIGGq9dPjko+BliaLjWIoWXjA28AbEoUocvH5LXxLA9DAXX+BO8oODHiLne5T J7xFBE2CuhccyjBxdHXog9XAUpmAaxM= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-677-qJOl0N1aOcyaX9rCLEzmOA-1; Wed, 2 Dec 2026 15:33:01 +0000 X-MC-Unique: qJOl0N1aOcyaX9rCLEzmOA-1 X-Mimecast-MFC-AGG-ID: qJOl0N1aOcyaX9rCLEzmOA_1796225579 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D006A193207E; Wed, 2 Dec 2026 15:32:58 +0000 (UTC) Received: from poros-thinkpadp16vgen1.tpbc.com (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9911D1801438; Wed, 2 Dec 2026 15:32:54 +0000 (UTC) From: Petr Oros To: netdev@vger.kernel.org Cc: Petr Oros , Ivan Vecera , Jonathan Corbet , Shuah Khan , Shuah Khan , Randy Dunlap , Jani Nikula , Vadim Fedorenko , Arkadiusz Kubalewski , Jiri Pirko , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH net-next v6 05/14] dpll: dpllsim: Add support to set input pin state Date: Wed, 2 Dec 2026 16:32:14 +0100 Message-ID: <20261202153223.2725780-6-poros@redhat.com> In-Reply-To: <20261202153223.2725780-1-poros@redhat.com> References: <20261202153223.2725780-1-poros@redhat.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Add support for setting the state of input pins on the device. Implement the state_on_dpll_set callback for input pins and advertise the state-can-change capability for them, so that userspace can move a pin between the states valid for the device mode. The core checks the capability only, the states a mode allows are up to the driver: in automatic mode a pin is selectable or disconnected, in manual mode connected or disconnected, as Documentation/driver-api/dpll.rst describes them. The device reports automatic mode, so connected is refused with -EINVAL and an extack message. The check is written for both modes already, so that manual mode has nothing to add to it when it arrives. The driver stores the requested state and reports it back unchanged, it does not act on it yet. Output pins keep reporting their state only. Reviewed-by: Ivan Vecera Signed-off-by: Petr Oros --- v6: - no changes v5: - no changes v4: - no change, add the Reviewed-by given to v3 (Ivan Vecera) v3: - refuse pin states that are not valid in the device mode, so that connected is refused in automatic mode, the mode the device reports, with an extack message (Ivan Vecera) - the Acked-by of v2 is not carried over, the callback changed v5: https://lore.kernel.org/all/20261125090522.3777494-6-poros@redhat.com/ v4: https://lore.kernel.org/all/20261112130359.840795-6-poros@redhat.com/ v3: https://lore.kernel.org/all/20261109093523.931201-6-poros@redhat.com/ v2: https://lore.kernel.org/all/20261105151852.1844305-6-poros@redhat.com/ v1: https://lore.kernel.org/all/20261103093910.596225-6-poros@redhat.com/ --- drivers/dpll/dpllsim/dpll.c | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/dpll/dpllsim/dpll.c b/drivers/dpll/dpllsim/dpll.c index 8786293dd6d88d..cf3c200ff3b071 100644 --- a/drivers/dpll/dpllsim/dpll.c +++ b/drivers/dpll/dpllsim/dpll.c @@ -109,10 +109,46 @@ static int dpllsim_pin_state_get(const struct dpll_pin *pin, void *pin_priv, return 0; } +/* + * The states a user may request depend on the device mode: connected and + * disconnected select and deselect the reference in manual mode, selectable + * and disconnected offer a pin to or withdraw it from the automatic + * selection. The core checks the state-can-change capability only. + */ +static bool dpllsim_pin_state_valid(const struct dpllsim_dev *sim, + enum dpll_pin_state state) +{ + if (state == DPLL_PIN_STATE_DISCONNECTED) + return true; + if (sim->mode == DPLL_MODE_MANUAL) + return state == DPLL_PIN_STATE_CONNECTED; + return state == DPLL_PIN_STATE_SELECTABLE; +} + +static int dpllsim_pin_state_set(const struct dpll_pin *pin, void *pin_priv, + const struct dpll_device *dpll, + void *dpll_priv, enum dpll_pin_state state, + struct netlink_ext_ack *extack) +{ + struct dpllsim_pin *sim_pin = pin_priv; + struct dpllsim_dev *sim = sim_pin->dev; + + guard(mutex)(&sim->lock); + if (!dpllsim_pin_state_valid(sim, state)) { + NL_SET_ERR_MSG_FMT(extack, "Pin state not valid in %s mode", + sim->mode == DPLL_MODE_MANUAL ? + "manual" : "automatic"); + return -EINVAL; + } + sim_pin->state = state; + return 0; +} + static const struct dpll_pin_ops dpllsim_input_pin_ops = { .frequency_get = dpllsim_pin_frequency_get, .direction_get = dpllsim_pin_direction_get, .state_on_dpll_get = dpllsim_pin_state_get, + .state_on_dpll_set = dpllsim_pin_state_set, }; static const struct dpll_pin_ops dpllsim_output_pin_ops = { @@ -154,6 +190,12 @@ static void dpllsim_pin_props(struct dpllsim_pin *pin, prop->freq_supported_num = ARRAY_SIZE(dpllsim_freq_ext); break; } + + /* Capabilities follow the ops the pin is served by */ + if (dpllsim_pin_select_ops(pin) == &dpllsim_input_pin_ops) + prop->capabilities = DPLL_PIN_CAPABILITIES_STATE_CAN_CHANGE; + else + prop->capabilities = 0; } static bool dpllsim_pin_frequency_valid(struct dpllsim_pin *pin) -- 2.56.1