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.

remoteproc: imx_rproc: Introduce start/stop/detect_mode ops for imx_rproc_dcfg

Simplify the logic in imx_rproc_start(), imx_rproc_stop() and
imx_rproc_detect_mode(), introduce start, stop and detect_mode ops for the
imx_rproc_dcfg structure. Allow each platform to provide its own
implementation of start/stop/detect_mode operations, and prepare to
eliminate the need for multiple switch-case statements.

Improve code readability and maintainability by encapsulating
platform-specific behavior.

No functional changes.

Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Link: https://lore.kernel.org/r/20250910-imx-rproc-cleanup-v2-1-10386685b8a9@nxp.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>

authored by

Peng Fan and committed by
Mathieu Poirier
ff24e5b2 24339619

+22
+15
drivers/remoteproc/imx_rproc.c
··· 376 376 if (ret) 377 377 return ret; 378 378 379 + if (dcfg->ops && dcfg->ops->start) { 380 + ret = dcfg->ops->start(rproc); 381 + goto start_ret; 382 + } 383 + 379 384 switch (dcfg->method) { 380 385 case IMX_RPROC_MMIO: 381 386 if (priv->gpr) { ··· 403 398 return -EOPNOTSUPP; 404 399 } 405 400 401 + start_ret: 406 402 if (ret) 407 403 dev_err(dev, "Failed to enable remote core!\n"); 408 404 ··· 417 411 struct device *dev = priv->dev; 418 412 struct arm_smccc_res res; 419 413 int ret; 414 + 415 + if (dcfg->ops && dcfg->ops->stop) { 416 + ret = dcfg->ops->stop(rproc); 417 + goto stop_ret; 418 + } 420 419 421 420 switch (dcfg->method) { 422 421 case IMX_RPROC_MMIO: ··· 451 440 return -EOPNOTSUPP; 452 441 } 453 442 443 + stop_ret: 454 444 if (ret) 455 445 dev_err(dev, "Failed to stop remote core\n"); 456 446 else ··· 944 932 int ret; 945 933 u32 val; 946 934 u8 pt; 935 + 936 + if (dcfg->ops && dcfg->ops->detect_mode) 937 + return dcfg->ops->detect_mode(priv->rproc); 947 938 948 939 switch (dcfg->method) { 949 940 case IMX_RPROC_NONE:
+7
drivers/remoteproc/imx_rproc.h
··· 31 31 /* dcfg flags */ 32 32 #define IMX_RPROC_NEED_SYSTEM_OFF BIT(0) 33 33 34 + struct imx_rproc_plat_ops { 35 + int (*start)(struct rproc *rproc); 36 + int (*stop)(struct rproc *rproc); 37 + int (*detect_mode)(struct rproc *rproc); 38 + }; 39 + 34 40 struct imx_rproc_dcfg { 35 41 u32 src_reg; 36 42 u32 src_mask; ··· 48 42 size_t att_size; 49 43 enum imx_rproc_method method; 50 44 u32 flags; 45 + const struct imx_rproc_plat_ops *ops; 51 46 }; 52 47 53 48 #endif /* _IMX_RPROC_H */