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 2D31E2459D7 for ; Mon, 15 Dec 2025 07:23:13 +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=1765783394; cv=none; b=aP4hyQjE/QvAhrW4haEuip/d3YPqQHPpjh5rz+HVV99WlU3YlColq+YZ8K/zIFpvGZlwLFdusqSghE4VRH77G1yu/dH8gw4H3Pwr7NVP07JsOuq6TTaBtfGqQoaM6Q3IaWHJmqdDKcWqRMTbjUcs2/j3EDX3sHoCXr3lv5uSEls= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765783394; c=relaxed/simple; bh=Ndkdct+kc4a23U8HI5m2DXW0sRa3QtnMfg6MmJAUS6M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fI700sI0CZ6B7+sh7fbNIArqTFwQmW7Sql6F4LgeH8V91vKzVN3R2Kjr+nULpmrzQPDZI493htIfVd8EzjB0t1RMqvCUXtlFdeB8PsVLBFXQn0+oKZ4t3rWar6oOPMUDhXGxI8c+XvV6gRUOBxg+9RD87GDzZ15eLmFkF0XPfPo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g9KVs2QE; 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="g9KVs2QE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB834C4CEF5; Mon, 15 Dec 2025 07:23:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765783393; bh=Ndkdct+kc4a23U8HI5m2DXW0sRa3QtnMfg6MmJAUS6M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=g9KVs2QEb9v9WsbvT6G6SiGNvw4t/6sgDycujOQd7ep5MrVJ8hfFmxniNpz3j2oQq 01aLmq87PypZAmIjsv6tGyAr3FYxGLHkBIWS2poLeEbSPPdlocFrJ1NrvtY5GxefGZ EHGOR2vF3DqPkXJ0yOYumtMClLl4EgRAax7hVqO8fcLoUad1V5QSl9W9zqgEPjZqcc x58h3rsI5z8Du8U62GftItu5YKzGkPH5oazPBnenMVtmsex5CsekX+QU7dr/k0rZIk NKINJTOx0MvJXFY0Z1jmZJpsoV9X2vx4oH0bR1I5XOgLvv+sysQohkQojzmCm1jVT7 T7Z7arg+CN+ew== Date: Mon, 15 Dec 2025 16:23:08 +0900 From: Sumit Garg To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: Jens Wiklander , op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 02/17] tee: Add probe, remove and shutdown bus callbacks to tee_client_driver Message-ID: References: <7f73b2ee784c0b78fa3bfee3aaa3b95f47041178.1765472125.git.u.kleine-koenig@baylibre.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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7f73b2ee784c0b78fa3bfee3aaa3b95f47041178.1765472125.git.u.kleine-koenig@baylibre.com> On Thu, Dec 11, 2025 at 06:14:56PM +0100, Uwe Kleine-König wrote: > Introduce a bus specific probe, remove and shutdown function. For now > this only allows to get rid of a cast of the generic device to a > tee_client device in the drivers and changes the remove prototype to > return void---a non-zero return value is ignored anyhow. > > The objective is to get rid of users of struct device_driver callbacks > .probe(), .remove() and .shutdown() to eventually remove these. Until > all tee_client drivers are converted this results in a runtime warning > about the drivers needing an update because there is a bus probe > function and a driver probe function. > > Signed-off-by: Uwe Kleine-König > --- > drivers/tee/tee_core.c | 68 +++++++++++++++++++++++++++++++++++++++++ > include/linux/tee_drv.h | 3 ++ > 2 files changed, 71 insertions(+) > > diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c > index 51379f7fc5d5..89164d35fc5c 100644 > --- a/drivers/tee/tee_core.c > +++ b/drivers/tee/tee_core.c > @@ -1398,19 +1398,87 @@ static int tee_client_device_uevent(const struct device *dev, > return add_uevent_var(env, "MODALIAS=tee:%pUb", dev_id); > } > > +static int tee_client_device_probe(struct device *dev) > +{ > + struct tee_client_device *tcdev= to_tee_client_device(dev); missing space: s/tcdev=/tcdev =/ > + struct tee_client_driver *drv = to_tee_client_driver(dev->driver); > + > + if (drv->probe) > + return drv->probe(tcdev); > + else > + return 0; > +} > + > +static void tee_client_device_remove(struct device *dev) > +{ > + struct tee_client_device *tcdev= to_tee_client_device(dev); ditto. > + struct tee_client_driver *drv = to_tee_client_driver(dev->driver); > + > + if (drv->remove) > + drv->remove(tcdev); > +} > + > +static void tee_client_device_shutdown(struct device *dev) > +{ > + struct tee_client_device *tcdev= to_tee_client_device(dev); ditto. > + struct tee_client_driver *drv = to_tee_client_driver(dev->driver); > + > + if (dev->driver && drv->remove) > + drv->remove(tcdev); don't we need to check and invoke drv->shutdown here? > +} > + > const struct bus_type tee_bus_type = { > .name = "tee", > .match = tee_client_device_match, > .uevent = tee_client_device_uevent, > + .probe = tee_client_device_probe, > + .remove = tee_client_device_remove, > + .shutdown = tee_client_device_shutdown, > }; > EXPORT_SYMBOL_GPL(tee_bus_type); > > +static int tee_client_device_probe_legacy(struct tee_client_device *tcdev) > +{ > + struct device *dev = &tcdev->dev; > + struct device_driver *driver = dev->driver; > + > + return driver->probe(dev); > +} > + > +static void tee_client_device_remove_legacy(struct tee_client_device *tcdev) > +{ > + struct device *dev = &tcdev->dev; > + struct device_driver *driver = dev->driver; > + > + driver->remove(dev); > +} > + > +static void tee_client_device_shutdown_legacy(struct tee_client_device *tcdev) > +{ > + struct device *dev = &tcdev->dev; > + struct device_driver *driver = dev->driver; > + > + driver->shutdown(dev); > +} > + > int __tee_client_driver_register(struct tee_client_driver *tee_driver, > struct module *owner) > { > tee_driver->driver.owner = owner; > tee_driver->driver.bus = &tee_bus_type; > > + /* > + * Drivers that have callbacks set for tee_driver->driver need updating > + * to use the callbacks in tee_driver instead. driver_register() warns > + * about that, so no need to warn here, too. > + */ > + if (!tee_driver->probe && tee_driver->driver.probe) > + tee_driver->probe = tee_client_device_probe_legacy; > + if (!tee_driver->remove && tee_driver->driver.remove) > + tee_driver->remove= tee_client_device_remove_legacy; missing space: s/tee_driver->remove=/tee_driver->remove =/ > + if (!tee_driver->shutdown && tee_driver->driver.probe) you should rather check here for tee_driver->driver.shutdown? -Sumit > + tee_driver->shutdown = tee_client_device_shutdown_legacy; > + > return driver_register(&tee_driver->driver); > } > EXPORT_SYMBOL_GPL(__tee_client_driver_register); > diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h > index 850c03b2cdea..e561a26f537a 100644 > --- a/include/linux/tee_drv.h > +++ b/include/linux/tee_drv.h > @@ -315,6 +315,9 @@ struct tee_client_device { > * @driver: driver structure > */ > struct tee_client_driver { > + int (*probe)(struct tee_client_device *); > + void (*remove)(struct tee_client_device *); > + void (*shutdown)(struct tee_client_device *); > const struct tee_client_device_id *id_table; > struct device_driver driver; > }; > -- > 2.47.3 >