[U-Boot] [PATCH 1/6] dm: Rename dev_get_parentdata() to dev_get_parent_priv()

The current name is inconsistent with other driver model data access functions. Rename it and fix up all users.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/cmd_usb.c | 10 +++++----- common/usb_hub.c | 4 ++-- common/usb_storage.c | 2 +- doc/driver-model/usb-info.txt | 4 ++-- drivers/core/device.c | 2 +- drivers/misc/cros_ec_spi.c | 4 ++-- drivers/mtd/spi/sf_dataflash.c | 2 +- drivers/mtd/spi/sf_probe.c | 2 +- drivers/spi/fsl_qspi.c | 2 +- drivers/spi/ich.c | 2 +- drivers/spi/soft_spi.c | 2 +- drivers/spi/spi-uclass.c | 8 ++++---- drivers/usb/eth/smsc95xx.c | 4 ++-- drivers/usb/eth/usb_ether.c | 2 +- drivers/usb/host/ehci-hcd.c | 6 +++--- drivers/usb/host/usb-uclass.c | 8 ++++---- drivers/usb/host/xhci.c | 4 ++-- drivers/usb/musb-new/usb-compat.h | 10 +++++----- include/dm/device.h | 10 +++++----- include/pci.h | 2 +- include/spi.h | 2 +- include/usb.h | 2 +- test/dm/bus.c | 26 +++++++++++++------------- 23 files changed, 60 insertions(+), 60 deletions(-)
diff --git a/common/cmd_usb.c b/common/cmd_usb.c index 6bdbbc5..1ef55dc 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -281,7 +281,7 @@ static struct usb_device *usb_find_device(int devnum)
if (!device_active(hub)) continue; - udev = dev_get_parentdata(hub); + udev = dev_get_parent_priv(hub); if (udev->devnum == devnum) return udev;
@@ -291,7 +291,7 @@ static struct usb_device *usb_find_device(int devnum) if (!device_active(hub)) continue;
- udev = dev_get_parentdata(dev); + udev = dev_get_parent_priv(dev); if (udev->devnum == devnum) return udev; } @@ -407,7 +407,7 @@ static void usb_show_tree_graph(struct usb_device *dev, char *pre) if (!device_active(child)) continue;
- udev = dev_get_parentdata(child); + udev = dev_get_parent_priv(child);
/* Ignore emulators, we only want real devices */ if (device_get_uclass_id(child) != UCLASS_USB_EMUL) { @@ -553,7 +553,7 @@ static void show_info(struct udevice *dev) struct udevice *child; struct usb_device *udev;
- udev = dev_get_parentdata(dev); + udev = dev_get_parent_priv(dev); usb_display_desc(udev); usb_display_config(udev); for (device_find_first_child(dev, &child); @@ -641,7 +641,7 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
device_find_first_child(bus, &dev); if (dev && device_active(dev)) { - udev = dev_get_parentdata(dev); + udev = dev_get_parent_priv(dev); usb_show_tree(udev); } } diff --git a/common/usb_hub.c b/common/usb_hub.c index 415b45c..a92c9fb 100644 --- a/common/usb_hub.c +++ b/common/usb_hub.c @@ -230,7 +230,7 @@ int legacy_hub_port_reset(struct usb_device *dev, int port, #ifdef CONFIG_DM_USB int hub_port_reset(struct udevice *dev, int port, unsigned short *portstat) { - struct usb_device *udev = dev_get_parentdata(dev); + struct usb_device *udev = dev_get_parent_priv(dev);
return legacy_hub_port_reset(udev, port, portstat); } @@ -610,7 +610,7 @@ int usb_hub_probe(struct usb_device *dev, int ifnum) #ifdef CONFIG_DM_USB int usb_hub_scan(struct udevice *hub) { - struct usb_device *udev = dev_get_parentdata(hub); + struct usb_device *udev = dev_get_parent_priv(hub);
return usb_hub_configure(udev); } diff --git a/common/usb_storage.c b/common/usb_storage.c index b390310..0ccaeb4 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -1408,7 +1408,7 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss,
static int usb_mass_storage_probe(struct udevice *dev) { - struct usb_device *udev = dev_get_parentdata(dev); + struct usb_device *udev = dev_get_parent_priv(dev); int ret;
usb_disable_asynch(1); /* asynch transfer not allowed */ diff --git a/doc/driver-model/usb-info.txt b/doc/driver-model/usb-info.txt index 66f2dae..e07e5ba 100644 --- a/doc/driver-model/usb-info.txt +++ b/doc/driver-model/usb-info.txt @@ -84,7 +84,7 @@ The following primary data structures are in use: This holds information about a device on the bus. All devices have this structure, even the root hub. The controller itself does not have this structure. You can access it for a device 'dev' with - dev_get_parentdata(dev). It matches the old structure except that the + dev_get_parent_priv(dev). It matches the old structure except that the parent and child information is not present (since driver model handles that). Once the device is set up, you can find the device descriptor and current configuration descriptor in this structure. @@ -279,7 +279,7 @@ USB hubs are scanned as in the section above. While hubs have their own uclass, they share some common elements with controllers:
- they both attach private data to their children (struct usb_device, -accessible for a child with dev_get_parentdata(child)) +accessible for a child with dev_get_parent_priv(child)) - they both use usb_child_pre_probe() to set up their children as proper USB devices
diff --git a/drivers/core/device.c b/drivers/core/device.c index 0bc04d4..6edf846 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -390,7 +390,7 @@ void *dev_get_uclass_priv(struct udevice *dev) return dev->uclass_priv; }
-void *dev_get_parentdata(struct udevice *dev) +void *dev_get_parent_priv(struct udevice *dev) { if (!dev) { dm_warn("%s: null device\n", __func__); diff --git a/drivers/misc/cros_ec_spi.c b/drivers/misc/cros_ec_spi.c index 0686925..253d91a 100644 --- a/drivers/misc/cros_ec_spi.c +++ b/drivers/misc/cros_ec_spi.c @@ -24,7 +24,7 @@ DECLARE_GLOBAL_DATA_PTR; int cros_ec_spi_packet(struct udevice *udev, int out_bytes, int in_bytes) { struct cros_ec_dev *dev = dev_get_uclass_priv(udev); - struct spi_slave *slave = dev_get_parentdata(dev->dev); + struct spi_slave *slave = dev_get_parent_priv(dev->dev); ulong start; uint8_t byte; int rv; @@ -84,7 +84,7 @@ int cros_ec_spi_command(struct udevice *udev, uint8_t cmd, int cmd_version, uint8_t **dinp, int din_len) { struct cros_ec_dev *dev = dev_get_uclass_priv(udev); - struct spi_slave *slave = dev_get_parentdata(dev->dev); + struct spi_slave *slave = dev_get_parent_priv(dev->dev); int in_bytes = din_len + 4; /* status, length, checksum, trailer */ uint8_t *out; uint8_t *p; diff --git a/drivers/mtd/spi/sf_dataflash.c b/drivers/mtd/spi/sf_dataflash.c index 3111f4f..b2a56da 100644 --- a/drivers/mtd/spi/sf_dataflash.c +++ b/drivers/mtd/spi/sf_dataflash.c @@ -577,7 +577,7 @@ static struct flash_info *jedec_probe(struct spi_slave *spi, u8 *id) */ static int spi_dataflash_probe(struct udevice *dev) { - struct spi_slave *spi = dev_get_parentdata(dev); + struct spi_slave *spi = dev_get_parent_priv(dev); struct spi_flash *spi_flash; struct flash_info *info; u8 idcode[5]; diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c index 954376d..3bf03f7 100644 --- a/drivers/mtd/spi/sf_probe.c +++ b/drivers/mtd/spi/sf_probe.c @@ -471,7 +471,7 @@ int spi_flash_std_erase(struct udevice *dev, u32 offset, size_t len)
int spi_flash_std_probe(struct udevice *dev) { - struct spi_slave *slave = dev_get_parentdata(dev); + struct spi_slave *slave = dev_get_parent_priv(dev); struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev); struct spi_flash *flash;
diff --git a/drivers/spi/fsl_qspi.c b/drivers/spi/fsl_qspi.c index 868df5f..02b557f 100644 --- a/drivers/spi/fsl_qspi.c +++ b/drivers/spi/fsl_qspi.c @@ -913,7 +913,7 @@ void spi_init(void) #else static int fsl_qspi_child_pre_probe(struct udevice *dev) { - struct spi_slave *slave = dev_get_parentdata(dev); + struct spi_slave *slave = dev_get_parent_priv(dev);
slave->max_write_size = TX_BUFFER_SIZE;
diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c index 2e388e7..9a3e002 100644 --- a/drivers/spi/ich.c +++ b/drivers/spi/ich.c @@ -739,7 +739,7 @@ static int ich_spi_child_pre_probe(struct udevice *dev) struct udevice *bus = dev_get_parent(dev); struct ich_spi_platdata *plat = dev_get_platdata(bus); struct ich_spi_priv *priv = dev_get_priv(bus); - struct spi_slave *slave = dev_get_parentdata(dev); + struct spi_slave *slave = dev_get_parent_priv(dev);
/* * Yes this controller can only write a small number of bytes at diff --git a/drivers/spi/soft_spi.c b/drivers/spi/soft_spi.c index 6ae45f5..aa4abcc 100644 --- a/drivers/spi/soft_spi.c +++ b/drivers/spi/soft_spi.c @@ -200,7 +200,7 @@ static int soft_spi_ofdata_to_platdata(struct udevice *dev)
static int soft_spi_probe(struct udevice *dev) { - struct spi_slave *slave = dev_get_parentdata(dev); + struct spi_slave *slave = dev_get_parent_priv(dev); struct soft_spi_platdata *plat = dev->platdata; int cs_flags, clk_flags;
diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c index d666272..58388ef 100644 --- a/drivers/spi/spi-uclass.c +++ b/drivers/spi/spi-uclass.c @@ -124,7 +124,7 @@ static int spi_post_probe(struct udevice *bus) static int spi_child_pre_probe(struct udevice *dev) { struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev); - struct spi_slave *slave = dev_get_parentdata(dev); + struct spi_slave *slave = dev_get_parent_priv(dev);
/* * This is needed because we pass struct spi_slave around the place @@ -282,7 +282,7 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode, ret = device_probe(dev); if (ret) goto err; - slave = dev_get_parentdata(dev); + slave = dev_get_parent_priv(dev); slave->dev = dev; }
@@ -291,7 +291,7 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode, goto err;
*busp = bus; - *devp = dev_get_parentdata(dev); + *devp = dev_get_parent_priv(dev); debug("%s: bus=%p, slave=%p\n", __func__, bus, *devp);
return 0; @@ -320,7 +320,7 @@ struct spi_slave *spi_setup_slave_fdt(const void *blob, int node, ret = device_get_child_by_of_offset(bus, node, &dev); if (ret) return NULL; - return dev_get_parentdata(dev); + return dev_get_parent_priv(dev); }
/* Compatibility function - to be removed */ diff --git a/drivers/usb/eth/smsc95xx.c b/drivers/usb/eth/smsc95xx.c index dc8fa88..d4b5ff4 100644 --- a/drivers/usb/eth/smsc95xx.c +++ b/drivers/usb/eth/smsc95xx.c @@ -945,7 +945,7 @@ int smsc95xx_eth_get_info(struct usb_device *dev, struct ueth_data *ss, #ifdef CONFIG_DM_ETH static int smsc95xx_eth_start(struct udevice *dev) { - struct usb_device *udev = dev_get_parentdata(dev); + struct usb_device *udev = dev_get_parent_priv(dev); struct smsc95xx_private *priv = dev_get_priv(dev); struct eth_pdata *pdata = dev_get_platdata(dev);
@@ -1029,7 +1029,7 @@ static int smsc95xx_free_pkt(struct udevice *dev, uchar *packet, int packet_len)
int smsc95xx_write_hwaddr(struct udevice *dev) { - struct usb_device *udev = dev_get_parentdata(dev); + struct usb_device *udev = dev_get_parent_priv(dev); struct eth_pdata *pdata = dev_get_platdata(dev); struct smsc95xx_private *priv = dev_get_priv(dev);
diff --git a/drivers/usb/eth/usb_ether.c b/drivers/usb/eth/usb_ether.c index 3c3e082..62d20f0 100644 --- a/drivers/usb/eth/usb_ether.c +++ b/drivers/usb/eth/usb_ether.c @@ -19,7 +19,7 @@
int usb_ether_register(struct udevice *dev, struct ueth_data *ueth, int rxsize) { - struct usb_device *udev = dev_get_parentdata(dev); + struct usb_device *udev = dev_get_parent_priv(dev); struct usb_interface_descriptor *iface_desc; bool ep_in_found = false, ep_out_found = false; struct usb_interface *iface; diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 135ef72..c85dbce 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -303,7 +303,7 @@ static void ehci_update_endpt2_dev_n_port(struct usb_device *udev,
ttdev = udev; parent = udev->dev; - uparent = dev_get_parentdata(parent); + uparent = dev_get_parent_priv(parent);
while (uparent->speed != USB_SPEED_HIGH) { struct udevice *dev = parent; @@ -313,9 +313,9 @@ static void ehci_update_endpt2_dev_n_port(struct usb_device *udev, return; }
- ttdev = dev_get_parentdata(dev); + ttdev = dev_get_parent_priv(dev); parent = dev->parent; - uparent = dev_get_parentdata(parent); + uparent = dev_get_parent_priv(parent); } parent_devnum = uparent->devnum; #else diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index c66ebb6..7f6a9a6 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -289,7 +289,7 @@ static struct usb_device *find_child_devnum(struct udevice *parent, int devnum)
if (!device_active(parent)) return NULL; - udev = dev_get_parentdata(parent); + udev = dev_get_parent_priv(parent); if (udev->devnum == devnum) return udev;
@@ -575,7 +575,7 @@ int usb_scan_device(struct udevice *parent, int port, udev->portnr = port; debug("Calling usb_setup_device(), portnr=%d\n", udev->portnr); parent_udev = device_get_uclass_id(parent) == UCLASS_USB_HUB ? - dev_get_parentdata(parent) : NULL; + dev_get_parent_priv(parent) : NULL; ret = usb_setup_device(udev, priv->desc_before_addr, parent_udev); debug("read_descriptor for '%s': ret=%d\n", parent->name, ret); if (ret) @@ -638,7 +638,7 @@ int usb_detect_change(void) if (!device_active(dev)) continue;
- udev = dev_get_parentdata(dev); + udev = dev_get_parent_priv(dev); if (usb_get_port_status(udev, udev->portnr, &status) < 0) /* USB request failed */ @@ -694,7 +694,7 @@ struct udevice *usb_get_bus(struct udevice *dev)
int usb_child_pre_probe(struct udevice *dev) { - struct usb_device *udev = dev_get_parentdata(dev); + struct usb_device *udev = dev_get_parent_priv(dev); struct usb_dev_platdata *plat = dev_get_parent_platdata(dev); int ret;
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 307e1a6..ca598aa 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1119,7 +1119,7 @@ static struct usb_device *get_usb_device(struct udevice *dev) if (device_get_uclass_id(dev) == UCLASS_USB) udev = dev_get_uclass_priv(dev); else - udev = dev_get_parentdata(dev); + udev = dev_get_parent_priv(dev);
return udev; } @@ -1150,7 +1150,7 @@ static int xhci_submit_control_msg(struct udevice *dev, struct usb_device *udev, } else { while (!is_root_hub(hub->parent)) hub = hub->parent; - uhop = dev_get_parentdata(hub); + uhop = dev_get_parent_priv(hub); root_portnr = uhop->portnr; } } diff --git a/drivers/usb/musb-new/usb-compat.h b/drivers/usb/musb-new/usb-compat.h index 53fe4ff..1c41e2a 100644 --- a/drivers/usb/musb-new/usb-compat.h +++ b/drivers/usb/musb-new/usb-compat.h @@ -82,7 +82,7 @@ static inline u16 find_tt(struct usb_device *udev) */ ttdev = udev; parent = udev->dev; - uparent = dev_get_parentdata(parent); + uparent = dev_get_parent_priv(parent);
while (uparent->speed != USB_SPEED_HIGH) { struct udevice *dev = parent; @@ -92,9 +92,9 @@ static inline u16 find_tt(struct usb_device *udev) return 0; }
- ttdev = dev_get_parentdata(dev); + ttdev = dev_get_parent_priv(dev); parent = dev->parent; - uparent = dev_get_parentdata(parent); + uparent = dev_get_parent_priv(parent); }
return (uparent->devnum << 8) | (ttdev->portnr - 1); @@ -119,12 +119,12 @@ static inline struct usb_device *usb_dev_get_parent(struct usb_device *udev) * If these 2 are not the same we are being called from * usb_scan_device() and udev itself is the parent. */ - if (dev_get_parentdata(udev->dev) != udev) + if (dev_get_parent_priv(udev->dev) != udev) return udev;
/* We are being called normally, use the parent pointer */ if (device_get_uclass_id(parent) == UCLASS_USB_HUB) - return dev_get_parentdata(parent); + return dev_get_parent_priv(parent);
return NULL; } diff --git a/include/dm/device.h b/include/dm/device.h index 8519612..f152008 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -233,18 +233,18 @@ void *dev_get_parent_platdata(struct udevice *dev); void *dev_get_uclass_platdata(struct udevice *dev);
/** - * dev_get_parentdata() - Get the parent data for a device + * dev_get_parent_priv() - Get the parent private data for a device * - * The parent data is data stored in the device but owned by the parent. - * For example, a USB device may have parent data which contains information - * about how to talk to the device over USB. + * The parent private data is data stored in the device but owned by the + * parent. For example, a USB device may have parent data which contains + * information about how to talk to the device over USB. * * This checks that dev is not NULL, but no other checks for now * * @dev Device to check * @return parent data, or NULL if none */ -void *dev_get_parentdata(struct udevice *dev); +void *dev_get_parent_priv(struct udevice *dev);
/** * dev_get_priv() - Get the private data for a device diff --git a/include/pci.h b/include/pci.h index e24c970..ed135a5 100644 --- a/include/pci.h +++ b/include/pci.h @@ -797,7 +797,7 @@ struct udevice; * * Every device on a PCI bus has this per-child data. * - * It can be accessed using dev_get_parentdata(dev) if dev->parent is a + * It can be accessed using dev_get_parent_priv(dev) if dev->parent is a * PCI bus (i.e. UCLASS_PCI) * * @devfn: Encoded device and function index - see PCI_DEVFN() diff --git a/include/spi.h b/include/spi.h index 51fdfd6..b4d2723 100644 --- a/include/spi.h +++ b/include/spi.h @@ -88,7 +88,7 @@ struct dm_spi_slave_platdata { * struct spi_slave - Representation of a SPI slave * * For driver model this is the per-child data used by the SPI bus. It can - * be accessed using dev_get_parentdata() on the slave device. The SPI uclass + * be accessed using dev_get_parent_priv() on the slave device. The SPI uclass * sets uip per_child_auto_alloc_size to sizeof(struct spi_slave), and the * driver should not override it. Two platform data fields (max_hz and mode) * are copied into this structure to provide an initial value. This allows diff --git a/include/usb.h b/include/usb.h index 88ebbe6..3d0facb 100644 --- a/include/usb.h +++ b/include/usb.h @@ -96,7 +96,7 @@ enum { * (the hubs) have this as parent data. Hubs are children of controllers or * other hubs and there is always a single root hub for each controller. * Therefore struct usb_device can always be accessed with - * dev_get_parentdata(dev), where dev is a USB device. + * dev_get_parent_priv(dev), where dev is a USB device. * * Pointers exist for obtaining both the device (could be any uclass) and * controller (UCLASS_USB) from this structure. The controller does not have diff --git a/test/dm/bus.c b/test/dm/bus.c index a215905..3b5a23b 100644 --- a/test/dm/bus.c +++ b/test/dm/bus.c @@ -46,7 +46,7 @@ static int testbus_child_post_bind(struct udevice *dev)
static int testbus_child_pre_probe(struct udevice *dev) { - struct dm_test_parent_data *parent_data = dev_get_parentdata(dev); + struct dm_test_parent_data *parent_data = dev_get_parent_priv(dev);
parent_data->flag += FLAG_CHILD_PROBED;
@@ -64,7 +64,7 @@ static int testbus_child_pre_probe_uclass(struct udevice *dev)
static int testbus_child_post_remove(struct udevice *dev) { - struct dm_test_parent_data *parent_data = dev_get_parentdata(dev); + struct dm_test_parent_data *parent_data = dev_get_parent_priv(dev); struct dm_test_state *dms = test_state;
parent_data->flag += FLAG_CHILD_REMOVED; @@ -215,20 +215,20 @@ static int test_bus_parent_data(struct unit_test_state *uts)
/* Check that parent data is allocated */ ut_assertok(device_find_child_by_seq(bus, 0, true, &dev)); - ut_asserteq_ptr(NULL, dev_get_parentdata(dev)); + ut_asserteq_ptr(NULL, dev_get_parent_priv(dev)); ut_assertok(device_get_child_by_seq(bus, 0, &dev)); - parent_data = dev_get_parentdata(dev); + parent_data = dev_get_parent_priv(dev); ut_assert(NULL != parent_data);
/* Check that it starts at 0 and goes away when device is removed */ parent_data->sum += 5; ut_asserteq(5, parent_data->sum); device_remove(dev); - ut_asserteq_ptr(NULL, dev_get_parentdata(dev)); + ut_asserteq_ptr(NULL, dev_get_parent_priv(dev));
/* Check that we can do this twice */ ut_assertok(device_get_child_by_seq(bus, 0, &dev)); - parent_data = dev_get_parentdata(dev); + parent_data = dev_get_parent_priv(dev); ut_assert(NULL != parent_data); parent_data->sum += 5; ut_asserteq(5, parent_data->sum); @@ -239,11 +239,11 @@ static int test_bus_parent_data(struct unit_test_state *uts) uclass_foreach_dev(dev, uc) { /* Ignore these if they are not on this bus */ if (dev->parent != bus) { - ut_asserteq_ptr(NULL, dev_get_parentdata(dev)); + ut_asserteq_ptr(NULL, dev_get_parent_priv(dev)); continue; } ut_assertok(device_probe(dev)); - parent_data = dev_get_parentdata(dev); + parent_data = dev_get_parent_priv(dev);
parent_data->sum = value; value += 5; @@ -255,7 +255,7 @@ static int test_bus_parent_data(struct unit_test_state *uts) /* Ignore these if they are not on this bus */ if (dev->parent != bus) continue; - parent_data = dev_get_parentdata(dev); + parent_data = dev_get_parent_priv(dev);
ut_asserteq(value, parent_data->sum); value += 5; @@ -311,10 +311,10 @@ static int dm_test_bus_parent_ops(struct unit_test_state *uts) /* Ignore these if they are not on this bus */ if (dev->parent != bus) continue; - ut_asserteq_ptr(NULL, dev_get_parentdata(dev)); + ut_asserteq_ptr(NULL, dev_get_parent_priv(dev));
ut_assertok(device_probe(dev)); - parent_data = dev_get_parentdata(dev); + parent_data = dev_get_parent_priv(dev); ut_asserteq(FLAG_CHILD_PROBED, parent_data->flag); }
@@ -322,10 +322,10 @@ static int dm_test_bus_parent_ops(struct unit_test_state *uts) /* Ignore these if they are not on this bus */ if (dev->parent != bus) continue; - parent_data = dev_get_parentdata(dev); + parent_data = dev_get_parent_priv(dev); ut_asserteq(FLAG_CHILD_PROBED, parent_data->flag); ut_assertok(device_remove(dev)); - ut_asserteq_ptr(NULL, dev_get_parentdata(dev)); + ut_asserteq_ptr(NULL, dev_get_parent_priv(dev)); ut_asserteq_ptr(dms->removed, dev); } test_state = NULL;

Move a few functions around so that the ordering is consistent.
Signed-off-by: Simon Glass sjg@chromium.org ---
include/dm/device.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/include/dm/device.h b/include/dm/device.h index f152008..e09f897 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -233,6 +233,16 @@ void *dev_get_parent_platdata(struct udevice *dev); void *dev_get_uclass_platdata(struct udevice *dev);
/** + * dev_get_priv() - Get the private data for a device + * + * This checks that dev is not NULL, but no other checks for now + * + * @dev Device to check + * @return private data, or NULL if none + */ +void *dev_get_priv(struct udevice *dev); + +/** * dev_get_parent_priv() - Get the parent private data for a device * * The parent private data is data stored in the device but owned by the @@ -247,14 +257,14 @@ void *dev_get_uclass_platdata(struct udevice *dev); void *dev_get_parent_priv(struct udevice *dev);
/** - * dev_get_priv() - Get the private data for a device + * dev_get_uclass_priv() - Get the private uclass data for a device * * This checks that dev is not NULL, but no other checks for now * * @dev Device to check - * @return private data, or NULL if none + * @return private uclass data for this device, or NULL if none */ -void *dev_get_priv(struct udevice *dev); +void *dev_get_uclass_priv(struct udevice *dev);
/** * struct dev_get_parent() - Get the parent of a device @@ -265,16 +275,6 @@ void *dev_get_priv(struct udevice *dev); struct udevice *dev_get_parent(struct udevice *child);
/** - * dev_get_uclass_priv() - Get the private uclass data for a device - * - * This checks that dev is not NULL, but no other checks for now - * - * @dev Device to check - * @return private uclass data for this device, or NULL if none - */ -void *dev_get_uclass_priv(struct udevice *dev); - -/** * dev_get_driver_data() - get the driver data used to bind a device * * When a device is bound using a device tree node, it matches a

On 28 September 2015 at 23:32, Simon Glass sjg@chromium.org wrote:
Move a few functions around so that the ordering is consistent.
Signed-off-by: Simon Glass sjg@chromium.org
include/dm/device.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
Applied to u-boot-dm.

Line up the flag values in the code for easier readability.
Signed-off-by: Simon Glass sjg@chromium.org ---
include/dm/device.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/dm/device.h b/include/dm/device.h index e09f897..286a702 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -21,13 +21,13 @@ struct driver_info;
/* Driver is active (probed). Cleared when it is removed */ -#define DM_FLAG_ACTIVATED (1 << 0) +#define DM_FLAG_ACTIVATED (1 << 0)
/* DM is responsible for allocating and freeing platdata */ -#define DM_FLAG_ALLOC_PDATA (1 << 1) +#define DM_FLAG_ALLOC_PDATA (1 << 1)
/* DM should init this device prior to relocation */ -#define DM_FLAG_PRE_RELOC (1 << 2) +#define DM_FLAG_PRE_RELOC (1 << 2)
/* DM is responsible for allocating and freeing parent_platdata */ #define DM_FLAG_ALLOC_PARENT_PDATA (1 << 3) @@ -36,10 +36,10 @@ struct driver_info; #define DM_FLAG_ALLOC_UCLASS_PDATA (1 << 4)
/* Allocate driver private data on a DMA boundary */ -#define DM_FLAG_ALLOC_PRIV_DMA (1 << 5) +#define DM_FLAG_ALLOC_PRIV_DMA (1 << 5)
/* Device is bound */ -#define DM_FLAG_BOUND (1 << 6) +#define DM_FLAG_BOUND (1 << 6)
/** * struct udevice - An instance of a driver

On 28 September 2015 at 23:32, Simon Glass sjg@chromium.org wrote:
Line up the flag values in the code for easier readability.
Signed-off-by: Simon Glass sjg@chromium.org
include/dm/device.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Applied to u-boot-dm.

Adjust the devres comments to be consistent with the rest of the file, and add one for the struct udevice member. Also rename the 'p' parameter to 'ptr' to avoid single-character names.
Signed-off-by: Simon Glass sjg@chromium.org ---
include/dm/device.h | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-)
diff --git a/include/dm/device.h b/include/dm/device.h index 286a702..f60d153 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -78,6 +78,10 @@ struct driver_info; * @req_seq: Requested sequence number for this device (-1 = any) * @seq: Allocated sequence number for this device (-1 = none). This is set up * when the device is probed and will be unique within the device's uclass. + * @devres_head: List of memory allocations associated with this device. + * When CONFIG_DEVRES is enabled, devm_kmalloc() and friends will + * add to this list. Memory so-allocated will be freed + * automatically when the device is removed / unbound */ struct udevice { const struct driver *driver; @@ -512,7 +516,7 @@ void *_devres_alloc(dr_release_t release, size_t size, gfp_t gfp); #endif
/** - * devres_alloc - Allocate device resource data + * devres_alloc() - Allocate device resource data * @release: Release function devres will be associated with * @size: Allocation size * @gfp: Allocation flags @@ -528,7 +532,7 @@ void *_devres_alloc(dr_release_t release, size_t size, gfp_t gfp); _devres_alloc(release, size, gfp | __GFP_ZERO)
/** - * devres_free - Free device resource data + * devres_free() - Free device resource data * @res: Pointer to devres data to free * * Free devres created with devres_alloc(). @@ -536,7 +540,7 @@ void *_devres_alloc(dr_release_t release, size_t size, gfp_t gfp); void devres_free(void *res);
/** - * devres_add - Register device resource + * devres_add() - Register device resource * @dev: Device to add resource to * @res: Resource to register * @@ -547,7 +551,7 @@ void devres_free(void *res); void devres_add(struct udevice *dev, void *res);
/** - * devres_find - Find device resource + * devres_find() - Find device resource * @dev: Device to lookup resource from * @release: Look for resources associated with this release function * @match: Match function (optional) @@ -557,14 +561,13 @@ void devres_add(struct udevice *dev, void *res); * and for which @match returns 1. If @match is NULL, it's considered * to match all. * - * RETURNS: - * Pointer to found devres, NULL if not found. + * @return pointer to found devres, NULL if not found. */ void *devres_find(struct udevice *dev, dr_release_t release, dr_match_t match, void *match_data);
/** - * devres_get - Find devres, if non-existent, add one atomically + * devres_get() - Find devres, if non-existent, add one atomically * @dev: Device to lookup or add devres for * @new_res: Pointer to new initialized devres to add if not found * @match: Match function (optional) @@ -574,14 +577,13 @@ void *devres_find(struct udevice *dev, dr_release_t release, * as @new_res and for which @match return 1. If found, @new_res is * freed; otherwise, @new_res is added atomically. * - * RETURNS: - * Pointer to found or added devres. + * @return ointer to found or added devres. */ void *devres_get(struct udevice *dev, void *new_res, dr_match_t match, void *match_data);
/** - * devres_remove - Find a device resource and remove it + * devres_remove() - Find a device resource and remove it * @dev: Device to find resource from * @release: Look for resources associated with this release function * @match: Match function (optional) @@ -592,14 +594,13 @@ void *devres_get(struct udevice *dev, void *new_res, * match all. If found, the resource is removed atomically and * returned. * - * RETURNS: - * Pointer to removed devres on success, NULL if not found. + * @return ointer to removed devres on success, NULL if not found. */ void *devres_remove(struct udevice *dev, dr_release_t release, dr_match_t match, void *match_data);
/** - * devres_destroy - Find a device resource and destroy it + * devres_destroy() - Find a device resource and destroy it * @dev: Device to find resource from * @release: Look for resources associated with this release function * @match: Match function (optional) @@ -613,14 +614,13 @@ void *devres_remove(struct udevice *dev, dr_release_t release, * only the devres-allocated data will be freed. The caller becomes * responsible for freeing any other data. * - * RETURNS: - * 0 if devres is found and freed, -ENOENT if not found. + * @return 0 if devres is found and freed, -ENOENT if not found. */ int devres_destroy(struct udevice *dev, dr_release_t release, dr_match_t match, void *match_data);
/** - * devres_release - Find a device resource and destroy it, calling release + * devres_release() - Find a device resource and destroy it, calling release * @dev: Device to find resource from * @release: Look for resources associated with this release function * @match: Match function (optional) @@ -631,15 +631,14 @@ int devres_destroy(struct udevice *dev, dr_release_t release, * match all. If found, the resource is removed atomically, the * release function called and the resource freed. * - * RETURNS: - * 0 if devres is found and freed, -ENOENT if not found. + * @return 0 if devres is found and freed, -ENOENT if not found. */ int devres_release(struct udevice *dev, dr_release_t release, dr_match_t match, void *match_data);
/* managed devm_k.alloc/kfree for device drivers */ /** - * devm_kmalloc - Resource-managed kmalloc + * devm_kmalloc() - Resource-managed kmalloc * @dev: Device to allocate memory for * @size: Allocation size * @gfp: Allocation gfp flags @@ -648,8 +647,7 @@ int devres_release(struct udevice *dev, dr_release_t release, * automatically freed on driver detach. Like all other devres * resources, guaranteed alignment is unsigned long long. * - * RETURNS: - * Pointer to allocated memory on success, NULL on failure. + * @return pointer to allocated memory on success, NULL on failure. */ void *devm_kmalloc(struct udevice *dev, size_t size, gfp_t gfp); static inline void *devm_kzalloc(struct udevice *dev, size_t size, gfp_t gfp) @@ -670,13 +668,13 @@ static inline void *devm_kcalloc(struct udevice *dev, }
/** - * devm_kfree - Resource-managed kfree + * devm_kfree() - Resource-managed kfree * @dev: Device this memory belongs to - * @p: Memory to free + * @ptr: Memory to free * * Free memory allocated with devm_kmalloc(). */ -void devm_kfree(struct udevice *dev, void *p); +void devm_kfree(struct udevice *dev, void *ptr);
#else /* ! CONFIG_DEVRES */
@@ -750,9 +748,9 @@ static inline void *devm_kcalloc(struct udevice *dev, return kmalloc(n * size, flags | __GFP_ZERO); }
-static inline void devm_kfree(struct udevice *dev, void *p) +static inline void devm_kfree(struct udevice *dev, void *ptr) { - kfree(p); + kfree(ptr); }
#endif /* ! CONFIG_DEVRES */

On 28 September 2015 at 23:32, Simon Glass sjg@chromium.org wrote:
Adjust the devres comments to be consistent with the rest of the file, and add one for the struct udevice member. Also rename the 'p' parameter to 'ptr' to avoid single-character names.
Signed-off-by: Simon Glass sjg@chromium.org
include/dm/device.h | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-)
Applied to u-boot-dm.

This has proven useful and we no-longer intend to remove it. Drop the comment.
Signed-off-by: Simon Glass sjg@chromium.org ---
include/dm/device.h | 4 ---- 1 file changed, 4 deletions(-)
diff --git a/include/dm/device.h b/include/dm/device.h index f60d153..0e40aaf 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -170,10 +170,6 @@ struct udevice_id { * @per_child_auto_alloc_size: Each device can hold private data owned by * its parent. If required this will be automatically allocated if this * value is non-zero. - * TODO(sjg@chromium.org): I'm considering dropping this, and just having - * device_probe_child() pass it in. So far the use case for allocating it - * is SPI, but I found that unsatisfactory. Since it is here I will leave it - * until things are clearer. * @per_child_platdata_auto_alloc_size: A bus likes to store information about * its children. If non-zero this is the size of this data, to be allocated * in the child's parent_platdata pointer.

On 28 September 2015 at 23:32, Simon Glass sjg@chromium.org wrote:
This has proven useful and we no-longer intend to remove it. Drop the comment.
Signed-off-by: Simon Glass sjg@chromium.org
include/dm/device.h | 4 ---- 1 file changed, 4 deletions(-)
Applied to u-boot-dm.

Correct a few nits found in a recent review. Expand the comments in dev_get_driver_data() to make it clearer.
Signed-off-by: Simon Glass sjg@chromium.org ---
include/dm/device.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/include/dm/device.h b/include/dm/device.h index 0e40aaf..28ba4ca 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -278,13 +278,26 @@ struct udevice *dev_get_parent(struct udevice *child); * dev_get_driver_data() - get the driver data used to bind a device * * When a device is bound using a device tree node, it matches a - * particular compatible string as in struct udevice_id. This function + * particular compatible string in struct udevice_id. This function * returns the associated data value for that compatible string. This is * the 'data' field in struct udevice_id. * + * As an example, consider this structure: + * static const struct udevice_id tegra_i2c_ids[] = { + * { .compatible = "nvidia,tegra114-i2c", .data = TYPE_114 }, + * { .compatible = "nvidia,tegra20-i2c", .data = TYPE_STD }, + * { .compatible = "nvidia,tegra20-i2c-dvc", .data = TYPE_DVC }, + * { } + * }; + * + * When driver model finds a driver for this it will store the 'data' value + * corresponding to the compatible string it matches. This function returns + * that value. This allows the driver to handle several variants of a device. + * * For USB devices, this is the driver_info field in struct usb_device_id. * * @dev: Device to check + * @return driver data (0 if none is provided) */ ulong dev_get_driver_data(struct udevice *dev);
@@ -299,7 +312,7 @@ ulong dev_get_driver_data(struct udevice *dev); */ const void *dev_get_driver_ops(struct udevice *dev);
-/* +/** * device_get_uclass_id() - return the uclass ID of a device * * @dev: Device to check @@ -307,7 +320,7 @@ const void *dev_get_driver_ops(struct udevice *dev); */ enum uclass_id device_get_uclass_id(struct udevice *dev);
-/* +/** * dev_get_uclass_name() - return the uclass name of a device * * This checks that dev is not NULL.

On 28 September 2015 at 23:32, Simon Glass sjg@chromium.org wrote:
Correct a few nits found in a recent review. Expand the comments in dev_get_driver_data() to make it clearer.
Signed-off-by: Simon Glass sjg@chromium.org
include/dm/device.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
Applied to u-boot-dm.

Hi Simon,
On Tue, Sep 29, 2015 at 12:32 AM, Simon Glass sjg@chromium.org wrote:
The current name is inconsistent with other driver model data access functions. Rename it and fix up all users.
Signed-off-by: Simon Glass sjg@chromium.org
Reviewed-by: Joe Hershberger joe.hershberger@ni.com

On 29 September 2015 at 11:45, Joe Hershberger joe.hershberger@gmail.com wrote:
Hi Simon,
On Tue, Sep 29, 2015 at 12:32 AM, Simon Glass sjg@chromium.org wrote:
The current name is inconsistent with other driver model data access functions. Rename it and fix up all users.
Signed-off-by: Simon Glass sjg@chromium.org
Reviewed-by: Joe Hershberger joe.hershberger@ni.com
Applied to u-boot-dm.
participants (2)
-
Joe Hershberger
-
Simon Glass