Skip to content

Commit

Permalink
[CORE] vmm_devdrv: Rename 'node' member of struct vmm_device to 'of_n…
Browse files Browse the repository at this point in the history
…ode'

This patch renames 'node' member of struct vmm_device to 'of_node'. This
is yet another step to bring our device driver model closer to Linux
device driver model thereby further helping in device driver porting.

Signed-off-by: Anup Patel <[email protected]>
  • Loading branch information
avpatel committed Jan 12, 2016
1 parent 8fc7837 commit 3a79542
Show file tree
Hide file tree
Showing 62 changed files with 310 additions and 292 deletions.
6 changes: 3 additions & 3 deletions arch/arm/board/common/versatile/clcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 160,11 @@ int versatile_clcd_setup_dma(struct clcd_fb *fb, unsigned long framesize)
unsigned long smem_len;
physical_addr_t smem_pa;

if (!fb->dev->node) {
if (!fb->dev->of_node) {
return VMM_EINVALID;
}

if (vmm_devtree_read_u32(fb->dev->node, "use_dma", &use_dma)) {
if (vmm_devtree_read_u32(fb->dev->of_node, "use_dma", &use_dma)) {
use_dma = 0;
}

Expand All @@ -184,7 184,7 @@ int versatile_clcd_setup_dma(struct clcd_fb *fb, unsigned long framesize)
return rc;
}
} else {
rc = vmm_devtree_read_u32_array(fb->dev->node,
rc = vmm_devtree_read_u32_array(fb->dev->of_node,
"framebuffer", val, 2);
if (rc) {
return rc;
Expand Down
4 changes: 2 additions & 2 deletions commands/cmd_chardev.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 49,9 @@ static int cmd_chardev_list_iter(struct vmm_chardev *cd, void *data)
char path[256];
struct vmm_chardev *cdev = data;

if (cd->dev.parent && cd->dev.parent->node) {
if (cd->dev.parent && cd->dev.parent->of_node) {
rc = vmm_devtree_getpath(path, sizeof(path),
cd->dev.parent->node);
cd->dev.parent->of_node);
if (rc) {
vmm_snprintf(path, sizeof(path),
"----- (error %d)", rc);
Expand Down
4 changes: 2 additions & 2 deletions commands/cmd_fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 56,9 @@ static int cmd_fb_list_iter(struct fb_info *info, void *data)
char path[256];
struct vmm_chardev *cdev = data;

if (info->dev.parent && info->dev.parent->node) {
if (info->dev.parent && info->dev.parent->of_node) {
rc = vmm_devtree_getpath(path, sizeof(path),
info->dev.parent->node);
info->dev.parent->of_node);
if (rc) {
vmm_snprintf(path, sizeof(path),
"----- (error %d)", rc);
Expand Down
4 changes: 2 additions & 2 deletions commands/cmd_rtcdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 64,9 @@ static int cmd_rtcdev_list_iter(struct rtc_device *rd, void *data)
char path[256];
struct vmm_chardev *cdev = data;

if (rd->dev.parent && rd->dev.parent->node) {
if (rd->dev.parent && rd->dev.parent->of_node) {
rc = vmm_devtree_getpath(path, sizeof(path),
rd->dev.parent->node);
rd->dev.parent->of_node);
if (rc) {
vmm_snprintf(path, sizeof(path),
"----- (error %d)", rc);
Expand Down
2 changes: 1 addition & 1 deletion core/include/vmm_devdrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 91,7 @@ struct vmm_device {
bool autoprobe_disabled;
struct vmm_bus *bus;
struct vmm_device_type *type;
struct vmm_devtree_node *node;
struct vmm_devtree_node *of_node;
struct vmm_device *parent;
struct vmm_class *class;
struct vmm_driver *driver;
Expand Down
20 changes: 10 additions & 10 deletions core/vmm_devdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 137,19 @@ static int platform_bus_match(struct vmm_device *dev, struct vmm_driver *drv)
{
const struct vmm_devtree_nodeid *match;

if (!dev || !dev->node || !drv || !drv->match_table) {
if (!dev || !dev->of_node || !drv || !drv->match_table) {
return 0;
}

if (!vmm_devtree_is_available(dev->node)) {
if (!vmm_devtree_is_available(dev->of_node)) {
return 0;
}

if (dev->parent && (dev->node == dev->parent->node)) {
if (dev->parent && (dev->of_node == dev->parent->of_node)) {
return 0;
}

match = vmm_devtree_match_node(drv->match_table, dev->node);
match = vmm_devtree_match_node(drv->match_table, dev->of_node);
if (!match) {
return 0;
}
Expand All @@ -170,7 170,7 @@ static int platform_bus_probe(struct vmm_device *dev)
struct vmm_driver *drv;
const struct vmm_devtree_nodeid *match;

if (!dev || !dev->node || !dev->driver) {
if (!dev || !dev->of_node || !dev->driver) {
return VMM_EFAIL;
}
drv = dev->driver;
Expand All @@ -184,7 184,7 @@ static int platform_bus_probe(struct vmm_device *dev)
return rc;
}

match = vmm_devtree_match_node(drv->match_table, dev->node);
match = vmm_devtree_match_node(drv->match_table, dev->of_node);
if (match) {
return drv->probe(dev, match);
}
Expand All @@ -196,7 196,7 @@ static int platform_bus_remove(struct vmm_device *dev)
{
struct vmm_driver *drv;

if (!dev || !dev->node || !dev->driver) {
if (!dev || !dev->of_node || !dev->driver) {
return VMM_EFAIL;
}
drv = dev->driver;
Expand All @@ -206,8 206,8 @@ static int platform_bus_remove(struct vmm_device *dev)

static void platform_device_release(struct vmm_device *dev)
{
vmm_devtree_dref_node(dev->node);
dev->node = NULL;
vmm_devtree_dref_node(dev->of_node);
dev->of_node = NULL;
vmm_free(dev);
}

Expand Down Expand Up @@ -513,7 513,7 @@ static int devdrv_probe(struct vmm_devtree_node *node,
return VMM_EOVERFLOW;
}
vmm_devtree_ref_node(node);
dev->node = node;
dev->of_node = node;
dev->parent = parent;
dev->bus = &ddctrl.platform_bus;
dev->release = platform_device_release;
Expand Down
4 changes: 2 additions & 2 deletions drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 298,12 @@ static int rbd_driver_probe(struct vmm_device *dev,
physical_addr_t pa;
physical_size_t sz;

rc = vmm_devtree_regaddr(dev->node, &pa, 0);
rc = vmm_devtree_regaddr(dev->of_node, &pa, 0);
if (rc) {
return rc;
}

rc = vmm_devtree_regsize(dev->node, &sz, 0);
rc = vmm_devtree_regsize(dev->of_node, &sz, 0);
if (rc) {
return rc;
}
Expand Down
4 changes: 0 additions & 4 deletions drivers/clk/clkdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 181,7 @@ struct clk *clk_get(struct device *dev, const char *con_id)
struct clk *clk;

if (dev) {
#if 0
clk = of_clk_get_by_name(dev->of_node, con_id);
#else
clk = of_clk_get_by_name(dev->node, con_id);
#endif
if (!IS_ERR(clk))
return clk;
if (PTR_ERR(clk) == -EPROBE_DEFER)
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpio/gpio-mxc.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 422,7 @@ static int __init mxc_gpio_init_gc(struct mxc_gpio_port *port,
gc->irq_unmask = irq_gc_mask_set_bit;
gc->irq_set_type = gpio_set_irq_type;

port->domain = vmm_host_irqdomain_add(dev->node, -1, sz,
port->domain = vmm_host_irqdomain_add(dev->of_node, -1, sz,
&irqdomain_simple_ops, port);
if (!port->domain)
return VMM_ENOTAVAIL;
Expand Down Expand Up @@ -486,7 486,7 @@ static int mxc_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
static int mxc_gpio_probe(struct vmm_device *dev,
const struct vmm_devtree_nodeid *devid)
{
struct device_node *np = dev->node;
struct device_node *np = dev->of_node;
struct mxc_gpio_port *port;
int err = VMM_OK;
int port_num = 0;
Expand Down Expand Up @@ -514,7 514,7 @@ static int mxc_gpio_probe(struct vmm_device *dev,
}

name = vmm_malloc(PORT_NAME_LEN);
port_num = vmm_devtree_alias_get_id(dev->node, "gpio");
port_num = vmm_devtree_alias_get_id(dev->of_node, "gpio");
snprintf(name, PORT_NAME_LEN, "gpio_mxc%d", port_num);

/* disable the interrupt and clear the status */
Expand Down
4 changes: 0 additions & 4 deletions drivers/gpio/gpiolib-of.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 334,7 @@ static void of_gpiochip_add_pin_range(struct gpio_chip *chip) {}
void of_gpiochip_add(struct gpio_chip *chip)
{
if ((!chip->of_node) && (chip->dev))
#if 0
chip->of_node = chip->dev->of_node;
#else
chip->of_node = chip->dev->node;
#endif

if (!chip->of_node)
return;
Expand Down
8 changes: 0 additions & 8 deletions drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1503,11 1503,7 @@ static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
else
snprintf(prop_name, 32, "%s", suffixes[i]);

#if 0
desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx,
#else
desc = of_get_named_gpiod_flags(dev->node, prop_name, idx,
#endif
&of_flags);
if (!IS_ERR(desc) || (PTR_ERR(desc) == -EPROBE_DEFER))
break;
Expand Down Expand Up @@ -1678,11 1674,7 @@ struct gpio_desc *__must_check __gpiod_get_index(struct device *dev,
dev_dbg(dev, "GPIO lookup for consumer %s\n", con_id);

/* Using device tree? */
#if 0
if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node) {
#else
if (IS_ENABLED(CONFIG_OF) && dev && dev->node) {
#endif
dev_dbg(dev, "using device tree for GPIO lookup\n");
desc = of_find_gpio(dev, con_id, idx, &lookupflags);
} else if (IS_ENABLED(CONFIG_ACPI) && dev && ACPI_HANDLE(dev)) {
Expand Down
8 changes: 4 additions & 4 deletions drivers/gpu/ipu-v3/ipu_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 334,7 @@ static int ipu_probe(struct vmm_device *dev,
if (!pltfm_data)
return VMM_ENOMEM;

ret = vmm_devtree_read_u32(dev->node, "bypass_reset", &bypass_reset);
ret = vmm_devtree_read_u32(dev->of_node, "bypass_reset", &bypass_reset);
if (ret < 0) {
dev_dbg(dev, "can not get bypass_reset\n");
return ret;
Expand All @@ -358,19 358,19 @@ static int ipu_probe(struct vmm_device *dev,
spin_lock_init(&ipu->rdy_reg_spin_lock);
mutex_init(&ipu->mutex_lock);

ipu->irq_sync = vmm_devtree_irq_parse_map(dev->node, 0);
ipu->irq_sync = vmm_devtree_irq_parse_map(dev->of_node, 0);
if (!ipu->irq_sync) {
dev_err(ipu->dev, "request SYNC interrupt failed\n");
return VMM_ENODEV;
}

ipu->irq_err = vmm_devtree_irq_parse_map(dev->node, 1);
ipu->irq_err = vmm_devtree_irq_parse_map(dev->of_node, 1);
if (!ipu->irq_err) {
dev_err(ipu->dev, "request ERR interrupt failed\n");
return VMM_ENODEV;
}

ret = vmm_devtree_regaddr(dev->node, &ipu_base, 0);
ret = vmm_devtree_regaddr(dev->of_node, &ipu_base, 0);
if (ret) {
dev_err(dev, "can't get device resources\n");
return ret;
Expand Down
18 changes: 9 additions & 9 deletions drivers/i2c/busses/i2c-bcm2835.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 232,7 @@ static int bcm2835_i2c_probe(struct vmm_device *dev,
i2c_dev->dev = dev;
init_completion(&i2c_dev->completion);

ret = vmm_devtree_request_regmap(dev->node, &mem, 0,
ret = vmm_devtree_request_regmap(dev->of_node, &mem, 0,
"BCM2835 I2C");
if (ret) {
return ret;
Expand All @@ -242,12 242,12 @@ static int bcm2835_i2c_probe(struct vmm_device *dev,
i2c_dev->clk = devm_clk_get(dev, NULL);
if (IS_ERR(i2c_dev->clk)) {
dev_err(dev, "Could not get clock\n");
vmm_devtree_regunmap_release(dev->node,
vmm_devtree_regunmap_release(dev->of_node,
(virtual_addr_t)i2c_dev->regs, 0);
return PTR_ERR(i2c_dev->clk);
}

ret = of_property_read_u32(dev->node, "clock-frequency",
ret = of_property_read_u32(dev->of_node, "clock-frequency",
&bus_clk_rate);
if (ret < 0) {
dev_warn(dev,
Expand All @@ -265,10 265,10 @@ static int bcm2835_i2c_probe(struct vmm_device *dev,
divider ;
bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_DIV, divider);

i2c_dev->irq = vmm_devtree_irq_parse_map(dev->node, 0);
i2c_dev->irq = vmm_devtree_irq_parse_map(dev->of_node, 0);
if (!i2c_dev->irq) {
dev_err(dev, "No IRQ resource\n");
vmm_devtree_regunmap_release(dev->node,
vmm_devtree_regunmap_release(dev->of_node,
(virtual_addr_t)i2c_dev->regs, 0);
return -ENODEV;
}
Expand All @@ -277,7 277,7 @@ static int bcm2835_i2c_probe(struct vmm_device *dev,
dev_name(dev), i2c_dev);
if (ret) {
dev_err(dev, "Could not request IRQ\n");
vmm_devtree_regunmap_release(dev->node,
vmm_devtree_regunmap_release(dev->of_node,
(virtual_addr_t)i2c_dev->regs, 0);
return -ENODEV;
}
Expand All @@ -289,14 289,14 @@ static int bcm2835_i2c_probe(struct vmm_device *dev,
strlcpy(adap->name, "bcm2835 I2C adapter", sizeof(adap->name));
adap->algo = &bcm2835_i2c_algo;
adap->dev.parent = dev;
adap->dev.node = dev->node;
adap->dev.of_node = dev->of_node;

bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, 0);

ret = i2c_add_adapter(adap);
if (ret) {
free_irq(i2c_dev->irq, i2c_dev);
vmm_devtree_regunmap_release(dev->node,
vmm_devtree_regunmap_release(dev->of_node,
(virtual_addr_t)i2c_dev->regs, 0);
}

Expand All @@ -308,7 308,7 @@ static int bcm2835_i2c_remove(struct vmm_device *dev)
struct bcm2835_i2c_dev *i2c_dev = vmm_devdrv_get_data(dev);

free_irq(i2c_dev->irq, i2c_dev);
vmm_devtree_regunmap_release(dev->node,
vmm_devtree_regunmap_release(dev->of_node,
(virtual_addr_t)i2c_dev->regs, 0);
i2c_del_adapter(&i2c_dev->adapter);

Expand Down
14 changes: 7 additions & 7 deletions drivers/i2c/busses/i2c-imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,18 650,18 @@ static int i2c_imx_probe(struct vmm_device *dev,
unsigned int irq = 0;
int ret = VMM_OK;

if (!vmm_devtree_is_available(dev->node)) {
if (!vmm_devtree_is_available(dev->of_node)) {
dev_info(dev, "device is disabled\n");
return -ENODEV;
}

irq = irq_of_parse_and_map(dev->node, 0);
irq = irq_of_parse_and_map(dev->of_node, 0);
if (!irq) {
dev_err(dev, "can't get irq number\n");
return -ENODEV;
}

ret = vmm_devtree_request_regmap(dev->node, &base, 0, "i.MX I2C");
ret = vmm_devtree_request_regmap(dev->of_node, &base, 0, "i.MX I2C");
if (VMM_OK != ret) {
dev_err(dev, "can't get mapping\n");
return ret;
Expand All @@ -683,8 683,8 @@ static int i2c_imx_probe(struct vmm_device *dev,
device_initialize(&i2c_imx->adapter.dev);
i2c_imx->adapter.algo = &i2c_imx_algo;
i2c_imx->adapter.dev.parent = dev;
i2c_imx->adapter.nr = vmm_devtree_alias_get_id(dev->node, "i2c");
i2c_imx->adapter.dev.node = dev->node;
i2c_imx->adapter.nr = vmm_devtree_alias_get_id(dev->of_node, "i2c");
i2c_imx->adapter.dev.of_node = dev->of_node;
i2c_imx->base = (void __iomem *)base;

/* Get I2C clock */
Expand Down Expand Up @@ -714,7 714,7 @@ static int i2c_imx_probe(struct vmm_device *dev,
i2c_set_adapdata(&i2c_imx->adapter, i2c_imx);

/* Set up clock divider */
ret = of_property_read_u32(dev->node,
ret = of_property_read_u32(dev->of_node,
"clock-frequency", &i2c_imx->bitrate);
if (ret < 0) {
i2c_imx->bitrate = IMX_I2C_BIT_RATE;
Expand Down Expand Up @@ -755,7 755,7 @@ static int i2c_imx_probe(struct vmm_device *dev,
err_pa:
devm_kfree(dev, i2c_imx);
err_alloc:
vmm_devtree_regunmap(dev->node, base, 0);
vmm_devtree_regunmap(dev->of_node, base, 0);
return ret;
}

Expand Down
Loading

0 comments on commit 3a79542

Please sign in to comment.