From patchwork Fri Jan 19 16:00:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuno Sa via B4 Relay X-Patchwork-Id: 13523967 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D27ADDF56; Fri, 19 Jan 2024 16:01:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705680069; cv=none; b=mTf6qZXmmRH/wUw5gOuluxHWMT74CWYfsFg3YUV0opg7gdhM947gyip9KA6xp5xc5h7TRnVoLakDbhIF1zqB7N+oOQO4i2OjoQEB8vqp7GKeWImr9N5O8COzhoY1YDzCa/n9xS9XX3gzIUdh9gicRxZi1wSWKMAbqHck44vwVmk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705680069; c=relaxed/simple; bh=OPRTb/XW+2zsH8AnZHeRHdEClBBBI7WQURvAeLFHUZo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qVlCtIKV5JJtgQ9ePmeJEPXosoSWCPrRlLsWwoVjdh7REVUgFz9ArW1YVGVe4nRQ27DPPDnmSrmYDo2LGEMUcJmT7jHRYWX/64faP6zast33yHVYCkFbrJ7Gxw9fFP2AsqlGB4VhxHIFSooJ8D84i/a3xaPH/8qfMk/uTvm1emg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Tz+I+sC4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Tz+I+sC4" Received: by smtp.kernel.org (Postfix) with ESMTPS id 7E3EDC43394; Fri, 19 Jan 2024 16:01:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705680069; bh=OPRTb/XW+2zsH8AnZHeRHdEClBBBI7WQURvAeLFHUZo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Tz+I+sC4oVQoJ/DgES3M5nEomwaZV4FVgKb40miwX2tV/dFGEPU9o3q+WH59lBJKU StEfITkPVCkciMJPRP+csHVG0CV+NtfKfS3RDNJOn6CB5g79/NQ1Kb21sIQMQ1lCtU jTK+kWshjZPufSGpGx16x97lAcoYyVkzQW5M0aLY4t257QX/WylG2AzvsZ2AQO593Y wK3+WG4eW3Uv8gkyy2NewJtgNuGMNLEO15Vb4+zQx1D8Cv7Q9/uj22sNnYKgkzKb/5 3KmpxPT40Ct7IbB58266bvp3h06iGQ9/+m69CpwtolBiNXBMEYGiOO9Pd1eAFgzBDc XShYYTwg29asw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61D13C47DD9; Fri, 19 Jan 2024 16:01:09 +0000 (UTC) From: Nuno Sa via B4 Relay Date: Fri, 19 Jan 2024 17:00:49 +0100 Subject: [PATCH v6 3/8] driver: core: allow modifying device_links flags Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240119-iio-backend-v6-3-189536c35a05@analog.com> References: <20240119-iio-backend-v6-0-189536c35a05@analog.com> In-Reply-To: <20240119-iio-backend-v6-0-189536c35a05@analog.com> To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , "Rafael J. Wysocki" , Frank Rowand , Olivier Moysan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705680065; l=1762; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=NLZHAx7QEa2fUUjKTtfo6RESv2OQO0JG++qc/yxWC4M=; b=eWpg0wm0ctUMFxKEi0QuhfrNYB6IveABxd5wnqdbFm0hIfu0qogKCmN2wXjJI1AxorYdqK+T0 XW6fzXmmOwpDf/wv4Lz6ZS3lvi4rdankHDPNYnweZzkDhqZJFDMRSTY X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-Endpoint-Received: by B4 Relay for nuno.sa@analog.com/20231116 with auth_id=100 X-Original-From: Nuno Sa Reply-To: From: Nuno Sa If a device_link is previously created (eg: via fw_devlink_create_devlink()) before the supplier + consumer are both present and bound to their respective drivers, there's no way to set DL_FLAG_AUTOREMOVE_CONSUMER anymore while one can still set DL_FLAG_AUTOREMOVE_SUPPLIER. Hence, rework the flags checks to allow for DL_FLAG_AUTOREMOVE_CONSUMER in the same way DL_FLAG_AUTOREMOVE_SUPPLIER is done. While at it, make sure that we are never left with DL_FLAG_AUTOPROBE_CONSUMER set together with one of DL_FLAG_AUTOREMOVE_CONSUMER or DL_FLAG_AUTOREMOVE_SUPPLIER. Signed-off-by: Nuno Sa --- drivers/base/core.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 67ba592afc77..fdbb5abc75d5 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -807,11 +807,15 @@ struct device_link *device_link_add(struct device *consumer, * update the existing link to stay around longer. */ if (flags & DL_FLAG_AUTOREMOVE_SUPPLIER) { - if (link->flags & DL_FLAG_AUTOREMOVE_CONSUMER) { - link->flags &= ~DL_FLAG_AUTOREMOVE_CONSUMER; - link->flags |= DL_FLAG_AUTOREMOVE_SUPPLIER; - } - } else if (!(flags & DL_FLAG_AUTOREMOVE_CONSUMER)) { + link->flags &= ~DL_FLAG_AUTOREMOVE_CONSUMER; + link->flags &= ~DL_FLAG_AUTOPROBE_CONSUMER; + link->flags |= DL_FLAG_AUTOREMOVE_SUPPLIER; + + } else if (flags & DL_FLAG_AUTOREMOVE_CONSUMER) { + link->flags &= ~DL_FLAG_AUTOREMOVE_SUPPLIER; + link->flags &= ~DL_FLAG_AUTOPROBE_CONSUMER; + link->flags |= DL_FLAG_AUTOREMOVE_CONSUMER; + } else { link->flags &= ~(DL_FLAG_AUTOREMOVE_CONSUMER | DL_FLAG_AUTOREMOVE_SUPPLIER); }