Skip to content

Commit 6e3b29d

Browse files
andy-shevlag-linaro
authored andcommitted
mfd: lpc_ich: Factor out lpc_ich_enable_spi_write()
Factor out duplicate code to lpc_ich_enable_spi_write() helper function. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Henning Schild <henning.schild@siemens.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Lee Jones <lee@kernel.org>
1 parent c551bd8 commit 6e3b29d

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

drivers/mfd/lpc_ich.c

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,35 +1100,32 @@ static bool lpc_ich_byt_set_writeable(void __iomem *base, void *data)
11001100
return val & BYT_BCR_WPD;
11011101
}
11021102

1103-
static bool lpc_ich_lpt_set_writeable(void __iomem *base, void *data)
1103+
static bool lpc_ich_set_writeable(struct pci_bus *bus, unsigned int devfn)
11041104
{
1105-
struct pci_dev *pdev = data;
11061105
u32 bcr;
11071106

1108-
pci_read_config_dword(pdev, BCR, &bcr);
1107+
pci_bus_read_config_dword(bus, devfn, BCR, &bcr);
11091108
if (!(bcr & BCR_WPD)) {
11101109
bcr |= BCR_WPD;
1111-
pci_write_config_dword(pdev, BCR, bcr);
1112-
pci_read_config_dword(pdev, BCR, &bcr);
1110+
pci_bus_write_config_dword(bus, devfn, BCR, bcr);
1111+
pci_bus_read_config_dword(bus, devfn, BCR, &bcr);
11131112
}
11141113

11151114
return bcr & BCR_WPD;
11161115
}
11171116

1118-
static bool lpc_ich_bxt_set_writeable(void __iomem *base, void *data)
1117+
static bool lpc_ich_lpt_set_writeable(void __iomem *base, void *data)
11191118
{
1120-
unsigned int spi = PCI_DEVFN(13, 2);
1121-
struct pci_bus *bus = data;
1122-
u32 bcr;
1119+
struct pci_dev *pdev = data;
11231120

1124-
pci_bus_read_config_dword(bus, spi, BCR, &bcr);
1125-
if (!(bcr & BCR_WPD)) {
1126-
bcr |= BCR_WPD;
1127-
pci_bus_write_config_dword(bus, spi, BCR, bcr);
1128-
pci_bus_read_config_dword(bus, spi, BCR, &bcr);
1129-
}
1121+
return lpc_ich_set_writeable(pdev->bus, pdev->devfn);
1122+
}
11301123

1131-
return bcr & BCR_WPD;
1124+
static bool lpc_ich_bxt_set_writeable(void __iomem *base, void *data)
1125+
{
1126+
struct pci_dev *pdev = data;
1127+
1128+
return lpc_ich_set_writeable(pdev->bus, PCI_DEVFN(13, 2));
11321129
}
11331130

11341131
static int lpc_ich_init_spi(struct pci_dev *dev)
@@ -1185,7 +1182,7 @@ static int lpc_ich_init_spi(struct pci_dev *dev)
11851182
res->end = res->start + SPIBASE_APL_SZ - 1;
11861183

11871184
info->set_writeable = lpc_ich_bxt_set_writeable;
1188-
info->data = bus;
1185+
info->data = dev;
11891186
}
11901187

11911188
pci_bus_write_config_byte(bus, p2sb, 0xe1, 0x1);

0 commit comments

Comments
 (0)