Commit f42cacf3 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] I2C: clean up i2c-prosavage.c driver

Remove direct memory accesses and link up device in the proper place in the
sysfs tree.
parent 02b0893f
...@@ -60,21 +60,14 @@ ...@@ -60,21 +60,14 @@
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/i2c-algo-bit.h> #include <linux/i2c-algo-bit.h>
#include <asm/io.h>
/* /*
* driver configuration * driver configuration
*/ */
#define DRIVER_ID "i2c-prosavage"
#define DRIVER_VERSION "20030621"
#define ADAPTER_NAME(x) (x).name
#define MAX_BUSSES 2 #define MAX_BUSSES 2
struct s_i2c_bus { struct s_i2c_bus {
u8 *mmvga; void *mmvga;
int i2c_reg; int i2c_reg;
int adap_ok; int adap_ok;
struct i2c_adapter adap; struct i2c_adapter adap;
...@@ -82,7 +75,7 @@ struct s_i2c_bus { ...@@ -82,7 +75,7 @@ struct s_i2c_bus {
}; };
struct s_i2c_chip { struct s_i2c_chip {
u8 *mmio; void *mmio;
struct s_i2c_bus i2c_bus[MAX_BUSSES]; struct s_i2c_bus i2c_bus[MAX_BUSSES];
}; };
...@@ -102,9 +95,6 @@ struct s_i2c_chip { ...@@ -102,9 +95,6 @@ struct s_i2c_chip {
/* /*
* S3/VIA 8365/8375 registers * S3/VIA 8365/8375 registers
*/ */
#ifndef PCI_VENDOR_ID_S3
#define PCI_VENDOR_ID_S3 0x5333
#endif
#ifndef PCI_DEVICE_ID_S3_SAVAGE4 #ifndef PCI_DEVICE_ID_S3_SAVAGE4
#define PCI_DEVICE_ID_S3_SAVAGE4 0x8a25 #define PCI_DEVICE_ID_S3_SAVAGE4 0x8a25
#endif #endif
...@@ -126,9 +116,9 @@ struct s_i2c_chip { ...@@ -126,9 +116,9 @@ struct s_i2c_chip {
#define I2C_SCL_IN 0x04 #define I2C_SCL_IN 0x04
#define I2C_SDA_IN 0x08 #define I2C_SDA_IN 0x08
#define SET_CR_IX(p, val) *((p)->mmvga + VGA_CR_IX) = (u8)(val) #define SET_CR_IX(p, val) writeb((val), (p)->mmvga + VGA_CR_IX)
#define SET_CR_DATA(p, val) *((p)->mmvga + VGA_CR_DATA) = (u8)(val) #define SET_CR_DATA(p, val) writeb((val), (p)->mmvga + VGA_CR_DATA)
#define GET_CR_DATA(p) *((p)->mmvga + VGA_CR_DATA) #define GET_CR_DATA(p) readb((p)->mmvga + VGA_CR_DATA)
/* /*
...@@ -190,12 +180,13 @@ static int bit_s3via_getsda(void *bus) ...@@ -190,12 +180,13 @@ static int bit_s3via_getsda(void *bus)
/* /*
* adapter initialisation * adapter initialisation
*/ */
static int i2c_register_bus(struct s_i2c_bus *p, u8 *mmvga, u32 i2c_reg) static int i2c_register_bus(struct pci_dev *dev, struct s_i2c_bus *p, u8 *mmvga, u32 i2c_reg)
{ {
int ret; int ret;
p->adap.owner = THIS_MODULE; p->adap.owner = THIS_MODULE;
p->adap.id = I2C_HW_B_S3VIA; p->adap.id = I2C_HW_B_S3VIA;
p->adap.algo_data = &p->algo; p->adap.algo_data = &p->algo;
p->adap.dev.parent = &dev->dev;
p->algo.setsda = bit_s3via_setsda; p->algo.setsda = bit_s3via_setsda;
p->algo.setscl = bit_s3via_setscl; p->algo.setscl = bit_s3via_setscl;
p->algo.getsda = bit_s3via_getsda; p->algo.getsda = bit_s3via_getsda;
...@@ -236,8 +227,8 @@ static void __devexit prosavage_remove(struct pci_dev *dev) ...@@ -236,8 +227,8 @@ static void __devexit prosavage_remove(struct pci_dev *dev)
ret = i2c_bit_del_bus(&chip->i2c_bus[i].adap); ret = i2c_bit_del_bus(&chip->i2c_bus[i].adap);
if (ret) { if (ret) {
printk(DRIVER_ID ": %s not removed\n", dev_err(&dev->dev, ": %s not removed\n",
ADAPTER_NAME(chip->i2c_bus[i].adap)); chip->i2c_bus[i].adap.name);
} }
} }
if (chip->mmio) { if (chip->mmio) {
...@@ -270,7 +261,7 @@ static int __devinit prosavage_probe(struct pci_dev *dev, const struct pci_devic ...@@ -270,7 +261,7 @@ static int __devinit prosavage_probe(struct pci_dev *dev, const struct pci_devic
chip->mmio = ioremap_nocache(base, len); chip->mmio = ioremap_nocache(base, len);
if (chip->mmio == NULL) { if (chip->mmio == NULL) {
printk (DRIVER_ID ": ioremap failed\n"); dev_err(&dev->dev, "ioremap failed\n");
prosavage_remove(dev); prosavage_remove(dev);
return -ENODEV; return -ENODEV;
} }
...@@ -286,10 +277,10 @@ static int __devinit prosavage_probe(struct pci_dev *dev, const struct pci_devic ...@@ -286,10 +277,10 @@ static int __devinit prosavage_probe(struct pci_dev *dev, const struct pci_devic
* i2c bus registration * i2c bus registration
*/ */
bus = &chip->i2c_bus[0]; bus = &chip->i2c_bus[0];
snprintf(ADAPTER_NAME(bus->adap), sizeof(ADAPTER_NAME(bus->adap)), snprintf(bus->adap.name, sizeof(bus->adap.name),
"ProSavage I2C bus at %02x:%02x.%x", "ProSavage I2C bus at %02x:%02x.%x",
dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
ret = i2c_register_bus(bus, chip->mmio + 0x8000, CR_SERIAL1); ret = i2c_register_bus(dev, bus, chip->mmio + 0x8000, CR_SERIAL1);
if (ret) { if (ret) {
goto err_adap; goto err_adap;
} }
...@@ -297,16 +288,16 @@ static int __devinit prosavage_probe(struct pci_dev *dev, const struct pci_devic ...@@ -297,16 +288,16 @@ static int __devinit prosavage_probe(struct pci_dev *dev, const struct pci_devic
* ddc bus registration * ddc bus registration
*/ */
bus = &chip->i2c_bus[1]; bus = &chip->i2c_bus[1];
snprintf(ADAPTER_NAME(bus->adap), sizeof(ADAPTER_NAME(bus->adap)), snprintf(bus->adap.name, sizeof(bus->adap.name),
"ProSavage DDC bus at %02x:%02x.%x", "ProSavage DDC bus at %02x:%02x.%x",
dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
ret = i2c_register_bus(bus, chip->mmio + 0x8000, CR_SERIAL2); ret = i2c_register_bus(dev, bus, chip->mmio + 0x8000, CR_SERIAL2);
if (ret) { if (ret) {
goto err_adap; goto err_adap;
} }
return 0; return 0;
err_adap: err_adap:
printk (DRIVER_ID ": %s failed\n", ADAPTER_NAME(bus->adap)); dev_err(&dev->dev, ": %s failed\n", bus->adap.name);
prosavage_remove(dev); prosavage_remove(dev);
return ret; return ret;
} }
...@@ -316,17 +307,9 @@ static int __devinit prosavage_probe(struct pci_dev *dev, const struct pci_devic ...@@ -316,17 +307,9 @@ static int __devinit prosavage_probe(struct pci_dev *dev, const struct pci_devic
* Data for PCI driver interface * Data for PCI driver interface
*/ */
static struct pci_device_id prosavage_pci_tbl[] = { static struct pci_device_id prosavage_pci_tbl[] = {
{ { PCI_DEVICE(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_SAVAGE4) },
.vendor = PCI_VENDOR_ID_S3, { PCI_DEVICE(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_PROSAVAGE8) },
.device = PCI_DEVICE_ID_S3_SAVAGE4, { 0, },
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
},{
.vendor = PCI_VENDOR_ID_S3,
.device = PCI_DEVICE_ID_S3_PROSAVAGE8,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
},{ 0, }
}; };
static struct pci_driver prosavage_driver = { static struct pci_driver prosavage_driver = {
...@@ -338,7 +321,6 @@ static struct pci_driver prosavage_driver = { ...@@ -338,7 +321,6 @@ static struct pci_driver prosavage_driver = {
static int __init i2c_prosavage_init(void) static int __init i2c_prosavage_init(void)
{ {
printk(DRIVER_ID " version %s (%s)\n", I2C_VERSION, DRIVER_VERSION);
return pci_module_init(&prosavage_driver); return pci_module_init(&prosavage_driver);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment