Skip to content

Commit

Permalink
i2c: pasemi: Split off common probing code
Browse files Browse the repository at this point in the history
Split off common probing code that will be used by both the PCI and the
platform device.

Signed-off-by: Sven Peter <sven@svenpeter.dev>
  • Loading branch information
svenpeter42 committed Sep 25, 2021
1 parent 302eed2 commit 288bd9b
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions drivers/i2c/busses/i2c-pasemi.c
Expand Up @@ -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 at 0x%lx", smbus->base);
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)
{
Expand Down Expand Up @@ -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 at 0x%lx", smbus->base);
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;

Expand Down

0 comments on commit 288bd9b

Please sign in to comment.