On Tue, Mar 15, 2022 at 05:14:46PM +0100, Johannes Holland wrote: > From: Alexander Steffen <Alexander.Steffen@xxxxxxxxxxxx> > > Only tpm_tis and tpm_tis_synquacer have a dedicated way to access > multiple bytes at once, every other driver will just fall back to > read_bytes/write_bytes. Therefore, move this common code out of > tpm_tis_spi_main and tpm_tis_spi_cr50 into tpm_tis_core, so that it is > automatically used when low-level drivers do not implement the > specialized methods. > > Signed-off-by: Alexander Steffen <Alexander.Steffen@xxxxxxxxxxxx> > Signed-off-by: Johannes Holland <johannes.holland@xxxxxxxxxxxx> > --- Please, add a change log to the next version, which also includes description of v2 changes. Redudancy is insignificant, and how things are now does not require special cases from the upper layer. Instead you should do this: enum tpm_tis_io_mode { TPM_TIS_PHYS_8, TPM_TIS_PHYS_16, TPM_TIS_PHYS_32, }; struct tpm_tis_phy_ops { int (*read_bytes)(struct tpm_tis_data *data, u32 addr, u16 len, u8 *result, int mode); int (*write_bytes)(struct tpm_tis_data *data, u32 addr, u16 len, const u8 *value, int mode); }; And e.g. static inline int tpm_tis_read16(struct tpm_tis_data *data, u32 addr, u16 *result) { rc = data->phy_ops->read_bytes(data, addr, sizeof(u16), &result_le, TPM_TIS_PHYS_16); } This takes away over half of the callback API, and does not require special cases on the top layer. BR, Jarkko