diff options
author | Sven Peter <sven@svenpeter.dev> | 2021-10-08 19:35:26 +0300 |
---|---|---|
committer | Wolfram Sang <wsa@kernel.org> | 2021-10-11 12:45:09 +0300 |
commit | 6adb00c7f0edc081f21e0abd4d7eebe99589a287 (patch) | |
tree | 767146c8d7b66486846616b5bc9a446e895a627f /drivers/i2c/busses/i2c-pasemi.c | |
parent | c06f50ed36cc0aeaf124bee0d676a21315aea5e7 (diff) | |
download | linux-6adb00c7f0edc081f21e0abd4d7eebe99589a287.tar.xz |
i2c: pasemi: Split off common probing code
Split off common probing code that will be used by both the PCI and the
platform device.
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Acked-by: Olof Johansson <olof@lixom.net>
Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Diffstat (limited to 'drivers/i2c/busses/i2c-pasemi.c')
-rw-r--r-- | drivers/i2c/busses/i2c-pasemi.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi.c index a018e9376023..baf338149673 100644 --- a/drivers/i2c/busses/i2c-pasemi.c +++ b/drivers/i2c/busses/i2c-pasemi.c @@ -329,6 +329,30 @@ static const struct i2c_algorithm smbus_algorithm = { .functionality = pasemi_smb_func, }; +static int pasemi_i2c_common_probe(struct pasemi_smbus *smbus) +{ + int error; + + smbus->adapter.owner = THIS_MODULE; + snprintf(smbus->adapter.name, sizeof(smbus->adapter.name), + "PA Semi SMBus adapter (%s)", dev_name(smbus->dev)); + smbus->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; + smbus->adapter.algo = &smbus_algorithm; + smbus->adapter.algo_data = smbus; + + /* set up the sysfs linkage to our parent device */ + smbus->adapter.dev.parent = smbus->dev; + + reg_write(smbus, REG_CTL, (CTL_MTR | CTL_MRR | + (CLK_100K_DIV & CTL_CLK_M))); + + error = i2c_add_adapter(&smbus->adapter); + if (error) + return error; + + return 0; +} + static int pasemi_smb_probe(struct pci_dev *dev, const struct pci_device_id *id) { @@ -358,20 +382,7 @@ static int pasemi_smb_probe(struct pci_dev *dev, goto out_release_region; } - smbus->adapter.owner = THIS_MODULE; - snprintf(smbus->adapter.name, sizeof(smbus->adapter.name), - "PA Semi SMBus adapter (%s)", dev_name(smbus->dev)); - smbus->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; - smbus->adapter.algo = &smbus_algorithm; - smbus->adapter.algo_data = smbus; - - /* set up the sysfs linkage to our parent device */ - smbus->adapter.dev.parent = smbus->dev; - - reg_write(smbus, REG_CTL, (CTL_MTR | CTL_MRR | - (CLK_100K_DIV & CTL_CLK_M))); - - error = i2c_add_adapter(&smbus->adapter); + int error = pasemi_i2c_common_probe(smbus); if (error) goto out_ioport_unmap; |