Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rtc: optee: remove unnecessary memory operations

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>
Link: https://lore.kernel.org/r/20250715-upstream-optee-rtc-v1-2-e0fdf8aae545@foss.st.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

authored by

Clément Le Goffic and committed by
Alexandre Belloni
44fee00f a531350d

+12 -17
+12 -17
drivers/rtc/rtc-optee.c
··· 97 97 struct optee_rtc *priv = dev_get_drvdata(dev); 98 98 struct tee_ioctl_invoke_arg inv_arg = {0}; 99 99 struct tee_param param[4] = {0}; 100 - struct optee_rtc_time optee_tm; 101 - void *rtc_data; 100 + struct optee_rtc_time *optee_tm; 102 101 int ret; 103 - 104 - optee_tm.tm_sec = tm->tm_sec; 105 - optee_tm.tm_min = tm->tm_min; 106 - optee_tm.tm_hour = tm->tm_hour; 107 - optee_tm.tm_mday = tm->tm_mday; 108 - optee_tm.tm_mon = tm->tm_mon; 109 - optee_tm.tm_year = tm->tm_year + 1900; 110 - optee_tm.tm_wday = tm->tm_wday; 111 102 112 103 inv_arg.func = TA_CMD_RTC_SET_TIME; 113 104 inv_arg.session = priv->session_id; ··· 108 117 param[0].u.memref.shm = priv->shm; 109 118 param[0].u.memref.size = sizeof(struct optee_rtc_time); 110 119 111 - rtc_data = tee_shm_get_va(priv->shm, 0); 112 - if (IS_ERR(rtc_data)) 113 - return PTR_ERR(rtc_data); 120 + optee_tm = tee_shm_get_va(priv->shm, 0); 121 + if (IS_ERR(optee_tm)) 122 + return PTR_ERR(optee_tm); 114 123 115 - memcpy(rtc_data, &optee_tm, sizeof(struct optee_rtc_time)); 124 + optee_tm->tm_min = tm->tm_min; 125 + optee_tm->tm_sec = tm->tm_sec; 126 + optee_tm->tm_hour = tm->tm_hour; 127 + optee_tm->tm_mday = tm->tm_mday; 128 + optee_tm->tm_mon = tm->tm_mon; 129 + optee_tm->tm_year = tm->tm_year + 1900; 130 + optee_tm->tm_wday = tm->tm_wday; 116 131 117 132 ret = tee_client_invoke_func(priv->ctx, &inv_arg, param); 118 133 if (ret < 0 || inv_arg.ret != 0) ··· 238 241 static int optee_rtc_probe(struct device *dev) 239 242 { 240 243 struct tee_client_device *rtc_device = to_tee_client_device(dev); 241 - struct tee_ioctl_open_session_arg sess_arg; 244 + struct tee_ioctl_open_session_arg sess_arg = {0}; 242 245 struct optee_rtc *priv; 243 246 struct rtc_device *rtc; 244 247 struct tee_shm *shm; 245 248 int ret, err; 246 - 247 - memset(&sess_arg, 0, sizeof(sess_arg)); 248 249 249 250 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 250 251 if (!priv)