spi_new_device(struct spi_master *master, struct spi_board_info *chip)
{
struct spi_device *proxy;
- struct device *dev = &master->dev;
+ struct device *dev = master->cdev.dev;
int status;
/* NOTE: caller did any chip->bus_num checks necessary */
proxy->modalias = chip->modalias;
snprintf(proxy->dev.bus_id, sizeof proxy->dev.bus_id,
- "%s.%u", master->dev.bus_id,
+ "%s.%u", master->cdev.class_id,
chip->chip_select);
proxy->dev.parent = dev;
proxy->dev.bus = &spi_bus_type;
scan_boardinfo(struct spi_master *master)
{
struct boardinfo *bi;
- struct device *dev = master->dev.parent;
+ struct device *dev = master->cdev.dev;
down(&board_lock);
list_for_each_entry(bi, &board_list, list) {
/*-------------------------------------------------------------------------*/
-static void spi_master_release(struct device *dev)
+static void spi_master_release(struct class_device *cdev)
{
struct spi_master *master;
- master = container_of(dev, struct spi_master, dev);
+ master = container_of(cdev, struct spi_master, cdev);
kfree(master);
}
static struct class spi_master_class = {
.name = "spi_master",
.owner = THIS_MODULE,
- .dev_release = spi_master_release,
+ .release = spi_master_release,
};
if (!master)
return NULL;
- device_initialize(&master->dev);
- master->dev.class = &spi_master_class;
- master->dev.parent = get_device(dev);
+ class_device_initialize(&master->cdev);
+ master->cdev.class = &spi_master_class;
+ master->cdev.dev = get_device(dev);
spi_master_set_devdata(master, &master[1]);
return master;
spi_register_master(struct spi_master *master)
{
static atomic_t dyn_bus_id = ATOMIC_INIT((1<<16) - 1);
- struct device *dev = master->dev.parent;
+ struct device *dev = master->cdev.dev;
int status = -ENODEV;
int dynamic = 0;
/* register the device, then userspace will see it.
* registration fails if the bus ID is in use.
*/
- snprintf(master->dev.bus_id, sizeof master->dev.bus_id,
+ snprintf(master->cdev.class_id, sizeof master->cdev.class_id,
"spi%u", master->bus_num);
- status = device_add(&master->dev);
+ status = class_device_add(&master->cdev);
if (status < 0)
goto done;
- dev_dbg(dev, "registered master %s%s\n", master->dev.bus_id,
+ dev_dbg(dev, "registered master %s%s\n", master->cdev.class_id,
dynamic ? " (dynamic)" : "");
/* populate children from any spi device tables */
{
int dummy;
- dummy = device_for_each_child(&master->dev, NULL, __unregister);
- device_unregister(&master->dev);
+ dummy = device_for_each_child(master->cdev.dev, NULL, __unregister);
+ class_device_unregister(&master->cdev);
}
EXPORT_SYMBOL_GPL(spi_unregister_master);
down(&spi_master_class.sem);
list_for_each_entry(cdev, &spi_master_class.children, node) {
- m = container_of(cdev, struct spi_master, dev.kobj);
+ m = container_of(cdev, struct spi_master, cdev);
if (m->bus_num == bus_num) {
master = spi_master_get(m);
break;
/* this task is the only thing to touch the SPI bits */
bitbang->busy = 0;
bitbang->workqueue = create_singlethread_workqueue(
- bitbang->master->dev.parent->bus_id);
+ bitbang->master->cdev.dev->bus_id);
if (bitbang->workqueue == NULL) {
status = -EBUSY;
goto err1;
while (!list_empty(&bitbang->queue) && limit--) {
spin_unlock_irq(&bitbang->lock);
- dev_dbg(&bitbang->master->dev, "wait for queue\n");
+ dev_dbg(bitbang->master->cdev.dev, "wait for queue\n");
msleep(10);
spin_lock_irq(&bitbang->lock);
}
spin_unlock_irq(&bitbang->lock);
if (!list_empty(&bitbang->queue)) {
- dev_err(&bitbang->master->dev, "queue didn't empty\n");
+ dev_err(bitbang->master->cdev.dev, "queue didn't empty\n");
return -EBUSY;
}
* message's completion function when the transaction completes.
*/
struct spi_master {
- struct device dev;
+ struct class_device cdev;
/* other than negative (== assign one dynamically), bus_num is fully
* board-specific. usually that simplifies to being SOC-specific.
static inline void *spi_master_get_devdata(struct spi_master *master)
{
- return dev_get_drvdata(&master->dev);
+ return class_get_devdata(&master->cdev);
}
static inline void spi_master_set_devdata(struct spi_master *master, void *data)
{
- dev_set_drvdata(&master->dev, data);
+ class_set_devdata(&master->cdev, data);
}
static inline struct spi_master *spi_master_get(struct spi_master *master)
{
- if (!master || !get_device(&master->dev))
+ if (!master || !class_device_get(&master->cdev))
return NULL;
return master;
}
static inline void spi_master_put(struct spi_master *master)
{
if (master)
- put_device(&master->dev);
+ class_device_put(&master->cdev);
}