From patchwork Mon Mar 27 19:07:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761928 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ECAybuNj; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PljC30Dttz1yYb for ; Tue, 28 Mar 2023 06:13:19 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0D61B86154; Mon, 27 Mar 2023 21:11:21 +0200 (CEST) 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="ECAybuNj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2EACF85CCA; Mon, 27 Mar 2023 21:09:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) (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 B29CA8610C for ; Mon, 27 Mar 2023 21:09:49 +0200 (CEST) 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-pl1-x634.google.com with SMTP id ix20so9411964plb.3 for ; Mon, 27 Mar 2023 12:09:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944188; 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=6KJd36yxWrmtsCCPI9d7M96cM1UNQddbZEpNP70PlzU=; b=ECAybuNjESpWTSUrnCIIr+KDo1yBEJyWoYBhSINQK/+UZ3QTteGnYD2F7z5Lwvm/Jn 0ssihMOwsPkq5W064i/WI54ztnftEv4EkordXNqjVPdaJrFdsobl3jz6S8JBxJioIqKE 7KGsWDbHJx8UYY7DCViO3YuwnfFQM5odbYzMQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944188; 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=6KJd36yxWrmtsCCPI9d7M96cM1UNQddbZEpNP70PlzU=; b=TQ5K18A0mN8k3MoLc7guzJV3lSSkTfLwGDNoHRCy+ipVj6jeI0KO3P0RNQwRVxgdVt i5yI30viReOmG2p4CAAfPmPyInSpv32sG+KNpNACIakpOBBrTMcXkySrpDxNzFWSy21m CCICSvz7wkrWfLl1Y+W71bD7GLIprx+lqfW08+Htv7dm4o9KtqtY84OoqULw3rMq1FbU eJbwpMhHdYq7Vru/+XXrwht1sJUrGVxXm5dnouFWVmZ+D+kQ5IuRNsIDMtEHjLKkyvhO LDL3Wg/9Cav+zNDPwxqt6cAPT+YDf4J5feSGpfAmKjkyy0putcEYAZPvJgPrmFudrMCJ gLNA== X-Gm-Message-State: AO0yUKX1yu09VnLVqAIYhK16/weahMJ7wpwocOiXVlXXWcL4NavfzfAz RukpkYtNZ5jINKkvzkfZBanOS7sC9gmvualNvPQ= X-Google-Smtp-Source: AK7set97a9zIm0Y6gjlHtXgqpJ9g88AYyz4E/IYeAsGQY2ACAhF2J8AbRylJpJSCtTpirERrFSYu8w== X-Received: by 2002:a05:6a20:bb1a:b0:d4:298b:8b8e with SMTP id fc26-20020a056a20bb1a00b000d4298b8b8emr11433461pzb.33.1679944187866; Mon, 27 Mar 2023 12:09:47 -0700 (PDT) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id d9-20020aa78e49000000b005cd81a74821sm15653334pfr.152.2023.03.27.12.09.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:09:47 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 19/30] ide: Move setting of vendor strings into ide_probe() Date: Tue, 28 Mar 2023 08:07:06 +1300 Message-Id: <20230328080702.19.I7c4998639fe1f60f4a01648adbb111370025121d@changeid> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog In-Reply-To: <20230327190717.1796230-1-sjg@chromium.org> References: <20230327190717.1796230-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean The current implementation adds this information in the block device's probe() function, which is called in the blk_probe_or_unbind() in ide_probe(). It is simpler to do this in ide_probe() itself, since the effect is the same. This helps to consolidate use of ide_dev_desc[] which we would like to remove. Use strlcpy() to keep checkpatch happy. Signed-off-by: Simon Glass --- drivers/block/ide.c | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 36c726225d0e..ecac8b6cfd55 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -987,24 +987,6 @@ ulong ide_or_atapi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, return ide_read(dev, blknr, blkcnt, buffer); } -static int ide_blk_probe(struct udevice *udev) -{ - struct blk_desc *desc = dev_get_uclass_plat(udev); - - /* fill in device vendor/product/rev strings */ - strncpy(desc->vendor, ide_dev_desc[desc->devnum].vendor, - BLK_VEN_SIZE); - desc->vendor[BLK_VEN_SIZE] = '\0'; - strncpy(desc->product, ide_dev_desc[desc->devnum].product, - BLK_PRD_SIZE); - desc->product[BLK_PRD_SIZE] = '\0'; - strncpy(desc->revision, ide_dev_desc[desc->devnum].revision, - BLK_REV_SIZE); - desc->revision[BLK_REV_SIZE] = '\0'; - - return 0; -} - static const struct blk_ops ide_blk_ops = { .read = ide_or_atapi_read, .write = ide_write, @@ -1014,7 +996,6 @@ U_BOOT_DRIVER(ide_blk) = { .name = "ide_blk", .id = UCLASS_BLK, .ops = &ide_blk_ops, - .probe = ide_blk_probe, }; static int ide_bootdev_bind(struct udevice *dev) @@ -1060,17 +1041,19 @@ BOOTDEV_HUNTER(ide_bootdev_hunter) = { static int ide_probe(struct udevice *udev) { - struct udevice *blk_dev; - char name[20]; - int blksz; - lbaint_t size; int i; - int ret; ide_init(); for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; i++) { if (ide_dev_desc[i].type != DEV_TYPE_UNKNOWN) { + struct udevice *blk_dev; + struct blk_desc *desc; + lbaint_t size; + char name[20]; + int blksz; + int ret; + sprintf(name, "blk#%d", i); blksz = ide_dev_desc[i].blksz; @@ -1095,6 +1078,17 @@ static int ide_probe(struct udevice *udev) ret = bootdev_setup_for_dev(udev, "ide_bootdev"); if (ret) return log_msg_ret("bootdev", ret); + + /* fill in device vendor/product/rev strings */ + desc = dev_get_uclass_plat(blk_dev); + strlcpy(desc->vendor, ide_dev_desc[desc->devnum].vendor, + BLK_VEN_SIZE); + strlcpy(desc->product, + ide_dev_desc[desc->devnum].product, + BLK_PRD_SIZE); + strlcpy(desc->revision, + ide_dev_desc[desc->devnum].revision, + BLK_REV_SIZE); } }