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

soc: mediatek: Refactor bus protection control

Put bus protection enable and disable control in separate functions.

Signed-off-by: Weiyi Lu <weiyi.lu@mediatek.com>
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>

authored by

Weiyi Lu and committed by
Matthias Brugger
662c9d55 0545aa1b

+30 -14
+30 -14
drivers/soc/mediatek/mtk-scpsys.c
··· 276 276 MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); 277 277 } 278 278 279 + static int scpsys_bus_protect_enable(struct scp_domain *scpd) 280 + { 281 + struct scp *scp = scpd->scp; 282 + 283 + if (!scpd->data->bus_prot_mask) 284 + return 0; 285 + 286 + return mtk_infracfg_set_bus_protection(scp->infracfg, 287 + scpd->data->bus_prot_mask, 288 + scp->bus_prot_reg_update); 289 + } 290 + 291 + static int scpsys_bus_protect_disable(struct scp_domain *scpd) 292 + { 293 + struct scp *scp = scpd->scp; 294 + 295 + if (!scpd->data->bus_prot_mask) 296 + return 0; 297 + 298 + return mtk_infracfg_clear_bus_protection(scp->infracfg, 299 + scpd->data->bus_prot_mask, 300 + scp->bus_prot_reg_update); 301 + } 302 + 279 303 static int scpsys_power_on(struct generic_pm_domain *genpd) 280 304 { 281 305 struct scp_domain *scpd = container_of(genpd, struct scp_domain, genpd); ··· 342 318 if (ret < 0) 343 319 goto err_pwr_ack; 344 320 345 - if (scpd->data->bus_prot_mask) { 346 - ret = mtk_infracfg_clear_bus_protection(scp->infracfg, 347 - scpd->data->bus_prot_mask, 348 - scp->bus_prot_reg_update); 349 - if (ret) 350 - goto err_pwr_ack; 351 - } 321 + ret = scpsys_bus_protect_disable(scpd); 322 + if (ret < 0) 323 + goto err_pwr_ack; 352 324 353 325 return 0; 354 326 ··· 366 346 u32 val; 367 347 int ret, tmp; 368 348 369 - if (scpd->data->bus_prot_mask) { 370 - ret = mtk_infracfg_set_bus_protection(scp->infracfg, 371 - scpd->data->bus_prot_mask, 372 - scp->bus_prot_reg_update); 373 - if (ret) 374 - goto out; 375 - } 349 + ret = scpsys_bus_protect_enable(scpd); 350 + if (ret < 0) 351 + goto out; 376 352 377 353 ret = scpsys_sram_disable(scpd, ctl_addr); 378 354 if (ret < 0)