aboutsummaryrefslogtreecommitdiff
path: root/drivers/virtio/virtio-uclass.c
diff options
context:
space:
mode:
authorSimon Glass2023-01-17 10:47:48 -0700
committerTom Rini2023-01-23 18:11:40 -0500
commit59a6be9b1147e43c68236cb52be7b56c586be03a (patch)
tree4c4f1c70b5392a50e949131f90a9b5347b00f31d /drivers/virtio/virtio-uclass.c
parent758c706c6873fda806e3ce70d08bbb8ef3b81707 (diff)
virtio: Avoid repeating a long expression
Use a local variable to hold this name, to reduce the amount of code that needs to be read. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/virtio/virtio-uclass.c')
-rw-r--r--drivers/virtio/virtio-uclass.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/virtio/virtio-uclass.c b/drivers/virtio/virtio-uclass.c
index da4f2f26a63..6d9b029390e 100644
--- a/drivers/virtio/virtio-uclass.c
+++ b/drivers/virtio/virtio-uclass.c
@@ -214,6 +214,7 @@ static int virtio_uclass_post_probe(struct udevice *udev)
struct virtio_dev_priv *uc_priv = dev_get_uclass_priv(udev);
char dev_name[30], *str;
struct udevice *vdev;
+ const char *name;
int ret;
if (uc_priv->device >= VIRTIO_ID_MAX_NUM) {
@@ -222,20 +223,19 @@ static int virtio_uclass_post_probe(struct udevice *udev)
return 0;
}
- if (!virtio_drv_name[uc_priv->device]) {
+ name = virtio_drv_name[uc_priv->device];
+ if (!name) {
debug("(%s): underlying virtio device driver unavailable\n",
udev->name);
return 0;
}
- snprintf(dev_name, sizeof(dev_name), "%s#%d",
- virtio_drv_name[uc_priv->device], dev_seq(udev));
+ snprintf(dev_name, sizeof(dev_name), "%s#%d", name, dev_seq(udev));
str = strdup(dev_name);
if (!str)
return -ENOMEM;
- ret = device_bind_driver(udev, virtio_drv_name[uc_priv->device],
- str, &vdev);
+ ret = device_bind_driver(udev, name, str, &vdev);
if (ret == -ENOENT) {
debug("(%s): no driver configured\n", udev->name);
return 0;