You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge branch 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6
* 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6: i2c: Convert most new-style drivers to use module aliasing i2c: Add support for device alias names i2c-amd756-s4882: Fix an error path i2c: Drop unused RTC driver IDs i2c/tps65010: Add missing intialization of client data i2c-sis5595: Minor cleanups in sis5595_access i2c-piix4: Minor cleanups i2c: Spelling fix (successful) i2c-stub: No newline in parameter description
This commit is contained in:
+6
-18
@@ -23,13 +23,7 @@
|
||||
#define PCA953X_INVERT 2
|
||||
#define PCA953X_DIRECTION 3
|
||||
|
||||
/* This is temporary - in 2.6.26 i2c_driver_data should replace it. */
|
||||
struct pca953x_desc {
|
||||
char name[I2C_NAME_SIZE];
|
||||
unsigned long driver_data;
|
||||
};
|
||||
|
||||
static const struct pca953x_desc pca953x_descs[] = {
|
||||
static const struct i2c_device_id pca953x_id[] = {
|
||||
{ "pca9534", 8, },
|
||||
{ "pca9535", 16, },
|
||||
{ "pca9536", 4, },
|
||||
@@ -37,7 +31,9 @@ static const struct pca953x_desc pca953x_descs[] = {
|
||||
{ "pca9538", 8, },
|
||||
{ "pca9539", 16, },
|
||||
/* REVISIT several pca955x parts should work here too */
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, pca953x_id);
|
||||
|
||||
struct pca953x_chip {
|
||||
unsigned gpio_start;
|
||||
@@ -192,26 +188,17 @@ static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios)
|
||||
gc->owner = THIS_MODULE;
|
||||
}
|
||||
|
||||
static int __devinit pca953x_probe(struct i2c_client *client)
|
||||
static int __devinit pca953x_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct pca953x_platform_data *pdata;
|
||||
struct pca953x_chip *chip;
|
||||
int ret, i;
|
||||
const struct pca953x_desc *id = NULL;
|
||||
|
||||
pdata = client->dev.platform_data;
|
||||
if (pdata == NULL)
|
||||
return -ENODEV;
|
||||
|
||||
/* this loop vanishes when we get i2c_device_id */
|
||||
for (i = 0; i < ARRAY_SIZE(pca953x_descs); i++)
|
||||
if (!strcmp(pca953x_descs[i].name, client->name)) {
|
||||
id = pca953x_descs + i;
|
||||
break;
|
||||
}
|
||||
if (!id)
|
||||
return -ENODEV;
|
||||
|
||||
chip = kzalloc(sizeof(struct pca953x_chip), GFP_KERNEL);
|
||||
if (chip == NULL)
|
||||
return -ENOMEM;
|
||||
@@ -291,6 +278,7 @@ static struct i2c_driver pca953x_driver = {
|
||||
},
|
||||
.probe = pca953x_probe,
|
||||
.remove = pca953x_remove,
|
||||
.id_table = pca953x_id,
|
||||
};
|
||||
|
||||
static int __init pca953x_init(void)
|
||||
|
||||
+21
-15
@@ -26,6 +26,21 @@
|
||||
#include <asm/gpio.h>
|
||||
|
||||
|
||||
static const struct i2c_device_id pcf857x_id[] = {
|
||||
{ "pcf8574", 8 },
|
||||
{ "pca8574", 8 },
|
||||
{ "pca9670", 8 },
|
||||
{ "pca9672", 8 },
|
||||
{ "pca9674", 8 },
|
||||
{ "pcf8575", 16 },
|
||||
{ "pca8575", 16 },
|
||||
{ "pca9671", 16 },
|
||||
{ "pca9673", 16 },
|
||||
{ "pca9675", 16 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, pcf857x_id);
|
||||
|
||||
/*
|
||||
* The pcf857x, pca857x, and pca967x chips only expose one read and one
|
||||
* write register. Writing a "one" bit (to match the reset state) lets
|
||||
@@ -142,7 +157,8 @@ static void pcf857x_set16(struct gpio_chip *chip, unsigned offset, int value)
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
static int pcf857x_probe(struct i2c_client *client)
|
||||
static int pcf857x_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct pcf857x_platform_data *pdata;
|
||||
struct pcf857x *gpio;
|
||||
@@ -172,13 +188,8 @@ static int pcf857x_probe(struct i2c_client *client)
|
||||
*
|
||||
* NOTE: we don't distinguish here between *4 and *4a parts.
|
||||
*/
|
||||
if (strcmp(client->name, "pcf8574") == 0
|
||||
|| strcmp(client->name, "pca8574") == 0
|
||||
|| strcmp(client->name, "pca9670") == 0
|
||||
|| strcmp(client->name, "pca9672") == 0
|
||||
|| strcmp(client->name, "pca9674") == 0
|
||||
) {
|
||||
gpio->chip.ngpio = 8;
|
||||
gpio->chip.ngpio = id->driver_data;
|
||||
if (gpio->chip.ngpio == 8) {
|
||||
gpio->chip.direction_input = pcf857x_input8;
|
||||
gpio->chip.get = pcf857x_get8;
|
||||
gpio->chip.direction_output = pcf857x_output8;
|
||||
@@ -198,13 +209,7 @@ static int pcf857x_probe(struct i2c_client *client)
|
||||
*
|
||||
* NOTE: we don't distinguish here between '75 and '75c parts.
|
||||
*/
|
||||
} else if (strcmp(client->name, "pcf8575") == 0
|
||||
|| strcmp(client->name, "pca8575") == 0
|
||||
|| strcmp(client->name, "pca9671") == 0
|
||||
|| strcmp(client->name, "pca9673") == 0
|
||||
|| strcmp(client->name, "pca9675") == 0
|
||||
) {
|
||||
gpio->chip.ngpio = 16;
|
||||
} else if (gpio->chip.ngpio == 16) {
|
||||
gpio->chip.direction_input = pcf857x_input16;
|
||||
gpio->chip.get = pcf857x_get16;
|
||||
gpio->chip.direction_output = pcf857x_output16;
|
||||
@@ -313,6 +318,7 @@ static struct i2c_driver pcf857x_driver = {
|
||||
},
|
||||
.probe = pcf857x_probe,
|
||||
.remove = pcf857x_remove,
|
||||
.id_table = pcf857x_id,
|
||||
};
|
||||
|
||||
static int __init pcf857x_init(void)
|
||||
|
||||
+17
-12
@@ -117,7 +117,8 @@ struct f75375_data {
|
||||
static int f75375_attach_adapter(struct i2c_adapter *adapter);
|
||||
static int f75375_detect(struct i2c_adapter *adapter, int address, int kind);
|
||||
static int f75375_detach_client(struct i2c_client *client);
|
||||
static int f75375_probe(struct i2c_client *client);
|
||||
static int f75375_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id);
|
||||
static int f75375_remove(struct i2c_client *client);
|
||||
|
||||
static struct i2c_driver f75375_legacy_driver = {
|
||||
@@ -128,12 +129,20 @@ static struct i2c_driver f75375_legacy_driver = {
|
||||
.detach_client = f75375_detach_client,
|
||||
};
|
||||
|
||||
static const struct i2c_device_id f75375_id[] = {
|
||||
{ "f75373", f75373 },
|
||||
{ "f75375", f75375 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, f75375_id);
|
||||
|
||||
static struct i2c_driver f75375_driver = {
|
||||
.driver = {
|
||||
.name = "f75375",
|
||||
},
|
||||
.probe = f75375_probe,
|
||||
.remove = f75375_remove,
|
||||
.id_table = f75375_id,
|
||||
};
|
||||
|
||||
static inline int f75375_read8(struct i2c_client *client, u8 reg)
|
||||
@@ -628,7 +637,8 @@ static void f75375_init(struct i2c_client *client, struct f75375_data *data,
|
||||
|
||||
}
|
||||
|
||||
static int f75375_probe(struct i2c_client *client)
|
||||
static int f75375_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct f75375_data *data = i2c_get_clientdata(client);
|
||||
struct f75375s_platform_data *f75375s_pdata = client->dev.platform_data;
|
||||
@@ -643,15 +653,7 @@ static int f75375_probe(struct i2c_client *client)
|
||||
i2c_set_clientdata(client, data);
|
||||
data->client = client;
|
||||
mutex_init(&data->update_lock);
|
||||
|
||||
if (strcmp(client->name, "f75375") == 0)
|
||||
data->kind = f75375;
|
||||
else if (strcmp(client->name, "f75373") == 0)
|
||||
data->kind = f75373;
|
||||
else {
|
||||
dev_err(&client->dev, "Unsupported device: %s\n", client->name);
|
||||
return -ENODEV;
|
||||
}
|
||||
data->kind = id->driver_data;
|
||||
|
||||
if ((err = sysfs_create_group(&client->dev.kobj, &f75375_group)))
|
||||
goto exit_free;
|
||||
@@ -712,6 +714,7 @@ static int f75375_detect(struct i2c_adapter *adapter, int address, int kind)
|
||||
u8 version = 0;
|
||||
int err = 0;
|
||||
const char *name = "";
|
||||
struct i2c_device_id id;
|
||||
|
||||
if (!(client = kzalloc(sizeof(*client), GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
@@ -748,7 +751,9 @@ static int f75375_detect(struct i2c_adapter *adapter, int address, int kind)
|
||||
if ((err = i2c_attach_client(client)))
|
||||
goto exit_free;
|
||||
|
||||
if ((err = f75375_probe(client)) < 0)
|
||||
strlcpy(id.name, name, I2C_NAME_SIZE);
|
||||
id.driver_data = kind;
|
||||
if ((err = f75375_probe(client, &id)) < 0)
|
||||
goto exit_detach;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* i2c-amd756-s4882.c - i2c-amd756 extras for the Tyan S4882 motherboard
|
||||
*
|
||||
* Copyright (C) 2004 Jean Delvare <khali@linux-fr.org>
|
||||
* Copyright (C) 2004, 2008 Jean Delvare <khali@linux-fr.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -231,7 +231,8 @@ ERROR2:
|
||||
kfree(s4882_adapter);
|
||||
s4882_adapter = NULL;
|
||||
ERROR1:
|
||||
i2c_del_adapter(&amd756_smbus);
|
||||
/* Restore physical bus */
|
||||
i2c_add_adapter(&amd756_smbus);
|
||||
ERROR0:
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#include <linux/ioport.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/apm_bios.h>
|
||||
#include <linux/dmi.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
@@ -223,7 +222,7 @@ static int piix4_transaction(void)
|
||||
dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp);
|
||||
return -1;
|
||||
} else {
|
||||
dev_dbg(&piix4_adapter.dev, "Successfull!\n");
|
||||
dev_dbg(&piix4_adapter.dev, "Successful!\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,12 +342,7 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
|
||||
|
||||
|
||||
switch (size) {
|
||||
case PIIX4_BYTE: /* Where is the result put? I assume here it is in
|
||||
SMBHSTDAT0 but it might just as well be in the
|
||||
SMBHSTCMD. No clue in the docs */
|
||||
|
||||
data->byte = inb_p(SMBHSTDAT0);
|
||||
break;
|
||||
case PIIX4_BYTE:
|
||||
case PIIX4_BYTE_DATA:
|
||||
data->byte = inb_p(SMBHSTDAT0);
|
||||
break;
|
||||
|
||||
@@ -238,7 +238,7 @@ static int sis5595_transaction(struct i2c_adapter *adap)
|
||||
dev_dbg(&adap->dev, "Failed! (%02x)\n", temp);
|
||||
return -1;
|
||||
} else {
|
||||
dev_dbg(&adap->dev, "Successfull!\n");
|
||||
dev_dbg(&adap->dev, "Successful!\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,14 +316,8 @@ static s32 sis5595_access(struct i2c_adapter *adap, u16 addr,
|
||||
}
|
||||
size = (size == I2C_SMBUS_PROC_CALL) ? SIS5595_PROC_CALL : SIS5595_WORD_DATA;
|
||||
break;
|
||||
/*
|
||||
case I2C_SMBUS_BLOCK_DATA:
|
||||
printk(KERN_WARNING "sis5595.o: Block data not yet implemented!\n");
|
||||
return -1;
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
printk(KERN_WARNING "sis5595.o: Unsupported transaction %d\n", size);
|
||||
dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -338,9 +332,7 @@ static s32 sis5595_access(struct i2c_adapter *adap, u16 addr,
|
||||
|
||||
|
||||
switch (size) {
|
||||
case SIS5595_BYTE: /* Where is the result put? I assume here it is in
|
||||
SMB_DATA but it might just as well be in the
|
||||
SMB_CMD. No clue in the docs */
|
||||
case SIS5595_BYTE:
|
||||
case SIS5595_BYTE_DATA:
|
||||
data->byte = sis5595_read(SMB_BYTE);
|
||||
break;
|
||||
|
||||
@@ -136,7 +136,7 @@ static int sis630_transaction_start(struct i2c_adapter *adap, int size, u8 *oldc
|
||||
dev_dbg(&adap->dev, "Failed! (%02x)\n", temp);
|
||||
return -1;
|
||||
} else {
|
||||
dev_dbg(&adap->dev, "Successfull!\n");
|
||||
dev_dbg(&adap->dev, "Successful!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
static unsigned short chip_addr[MAX_CHIPS];
|
||||
module_param_array(chip_addr, ushort, NULL, S_IRUGO);
|
||||
MODULE_PARM_DESC(chip_addr,
|
||||
"Chip addresses (up to 10, between 0x03 and 0x77)\n");
|
||||
"Chip addresses (up to 10, between 0x03 and 0x77)");
|
||||
|
||||
struct stub_chip {
|
||||
u8 pointer;
|
||||
|
||||
@@ -51,7 +51,6 @@ struct taos_data {
|
||||
/* TAOS TSL2550 EVM */
|
||||
static struct i2c_board_info tsl2550_info = {
|
||||
I2C_BOARD_INFO("tsl2550", 0x39),
|
||||
.type = "tsl2550",
|
||||
};
|
||||
|
||||
/* Instantiate i2c devices based on the adapter name */
|
||||
@@ -59,7 +58,7 @@ static struct i2c_client *taos_instantiate_device(struct i2c_adapter *adapter)
|
||||
{
|
||||
if (!strncmp(adapter->name, "TAOS TSL2550 EVM", 16)) {
|
||||
dev_info(&adapter->dev, "Instantiating device %s at 0x%02x\n",
|
||||
tsl2550_info.driver_name, tsl2550_info.addr);
|
||||
tsl2550_info.type, tsl2550_info.addr);
|
||||
return i2c_new_device(adapter, &tsl2550_info);
|
||||
}
|
||||
|
||||
|
||||
@@ -200,7 +200,8 @@ static struct bin_attribute ds1682_eeprom_attr = {
|
||||
/*
|
||||
* Called when a ds1682 device is matched with this driver
|
||||
*/
|
||||
static int ds1682_probe(struct i2c_client *client)
|
||||
static int ds1682_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
int rc;
|
||||
|
||||
@@ -234,12 +235,19 @@ static int ds1682_remove(struct i2c_client *client)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id ds1682_id[] = {
|
||||
{ "ds1682", 0 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, ds1682_id);
|
||||
|
||||
static struct i2c_driver ds1682_driver = {
|
||||
.driver = {
|
||||
.name = "ds1682",
|
||||
},
|
||||
.probe = ds1682_probe,
|
||||
.remove = ds1682_remove,
|
||||
.id_table = ds1682_id,
|
||||
};
|
||||
|
||||
static int __init ds1682_init(void)
|
||||
|
||||
@@ -1149,7 +1149,8 @@ static inline void menelaus_rtc_init(struct menelaus_chip *m)
|
||||
|
||||
static struct i2c_driver menelaus_i2c_driver;
|
||||
|
||||
static int menelaus_probe(struct i2c_client *client)
|
||||
static int menelaus_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct menelaus_chip *menelaus;
|
||||
int rev = 0, val;
|
||||
@@ -1242,12 +1243,19 @@ static int __exit menelaus_remove(struct i2c_client *client)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id menelaus_id[] = {
|
||||
{ "menelaus", 0 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, menelaus_id);
|
||||
|
||||
static struct i2c_driver menelaus_i2c_driver = {
|
||||
.driver = {
|
||||
.name = DRIVER_NAME,
|
||||
},
|
||||
.probe = menelaus_probe,
|
||||
.remove = __exit_p(menelaus_remove),
|
||||
.id_table = menelaus_id,
|
||||
};
|
||||
|
||||
static int __init menelaus_init(void)
|
||||
|
||||
@@ -64,7 +64,6 @@ static struct i2c_driver tps65010_driver;
|
||||
* as part of board setup by a bootloader.
|
||||
*/
|
||||
enum tps_model {
|
||||
TPS_UNKNOWN = 0,
|
||||
TPS65010,
|
||||
TPS65011,
|
||||
TPS65012,
|
||||
@@ -527,11 +526,13 @@ static int __exit tps65010_remove(struct i2c_client *client)
|
||||
flush_scheduled_work();
|
||||
debugfs_remove(tps->file);
|
||||
kfree(tps);
|
||||
i2c_set_clientdata(client, NULL);
|
||||
the_tps = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tps65010_probe(struct i2c_client *client)
|
||||
static int tps65010_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct tps65010 *tps;
|
||||
int status;
|
||||
@@ -552,20 +553,7 @@ static int tps65010_probe(struct i2c_client *client)
|
||||
mutex_init(&tps->lock);
|
||||
INIT_DELAYED_WORK(&tps->work, tps65010_work);
|
||||
tps->client = client;
|
||||
|
||||
if (strcmp(client->name, "tps65010") == 0)
|
||||
tps->model = TPS65010;
|
||||
else if (strcmp(client->name, "tps65011") == 0)
|
||||
tps->model = TPS65011;
|
||||
else if (strcmp(client->name, "tps65012") == 0)
|
||||
tps->model = TPS65012;
|
||||
else if (strcmp(client->name, "tps65013") == 0)
|
||||
tps->model = TPS65013;
|
||||
else {
|
||||
dev_warn(&client->dev, "unknown chip '%s'\n", client->name);
|
||||
status = -ENODEV;
|
||||
goto fail1;
|
||||
}
|
||||
tps->model = id->driver_data;
|
||||
|
||||
/* the IRQ is active low, but many gpio lines can't support that
|
||||
* so this driver uses falling-edge triggers instead.
|
||||
@@ -594,9 +582,6 @@ static int tps65010_probe(struct i2c_client *client)
|
||||
case TPS65012:
|
||||
tps->por = 1;
|
||||
break;
|
||||
case TPS_UNKNOWN:
|
||||
printk(KERN_WARNING "%s: unknown TPS chip\n", DRIVER_NAME);
|
||||
break;
|
||||
/* else CHGCONFIG.POR is replaced by AUA, enabling a WAIT mode */
|
||||
}
|
||||
tps->chgconf = i2c_smbus_read_byte_data(client, TPS_CHGCONFIG);
|
||||
@@ -615,6 +600,7 @@ static int tps65010_probe(struct i2c_client *client)
|
||||
i2c_smbus_read_byte_data(client, TPS_DEFGPIO),
|
||||
i2c_smbus_read_byte_data(client, TPS_MASK3));
|
||||
|
||||
i2c_set_clientdata(client, tps);
|
||||
the_tps = tps;
|
||||
|
||||
#if defined(CONFIG_USB_GADGET) && !defined(CONFIG_USB_OTG)
|
||||
@@ -682,12 +668,22 @@ fail1:
|
||||
return status;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id tps65010_id[] = {
|
||||
{ "tps65010", TPS65010 },
|
||||
{ "tps65011", TPS65011 },
|
||||
{ "tps65012", TPS65012 },
|
||||
{ "tps65013", TPS65013 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, tps65010_id);
|
||||
|
||||
static struct i2c_driver tps65010_driver = {
|
||||
.driver = {
|
||||
.name = "tps65010",
|
||||
},
|
||||
.probe = tps65010_probe,
|
||||
.remove = __exit_p(tps65010_remove),
|
||||
.id_table = tps65010_id,
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
@@ -364,7 +364,8 @@ static int tsl2550_init_client(struct i2c_client *client)
|
||||
*/
|
||||
|
||||
static struct i2c_driver tsl2550_driver;
|
||||
static int __devinit tsl2550_probe(struct i2c_client *client)
|
||||
static int __devinit tsl2550_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
|
||||
struct tsl2550_data *data;
|
||||
@@ -451,6 +452,12 @@ static int tsl2550_resume(struct i2c_client *client)
|
||||
|
||||
#endif /* CONFIG_PM */
|
||||
|
||||
static const struct i2c_device_id tsl2550_id[] = {
|
||||
{ "tsl2550", 0 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, tsl2550_id);
|
||||
|
||||
static struct i2c_driver tsl2550_driver = {
|
||||
.driver = {
|
||||
.name = TSL2550_DRV_NAME,
|
||||
@@ -460,6 +467,7 @@ static struct i2c_driver tsl2550_driver = {
|
||||
.resume = tsl2550_resume,
|
||||
.probe = tsl2550_probe,
|
||||
.remove = __devexit_p(tsl2550_remove),
|
||||
.id_table = tsl2550_id,
|
||||
};
|
||||
|
||||
static int __init tsl2550_init(void)
|
||||
|
||||
+42
-9
@@ -48,6 +48,17 @@ static DEFINE_IDR(i2c_adapter_idr);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id,
|
||||
const struct i2c_client *client)
|
||||
{
|
||||
while (id->name[0]) {
|
||||
if (strcmp(client->name, id->name) == 0)
|
||||
return id;
|
||||
id++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int i2c_device_match(struct device *dev, struct device_driver *drv)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
@@ -59,6 +70,10 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv)
|
||||
if (!is_newstyle_driver(driver))
|
||||
return 0;
|
||||
|
||||
/* match on an id table if there is one */
|
||||
if (driver->id_table)
|
||||
return i2c_match_id(driver->id_table, client) != NULL;
|
||||
|
||||
/* new style drivers use the same kind of driver matching policy
|
||||
* as platform devices or SPI: compare device and driver IDs.
|
||||
*/
|
||||
@@ -73,11 +88,17 @@ static int i2c_device_uevent(struct device *dev, struct kobj_uevent_env *env)
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
|
||||
/* by definition, legacy drivers can't hotplug */
|
||||
if (dev->driver || !client->driver_name)
|
||||
if (dev->driver)
|
||||
return 0;
|
||||
|
||||
if (add_uevent_var(env, "MODALIAS=%s", client->driver_name))
|
||||
return -ENOMEM;
|
||||
if (client->driver_name[0]) {
|
||||
if (add_uevent_var(env, "MODALIAS=%s", client->driver_name))
|
||||
return -ENOMEM;
|
||||
} else {
|
||||
if (add_uevent_var(env, "MODALIAS=%s%s",
|
||||
I2C_MODULE_PREFIX, client->name))
|
||||
return -ENOMEM;
|
||||
}
|
||||
dev_dbg(dev, "uevent\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -90,13 +111,19 @@ static int i2c_device_probe(struct device *dev)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct i2c_driver *driver = to_i2c_driver(dev->driver);
|
||||
const struct i2c_device_id *id;
|
||||
int status;
|
||||
|
||||
if (!driver->probe)
|
||||
return -ENODEV;
|
||||
client->driver = driver;
|
||||
dev_dbg(dev, "probe\n");
|
||||
status = driver->probe(client);
|
||||
|
||||
if (driver->id_table)
|
||||
id = i2c_match_id(driver->id_table, client);
|
||||
else
|
||||
id = NULL;
|
||||
status = driver->probe(client, id);
|
||||
if (status)
|
||||
client->driver = NULL;
|
||||
return status;
|
||||
@@ -179,9 +206,9 @@ static ssize_t show_client_name(struct device *dev, struct device_attribute *att
|
||||
static ssize_t show_modalias(struct device *dev, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
return client->driver_name
|
||||
return client->driver_name[0]
|
||||
? sprintf(buf, "%s\n", client->driver_name)
|
||||
: 0;
|
||||
: sprintf(buf, "%s%s\n", I2C_MODULE_PREFIX, client->name);
|
||||
}
|
||||
|
||||
static struct device_attribute i2c_dev_attrs[] = {
|
||||
@@ -300,15 +327,21 @@ void i2c_unregister_device(struct i2c_client *client)
|
||||
EXPORT_SYMBOL_GPL(i2c_unregister_device);
|
||||
|
||||
|
||||
static int dummy_nop(struct i2c_client *client)
|
||||
static int dummy_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dummy_remove(struct i2c_client *client)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct i2c_driver dummy_driver = {
|
||||
.driver.name = "dummy",
|
||||
.probe = dummy_nop,
|
||||
.remove = dummy_nop,
|
||||
.probe = dummy_probe,
|
||||
.remove = dummy_remove,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -142,7 +142,8 @@ static int cs5345_command(struct i2c_client *client, unsigned cmd, void *arg)
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
static int cs5345_probe(struct i2c_client *client)
|
||||
static int cs5345_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
/* Check if the adapter supports the needed features */
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
|
||||
|
||||
@@ -135,7 +135,8 @@ static int cs53l32a_command(struct i2c_client *client, unsigned cmd, void *arg)
|
||||
* concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1'
|
||||
*/
|
||||
|
||||
static int cs53l32a_probe(struct i2c_client *client)
|
||||
static int cs53l32a_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
@@ -1209,7 +1209,8 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
static int cx25840_probe(struct i2c_client *client)
|
||||
static int cx25840_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *did)
|
||||
{
|
||||
struct cx25840_state *state;
|
||||
u32 id;
|
||||
|
||||
@@ -126,7 +126,8 @@ static int m52790_command(struct i2c_client *client, unsigned int cmd,
|
||||
|
||||
/* i2c implementation */
|
||||
|
||||
static int m52790_probe(struct i2c_client *client)
|
||||
static int m52790_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct m52790_state *state;
|
||||
|
||||
|
||||
@@ -805,7 +805,7 @@ static int msp_resume(struct i2c_client *client)
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
static int msp_probe(struct i2c_client *client)
|
||||
static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
{
|
||||
struct msp_state *state;
|
||||
int (*thread_func)(void *data) = NULL;
|
||||
|
||||
@@ -620,7 +620,8 @@ static void mt9m001_video_remove(struct soc_camera_device *icd)
|
||||
soc_camera_video_stop(&mt9m001->icd);
|
||||
}
|
||||
|
||||
static int mt9m001_probe(struct i2c_client *client)
|
||||
static int mt9m001_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *did)
|
||||
{
|
||||
struct mt9m001 *mt9m001;
|
||||
struct soc_camera_device *icd;
|
||||
@@ -696,12 +697,19 @@ static int mt9m001_remove(struct i2c_client *client)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id mt9m001_id[] = {
|
||||
{ "mt9m001", 0 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, mt9m001_id);
|
||||
|
||||
static struct i2c_driver mt9m001_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "mt9m001",
|
||||
},
|
||||
.probe = mt9m001_probe,
|
||||
.remove = mt9m001_remove,
|
||||
.id_table = mt9m001_id,
|
||||
};
|
||||
|
||||
static int __init mt9m001_mod_init(void)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user