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 52E45C54EBC for ; Sun, 8 Jan 2023 02:59:32 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E908F85605; Sun, 8 Jan 2023 03:55:28 +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="jzVMBeGW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 992DE85634; Sun, 8 Jan 2023 03:55:25 +0100 (CET) Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) (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 CFB8985667 for ; Sun, 8 Jan 2023 03:51:24 +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-il1-x133.google.com with SMTP id m15so3288662ilj.8 for ; Sat, 07 Jan 2023 18:51:24 -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=oW66sd1nPf2jcQe1VZ8Ekikleh2t6UpUHUT97WzhlF8=; b=jzVMBeGWLS87LZSsb/YozQptORMS85PFP5KopOHW+nZ7J0bAf86R9TPGHcVIArMdVI N3zcZGSV/ZOqbXCU/TYoWZ2thJcikwa7kWCSE4am5AlL84UDg2HmRh2bg1vMhXQwnDLt 8d5gpFzwJ34DSqX3wXUumJYWPEvyUVq5L8Xgg= 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=oW66sd1nPf2jcQe1VZ8Ekikleh2t6UpUHUT97WzhlF8=; b=4JUNLx+OZSQDn96fj6TcZx8hNeM9OXJB8s2uOMiINGiZrkdSkvCTcEpHKK4rb0+U6w tnWbIAOMtWTzwyFhP7jJmORNf1s1rVnnqsfj/90ADdrBKaCxrIPvZJiMWUVMvp9SCPZM nHTcTpMFaTJHyIY/gS6GVrTKSydffeTH9kee02N0bynyzCQfA2j8V4M2mE0YZGxGibXY YCdylhRDP+5ufgGXVaaqH9nZi0HKA7b7sIfef2gdRSw+5KGnqdzlMSD50RH8JpzIYcTh Kx6pQFFAMzQfmSKB8is6E2dVGPn2i07dgpZTIEVDlNrgAGd+CpzQ9tMT0sGgFvyurzz+ zSqg== X-Gm-Message-State: AFqh2krHcO4KpfRnbO7G5+k03nmTcklivwGZLNGOoGoXrlIwDkr+vB5y /wlj7Vwlpe8tSbHmdV07h8WlLhsqVgW5qrw2 X-Google-Smtp-Source: AMrXdXsIVweJGtctTbjsuwkrpo3HJqidNW3FkXnS2A6CNW5snJqAEKMJQRV78uG3lbPXzwAufnj+4Q== X-Received: by 2002:a92:cc82:0:b0:30b:d94a:db16 with SMTP id x2-20020a92cc82000000b0030bd94adb16mr37153978ilo.10.1673146284358; Sat, 07 Jan 2023 18:51:24 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-71-56-217-229.hsd1.co.comcast.net. [71.56.217.229]) by smtp.gmail.com with ESMTPSA id c17-20020a92bd11000000b00302a00aaefasm1622174ile.26.2023.01.07.18.51.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Jan 2023 18:51:24 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: U-Boot Custodians , Simon Glass Subject: [PATCH v2 39/71] virtio: Avoid repeating a long expression Date: Sat, 7 Jan 2023 19:50:15 -0700 Message-Id: <20230108025047.522240-40-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230108025047.522240-1-sjg@chromium.org> References: <20230108025047.522240-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 --- (no changes since v1) 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.314.g84b9a713c41-goog