Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 57F23C352A1 for ; Wed, 7 Dec 2022 09:03:06 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A1D59856C7; Wed, 7 Dec 2022 09:56:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="O2lShDSS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7AAD185652; Wed, 7 Dec 2022 09:56:15 +0100 (CET) Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3BA1585674 for ; Wed, 7 Dec 2022 09:56:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-pj1-x1033.google.com with SMTP id 3-20020a17090a098300b00219041dcbe9so935840pjo.3 for ; Wed, 07 Dec 2022 00:56:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OVPBAV8cepJ5DONYQsKJq7Zw2wNGGRTYUKtLMCXGqOM=; b=O2lShDSSwO7wOZ6oE46RGqbeB3twIAFwH/xWfmKOYi90Bw1KTgG34JS2MxS7eIZYrp BCvzNk27slC5pF+6KbUkBcmG6m7EEu1xVaDVAHQblk7Fkn/o5eAFDv8Z60QbXc6WLXPS DoK8OfGRoFphhu6RPvdDU07GjSJjwy9kXNJrs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OVPBAV8cepJ5DONYQsKJq7Zw2wNGGRTYUKtLMCXGqOM=; b=Xm6FxY1y1A3oRQ8wAFy7k8+8mNzRjkh3bvixtujcR/9yVerTZVPaB9/xX0laucKPjs OwamCw2qzZuBpmnMqib+Q6DaOjyWlrcVtCr0P8mGy3+FfErHvlC/PF7GzbT9u9fpIvxZ RbLJr9H4iPKJXDWQSJ1ueZ6DPGP9OJRaOM1LLefyQ2KSqvGguJrxlx9edggQb+yoyBN/ Q+tsx3I+hc9f2Sno9wY8n4JwsbyEm8CatXjjLwqPrAf9rveHEInsx9Omq3VxNvTf0Ey+ GLvJjla7PEH8jk17c4RRl3adDv3gr9MrVOoRNhHTLbJMCurMiXWR4idg/KWpxUbxm5tO 8r7w== X-Gm-Message-State: ANoB5pka07747/TCx1i10VMx/cPchJPv6XWT7My/Bma1CBcttO5H3VHc jkegqpY4YLTj0EPw03nrHcj3mDxl01OO2Kya X-Google-Smtp-Source: AA0mqf45TW4oIZ8r58xZs8BCFxyITER5GPSBIhSMIkf8c8Uwt2c7NwNKgJezaQoHRsDQZp0xFz8jDw== X-Received: by 2002:a17:902:b40b:b0:188:ca57:ce0c with SMTP id x11-20020a170902b40b00b00188ca57ce0cmr79315370plr.57.1670403370415; Wed, 07 Dec 2022 00:56:10 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:56:10 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass , Bin Meng Subject: [PATCH 39/71] virtio: Avoid repeating a long expression Date: Wed, 7 Dec 2022 21:51:05 +1300 Message-Id: <20221207085137.445249-40-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Use a local variable to hold this name, to reduce the amount of code that needs to be read. Signed-off-by: Simon Glass --- drivers/virtio/virtio-uclass.c | 10 +++++----- 1 file 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; -- 2.39.0.rc0.267.gcb52ba06e7-goog