Source
/*
* DIO Driver Services
*
* Copyright (C) 2004 Jochen Friedrich
*
* Loosely based on drivers/pci/pci-driver.c and drivers/zorro/zorro-driver.c
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive
* for more details.
*/
/**
* dio_match_device - Tell if a DIO device structure has a matching DIO device id structure
* @ids: array of DIO device id structures to search in
* @d: the DIO device structure to match against
*
* Used by a driver to check whether a DIO device present in the
* system is in its list of supported devices. Returns the matching
* dio_device_id structure or %NULL if there is no match.
*/
const struct dio_device_id *
dio_match_device(const struct dio_device_id *ids,
const struct dio_dev *d)
{
while (ids->id) {
if (ids->id == DIO_WILDCARD)
return ids;
if (DIO_NEEDSSECID(ids->id & 0xff)) {
if (ids->id == d->id)
return ids;
} else {
if ((ids->id & 0xff) == (d->id & 0xff))
return ids;
}
ids++;
}
return NULL;
}
static int dio_device_probe(struct device *dev)
{
int error = 0;
struct dio_driver *drv = to_dio_driver(dev->driver);
struct dio_dev *d = to_dio_dev(dev);
if (!d->driver && drv->probe) {
const struct dio_device_id *id;
id = dio_match_device(drv->id_table, d);
if (id)
error = drv->probe(d, id);
if (error >= 0) {
d->driver = drv;
error = 0;
}
}