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 0693D3A1CD; Thu, 5 Mar 2026 14:15:50 +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=1772720151; cv=none; b=M5w5q8tSmwoyn0LoTcfzdvafs+Uj5A9h/5jT01+lU9pVb3IYYYuGe1nR1qlkWft42Bx6ohIhyag8jdbsHziAF4WxWkBlMHwNBvZMu+p9qhtFKafJLqzLFVh/G95MIBXDF8rdSXvc18+RzEbjXeCykPO48uyGQb8KMmHEMBARcPw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772720151; c=relaxed/simple; bh=kLWb8VZ+IMnJVdrAXVM1cp3XVDC6P/pyuL00CU9cNh4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CA8iPFQiAc7wcWrJGSiDvwbrVYliCXxCrVKX80GzQ0LL+32Me4lgWwcdFZccRuKhi/wgrx71t6jKPEy34+UFMm+vN1YEHcFs/uT7chqzyX1nbJXsM6nYnamAvB2dtaC97JJjxen7ohrLDJcq8r81s96YyTDgZkQm1WT//ODkjuQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=If21Ar/J; 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="If21Ar/J" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8762FC116C6; Thu, 5 Mar 2026 14:15:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772720150; bh=kLWb8VZ+IMnJVdrAXVM1cp3XVDC6P/pyuL00CU9cNh4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=If21Ar/Jhy7PHBtlIIgl5FkbElMU2v+aeeoIy35PuaIvpFzxNu7HK+tQgYOujMzRQ ndQC8HslP+oJ17/lkt3V8HPj2/gS6kSCYb7NiJH1a+2G8Uvgn3ept55O+tAH/FWdeE CltJ1dehHI+MJSzuvGJVKAHRX+daWIy/6bGSJd6+2slpMGPj9jgct55n6E4dBWVr3v wrmvrqDOgQfmcyemQ0g+Xu90oyb42Cgi44w2nxcaZKBOTgu9efxf0k2CzIBgTkAXHl W2MEOK6Y3Lqj7wFGmwcGRGDv4VLlVE4LAIkjBTLGXveqTF1vSGGcfP140N1Tdd6bva DW33Ww3rgQoOQ== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1vy9UR-000000001Sf-3y17; Thu, 05 Mar 2026 15:15:47 +0100 Date: Thu, 5 Mar 2026 15:15:47 +0100 From: Johan Hovold To: Stanislaw Gruszka Cc: linux-wireless@vger.kernel.org, Brian Norris , Francesco Dolcini , Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Jakub Kicinski , Hin-Tak Leung , Jes Sorensen , Ping-Ke Shih , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Matthias Brugger , AngeloGioacchino Del Regno , libertas-dev@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 10/13] wifi: rt2x00: drop redundant device reference Message-ID: References: <20260305110713.17725-1-johan@kernel.org> <20260305110713.17725-11-johan@kernel.org> <20260305133755.GA75655@wp.pl> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260305133755.GA75655@wp.pl> On Thu, Mar 05, 2026 at 02:37:55PM +0100, Stanislaw Gruszka wrote: > On Thu, Mar 05, 2026 at 12:07:10PM +0100, Johan Hovold wrote: > > Driver core holds a reference to the USB interface and its parent USB > > device while the interface is bound to a driver and there is no need to > > take additional references unless the structures are needed after > > disconnect. > > > > Drop the redundant device reference to reduce cargo culting, make it > > Getting the reference in probe() and drop it in disconnect() was not a cargo cult. > That was requirement from usb_get_dev() comment, that later it was changed > by below commit: > > commit f6a9a2d64dd168b7d71076c0e6b2be7db7cb7399 > Author: Alan Stern > Date: Fri Feb 25 09:38:25 2022 -0500 > > USB: core: Update kerneldoc for usb_get_dev() and usb_get_intf() > > The kerneldoc for usb_get_dev() and usb_get_intf() says that drivers > should always refcount the references they hold for the usb_device or > usb_interface structure, respectively. But this is an overstatement: > In many cases drivers do not access these references after they have > been unbound, and in such cases refcounting is unnecessary. > > This patch updates the kerneldoc for the two routines, explaining when > a driver does not need to increment and decrement the refcount. This > should help dispel misconceptions which might otherwise afflict > programmers new to the USB subsystem. Yeah, the documentation indeed was misleading for a very long time. That reference comment even predates the driver model. Many authors base their work on existing drivers so we still get new ones that take such references even after the docs were amended. Johan