From mboxrd@z Thu Jan 1 00:00:00 1970 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 D68B2C12F; Sun, 10 Dec 2023 14:22:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QUh+fVk1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CA2BC433C7; Sun, 10 Dec 2023 14:22:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702218163; bh=jN6uzRWmmGFEhpJKZKXMmzG8V3dn+Y/d+3+tfSvJJ/Q=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=QUh+fVk1P2ElqVFYtDZiqwJL4NTbgvdlY1t69x6/T1s6zKSbT1t65F4M9xQhx0YVB Ry57wn5pA0QlVjaTes6RiMMMlUVxyNcE/ZJcWDWu525Q99mvhuvLqg+hCS38ZFFo1V 2WyWVUL7wP4rN5BpQCjCT3LdFBvRdR9+Ob6YeAv2UUc1VgMItaE21e/7Rib5sAkD+3 CfcI7XmvuHm9QmHqjDVTQpXx6QUQ8IQjrR4cFbiViyfhEsyTkbx7Gs7o3XNz3c3U7N T2/e0lQ0iD/0SJiziyQeVin09aH5bk0Np0ll9/aRA1ArElsvr2u0HWbqCEyw5Xavay nd1OWgDrZ3utQ== Date: Sun, 10 Dec 2023 14:22:36 +0000 From: Jonathan Cameron To: Nuno Sa via B4 Relay Cc: , devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Frank Rowand , Lars-Peter Clausen , Michael Hennerich , Krzysztof Kozlowski , Conor Dooley Subject: Re: [PATCH v2 3/8] driver: core: allow modifying device_links flags Message-ID: <20231210142236.4bbc6db4@jic23-huawei> In-Reply-To: <20231208-dev-iio-backend-v2-3-5450951895e1@analog.com> References: <20231208-dev-iio-backend-v2-0-5450951895e1@analog.com> <20231208-dev-iio-backend-v2-3-5450951895e1@analog.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.38; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 08 Dec 2023 16:14:10 +0100 Nuno Sa via B4 Relay wrote: > 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; > + Trivial but this blank line seems unwanted variation in formatting. > + } 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); > } >