From: "Clément Le Goffic" <clement.legoffic@foss.st.com>
To: "Clément Léger" <clement.leger@bootlin.com>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
"Jens Wiklander" <jens.wiklander@linaro.org>
Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org,
"Clément Le Goffic" <clement.legoffic@foss.st.com>,
linux-stm32@st-md-mailman.stormreply.com
Subject: [PATCH 2/3] rtc: optee: remove unnecessary memory operations
Date: Tue, 15 Jul 2025 16:07:14 +0200 [thread overview]
Message-ID: <20250715-upstream-optee-rtc-v1-2-e0fdf8aae545@foss.st.com> (raw)
In-Reply-To: <20250715-upstream-optee-rtc-v1-0-e0fdf8aae545@foss.st.com>
Remove memcpy by using directly the shared memory.
Remove memset be initialize variable to 0 on stack.
Signed-off-by: Clément Le Goffic <clement.legoffic@foss.st.com>
---
drivers/rtc/rtc-optee.c | 29 ++++++++++++-----------------
1 file changed, 12 insertions(+), 17 deletions(-)
diff --git a/drivers/rtc/rtc-optee.c b/drivers/rtc/rtc-optee.c
index 6b77c122fdc1..b65953eb7ca1 100644
--- a/drivers/rtc/rtc-optee.c
+++ b/drivers/rtc/rtc-optee.c
@@ -97,18 +97,9 @@ static int optee_rtc_settime(struct device *dev, struct rtc_time *tm)
struct optee_rtc *priv = dev_get_drvdata(dev);
struct tee_ioctl_invoke_arg inv_arg = {0};
struct tee_param param[4] = {0};
- struct optee_rtc_time optee_tm;
- void *rtc_data;
+ struct optee_rtc_time *optee_tm;
int ret;
- optee_tm.tm_sec = tm->tm_sec;
- optee_tm.tm_min = tm->tm_min;
- optee_tm.tm_hour = tm->tm_hour;
- optee_tm.tm_mday = tm->tm_mday;
- optee_tm.tm_mon = tm->tm_mon;
- optee_tm.tm_year = tm->tm_year + 1900;
- optee_tm.tm_wday = tm->tm_wday;
-
inv_arg.func = TA_CMD_RTC_SET_TIME;
inv_arg.session = priv->session_id;
inv_arg.num_params = 4;
@@ -117,11 +108,17 @@ static int optee_rtc_settime(struct device *dev, struct rtc_time *tm)
param[0].u.memref.shm = priv->shm;
param[0].u.memref.size = sizeof(struct optee_rtc_time);
- rtc_data = tee_shm_get_va(priv->shm, 0);
- if (IS_ERR(rtc_data))
- return PTR_ERR(rtc_data);
+ optee_tm = tee_shm_get_va(priv->shm, 0);
+ if (IS_ERR(optee_tm))
+ return PTR_ERR(optee_tm);
- memcpy(rtc_data, &optee_tm, sizeof(struct optee_rtc_time));
+ optee_tm->tm_min = tm->tm_min;
+ optee_tm->tm_sec = tm->tm_sec;
+ optee_tm->tm_hour = tm->tm_hour;
+ optee_tm->tm_mday = tm->tm_mday;
+ optee_tm->tm_mon = tm->tm_mon;
+ optee_tm->tm_year = tm->tm_year + 1900;
+ optee_tm->tm_wday = tm->tm_wday;
ret = tee_client_invoke_func(priv->ctx, &inv_arg, param);
if (ret < 0 || inv_arg.ret != 0)
@@ -241,14 +238,12 @@ static int optee_ctx_match(struct tee_ioctl_version_data *ver, const void *data)
static int optee_rtc_probe(struct device *dev)
{
struct tee_client_device *rtc_device = to_tee_client_device(dev);
- struct tee_ioctl_open_session_arg sess_arg;
+ struct tee_ioctl_open_session_arg sess_arg = {0};
struct optee_rtc *priv;
struct rtc_device *rtc;
struct tee_shm *shm;
int ret, err;
- memset(&sess_arg, 0, sizeof(sess_arg));
-
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
--
2.43.0
next prev parent reply other threads:[~2025-07-15 14:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-15 14:07 [PATCH 0/3] Add alarm operation to the rtc-optee driver Clément Le Goffic
2025-07-15 14:07 ` [PATCH 1/3] rtc: rtc-optee: fix memory leak on driver removal Clément Le Goffic
2025-07-15 14:07 ` Clément Le Goffic [this message]
2025-07-15 14:07 ` [PATCH 3/3] rtc: optee: add alarm related rtc ops to optee rtc driver Clément Le Goffic
2025-09-11 12:56 ` [PATCH 0/3] Add alarm operation to the rtc-optee driver Clément Le Goffic
2025-09-11 13:02 ` Clément Le Goffic
2025-09-14 23:18 ` Alexandre Belloni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250715-upstream-optee-rtc-v1-2-e0fdf8aae545@foss.st.com \
--to=clement.legoffic@foss.st.com \
--cc=alexandre.belloni@bootlin.com \
--cc=clement.leger@bootlin.com \
--cc=jens.wiklander@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).