Merge branch 'for-next/modalias'
This commit is contained in:
commit
98615784a6
|
@ -71,3 +71,40 @@ int device_match(struct device_d *dev, struct driver_d *drv)
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int device_match_of_modalias(struct device_d *dev, struct driver_d *drv)
|
||||||
|
{
|
||||||
|
struct platform_device_id *id = drv->id_table;
|
||||||
|
const char *of_modalias = NULL, *p;
|
||||||
|
int cplen;
|
||||||
|
const char *compat;
|
||||||
|
|
||||||
|
if (!device_match(dev, drv))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!id || !IS_ENABLED(CONFIG_OFDEVICE) || !dev->device_node)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
compat = of_get_property(dev->device_node, "compatible", &cplen);
|
||||||
|
if (!compat)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
p = strchr(compat, ',');
|
||||||
|
of_modalias = p ? p + 1 : compat;
|
||||||
|
|
||||||
|
while (id->name) {
|
||||||
|
if (!strcmp(id->name, dev->name)) {
|
||||||
|
dev->id_entry = id;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (of_modalias && !strcmp(id->name, of_modalias)) {
|
||||||
|
dev->id_entry = id;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
id++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
|
@ -466,7 +466,7 @@ static void i2c_remove(struct device_d *dev)
|
||||||
|
|
||||||
struct bus_type i2c_bus = {
|
struct bus_type i2c_bus = {
|
||||||
.name = "i2c",
|
.name = "i2c",
|
||||||
.match = device_match,
|
.match = device_match_of_modalias,
|
||||||
.probe = i2c_probe,
|
.probe = i2c_probe,
|
||||||
.remove = i2c_remove,
|
.remove = i2c_remove,
|
||||||
};
|
};
|
||||||
|
|
|
@ -73,11 +73,6 @@
|
||||||
|
|
||||||
#define SPI_NAME_SIZE 32
|
#define SPI_NAME_SIZE 32
|
||||||
|
|
||||||
struct spi_device_id {
|
|
||||||
char name[SPI_NAME_SIZE];
|
|
||||||
unsigned long driver_data;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct m25p {
|
struct m25p {
|
||||||
struct spi_device *spi;
|
struct spi_device *spi;
|
||||||
struct mtd_info mtd;
|
struct mtd_info mtd;
|
||||||
|
@ -618,7 +613,7 @@ struct flash_info {
|
||||||
* more flash chips. This current list focusses on newer chips, which
|
* more flash chips. This current list focusses on newer chips, which
|
||||||
* have been converging on command sets which including JEDEC ID.
|
* have been converging on command sets which including JEDEC ID.
|
||||||
*/
|
*/
|
||||||
static const struct spi_device_id m25p_ids[] = {
|
static const struct platform_device_id m25p_ids[] = {
|
||||||
/* Atmel -- some are (confusingly) marketed as "DataFlash" */
|
/* Atmel -- some are (confusingly) marketed as "DataFlash" */
|
||||||
{ "at25fs010", INFO(0x1f6601, 0, 32 * 1024, 4, SECT_4K) },
|
{ "at25fs010", INFO(0x1f6601, 0, 32 * 1024, 4, SECT_4K) },
|
||||||
{ "at25fs040", INFO(0x1f6604, 0, 64 * 1024, 8, SECT_4K) },
|
{ "at25fs040", INFO(0x1f6604, 0, 64 * 1024, 8, SECT_4K) },
|
||||||
|
@ -755,7 +750,7 @@ static const struct spi_device_id m25p_ids[] = {
|
||||||
{ },
|
{ },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct spi_device_id *jedec_probe(struct spi_device *spi)
|
static const struct platform_device_id *jedec_probe(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
int tmp;
|
int tmp;
|
||||||
u8 code = OPCODE_RDID;
|
u8 code = OPCODE_RDID;
|
||||||
|
@ -803,13 +798,14 @@ static const struct spi_device_id *jedec_probe(struct spi_device *spi)
|
||||||
static int m25p_probe(struct device_d *dev)
|
static int m25p_probe(struct device_d *dev)
|
||||||
{
|
{
|
||||||
struct spi_device *spi = (struct spi_device *)dev->type_data;
|
struct spi_device *spi = (struct spi_device *)dev->type_data;
|
||||||
const struct spi_device_id *id = NULL;
|
const struct platform_device_id *id = NULL;
|
||||||
struct flash_platform_data *data;
|
struct flash_platform_data *data;
|
||||||
struct m25p *flash;
|
struct m25p *flash;
|
||||||
struct flash_info *info = NULL;
|
struct flash_info *info = NULL;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
unsigned do_jdec_probe = 1;
|
unsigned do_jdec_probe = 1;
|
||||||
char *flashname = NULL;
|
char *flashname = NULL;
|
||||||
|
const char *typename = NULL;
|
||||||
int device_id;
|
int device_id;
|
||||||
|
|
||||||
/* Platform data helps sort out which chip type we have, as
|
/* Platform data helps sort out which chip type we have, as
|
||||||
|
@ -818,12 +814,17 @@ static int m25p_probe(struct device_d *dev)
|
||||||
* newer chips, even if we don't recognize the particular chip.
|
* newer chips, even if we don't recognize the particular chip.
|
||||||
*/
|
*/
|
||||||
data = dev->platform_data;
|
data = dev->platform_data;
|
||||||
if (data && data->type) {
|
if (data && data->type)
|
||||||
const struct spi_device_id *plat_id;
|
typename = data->type;
|
||||||
|
else if (dev->id_entry)
|
||||||
|
typename = dev->id_entry->name;
|
||||||
|
|
||||||
|
if (typename) {
|
||||||
|
const struct platform_device_id *plat_id;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(m25p_ids) - 1; i++) {
|
for (i = 0; i < ARRAY_SIZE(m25p_ids) - 1; i++) {
|
||||||
plat_id = &m25p_ids[i];
|
plat_id = &m25p_ids[i];
|
||||||
if (strcmp(data->type, plat_id->name))
|
if (strcmp(typename, plat_id->name))
|
||||||
continue;
|
continue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -836,11 +837,11 @@ static int m25p_probe(struct device_d *dev)
|
||||||
if (!info->jedec_id)
|
if (!info->jedec_id)
|
||||||
do_jdec_probe = 0;
|
do_jdec_probe = 0;
|
||||||
} else
|
} else
|
||||||
dev_warn(&spi->dev, "unrecognized id %s\n", data->type);
|
dev_warn(&spi->dev, "unrecognized id %s\n", typename);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_jdec_probe) {
|
if (do_jdec_probe) {
|
||||||
const struct spi_device_id *jid;
|
const struct platform_device_id *jid;
|
||||||
|
|
||||||
jid = jedec_probe(spi);
|
jid = jedec_probe(spi);
|
||||||
if (IS_ERR(jid)) {
|
if (IS_ERR(jid)) {
|
||||||
|
@ -969,6 +970,7 @@ static struct driver_d m25p80_driver = {
|
||||||
.name = "m25p80",
|
.name = "m25p80",
|
||||||
.probe = m25p_probe,
|
.probe = m25p_probe,
|
||||||
.of_compatible = DRV_OF_COMPAT(m25p80_dt_ids),
|
.of_compatible = DRV_OF_COMPAT(m25p80_dt_ids),
|
||||||
|
.id_table = (struct platform_device_id *)m25p_ids,
|
||||||
};
|
};
|
||||||
device_spi_driver(m25p80_driver);
|
device_spi_driver(m25p80_driver);
|
||||||
|
|
||||||
|
|
|
@ -316,7 +316,7 @@ static void spi_remove(struct device_d *dev)
|
||||||
|
|
||||||
struct bus_type spi_bus = {
|
struct bus_type spi_bus = {
|
||||||
.name = "spi",
|
.name = "spi",
|
||||||
.match = device_match,
|
.match = device_match_of_modalias,
|
||||||
.probe = spi_probe,
|
.probe = spi_probe,
|
||||||
.remove = spi_remove,
|
.remove = spi_remove,
|
||||||
};
|
};
|
||||||
|
|
|
@ -496,5 +496,6 @@ int devfs_del_partition(const char *name);
|
||||||
|
|
||||||
int dev_get_drvdata(struct device_d *dev, unsigned long *data);
|
int dev_get_drvdata(struct device_d *dev, unsigned long *data);
|
||||||
|
|
||||||
#endif /* DRIVER_H */
|
int device_match_of_modalias(struct device_d *dev, struct driver_d *drv);
|
||||||
|
|
||||||
|
#endif /* DRIVER_H */
|
||||||
|
|
Loading…
Reference in New Issue