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

i2c: piix4: Export i2c_piix4 driver functions as library

Export the following i2c_piix4 driver functions as a library so that the
AMD ASF driver can utilize these core functionalities from the i2c_piix4
driver:

- piix4_sb800_region_request(): Request access to a specific SMBus region
on the SB800 chipset.

- piix4_sb800_region_release(): Release the previously requested SMBus
region on the SB800 chipset.

- piix4_transaction(): Handle SMBus transactions between the SMBus
controller and connected devices.

- piix4_sb800_port_sel(): Select the appropriate SMBus port on the SB800
chipset.

By making these functions available as a library, enable the AMD ASF
driver to leverage the established mechanisms in the i2c_piix4 driver,
promoting code reuse and consistency across different drivers.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Co-developed-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>

authored by

Shyam Sundar S K and committed by
Andi Shyti
05d98004 650e2c39

+13 -6
+8 -6
drivers/i2c/busses/i2c-piix4.c
··· 156 156 struct sb800_mmio_cfg mmio_cfg; 157 157 }; 158 158 159 - static int piix4_sb800_region_request(struct device *dev, 160 - struct sb800_mmio_cfg *mmio_cfg) 159 + int piix4_sb800_region_request(struct device *dev, struct sb800_mmio_cfg *mmio_cfg) 161 160 { 162 161 if (mmio_cfg->use_mmio) { 163 162 void __iomem *addr; ··· 194 195 195 196 return 0; 196 197 } 198 + EXPORT_SYMBOL_NS_GPL(piix4_sb800_region_request, PIIX4_SMBUS); 197 199 198 - static void piix4_sb800_region_release(struct device *dev, 199 - struct sb800_mmio_cfg *mmio_cfg) 200 + void piix4_sb800_region_release(struct device *dev, struct sb800_mmio_cfg *mmio_cfg) 200 201 { 201 202 if (mmio_cfg->use_mmio) { 202 203 iounmap(mmio_cfg->addr); ··· 207 208 208 209 release_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE); 209 210 } 211 + EXPORT_SYMBOL_NS_GPL(piix4_sb800_region_release, PIIX4_SMBUS); 210 212 211 213 static bool piix4_sb800_use_mmio(struct pci_dev *PIIX4_dev) 212 214 { ··· 517 517 return piix4_smba; 518 518 } 519 519 520 - static int piix4_transaction(struct i2c_adapter *piix4_adapter, unsigned short piix4_smba) 520 + int piix4_transaction(struct i2c_adapter *piix4_adapter, unsigned short piix4_smba) 521 521 { 522 522 int temp; 523 523 int result = 0; ··· 590 590 inb_p(SMBHSTDAT1)); 591 591 return result; 592 592 } 593 + EXPORT_SYMBOL_NS_GPL(piix4_transaction, PIIX4_SMBUS); 593 594 594 595 /* Return negative errno on error. */ 595 596 static s32 piix4_access(struct i2c_adapter * adap, u16 addr, ··· 744 743 release_region(KERNCZ_IMC_IDX, 2); 745 744 } 746 745 747 - static int piix4_sb800_port_sel(u8 port, struct sb800_mmio_cfg *mmio_cfg) 746 + int piix4_sb800_port_sel(u8 port, struct sb800_mmio_cfg *mmio_cfg) 748 747 { 749 748 u8 smba_en_lo, val; 750 749 ··· 766 765 767 766 return (smba_en_lo & piix4_port_mask_sb800); 768 767 } 768 + EXPORT_SYMBOL_NS_GPL(piix4_sb800_port_sel, PIIX4_SMBUS); 769 769 770 770 /* 771 771 * Handles access to multiple SMBus ports on the SB800.
+5
drivers/i2c/busses/i2c-piix4.h
··· 36 36 bool use_mmio; 37 37 }; 38 38 39 + int piix4_sb800_port_sel(u8 port, struct sb800_mmio_cfg *mmio_cfg); 40 + int piix4_transaction(struct i2c_adapter *piix4_adapter, unsigned short piix4_smba); 41 + int piix4_sb800_region_request(struct device *dev, struct sb800_mmio_cfg *mmio_cfg); 42 + void piix4_sb800_region_release(struct device *dev, struct sb800_mmio_cfg *mmio_cfg); 43 + 39 44 #endif /* I2C_PIIX4_H */