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 5CB2E367F28 for ; Tue, 17 Mar 2026 10:44:46 +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=1773744286; cv=none; b=ULBye1GeY989dHQyVPC2Z9FOKB8vryyOrSIX0QGCxN1H5PfZCxCKl2NGyr+yClXqn/klZV+XCoLd6gxN8TApUPdtqYbrVxx/KSB+VqPtI0jiXF86e6GqqltAYQ1+RMSP4yC3tpQf19qTWSiqZrIBMtCJMyNriVkmI9suhMtG+0I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773744286; c=relaxed/simple; bh=Wv07C9RP0y832jDxehSUDwHBeQBi6/ziXlEXTqOqHJ4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=se5u6AMgVKDTY3mJukXarqnKrMVt4ogGRRJrG6dj3gs54rZw32MRjA8iKB2SUMX82PWZn6vaylu2czbcclxLv/Ug8/0v4DRlS6nJ2F/wvc6jSRbugf/Mw68G8VGqX3BD7TcsmKbsharHl2P9dvuKGpR3sU9cO9eKxh+gatvSFbA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jbPtrCW1; 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="jbPtrCW1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04EC0C4CEF7; Tue, 17 Mar 2026 10:44:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773744286; bh=Wv07C9RP0y832jDxehSUDwHBeQBi6/ziXlEXTqOqHJ4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jbPtrCW1YT60GumG3wl7jDlLf46Vjg6/FKVpE3vTBNLb1H6P+D/qOzh53YJgTrgGX nOWYXWmcyiGJBpYW/QhfpCRRhX6O1SBz+rao9tlRQ8Zp8lqP8AsBxFbezw2swhXsUy YtxwAJPjIjdSfmvVEFAXhur8PMxvEgFjIbr8i4Il/TfllQhfJG+3/56Th36/LRg9OC u7RO3AcPShyKp9DFfUS+zCzQXA0GXpInRdJCWh9Te/MmreGhe3a8R5GLyws9DhXIVM hyR7RAjNz9weyZYWC4kFF0jdg5lHebQA7crqCIJEwXLS2h1phPRSRua3DhTldhXiYV Qr4QO5RNqj/eg== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1w2Rul-00000000732-2pKy; Tue, 17 Mar 2026 11:44:43 +0100 Date: Tue, 17 Mar 2026 11:44:43 +0100 From: Johan Hovold To: Bartosz Golaszewski Cc: Srinivas Kandagatla , Bartosz Golaszewski , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 6/7] nvmem: split struct nvmem_device into refcounted and provider-owned data Message-ID: References: <20260223-nvmem-unbind-v2-0-0df33a933dca@oss.qualcomm.com> <20260223-nvmem-unbind-v2-6-0df33a933dca@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@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: <20260223-nvmem-unbind-v2-6-0df33a933dca@oss.qualcomm.com> On Mon, Feb 23, 2026 at 11:57:07AM +0100, Bartosz Golaszewski wrote: > Data owned by the nvmem provider must not be part of the > reference-counted struct nvmem_device. It can be as long as it's not referenced after deregistration so this claim is too strong. It can be handled the way you are doing it here, but you could also just use a boolean flag to indicate that no further callbacks should be made. > Ahead of protecting that data > with SRCU, move it into a separate structure the address of which is > stored in nvmem_device. > +/* > + * Holds data owned by the provider of the nvmem implementation. This goes > + * away immediately the moment nvmem_unregister() is called. > + */ > +struct nvmem_impl { > + nvmem_reg_read_t reg_read; > + nvmem_reg_write_t reg_write; > + void *priv; And priv is just a pointer that is never used by nvmem core directly. > +}; How about just wrapping the callbacks and calling the struct nvmem_ops to make it more clear how this is used? That is, that nvmem core guarantees that there will be no further callbacks after deregistration. > struct nvmem_device { > struct module *owner; > struct device dev; > + struct nvmem_impl *impl; > int stride; > int word_size; > int id; > @@ -26,11 +37,8 @@ struct nvmem_device { > struct nvmem_cell_info *cell); > const struct nvmem_keepout *keepout; > unsigned int nkeepout; > - nvmem_reg_read_t reg_read; > - nvmem_reg_write_t reg_write; > struct gpio_desc *wp_gpio; > struct nvmem_layout *layout; > - void *priv; > bool sysfs_cells_populated; > }; Johan