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 AD504FBFA; Sun, 21 Jan 2024 17:21:01 +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=1705857661; cv=none; b=fIuz9TzM4xQY8yxCZ1PNqQvP94Ind3rgqTOZ/w3qdy99fhZGOA1dMXdfPuUD6QBr//YDD3w3pLckHDPYIybjlkjAC1LgfK9jxm2LqSYlaiNJCK4zp8wotgxPJwjdtsNudunw+9/9YZifwfCEpjVI/wSS01Bd0VYl6NCLi8vkUcM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705857661; c=relaxed/simple; bh=UE2zBBIEQEnrIlIyEVcaouPk0IJlvT21BR3gdxJo4es=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WB+fjqRlgukq7OGlvg5icaoU2V8gIUW3AoLo3jCU8noQ+BQfQWWKYBB99lUvTuzfXkd6ZGCzpIOjliHkl5xaORl3KARToUO1lwUP8SaZRYWUU4O+cupBUaQWe9SxMrVm+enTTnJlSxUc1vhAQy6htny3Yr8SmrNmgYCa/K5c0Sc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=J5sN1fWe; 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="J5sN1fWe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99A3DC433C7; Sun, 21 Jan 2024 17:20:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705857661; bh=UE2zBBIEQEnrIlIyEVcaouPk0IJlvT21BR3gdxJo4es=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=J5sN1fWePx5Wuv6bIAmB0OjbAGxSEc8jzkeT/gBDxROEw9gEt+KPgNjH2Va0IkeuM hqt5NanKRDtTKCDH2BHiNFEqhNggdxQVzxPkApOQKtkrhAzTyD6cDBCpFYlwyvwOHO Z1zJSYs71v4KThn8+6enz0bMKgy1hpXywL/zhRnWiBqHJu2+FjcY6KTyOS+4OSFyYW 0/12QR9dBdMu4wcb/Espoo33RVuPoW9hzTqjyH91+98KiJaRxzKZ73/OfIwomxa4T0 rGpY6ovc+uTRsPaT63raq2x3sKYC1AWG2y9+7bdASeTcrVJZh9BsWx1MFCO130CWRR zFw2hd/VeLY2w== Date: Sun, 21 Jan 2024 17:20:46 +0000 From: Jonathan Cameron To: Nuno Sa via B4 Relay Cc: , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, Lars-Peter Clausen , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , "Rafael J. Wysocki" , Frank Rowand , Olivier Moysan Subject: Re: [PATCH v6 3/8] driver: core: allow modifying device_links flags Message-ID: <20240121172046.450296bc@jic23-huawei> In-Reply-To: <20240119-iio-backend-v6-3-189536c35a05@analog.com> References: <20240119-iio-backend-v6-0-189536c35a05@analog.com> <20240119-iio-backend-v6-3-189536c35a05@analog.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.40; 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, 19 Jan 2024 17:00:49 +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 Looking for an Ack or RB from someone more familiar with device links than I am. Greg / Rafael? thanks Jonathan > --- > 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); > } >