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>
23 files changed:
if (!device_active(hub))
continue;
if (!device_active(hub))
continue;
- udev = dev_get_parentdata(hub);
+ udev = dev_get_parent_priv(hub);
if (udev->devnum == devnum)
return udev;
if (udev->devnum == devnum)
return udev;
if (!device_active(hub))
continue;
if (!device_active(hub))
continue;
- udev = dev_get_parentdata(dev);
+ udev = dev_get_parent_priv(dev);
if (udev->devnum == devnum)
return udev;
}
if (udev->devnum == devnum)
return udev;
}
if (!device_active(child))
continue;
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) {
/* Ignore emulators, we only want real devices */
if (device_get_uclass_id(child) != UCLASS_USB_EMUL) {
struct udevice *child;
struct usb_device *udev;
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);
usb_display_desc(udev);
usb_display_config(udev);
for (device_find_first_child(dev, &child);
device_find_first_child(bus, &dev);
if (dev && device_active(dev)) {
device_find_first_child(bus, &dev);
if (dev && device_active(dev)) {
- udev = dev_get_parentdata(dev);
+ udev = dev_get_parent_priv(dev);
#ifdef CONFIG_DM_USB
int hub_port_reset(struct udevice *dev, int port, unsigned short *portstat)
{
#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);
}
return legacy_hub_port_reset(udev, port, portstat);
}
#ifdef CONFIG_DM_USB
int usb_hub_scan(struct udevice *hub)
{
#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);
}
return usb_hub_configure(udev);
}
static int usb_mass_storage_probe(struct udevice *dev)
{
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 */
int ret;
usb_disable_asynch(1); /* asynch transfer not allowed */
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
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.
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.
uclass, they share some common elements with controllers:
- they both attach private data to their children (struct usb_device,
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
- they both use usb_child_pre_probe() to set up their children as proper USB
devices
return dev->uclass_priv;
}
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__);
{
if (!dev) {
dm_warn("%s: null device\n", __func__);
int cros_ec_spi_packet(struct udevice *udev, int out_bytes, int in_bytes)
{
struct cros_ec_dev *dev = dev_get_uclass_priv(udev);
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;
ulong start;
uint8_t byte;
int rv;
uint8_t **dinp, int din_len)
{
struct cros_ec_dev *dev = dev_get_uclass_priv(udev);
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;
int in_bytes = din_len + 4; /* status, length, checksum, trailer */
uint8_t *out;
uint8_t *p;
*/
static int spi_dataflash_probe(struct udevice *dev)
{
*/
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];
struct spi_flash *spi_flash;
struct flash_info *info;
u8 idcode[5];
int spi_flash_std_probe(struct udevice *dev)
{
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;
struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev);
struct spi_flash *flash;
#else
static int fsl_qspi_child_pre_probe(struct udevice *dev)
{
#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;
slave->max_write_size = TX_BUFFER_SIZE;
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 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
/*
* Yes this controller can only write a small number of bytes at
static int soft_spi_probe(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;
struct soft_spi_platdata *plat = dev->platdata;
int cs_flags, clk_flags;
static int spi_child_pre_probe(struct udevice *dev)
{
struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev);
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
/*
* This is needed because we pass struct spi_slave around the place
ret = device_probe(dev);
if (ret)
goto err;
ret = device_probe(dev);
if (ret)
goto err;
- slave = dev_get_parentdata(dev);
+ slave = dev_get_parent_priv(dev);
- *devp = dev_get_parentdata(dev);
+ *devp = dev_get_parent_priv(dev);
debug("%s: bus=%p, slave=%p\n", __func__, bus, *devp);
return 0;
debug("%s: bus=%p, slave=%p\n", __func__, bus, *devp);
return 0;
ret = device_get_child_by_of_offset(bus, node, &dev);
if (ret)
return NULL;
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 */
}
/* Compatibility function - to be removed */
#ifdef CONFIG_DM_ETH
static int smsc95xx_eth_start(struct udevice *dev)
{
#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);
struct smsc95xx_private *priv = dev_get_priv(dev);
struct eth_pdata *pdata = dev_get_platdata(dev);
int smsc95xx_write_hwaddr(struct udevice *dev)
{
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);
struct eth_pdata *pdata = dev_get_platdata(dev);
struct smsc95xx_private *priv = dev_get_priv(dev);
int usb_ether_register(struct udevice *dev, struct ueth_data *ueth, int rxsize)
{
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;
struct usb_interface_descriptor *iface_desc;
bool ep_in_found = false, ep_out_found = false;
struct usb_interface *iface;
ttdev = udev;
parent = udev->dev;
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;
while (uparent->speed != USB_SPEED_HIGH) {
struct udevice *dev = parent;
- ttdev = dev_get_parentdata(dev);
+ ttdev = dev_get_parent_priv(dev);
- uparent = dev_get_parentdata(parent);
+ uparent = dev_get_parent_priv(parent);
}
parent_devnum = uparent->devnum;
#else
}
parent_devnum = uparent->devnum;
#else
if (!device_active(parent))
return NULL;
if (!device_active(parent))
return NULL;
- udev = dev_get_parentdata(parent);
+ udev = dev_get_parent_priv(parent);
if (udev->devnum == devnum)
return udev;
if (udev->devnum == devnum)
return udev;
udev->portnr = port;
debug("Calling usb_setup_device(), portnr=%d\n", udev->portnr);
parent_udev = device_get_uclass_id(parent) == UCLASS_USB_HUB ?
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)
ret = usb_setup_device(udev, priv->desc_before_addr, parent_udev);
debug("read_descriptor for '%s': ret=%d\n", parent->name, ret);
if (ret)
if (!device_active(dev))
continue;
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 */
if (usb_get_port_status(udev, udev->portnr, &status)
< 0)
/* USB request failed */
int usb_child_pre_probe(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;
struct usb_dev_platdata *plat = dev_get_parent_platdata(dev);
int ret;
if (device_get_uclass_id(dev) == UCLASS_USB)
udev = dev_get_uclass_priv(dev);
else
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);
} else {
while (!is_root_hub(hub->parent))
hub = hub->parent;
} 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;
}
}
root_portnr = uhop->portnr;
}
}
*/
ttdev = udev;
parent = udev->dev;
*/
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;
while (uparent->speed != USB_SPEED_HIGH) {
struct udevice *dev = parent;
- ttdev = dev_get_parentdata(dev);
+ ttdev = dev_get_parent_priv(dev);
- uparent = dev_get_parentdata(parent);
+ uparent = dev_get_parent_priv(parent);
}
return (uparent->devnum << 8) | (ttdev->portnr - 1);
}
return (uparent->devnum << 8) | (ttdev->portnr - 1);
* If these 2 are not the same we are being called from
* usb_scan_device() and udev itself is the parent.
*/
* 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 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);
void *dev_get_uclass_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
*/
*
* 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
/**
* dev_get_priv() - Get the private data for a device
*
* Every device on a PCI bus has this per-child data.
*
*
* 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()
* PCI bus (i.e. UCLASS_PCI)
*
* @devfn: Encoded device and function index - see PCI_DEVFN()
* struct spi_slave - Representation of a SPI slave
*
* For driver model this is the per-child data used by the SPI bus. It can
* 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
* 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
* (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
* (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
*
* Pointers exist for obtaining both the device (could be any uclass) and
* controller (UCLASS_USB) from this structure. The controller does not have
static int testbus_child_pre_probe(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;
parent_data->flag += FLAG_CHILD_PROBED;
static int testbus_child_post_remove(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;
struct dm_test_state *dms = test_state;
parent_data->flag += FLAG_CHILD_REMOVED;
/* Check that parent data is allocated */
ut_assertok(device_find_child_by_seq(bus, 0, true, &dev));
/* 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));
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_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));
/* 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);
ut_assert(NULL != parent_data);
parent_data->sum += 5;
ut_asserteq(5, parent_data->sum);
uclass_foreach_dev(dev, uc) {
/* Ignore these if they are not on this bus */
if (dev->parent != bus) {
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));
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;
parent_data->sum = value;
value += 5;
/* Ignore these if they are not on this bus */
if (dev->parent != bus)
continue;
/* 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;
ut_asserteq(value, parent_data->sum);
value += 5;
/* Ignore these if they are not on this bus */
if (dev->parent != bus)
continue;
/* 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));
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);
}
ut_asserteq(FLAG_CHILD_PROBED, parent_data->flag);
}
/* Ignore these if they are not on this bus */
if (dev->parent != bus)
continue;
/* 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(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;
ut_asserteq_ptr(dms->removed, dev);
}
test_state = NULL;