diff options
author | Simon Glass <sjg@chromium.org> | 2017-09-17 16:54:51 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2017-10-08 20:08:19 -0600 |
commit | 1ba214767d85ed37c0af3ac41d2e8617a609741f (patch) | |
tree | 9cf62eb5520cf76e6e3527f5a31141e805b8ca13 /drivers/gpio/vybrid_gpio.c | |
parent | 085391b22349b453aefad677853ff2d9955dd967 (diff) | |
download | u-boot-1ba214767d85ed37c0af3ac41d2e8617a609741f.tar.gz |
dm: gpio: vybrid_gpio: Correct driver's use of bind() method
It does not look like this driver needs to use a bind() method. It does
not manually create devices with device_bind() nor does it create devices
using U_BOOT_DEVICE(). It seems to only use device tree.
Therefore the manual allocation of platform data is not needed and is
confusing. Also platform data should be set up by the ofdata_to_platdata()
method, not bind().
Update the driver in case others use it as a model in future.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Adam Ford <aford173@gmail.com>
Diffstat (limited to 'drivers/gpio/vybrid_gpio.c')
-rw-r--r-- | drivers/gpio/vybrid_gpio.c | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/drivers/gpio/vybrid_gpio.c b/drivers/gpio/vybrid_gpio.c index 89918e48dd..030e8d08a4 100644 --- a/drivers/gpio/vybrid_gpio.c +++ b/drivers/gpio/vybrid_gpio.c @@ -105,32 +105,18 @@ static int vybrid_gpio_probe(struct udevice *dev) return 0; } -static int vybrid_gpio_bind(struct udevice *dev) +static int vybrid_gpio_odata_to_platdata(struct udevice *dev) { - struct vybrid_gpio_platdata *plat = dev->platdata; + struct vybrid_gpio_platdata *plat = dev_get_platdata(dev); fdt_addr_t base_addr; - if (plat) - return 0; - base_addr = devfdt_get_addr(dev); if (base_addr == FDT_ADDR_T_NONE) - return -ENODEV; - - /* - * TODO: - * When every board is converted to driver model and DT is - * supported, this can be done by auto-alloc feature, but - * not using calloc to alloc memory for platdata. - */ - plat = calloc(1, sizeof(*plat)); - if (!plat) - return -ENOMEM; + return -EINVAL; plat->base = base_addr; plat->chip = dev->req_seq; plat->port_name = fdt_get_name(gd->fdt_blob, dev_of_offset(dev), NULL); - dev->platdata = plat; return 0; } @@ -144,8 +130,9 @@ U_BOOT_DRIVER(gpio_vybrid) = { .name = "gpio_vybrid", .id = UCLASS_GPIO, .ops = &gpio_vybrid_ops, + .of_match = vybrid_gpio_ids, + .ofdata_to_platdata = vybrid_gpio_odata_to_platdata, .probe = vybrid_gpio_probe, .priv_auto_alloc_size = sizeof(struct vybrid_gpios), - .of_match = vybrid_gpio_ids, - .bind = vybrid_gpio_bind, + .platdata_auto_alloc_size = sizeof(struct vybrid_gpio_platdata), }; |