mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
tpm: use DEFINE_SIMPLE_DEV_PM_OPS and pm_sleep_ptr()
Replace the deprecated SIMPLE_DEV_PM_OPS with DEFINE_SIMPLE_DEV_PM_OPS and wrap the struct assignment with pm_sleep_ptr(). The old code keeps a completely empty dev_pm_ops structure -- all callbacks are NULL -- as dead code in the object file when CONFIG_PM_SLEEP=n, because SET_SYSTEM_SLEEP_PM_OPS() expands to nothing while __maybe_unused on the struct only silences the warning without removing the struct. Switching to DEFINE_SIMPLE_DEV_PM_OPS() lets pm_sleep_ptr() eliminate the callback references at compile time, and wrapping the struct assignment with pm_sleep_ptr() drops the entire structure when CONFIG_PM_SLEEP is disabled, instead of retaining an empty one. Signed-off-by: Li Jun <lijun01@kylinos.cn> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> Link: https://lore.kernel.org/r/20260909082459.796628-1-lijun01@kylinos.cn Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
This commit is contained in:
parent
fc0ddb3174
commit
03f0525735
|
|
@ -205,12 +205,12 @@ static void atml_plat_remove(void)
|
|||
platform_device_unregister(pdev);
|
||||
}
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(tpm_atml_pm, tpm_pm_suspend, tpm_pm_resume);
|
||||
static DEFINE_SIMPLE_DEV_PM_OPS(tpm_atml_pm, tpm_pm_suspend, tpm_pm_resume);
|
||||
|
||||
static struct platform_driver atml_drv = {
|
||||
.driver = {
|
||||
.name = "tpm_atmel",
|
||||
.pm = &tpm_atml_pm,
|
||||
.pm = pm_sleep_ptr(&tpm_atml_pm),
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ static const struct of_device_id i2c_atmel_of_match[] = {
|
|||
MODULE_DEVICE_TABLE(of, i2c_atmel_of_match);
|
||||
#endif
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(i2c_atmel_pm_ops, tpm_pm_suspend, tpm_pm_resume);
|
||||
static DEFINE_SIMPLE_DEV_PM_OPS(i2c_atmel_pm_ops, tpm_pm_suspend, tpm_pm_resume);
|
||||
|
||||
static struct i2c_driver i2c_atmel_driver = {
|
||||
.id_table = i2c_atmel_id,
|
||||
|
|
@ -220,7 +220,7 @@ static struct i2c_driver i2c_atmel_driver = {
|
|||
.remove = i2c_atmel_remove,
|
||||
.driver = {
|
||||
.name = I2C_DRIVER_NAME,
|
||||
.pm = &i2c_atmel_pm_ops,
|
||||
.pm = pm_sleep_ptr(&i2c_atmel_pm_ops),
|
||||
.of_match_table = of_match_ptr(i2c_atmel_of_match),
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -682,7 +682,7 @@ static const struct of_device_id tpm_tis_i2c_of_match[] = {
|
|||
MODULE_DEVICE_TABLE(of, tpm_tis_i2c_of_match);
|
||||
#endif
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(tpm_tis_i2c_ops, tpm_pm_suspend, tpm_pm_resume);
|
||||
static DEFINE_SIMPLE_DEV_PM_OPS(tpm_tis_i2c_ops, tpm_pm_suspend, tpm_pm_resume);
|
||||
|
||||
static int tpm_tis_i2c_probe(struct i2c_client *client)
|
||||
{
|
||||
|
|
@ -723,7 +723,7 @@ static struct i2c_driver tpm_tis_i2c_driver = {
|
|||
.remove = tpm_tis_i2c_remove,
|
||||
.driver = {
|
||||
.name = "tpm_i2c_infineon",
|
||||
.pm = &tpm_tis_i2c_ops,
|
||||
.pm = pm_sleep_ptr(&tpm_tis_i2c_ops),
|
||||
.of_match_table = of_match_ptr(tpm_tis_i2c_of_match),
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -640,7 +640,7 @@ static const struct of_device_id i2c_nuvoton_of_match[] = {
|
|||
MODULE_DEVICE_TABLE(of, i2c_nuvoton_of_match);
|
||||
#endif
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(i2c_nuvoton_pm_ops, tpm_pm_suspend, tpm_pm_resume);
|
||||
static DEFINE_SIMPLE_DEV_PM_OPS(i2c_nuvoton_pm_ops, tpm_pm_suspend, tpm_pm_resume);
|
||||
|
||||
static struct i2c_driver i2c_nuvoton_driver = {
|
||||
.id_table = i2c_nuvoton_id,
|
||||
|
|
@ -648,7 +648,7 @@ static struct i2c_driver i2c_nuvoton_driver = {
|
|||
.remove = i2c_nuvoton_remove,
|
||||
.driver = {
|
||||
.name = "tpm_i2c_nuvoton",
|
||||
.pm = &i2c_nuvoton_pm_ops,
|
||||
.pm = pm_sleep_ptr(&i2c_nuvoton_pm_ops),
|
||||
.of_match_table = of_match_ptr(i2c_nuvoton_of_match),
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -594,7 +594,6 @@ static void tpm_inf_pnp_remove(struct pnp_dev *dev)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int tpm_inf_resume(struct device *dev)
|
||||
{
|
||||
/* Re-configure TPM after suspending */
|
||||
|
|
@ -611,8 +610,8 @@ static int tpm_inf_resume(struct device *dev)
|
|||
tpm_data_out(RESET_LP_IRQC_DISABLE, CMD);
|
||||
return tpm_pm_resume(dev);
|
||||
}
|
||||
#endif
|
||||
static SIMPLE_DEV_PM_OPS(tpm_inf_pm, tpm_pm_suspend, tpm_inf_resume);
|
||||
|
||||
static DEFINE_SIMPLE_DEV_PM_OPS(tpm_inf_pm, tpm_pm_suspend, tpm_inf_resume);
|
||||
|
||||
static struct pnp_driver tpm_inf_pnp_driver = {
|
||||
.name = "tpm_inf_pnp",
|
||||
|
|
@ -620,7 +619,7 @@ static struct pnp_driver tpm_inf_pnp_driver = {
|
|||
.probe = tpm_inf_pnp_probe,
|
||||
.remove = tpm_inf_pnp_remove,
|
||||
.driver = {
|
||||
.pm = &tpm_inf_pm,
|
||||
.pm = pm_sleep_ptr(&tpm_inf_pm),
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -270,12 +270,12 @@ static void tpm_nsc_remove(struct device *dev)
|
|||
release_region(priv->base, 2);
|
||||
}
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(tpm_nsc_pm, tpm_pm_suspend, tpm_pm_resume);
|
||||
static DEFINE_SIMPLE_DEV_PM_OPS(tpm_nsc_pm, tpm_pm_suspend, tpm_pm_resume);
|
||||
|
||||
static struct platform_driver nsc_drv = {
|
||||
.driver = {
|
||||
.name = "tpm_nsc",
|
||||
.pm = &tpm_nsc_pm,
|
||||
.pm = pm_sleep_ptr(&tpm_nsc_pm),
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info)
|
|||
ACPI_HANDLE(dev));
|
||||
}
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(tpm_tis_pm, tpm_pm_suspend, tpm_tis_resume);
|
||||
static DEFINE_SIMPLE_DEV_PM_OPS(tpm_tis_pm, tpm_pm_suspend, tpm_tis_resume);
|
||||
|
||||
static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
|
||||
const struct pnp_device_id *pnp_id)
|
||||
|
|
@ -302,7 +302,7 @@ static struct pnp_driver tis_pnp_driver = {
|
|||
.probe = tpm_tis_pnp_init,
|
||||
.remove = tpm_tis_pnp_remove,
|
||||
.driver = {
|
||||
.pm = &tpm_tis_pm,
|
||||
.pm = pm_sleep_ptr(&tpm_tis_pm),
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -161,8 +161,6 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
|
|||
const struct tpm_tis_phy_ops *phy_ops,
|
||||
acpi_handle acpi_dev_handle);
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
int tpm_tis_resume(struct device *dev);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ static int tpm_tis_i2c_init_guard_time(struct tpm_tis_i2c_phy *phy)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(tpm_tis_pm, tpm_pm_suspend, tpm_tis_resume);
|
||||
static DEFINE_SIMPLE_DEV_PM_OPS(tpm_tis_pm, tpm_pm_suspend, tpm_tis_resume);
|
||||
|
||||
static const struct tpm_tis_phy_ops tpm_i2c_phy_ops = {
|
||||
.read_bytes = tpm_tis_i2c_read_bytes,
|
||||
|
|
@ -405,7 +405,7 @@ MODULE_DEVICE_TABLE(of, of_tis_i2c_match);
|
|||
static struct i2c_driver tpm_tis_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "tpm_tis_i2c",
|
||||
.pm = &tpm_tis_pm,
|
||||
.pm = pm_sleep_ptr(&tpm_tis_pm),
|
||||
.of_match_table = of_match_ptr(of_tis_i2c_match),
|
||||
},
|
||||
.probe = tpm_tis_i2c_probe,
|
||||
|
|
|
|||
|
|
@ -816,14 +816,14 @@ static void tpm_cr50_i2c_remove(struct i2c_client *client)
|
|||
tpm_chip_unregister(chip);
|
||||
}
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(cr50_i2c_pm, tpm_pm_suspend, tpm_pm_resume);
|
||||
static DEFINE_SIMPLE_DEV_PM_OPS(cr50_i2c_pm, tpm_pm_suspend, tpm_pm_resume);
|
||||
|
||||
static struct i2c_driver cr50_i2c_driver = {
|
||||
.probe = tpm_cr50_i2c_probe,
|
||||
.remove = tpm_cr50_i2c_remove,
|
||||
.driver = {
|
||||
.name = "cr50_i2c",
|
||||
.pm = &cr50_i2c_pm,
|
||||
.pm = pm_sleep_ptr(&cr50_i2c_pm),
|
||||
.acpi_match_table = ACPI_PTR(cr50_i2c_acpi_id),
|
||||
.of_match_table = of_match_ptr(of_cr50_i2c_match),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ static int tpm_tis_spi_driver_probe(struct spi_device *spi)
|
|||
return probe_func(spi);
|
||||
}
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(tpm_tis_pm, tpm_pm_suspend, tpm_tis_spi_resume);
|
||||
static DEFINE_SIMPLE_DEV_PM_OPS(tpm_tis_pm, tpm_pm_suspend, tpm_tis_spi_resume);
|
||||
|
||||
static void tpm_tis_spi_remove(struct spi_device *dev)
|
||||
{
|
||||
|
|
@ -347,7 +347,7 @@ MODULE_DEVICE_TABLE(acpi, acpi_tis_spi_match);
|
|||
static struct spi_driver tpm_tis_spi_driver = {
|
||||
.driver = {
|
||||
.name = "tpm_tis_spi",
|
||||
.pm = &tpm_tis_pm,
|
||||
.pm = pm_sleep_ptr(&tpm_tis_pm),
|
||||
.of_match_table = of_match_ptr(of_tis_spi_match),
|
||||
.acpi_match_table = ACPI_PTR(acpi_tis_spi_match),
|
||||
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ static int tpm_tis_synquacer_init(struct device *dev,
|
|||
ACPI_HANDLE(dev));
|
||||
}
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(tpm_tis_synquacer_pm, tpm_pm_suspend, tpm_tis_resume);
|
||||
static DEFINE_SIMPLE_DEV_PM_OPS(tpm_tis_synquacer_pm, tpm_pm_suspend, tpm_tis_resume);
|
||||
|
||||
static int tpm_tis_synquacer_probe(struct platform_device *pdev)
|
||||
{
|
||||
|
|
@ -155,7 +155,7 @@ static struct platform_driver tis_synquacer_drv = {
|
|||
.remove = tpm_tis_synquacer_remove,
|
||||
.driver = {
|
||||
.name = "tpm_tis_synquacer",
|
||||
.pm = &tpm_tis_synquacer_pm,
|
||||
.pm = pm_sleep_ptr(&tpm_tis_synquacer_pm),
|
||||
.of_match_table = of_match_ptr(tis_synquacer_of_platform_match),
|
||||
.acpi_match_table = ACPI_PTR(tpm_synquacer_acpi_tbl),
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user