Skip to content

Commit

Permalink
i2c: piix4: don't regress on bus names
Browse files Browse the repository at this point in the history
The I2C bus names are supposed to be stable as they can be used by
userspace to uniquely identify a specific I2C bus. So restore the
original names for all legacy (pre-SB800) devices.

For SB800 devices and later, improve the names. "SDA" refers to the
serial data pin of each SMBus port, it's an implementation detail the
user doesn't need to know. Use "port" instead, which is easier to
understand.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Tested-by: Christian Fetzer <fetzer.ch@gmail.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
  • Loading branch information
Jean Delvare authored and Wolfram Sang committed Jan 29, 2016
1 parent 08c6e8c commit 52795f6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions drivers/i2c/busses/i2c-piix4.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ static const struct dmi_system_id piix4_dmi_ibm[] = {
/* SB800 globals */
static DEFINE_MUTEX(piix4_mutex_sb800);
static const char *piix4_main_port_names_sb800[PIIX4_MAX_ADAPTERS] = {
"SDA0", "SDA2", "SDA3", "SDA4"
" port 0", " port 2", " port 3", " port 4"
};
static const char *piix4_aux_port_name_sb800 = "SDA1";
static const char *piix4_aux_port_name_sb800 = " port 1";

struct i2c_piix4_adapdata {
unsigned short smba;
Expand Down Expand Up @@ -660,7 +660,7 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba,
adap->dev.parent = &dev->dev;

snprintf(adap->name, sizeof(adap->name),
"SMBus PIIX4 adapter %s at %04x", name, smba);
"SMBus PIIX4 adapter%s at %04x", name, smba);

i2c_set_adapdata(adap, adapdata);

Expand Down Expand Up @@ -712,11 +712,14 @@ static int piix4_add_adapters_sb800(struct pci_dev *dev, unsigned short smba)
static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id)
{
int retval;
bool is_sb800 = false;

if ((dev->vendor == PCI_VENDOR_ID_ATI &&
dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS &&
dev->revision >= 0x40) ||
dev->vendor == PCI_VENDOR_ID_AMD) {
is_sb800 = true;

if (!request_region(SB800_PIIX4_SMB_IDX, 2, "smba_idx")) {
dev_err(&dev->dev,
"SMBus base address index region 0x%x already in use!\n",
Expand Down Expand Up @@ -746,7 +749,7 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id)
return retval;

/* Try to register main SMBus adapter, give up if we can't */
retval = piix4_add_adapter(dev, retval, false, 0, "main",
retval = piix4_add_adapter(dev, retval, false, 0, "",
&piix4_main_adapters[0]);
if (retval < 0)
return retval;
Expand Down Expand Up @@ -774,7 +777,7 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id)
/* Try to add the aux adapter if it exists,
* piix4_add_adapter will clean up if this fails */
piix4_add_adapter(dev, retval, false, 0,
piix4_aux_port_name_sb800,
is_sb800 ? piix4_aux_port_name_sb800 : "",
&piix4_aux_adapter);
}

Expand Down

0 comments on commit 52795f6

Please sign in to comment.