From patchwork Mon Mar 27 19:06:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761912 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=eiMwstEp; 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 4Plj641XWxz1yXq for ; Tue, 28 Mar 2023 06:09:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C619186100; Mon, 27 Mar 2023 21:08:56 +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="eiMwstEp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 93FA386100; Mon, 27 Mar 2023 21:08: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-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) (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 BA77B85B31 for ; Mon, 27 Mar 2023 21:08:51 +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-x630.google.com with SMTP id iw3so9392738plb.6 for ; Mon, 27 Mar 2023 12:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944130; 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=nszod5QmzvALhEYs2zZgBfktY4kQIUm0An3Yp/P1XcU=; b=eiMwstEpoEwuNYM+L0/A4TyLnTx8NaOp7s8dXkSmA0r3CD5IeDjvsW3wTrdAu6ZlZA oUTAILMGvT9x3+W1GuBCuEDJx3wivMRCyGhtM8EmTsGKsuU1XThaWcMCTAIQc/CLbiBy IZH57XO9OcLTEPSTd8TBKEOXKrUm0j8qb9fzw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944130; 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=nszod5QmzvALhEYs2zZgBfktY4kQIUm0An3Yp/P1XcU=; b=ikyk7E926v4VpmMcHukhsbjWUhZXNWj93mvJJ9GnQvX5Z28Rap3zeFH9QBCWLP1/io EJT+l0+b9AuMYmzS72vzGDL+MCtv+Karl5B2Sb0qLAboPe8Laryl+wSWBgWYmf/F8vyZ 29k21QhoSJX1dMm4BNXyzgs1Mi4G3EcGN6mPPu0cu6KPcS4RMOWv8HTAj/eYw1fh0EeK KYxQDPoud/YtfLff//ts5LuwvQSZmOs327jKcIKXz9Xb2Fi/r2l+qamgqbuRTX9LmUxX RKlq3sNgwdxp2MFlwhK6nNoCH83MRyn+6g9cVIMJC0hdHwaaIm8G87Ce+Zo93RdWgf23 4xwA== X-Gm-Message-State: AO0yUKWatfG+BdsngS92qttX3J4LhdH0Sfn+2rDC5hy+SRMiFK3kqg2z 0aj4a3ZRjaGWieF9BrG5h2IRMLQbyDH8/+KQccs= X-Google-Smtp-Source: AK7set9JLnZOq8pTNwgRD5sjpRDErqtJltlPkTGEf1EQg+QovUqtvbSF3ywGuIQudfAfzGq6SveouQ== X-Received: by 2002:a05:6a20:2a21:b0:cd:5334:e25e with SMTP id e33-20020a056a202a2100b000cd5334e25emr9755510pzh.17.1679944129929; Mon, 27 Mar 2023 12:08:49 -0700 (PDT) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id d9-20020aa78e49000000b005cd81a74821sm15653334pfr.152.2023.03.27.12.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:08:49 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 01/30] ide: Move ATA_CURR_BASE to C file Date: Tue, 28 Mar 2023 08:06:48 +1300 Message-Id: <20230328080702.1.I0924c08ed4f8a97ffbe3f718e5958a0b0c45663b@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 This is not used outside one C file. Move it out of the header to reduce its visbility. Signed-off-by: Simon Glass --- drivers/block/ide.c | 3 +++ include/ide.h | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 1ad9b6c1267e..f36bec8b3a8a 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -36,6 +36,9 @@ ulong ide_bus_offset[CONFIG_SYS_IDE_MAXBUS] = { #endif }; +#define ATA_CURR_BASE(dev) (CONFIG_SYS_ATA_BASE_ADDR + \ + ide_bus_offset[IDE_BUS(dev)]) + static int ide_bus_ok[CONFIG_SYS_IDE_MAXBUS]; struct blk_desc ide_dev_desc[CONFIG_SYS_IDE_MAXDEVICE]; diff --git a/include/ide.h b/include/ide.h index 426cef4e39e0..58f6640c61be 100644 --- a/include/ide.h +++ b/include/ide.h @@ -11,9 +11,6 @@ #define IDE_BUS(dev) (dev / (CONFIG_SYS_IDE_MAXDEVICE / CONFIG_SYS_IDE_MAXBUS)) -#define ATA_CURR_BASE(dev) (CONFIG_SYS_ATA_BASE_ADDR+ide_bus_offset[IDE_BUS(dev)]) -extern ulong ide_bus_offset[]; - /* * Function Prototypes */ From patchwork Mon Mar 27 19:06:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761913 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=nPI3Vc3D; 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 4Plj6t703kz1yXq for ; Tue, 28 Mar 2023 06:09:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2FA848611A; Mon, 27 Mar 2023 21:09:26 +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="nPI3Vc3D"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 388AC860FE; Mon, 27 Mar 2023 21:08:58 +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-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) (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 9808085B31 for ; Mon, 27 Mar 2023 21:08:54 +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-pj1-x102d.google.com with SMTP id fy10-20020a17090b020a00b0023b4bcf0727so10040503pjb.0 for ; Mon, 27 Mar 2023 12:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944133; 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=Pnwf+MqN3X+FxACkfXxr/QZFV4E9e+syViCop3sy6FM=; b=nPI3Vc3D1NTFSvDUb22OM5ueyUbFlRfnOtZbE3t+z5eo+N/CjxDlobpFqP1q95bOwX iC0pulCIBF8w8L6rrSS4NHki+dvoNaEVdOQ9s0V61K/k2wFVHndhkYxvSjP5PlvNTI8W T83lU3Ff7gZ2J9moO+mkYF/yABmRnLSCsxYJs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944133; 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=Pnwf+MqN3X+FxACkfXxr/QZFV4E9e+syViCop3sy6FM=; b=VpvPn8FB5bpIno5cV2ObtY5qknZwshUcT9z3LzIQ3Dt6WnylYlOeMzlSTEI/vLjaSG OR6t+3N14SDA9HqJsYBr6PfjrSEyJSu6mgbPLNlR/2pYADz8ppFHJAXZeAhHSmZOiwV1 rxwm/enjIGU3HfBpdG7ZsX5e2l2rpQah8nF3IAFQXzTCFVrPSPcv0c12JJCLwZEg9PBE jZWqC0l1h1hTso854Tl77+LiaMvj0uIOe6baKPN49OGmMJaJ263FnY4lV2ql3b8A8ZuF MoyWcKYV16wi8T+Xey1e2T/lH6qz6kwj1n20nnDsDVCo5WYMsQPihOwOYOmCDy+hb3de MPXw== X-Gm-Message-State: AO0yUKXaeXeZi4FYOVIB+8hj9IcV5yiUhyUyneO2BukoYR1IpYv+j9mA jI/V1CdmmufAN9WGmiT0Zd98LOKcy9stEAefqUE= X-Google-Smtp-Source: AK7set9Hb3I2sCMwK9IUFa66zMTalqDlSKSpWn+XoOrcWymWXNi5Vy8hMrNaDtMsBoXvacpVpAuJcA== X-Received: by 2002:a05:6a20:389e:b0:dc:4369:16a4 with SMTP id n30-20020a056a20389e00b000dc436916a4mr10306845pzf.19.1679944132844; Mon, 27 Mar 2023 12:08:52 -0700 (PDT) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id d9-20020aa78e49000000b005cd81a74821sm15653334pfr.152.2023.03.27.12.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:08:52 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 02/30] ide: Use mdelay() for long delays Date: Tue, 28 Mar 2023 08:06:49 +1300 Message-Id: <20230328080702.2.I8ff6ead2bbb4cab773ce06d54045810aab0a56bb@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 Rather than using very large numbers with udelay(), use mdelay(), which is easier to follow. Signed-off-by: Simon Glass --- drivers/block/ide.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index f36bec8b3a8a..6f601bcf8646 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -71,9 +71,7 @@ static void ide_reset(void) /* de-assert RESET signal */ ide_set_reset(0); - /* wait 250 ms */ - for (i = 0; i < 250; ++i) - udelay(1000); + mdelay(250); } #else #define ide_reset() /* dummy */ @@ -237,7 +235,7 @@ unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen, ide_output_data_shorts(device, (unsigned short *)ccb, ccblen / 2); /* ATAPI Command written wait for completition */ - udelay(5000); /* device must set bsy */ + mdelay(5); /* device must set bsy */ mask = ATA_STAT_DRQ | ATA_STAT_BUSY | ATA_STAT_ERR; /* @@ -293,7 +291,7 @@ unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen, n); } } - udelay(5000); /* seems that some CD ROMs need this... */ + mdelay(5); /* seems that some CD ROMs need this... */ mask = ATA_STAT_BUSY | ATA_STAT_ERR; res = 0; c = atapi_wait_mask(device, ATAPI_TIME_OUT, mask, res); @@ -357,7 +355,7 @@ retry: if ((key == 6) || (asc == 0x29) || (asc == 0x28)) { /* Unit Attention */ if (unitattn-- > 0) { - udelay(200 * 1000); + mdelay(200); goto retry; } printf("Unit Attention, tried %d\n", ATAPI_UNIT_ATTN); @@ -366,7 +364,7 @@ retry: if ((asc == 0x4) && (ascq == 0x1)) { /* not ready, but will be ready soon */ if (notready-- > 0) { - udelay(200 * 1000); + mdelay(200); goto retry; } printf("Drive not ready, tried %d times\n", @@ -586,9 +584,9 @@ static void ide_ident(struct blk_desc *dev_desc) debug("Retrying...\n"); ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device)); - udelay(100000); + mdelay(100); ide_outb(device, ATA_COMMAND, 0x08); - udelay(500000); /* 500 ms */ + mdelay(500); } /* * Select device @@ -715,14 +713,13 @@ void ide_init(void) ide_bus_ok[bus] = 0; - /* Select device - */ - udelay(100000); /* 100 ms */ + /* Select device */ + mdelay(100); ide_outb(dev, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(dev)); - udelay(100000); /* 100 ms */ + mdelay(100); i = 0; do { - udelay(10000); /* 10 ms */ + mdelay(10); c = ide_inb(dev, ATA_STATUS); i++; From patchwork Mon Mar 27 19:06:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761914 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=CVEhuSdc; 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 4Plj744FwCz1yXq for ; Tue, 28 Mar 2023 06:09:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1C1E686119; Mon, 27 Mar 2023 21:09:32 +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="CVEhuSdc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D4B0A8611D; Mon, 27 Mar 2023 21:09:10 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) (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 9EF0886101 for ; Mon, 27 Mar 2023 21:08:59 +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-pg1-x531.google.com with SMTP id y35so5799572pgl.4 for ; Mon, 27 Mar 2023 12:08:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944137; 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=n75pgKuXBjITBC3lS8y/E6pK06qSiTtegStt0smz+pA=; b=CVEhuSdcwHybpdYXxQkR7KL4cLnpCHp1+VwBlVHITkiLRIC5poxzAlVtH2h+a/1VPL /z9Ni+0pB1RVPr0hGj/4pxnMy93ynEVQYcKsJqggGGbQU93mp+bRBNSVH31K58KVmkQ0 i5ZhmNCaVX9Tflz/lj8oqg1WJ9tgdJcUxVvHk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944137; 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=n75pgKuXBjITBC3lS8y/E6pK06qSiTtegStt0smz+pA=; b=LuYHFCqkiS+zFh2605NL98467olt9eLpaGo7s89fWrwme3sn4lSL5PLU5xnUh3LyFd 43dCuwn1CnjmChssSvaRxJRrl3gaUzGTBC3V8IHIf1hw9FUbimUZv1xDUTSr8RWnItJR 6xzs08gU9pFpfmdf3getgxm1ThPcOWIjEdws7Shtb8n/ERKqvBKswJLU0M5bx9VA1PrX BUeS8nvizIyeoBMeBb6ZozRWgAy5tXIwtzC9u1qYu7GREdmbJlgs/Zaz3HgvM2vg5pfe E+Y3Jc4VSgBn0fnY9+TsSjUEc1e4E+qDRc/ekbwDJg5+XzY0CkAf9ZWqyiwxqSjfUIQO aGLQ== X-Gm-Message-State: AAQBX9d1Pkuln4tWG1NSNKfdohQDJbGFJzP6pyE8Ecssx3dbMt07MJS3 UokzIlp7gVlDqNuv6ub21Faz74dIfctmz+B7Jac= X-Google-Smtp-Source: AKy350Z3TeWGZ4x7ranDILKXoDbMk0/gfgR9ZzkXnnfLyhxJZggoo816m8X4LgeY+kIEZxatidQJAQ== X-Received: by 2002:a62:1bc4:0:b0:61d:e10f:4e70 with SMTP id b187-20020a621bc4000000b0061de10f4e70mr11952595pfb.0.1679944137743; Mon, 27 Mar 2023 12:08:57 -0700 (PDT) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id d9-20020aa78e49000000b005cd81a74821sm15653334pfr.152.2023.03.27.12.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:08:57 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass , AKASHI Takahiro , Dzmitry Sankouski , Ilias Apalodimas , Ovidiu Panait , Rasmus Villemoes , Stefan Roese Subject: [PATCH 03/30] ide: Drop CONFIG_START_IDE Date: Tue, 28 Mar 2023 08:06:50 +1300 Message-Id: <20230328080702.3.If27cd09c62f628a54f22cc501388bbd1dd001f19@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 This is not used by any board. Drop it. Signed-off-by: Simon Glass --- common/board_r.c | 5 ----- include/ide.h | 7 ------- 2 files changed, 12 deletions(-) diff --git a/common/board_r.c b/common/board_r.c index 6b4180b3ecde..7076af64f5de 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -523,12 +523,7 @@ static int initr_post(void) static int initr_ide(void) { puts("IDE: "); -#if defined(CONFIG_START_IDE) - if (board_start_ide()) - ide_init(); -#else ide_init(); -#endif return 0; } #endif diff --git a/include/ide.h b/include/ide.h index 58f6640c61be..9c0d40364a8f 100644 --- a/include/ide.h +++ b/include/ide.h @@ -47,11 +47,4 @@ void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts); void ide_led(uchar led, uchar status); -/** - * board_start_ide() - Start up the board IDE interfac - * - * Return: 0 if ok - */ -int board_start_ide(void); - #endif /* _IDE_H */ From patchwork Mon Mar 27 19:06:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761915 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=h4eYRhRm; 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 4Plj7P4QpMz1yXv for ; Tue, 28 Mar 2023 06:10:09 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 01D4486121; Mon, 27 Mar 2023 21:09:43 +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="h4eYRhRm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 919878610A; Mon, 27 Mar 2023 21:09:17 +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-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) (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 4BF39860FE for ; Mon, 27 Mar 2023 21:09:04 +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-pj1-x102a.google.com with SMTP id h12-20020a17090aea8c00b0023d1311fab3so10016459pjz.1 for ; Mon, 27 Mar 2023 12:09:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944142; 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=Xw+gSeIowdRe0Eo4+0zdosz6YIQuQSmWFIOvC6HJ38g=; b=h4eYRhRmmyzZ1zckOSOXYcYQLCtQ5xzM82BB841NH2SoRcVnRU70l9D33J2BPcyp6z 4Bn/KZlb+qqCX+5IQv1lCjbNHYN4udLm1TXGeAYcTJXRruXJ7S2DkvY31rPnfvSmlGOj SUJKpflpg7Wcs6AJ8o9eU3GdOwrLprs1AvwRM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944142; 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=Xw+gSeIowdRe0Eo4+0zdosz6YIQuQSmWFIOvC6HJ38g=; b=wC3V6/HhUE97Kk62AOKTHLnCIEsWhvlvJb/O5uhW+Ai7V3XoSA40/DhE62kqcYQlVi zztnqZDCH26v/tf28/PAE32exJkeLLFRrwMiClbElRAPnLp0LLz5P5EVAoC4aEEYKO6p P0H/odL7mOo1dwqzlhxfv8hNNywbGIkjAB/j3DT4PNnVUNVz3hnH1sI2O54gHlReKUhz lkHzTYuFEUy8YbSkYJOd0lti1E5bcnTVZAWUak+BmmxGvkkTpr3WkkHja+ieZMaPJOg6 BVjneo++1S7b3bC9A2JWOT7XLzPnFBRXmZZYreYy/31KoI3F7C4tzlB6w1G4bEfETyiw 10jA== X-Gm-Message-State: AO0yUKXSXv83YOMYyfp68u55BMoRw+sfjqCZ8/XERiPhRX9prwQi1rAm 7/wMQP3Y8Ilh4+G25AU0RbSYYXfuB555RlTwKMw= X-Google-Smtp-Source: AK7set9a0ORuHPZc2InLg8Z4XSdFe8DBkkcivCmkR7Zne8avkXj8LjfocL2hzYKQNUlzToiY86JGlA== X-Received: by 2002:a05:6a20:2a18:b0:db:6d41:d628 with SMTP id e24-20020a056a202a1800b000db6d41d628mr11004816pzh.22.1679944142340; Mon, 27 Mar 2023 12:09:02 -0700 (PDT) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id d9-20020aa78e49000000b005cd81a74821sm15653334pfr.152.2023.03.27.12.08.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:09:02 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass , AKASHI Takahiro , Dzmitry Sankouski , Ovidiu Panait , Rasmus Villemoes , Stefan Roese Subject: [PATCH 04/30] ide: Drop init for not using BLK Date: Tue, 28 Mar 2023 08:06:51 +1300 Message-Id: <20230328080702.4.Ib505526dc5a040597d0ef8a46116969732e10c04@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 ALl boards use CONFIG_BLK now so this code is not used. Drop it and the header-file #ifdef Signed-off-by: Simon Glass --- common/board_r.c | 12 ------------ include/ide.h | 7 ------- 2 files changed, 19 deletions(-) diff --git a/common/board_r.c b/common/board_r.c index 7076af64f5de..d798c00a80a5 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -519,15 +519,6 @@ static int initr_post(void) } #endif -#if defined(CONFIG_IDE) && !defined(CONFIG_BLK) -static int initr_ide(void) -{ - puts("IDE: "); - ide_init(); - return 0; -} -#endif - #if defined(CFG_PRAM) /* * Export available size of memory for Linux, taking into account the @@ -778,9 +769,6 @@ static init_fnc_t init_sequence_r[] = { #ifdef CONFIG_POST initr_post, #endif -#if defined(CONFIG_IDE) && !defined(CONFIG_BLK) - initr_ide, -#endif #ifdef CONFIG_LAST_STAGE_INIT INIT_FUNC_WATCHDOG_RESET /* diff --git a/include/ide.h b/include/ide.h index 9c0d40364a8f..457f275c61b4 100644 --- a/include/ide.h +++ b/include/ide.h @@ -18,17 +18,10 @@ void ide_init(void); struct blk_desc; struct udevice; -#ifdef CONFIG_BLK ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer); ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer); -#else -ulong ide_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, - void *buffer); -ulong ide_write(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, - const void *buffer); -#endif #if defined(CONFIG_OF_IDE_FIXUP) int ide_device_present(int dev); From patchwork Mon Mar 27 19:06:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761919 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=DSHdIY8/; 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 4Plj8Y2KXKz1yXv for ; Tue, 28 Mar 2023 06:11:09 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AAD258614B; Mon, 27 Mar 2023 21:10:32 +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="DSHdIY8/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7DEC086112; Mon, 27 Mar 2023 21:09:22 +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-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) (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 23AA986113 for ; Mon, 27 Mar 2023 21:09:07 +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-x630.google.com with SMTP id ix20so9409886plb.3 for ; Mon, 27 Mar 2023 12:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944145; 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=NxCmv3AZc+PyEpVVvzqFwL76sUljosi/KmCpib8mCvc=; b=DSHdIY8/HLUPXtDP0cNvg8c1qUxfuVYTflN+Al++Mv6Ub+cUEcMKo5HrGBpRiERhyQ JhXti3tD+2YPnOqgXgETTtkgmSMvQOs+U4u243BlpnU848yx74hsHceMM0SKhO9g8Lft MPwT+sPnLFR085ZiALwX6WWouZCq53d/2trmg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944145; 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=NxCmv3AZc+PyEpVVvzqFwL76sUljosi/KmCpib8mCvc=; b=QTMw2nODEK9SvIBiZrClMeVTfzKpuzKYfsEOW9BDi1vFYdNA7Rs+aiX5XZ5FFAx6oN cyH82XIDcNY0oIib8QQ00aBx+oHGtUvAsapQFQDwETj8vsy3s3Vq99oBS4LGAtaSOLvO 13VSGqL1Jv/Dc2AHB/DcWSPSjnj7BCFmCdI5FbVIbnVDZGvcdlCX7vz+1h/5zlHbo/r0 HFG2mb09ojXFUFLN4G9J+GO7Jwwj9p/eF9iloGo4ojqvsT+d+W+OqBJuDxMIdniDSJf7 i0w32uOuKCzvhMzDUWIS8R1KKajY5bIrhd/MRgh7U0qwtt4iZRlZF3MIp4hXvn+yOg9V UMiA== X-Gm-Message-State: AO0yUKXa2AasukgEWCpbq0/cnDEFqlY7mQI1/tw6k+Z1vpeqR4n1y285 Gp5t8qyo0h9i6rn6Q5YB2BiO7sAUdmWNvCXDN6E= X-Google-Smtp-Source: AK7set9rl9p3QlU0hreie+3h4HhlT50mvGJGunLR2TUiX9krenNqXP3Y3bNOtUjS2xfJBwncxmFM5A== X-Received: by 2002:a05:6a20:4ca5:b0:d9:162d:98e4 with SMTP id fq37-20020a056a204ca500b000d9162d98e4mr9690147pzb.54.1679944145237; Mon, 27 Mar 2023 12:09:05 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:09:05 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 05/30] ide: Move ide_init() into probing Date: Tue, 28 Mar 2023 08:06:52 +1300 Message-Id: <20230328080702.5.I08f24ecd3a978034f274fd7b737f9ab7804be7ec@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 At present the code does ide_init() as a separate operation, then calls device_probe() to copy over the information. We can call ide_init() from probe just as easily. The only difference is that using 'ide init' twice will do nothing. However it already fails to copy over the new data in that case, so the effect is the same. For now, unbind the block devices and remove the IDE device, which causes the bus to be probed again. Later patches will fix this up fully, so that all blk_desc data is copied across. Since ide_reset() is only called from ide_init(), there is no need to init the ide_dev_desc[] array. This is already done at the end of ide_init() so drop this code. The call to uclass_first_device() is now within the probe() function of the same device, so does nothing. Drop it. Signed-off-by: Simon Glass --- cmd/ide.c | 22 +++++++++++++++++++++- drivers/block/ide.c | 13 ++++++------- include/ide.h | 1 - test/boot/bootdev.c | 2 -- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/cmd/ide.c b/cmd/ide.c index 6739f0b12d1a..ddc87d3a0bb9 100644 --- a/cmd/ide.c +++ b/cmd/ide.c @@ -10,12 +10,15 @@ #include #include +#include #include #include #include #include #include #include +#include +#include #include #include @@ -31,8 +34,25 @@ int do_ide(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { if (argc == 2) { if (strncmp(argv[1], "res", 3) == 0) { + struct udevice *dev; + int ret; + puts("\nReset IDE: "); - ide_init(); + ret = uclass_find_first_device(UCLASS_IDE, &dev); + ret = device_remove(dev, DM_REMOVE_NORMAL); + if (!ret) + ret = device_chld_unbind(dev, NULL); + if (ret) { + printf("Cannot remove IDE (err=%dE)\n", ret); + return CMD_RET_FAILURE; + } + + ret = uclass_first_device_err(UCLASS_IDE, &dev); + if (ret) { + printf("Init failed (err=%dE)\n", ret); + return CMD_RET_FAILURE; + } + return 0; } } diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 6f601bcf8646..13770484b36a 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -58,8 +58,6 @@ static void ide_reset(void) for (i = 0; i < CONFIG_SYS_IDE_MAXBUS; ++i) ide_bus_ok[i] = 0; - for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; ++i) - ide_dev_desc[i].type = DEV_TYPE_UNKNOWN; ide_set_reset(1); /* assert reset */ @@ -689,9 +687,8 @@ __weak unsigned char ide_inb(int dev, int port) return val; } -void ide_init(void) +static void ide_init(void) { - struct udevice *dev; unsigned char c; int i, bus; @@ -764,8 +761,6 @@ void ide_init(void) dev_print(&ide_dev_desc[i]); } schedule(); - - uclass_first_device(UCLASS_IDE, &dev); } __weak void ide_input_swap_data(int dev, ulong *sect_buf, int words) @@ -1067,7 +1062,9 @@ static int ide_bootdev_bind(struct udevice *dev) static int ide_bootdev_hunt(struct bootdev_hunter *info, bool show) { - ide_init(); + struct udevice *dev; + + uclass_first_device(UCLASS_IDE, &dev); return 0; } @@ -1104,6 +1101,8 @@ static int ide_probe(struct udevice *udev) int i; int ret; + ide_init(); + for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; i++) { if (ide_dev_desc[i].type != DEV_TYPE_UNKNOWN) { sprintf(name, "blk#%d", i); diff --git a/include/ide.h b/include/ide.h index 457f275c61b4..3f36b4340d06 100644 --- a/include/ide.h +++ b/include/ide.h @@ -15,7 +15,6 @@ * Function Prototypes */ -void ide_init(void); struct blk_desc; struct udevice; ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 4fe9fd722084..365b7f518ab2 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -376,7 +376,6 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts) ut_assert_nextline("Hunting with: simple_bus"); ut_assert_nextline("Found 2 extension board(s)."); ut_assert_nextline("Hunting with: ide"); - ut_assert_nextline("Bus 0: not available "); /* mmc hunter has already been used so should not run again */ @@ -487,7 +486,6 @@ static int bootdev_test_hunt_prio(struct unit_test_state *uts) /* now try a different priority, verbosely */ ut_assertok(bootdev_hunt_prio(BOOTDEVP_5_SCAN_SLOW, true)); ut_assert_nextline("Hunting with: ide"); - ut_assert_nextline("Bus 0: not available "); ut_assert_nextline("Hunting with: usb"); ut_assert_nextline( "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); From patchwork Mon Mar 27 19:06:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761918 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=85.214.62.61; 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=mBLjkJSC; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4Plj8D4qkbz1yXv for ; Tue, 28 Mar 2023 06:10:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 90E868610A; Mon, 27 Mar 2023 21:10:27 +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="mBLjkJSC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B1EEE8610D; Mon, 27 Mar 2023 21:09:21 +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-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) (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 A5E6F8611A for ; Mon, 27 Mar 2023 21:09:10 +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-pj1-x102d.google.com with SMTP id l9-20020a17090a3f0900b0023d32684e7fso6540pjc.1 for ; Mon, 27 Mar 2023 12:09:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944148; 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=jrabEmAEbrbMebgCKcb/n3LDgAVLhQhDkIklaTNylGw=; b=mBLjkJSCczD04F/UvxYmGio9mHYBN1p3iGQmeDV4tKoGVzhPlWqpI3G1IHpnjTbK55 6RGFN/CUIlmiQaUYP5CHtBeISbUGeIJw28l80cmleGqzwVicJW1OpQ5DYqLs1EG/fF3G ovFZJnxe+QgUvr2/c5xSpKvZG2YHHSouLQnrk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944148; 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=jrabEmAEbrbMebgCKcb/n3LDgAVLhQhDkIklaTNylGw=; b=PkF98Psk+XUAYwkZ5qkiOAGruV6yykuzwKSajtPQBcEXVUxqRyJZMcwOw6qxjA5OSU 65S3RpG0rzGXvc5SVmPMwZmp+9WwRcalh3IKvmq7g4EUs6zI61AeCQoCfcMzoVsHo+ZZ xWgyql/MrP8x3LXVyXiIfaWFr7LyHG8HkfvxZbCYKC4Bw+pLIXiSStQQeg+cloP1X61o hPl7/QqSwQsNgQmft14BDiczTBfY5uPJOWyiYQ8iKIg7dBxJgn5232B+eOBkkVNYaI7w VDUvfUBeuJ8o0QQaLWhmlWLECbDqdp7E7VcF+P96qesfk49EFpef43CcSm6wRWMXtKbP gvLw== X-Gm-Message-State: AO0yUKUKENMbiDAACKbnNdf3o/XJl/ZKpS7S9FnGzlZTHLjdi1aEkQLH hZvlN13FuuslfpvHXthf5dkd7PtPWbUBtpJZUhs= X-Google-Smtp-Source: AK7set+8iTrd6XOWEAuUP37fn3pxUZTEQuKW+cRj6ztaZQruTkiqcBZCrUkj04mhChpNtKTaWvnPxA== X-Received: by 2002:a05:6a20:4d97:b0:bc:80bd:462d with SMTP id gj23-20020a056a204d9700b000bc80bd462dmr12520327pzb.46.1679944148235; Mon, 27 Mar 2023 12:09:08 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:09:07 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 06/30] ide: Drop ide_device_present() Date: Tue, 28 Mar 2023 08:06:53 +1300 Message-Id: <20230328080702.6.I020ee546cc3d86228e9e0279d4b02f3fd356fb96@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 This function is not used anymore. Drop it. Signed-off-by: Simon Glass --- drivers/block/ide.c | 9 --------- include/ide.h | 4 ---- 2 files changed, 13 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 13770484b36a..b5be022a0673 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -1012,15 +1012,6 @@ WR_OUT: return n; } -#if defined(CONFIG_OF_IDE_FIXUP) -int ide_device_present(int dev) -{ - if (dev >= CONFIG_SYS_IDE_MAXBUS) - return 0; - return ide_dev_desc[dev].type == DEV_TYPE_UNKNOWN ? 0 : 1; -} -#endif - static int ide_blk_probe(struct udevice *udev) { struct blk_desc *desc = dev_get_uclass_plat(udev); diff --git a/include/ide.h b/include/ide.h index 3f36b4340d06..09b0117879f7 100644 --- a/include/ide.h +++ b/include/ide.h @@ -22,10 +22,6 @@ ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer); -#if defined(CONFIG_OF_IDE_FIXUP) -int ide_device_present(int dev); -#endif - /* * I/O function overrides */ From patchwork Mon Mar 27 19:06:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761937 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=FFmCGgn+; 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 4PljH60KJbz1yYb for ; Tue, 28 Mar 2023 06:16:50 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3D21A8609D; Mon, 27 Mar 2023 21:16:47 +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="FFmCGgn+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AF9E6857EC; Mon, 27 Mar 2023 21:16:45 +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-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) (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 41CF286126 for ; Mon, 27 Mar 2023 21:09:16 +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-pj1-x102d.google.com with SMTP id l7so8625744pjg.5 for ; Mon, 27 Mar 2023 12:09:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944154; 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=buu/GkXt/8k6SNRWofxE2mrM9L+hggclEljvFVRqxm0=; b=FFmCGgn+IHSpLMKpKQ9g8+S3X7lCXMC+pRgMCzL25BkAZHet1zHUeC0NtarZ+3YGDx 7Wn0z4C8sRoUCmFUdEi6Aub78U19ggcHMOCAEOB4rth3OPMUli9GYtgaW2loNwg7ndTe 1kC7ewl4dFzB18NqUsE+0uuk6YjXNzK6fRFCQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944154; 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=buu/GkXt/8k6SNRWofxE2mrM9L+hggclEljvFVRqxm0=; b=VrkJFhirmUiujmJcaDBkyXeYqhR38HsU90E2JOk7hLCuBpGLmcNHI5hD7sbiNVWe0v yFu8eETjYxWpAb9DaMvaqIxMy+WuHoQ6iDC9xDTi4gnsmt9L1Nyui/js99AXWPmwk6d5 uVitG4hMwSQU9BPuYIJ9XyzSL4rk3NixEPiO4WA8/mUjXQ2sq8g7G0ovt3P6kjyV5BWR V2N0z7MCGfNP5EqH3AsXtWnsqy9U+fwYJp5pPdYvme+yCGD8sgOzk3O5c2ZdX1xLSh3X SrvouJSDL2X6xgox5dQiwbRcapJJsBw5cSYWYt/b2tCMra3nQroMsqRrW9PTfZGhLKrM S7Og== X-Gm-Message-State: AO0yUKV8Jd/IVE2YxNA7z86fd23CuOlRTQQ29pyHE5pVEOaQakpYRQnJ NHdPwJ2ZXfzOmRaWMOpwk8+EwkJejJzjYVYfGlA= X-Google-Smtp-Source: AK7set8ZQHB1x78SCK30nicbWyxFaOjHAG81NCf8CrVjoNNSjDVGv6O4aPXXPbjUaXTu/zajEtk3fA== X-Received: by 2002:a05:6a20:af1c:b0:d9:3683:bc15 with SMTP id dr28-20020a056a20af1c00b000d93683bc15mr11028042pzb.19.1679944154148; Mon, 27 Mar 2023 12:09:14 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:09:13 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 08/30] ide: Drop weak functions Date: Tue, 28 Mar 2023 08:06:55 +1300 Message-Id: <20230328080702.8.I849a603c3a9ab189f9576a7b2a58e5e244d895c2@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 These are not used from outside this file anymore. Make them static and remove them from the header file. Signed-off-by: Simon Glass --- drivers/block/ide.c | 14 +++++++------- include/ide.h | 13 ------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 58f1ef8f1777..46e110fec5e8 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -75,7 +75,7 @@ static void ide_reset(void) #define ide_reset() /* dummy */ #endif /* CONFIG_IDE_RESET */ -__weak void ide_outb(int dev, int port, unsigned char val) +static void ide_outb(int dev, int port, unsigned char val) { debug("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n", dev, port, val, ATA_CURR_BASE(dev) + port); @@ -83,7 +83,7 @@ __weak void ide_outb(int dev, int port, unsigned char val) outb(val, ATA_CURR_BASE(dev) + port); } -__weak unsigned char ide_inb(int dev, int port) +static unsigned char ide_inb(int dev, int port) { uchar val; @@ -94,7 +94,7 @@ __weak unsigned char ide_inb(int dev, int port) return val; } -__weak void ide_input_swap_data(int dev, ulong *sect_buf, int words) +static void ide_input_swap_data(int dev, ulong *sect_buf, int words) { uintptr_t paddr = (ATA_CURR_BASE(dev) + ATA_DATA_REG); ushort *dbuf = (ushort *)sect_buf; @@ -164,7 +164,7 @@ OUT: /* since ATAPI may use commands with not 4 bytes alligned length * we have our own transfer functions, 2 bytes alligned */ -__weak void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts) +static void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts) { uintptr_t paddr = (ATA_CURR_BASE(dev) + ATA_DATA_REG); ushort *dbuf; @@ -179,7 +179,7 @@ __weak void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts) } } -__weak void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts) +static void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts) { uintptr_t paddr = (ATA_CURR_BASE(dev) + ATA_DATA_REG); ushort *dbuf; @@ -778,7 +778,7 @@ static void ide_init(void) schedule(); } -__weak void ide_output_data(int dev, const ulong *sect_buf, int words) +static void ide_output_data(int dev, const ulong *sect_buf, int words) { uintptr_t paddr = (ATA_CURR_BASE(dev) + ATA_DATA_REG); ushort *dbuf; @@ -792,7 +792,7 @@ __weak void ide_output_data(int dev, const ulong *sect_buf, int words) } } -__weak void ide_input_data(int dev, ulong *sect_buf, int words) +static void ide_input_data(int dev, ulong *sect_buf, int words) { uintptr_t paddr = (ATA_CURR_BASE(dev) + ATA_DATA_REG); ushort *dbuf; diff --git a/include/ide.h b/include/ide.h index 09b0117879f7..8c0eb2a022fd 100644 --- a/include/ide.h +++ b/include/ide.h @@ -22,17 +22,4 @@ ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer); -/* - * I/O function overrides - */ -unsigned char ide_inb(int dev, int port); -void ide_outb(int dev, int port, unsigned char val); -void ide_input_swap_data(int dev, ulong *sect_buf, int words); -void ide_input_data(int dev, ulong *sect_buf, int words); -void ide_output_data(int dev, const ulong *sect_buf, int words); -void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts); -void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts); - -void ide_led(uchar led, uchar status); - #endif /* _IDE_H */ From patchwork Mon Mar 27 19:06:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761916 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=I39gP8ls; 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 4Plj7h5n1lz1yXv for ; Tue, 28 Mar 2023 06:10:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 27E5D86133; Mon, 27 Mar 2023 21:10:01 +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="I39gP8ls"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E7FCA85DDA; Mon, 27 Mar 2023 21:09:27 +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-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) (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 0C50F860F5 for ; Mon, 27 Mar 2023 21:09:19 +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-x635.google.com with SMTP id z19so9417387plo.2 for ; Mon, 27 Mar 2023 12:09:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944157; 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=PCYRLV/KVdJP8IgWXn+MKGBs0Hdv3s8wOLqzyl8BQls=; b=I39gP8ls7B/lV/7QsV5oB+M2hZGh6JWim4fKZTRb5fmpmEceqK1HN48u9PaMLvFHmh bI4olgaxe+ZNyt6hwTsU8A9dHjPLEWoL5FtliMb66fhmbGQrwHRj56k7/prhAQczC/M3 bYkmCqwRsVs8cm5xvWVAgYJh4mFRTEbPX/IRc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944157; 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=PCYRLV/KVdJP8IgWXn+MKGBs0Hdv3s8wOLqzyl8BQls=; b=t4YDieSw+D4OUBsbA/1/ZOnUrIVRNPEXDF7TSNK0yRBNdPOPh1ahivHmQc/Gr7nKh2 Kr3fmEKwF4tOK5Ybp4ggVjDb0MfgpXyVXqnDm0+fYOD8Ifswq4f3pQfn2UymT4BmnnnK 2oWU2376FncsGeVg1b9J0224hQ/m/3UXk7xwjoNCzHKRG+5Qsk5mCVzVu/TL8KmVNu3k SJuK/OvYI0M9tOfK2DVmbOrpM2ljyHK37fdHEEby2I9gghObe3itV00CpCIHHZxnDx+Y 12/htow6b1RJPQLeYUC6cDW/J9Ytj5wGaQZ8UCDNK6rqzodtX6FSMAM0nvXVhUM9UJNz a9oQ== X-Gm-Message-State: AO0yUKXC5fe5H+YeRpEjOV2dZRvWUvnu+HBxE2jcNk0xTtGVDtoxHDPv +64oEpZ9yt7Ovd2NoaUKemZDQ8xcG2hI5yJnv3M= X-Google-Smtp-Source: AK7set/sAapcuN/KwSkidga0IoSPbfF4Z3vN/aaC73TaYSsfIjCRJY8U3gyKJ+ChCWuSSIbCxy/61g== X-Received: by 2002:a05:6a20:ce01:b0:d9:949e:a72 with SMTP id ic1-20020a056a20ce0100b000d9949e0a72mr10557341pzb.60.1679944157040; Mon, 27 Mar 2023 12:09:17 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:09:16 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 09/30] ide: Create a prototype for ide_set_reset() Date: Tue, 28 Mar 2023 08:06:56 +1300 Message-Id: <20230328080702.9.I942c3375671301f576cbdc5826b7b54c3b082a82@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 This is used by a board so should be in the header file. Add it. Signed-off-by: Simon Glass --- drivers/block/ide.c | 2 -- include/ide.h | 10 ++++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 46e110fec5e8..fa5f68ffeb01 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -50,8 +50,6 @@ struct blk_desc ide_dev_desc[CONFIG_SYS_IDE_MAXDEVICE]; #define IDE_SPIN_UP_TIME_OUT 5000 /* 5 sec spin-up timeout */ #ifdef CONFIG_IDE_RESET -extern void ide_set_reset(int idereset); - static void ide_reset(void) { int i; diff --git a/include/ide.h b/include/ide.h index 8c0eb2a022fd..b586ba3df4bf 100644 --- a/include/ide.h +++ b/include/ide.h @@ -22,4 +22,14 @@ ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer); +/** + * ide_set_reset() - Assert or de-assert reset for the IDE device + * + * This is provided by boards which need to reset the device through another + * means, e.g. a GPIO. + * + * @idereset: 1 to assert reset, 0 to de-assert it + */ +void ide_set_reset(int idereset); + #endif /* _IDE_H */ From patchwork Mon Mar 27 19:06:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761921 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=85.214.62.61; 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=D8eOtGtI; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4Plj934NL9z1yXv for ; Tue, 28 Mar 2023 06:11:35 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 930E786119; Mon, 27 Mar 2023 21:10:39 +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="D8eOtGtI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D5D6D8610C; Mon, 27 Mar 2023 21:09:31 +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-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) (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 D69C486113 for ; Mon, 27 Mar 2023 21:09:22 +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-pg1-x52f.google.com with SMTP id h31so5792835pgl.6 for ; Mon, 27 Mar 2023 12:09:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944161; 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=j+sO1O9ajkpBbuMe6WNg5SkIElzks2a6aNycYigxSx0=; b=D8eOtGtIYRwzPJu3GM1vPcMaYgP46hMLEIyroNX4qpNmZtbCrL1ZUU2VANbHA7QgAx aFsdhtf2PsA4+zokCuI2HQK9a2KlMeixa0cuNpO0XStpjr6YQd0PU2gdKc2xV7a6Lyho VSaTkX9d9vdbw/hkxjqXxwLayaF6B4mXWrsWU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944161; 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=j+sO1O9ajkpBbuMe6WNg5SkIElzks2a6aNycYigxSx0=; b=UI3oCfAyKoN7CMhhn/W6NO6LVTpHqNo1JgiiAy8KYmOg60inuHvpaYw+aDfRpGbgOv PeKQE53jxYq5Mg8MGsjwaTD8/5uWfTQHq9tItm0T5gsMvGFfD4ILzuSk/curXLbRISeQ eB3oH5+ckUvhMWwHURMbQ9JE14cI1PTZCjNnFKg0S+fyHLujPCUOBMWmH2EShjmAwV3w 7q6vKeq/otOZijiDsi2k+3yRSaLEL6qvQ+wLGyZby9iYeeXxzgedDeWFzj0lYAIsVCT8 glPnTxc35gEuQyo/l4/MTJT1zAf+X7Vz9N1WhXlOBW0NW6bfkzg7aE+yCbGYx+T9kxaZ iFkg== X-Gm-Message-State: AAQBX9fdZM/hGiYDhEsLin/Axvm5pgcLkjAvbmztrogvJxuaXzKtQHrQ EiRVZBPRuBg06++J11d8qBzdNHWwrFLELmJoRag= X-Google-Smtp-Source: AKy350boWzW3T6uUyeevpeMSI6RYgRGgFFoZLyShrdDskOjbwim7ivzGPfi37OHRjCrlMguueo3Hwg== X-Received: by 2002:aa7:956d:0:b0:627:8e40:68e0 with SMTP id x13-20020aa7956d000000b006278e4068e0mr12385617pfq.15.1679944160764; Mon, 27 Mar 2023 12:09:20 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:09:20 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass , Heinrich Schuchardt , Mattijs Korpershoek Subject: [PATCH 10/30] ide: Correct use of ATAPI Date: Tue, 28 Mar 2023 08:06:57 +1300 Message-Id: <20230328080702.10.Ia41ab329f6a5b52b15e58c5f405ce07c5b5545d1@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 use of atapi_read() was incorrect dropped. Fix this so that it will be used when needed. Use a udevice for the first argument of atapi_read() so it is consistent with ide_read(). This requires much of the ATAPI code to be brought out from behind the existing #ifdef. It will still be removed by the compiler if it is not needed. Add an atapi flag to struct blk_desc so the information can be retained. Fixes: 145df842b44 ("dm: ide: Add support for driver-model block devices") Fixes: d0075059e4d ("ide: Drop non-DM code for BLK") Signed-off-by: Simon Glass Reviewed-by: Mattijs Korpershoek --- drivers/block/ide.c | 20 +++++++++++++++++--- include/blk.h | 1 + 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index fa5f68ffeb01..875192cba163 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -155,7 +155,6 @@ OUT: *last = '\0'; } -#ifdef CONFIG_ATAPI /**************************************************************************** * ATAPI Support */ @@ -422,9 +421,10 @@ error: #define ATAPI_READ_BLOCK_SIZE 2048 /* assuming CD part */ #define ATAPI_READ_MAX_BLOCK (ATAPI_READ_MAX_BYTES/ATAPI_READ_BLOCK_SIZE) -ulong atapi_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, +ulong atapi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) { + struct blk_desc *block_dev = dev_get_uclass_plat(dev); int device = block_dev->devnum; ulong n = 0; unsigned char ccb[12]; /* Command descriptor block */ @@ -466,6 +466,8 @@ ulong atapi_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt, return n; } +#ifdef CONFIG_ATAPI + static void atapi_inquiry(struct blk_desc *dev_desc) { unsigned char ccb[12]; /* Command descriptor block */ @@ -653,6 +655,7 @@ static void ide_ident(struct blk_desc *dev_desc) #ifdef CONFIG_ATAPI if (is_atapi) { + dev_desc->atapi = true; atapi_inquiry(dev_desc); return; } @@ -1010,6 +1013,17 @@ WR_OUT: return n; } +ulong ide_or_atapi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, + void *buffer) +{ + struct blk_desc *desc = dev_get_uclass_plat(dev); + + if (IS_ENABLED(CONFIG_ATAPI) && desc->atapi) + return atapi_read(dev, blknr, blkcnt, buffer); + + return ide_read(dev, blknr, blkcnt, buffer); +} + static int ide_blk_probe(struct udevice *udev) { struct blk_desc *desc = dev_get_uclass_plat(udev); @@ -1029,7 +1043,7 @@ static int ide_blk_probe(struct udevice *udev) } static const struct blk_ops ide_blk_ops = { - .read = ide_read, + .read = ide_or_atapi_read, .write = ide_write, }; diff --git a/include/blk.h b/include/blk.h index 1db203c1baba..871922dcde07 100644 --- a/include/blk.h +++ b/include/blk.h @@ -66,6 +66,7 @@ struct blk_desc { /* device can use 48bit addr (ATA/ATAPI v7) */ unsigned char lba48; #endif + unsigned char atapi; /* Use ATAPI protocol */ lbaint_t lba; /* number of blocks */ unsigned long blksz; /* block size */ int log2blksz; /* for convenience: log2(blksz) */ From patchwork Mon Mar 27 19:06:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761917 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=jqDbu06d; 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 4Plj7y0Kv9z1yXv for ; Tue, 28 Mar 2023 06:10:38 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7642486151; Mon, 27 Mar 2023 21:10:17 +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="jqDbu06d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5D80286101; Mon, 27 Mar 2023 21:09:31 +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-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) (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 7407F86103 for ; Mon, 27 Mar 2023 21:09:25 +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-pg1-x532.google.com with SMTP id d8so5797860pgm.3 for ; Mon, 27 Mar 2023 12:09:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944163; 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=G4fVDGD149tXY0s4ytbtuswtpCLUm/o7Yukc1Vzacnc=; b=jqDbu06didOropaMblc4HD23KzxVzekXHy/dSc0Z81jTTrlRCjM1XkI9sCP0P5qV6b YDuPVW5ASvKWrP//0dpPni2koadLcJTjht/6SC7x910do5qDvj49tCpF3YAjPJh3+Y6I kTIlBKdwFw6WQ+bUoBx44fewKUNSUgsaTSpRc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944163; 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=G4fVDGD149tXY0s4ytbtuswtpCLUm/o7Yukc1Vzacnc=; b=ec01B6tNBHv2TYgqlQ3nPxHOUcVriKMAR0cNR2BBKEVDzex6lrWU12jQe/2kseR3UD fWES6X5t6UkIOc739LV9D9r6Ck1upQn482wO8AW+sWGPwdSOJMFZ8HgCnxKauLZ6nBDB oNeG+MblQHI5gYKsoQhbhDPYYK0KktpNpPGCLDQvHPFPeam6fEPA9qCHd/AaTPPGIZiy H+YooKoVajpufcgZ1YSDHf65kmm73ldEHY9N5a2QQuXR1uK4ixljxW0SAk82FP0744+e V6lXpq0TW3pxbJEZZPD4Gxx59w59/BEkY+ZU+g9eDT7walWIXsQ8Nw2fz7/QXwmN9kbt u9UA== X-Gm-Message-State: AAQBX9ck6NzwqrwJ5uihtQPwASGSrJ6Xhwhv5mcvuvy63z+en8dcjmxR onmOMQgeNFmLA+j6q62Qe/Dk3s2gSoJfUJns7RQ= X-Google-Smtp-Source: AKy350bPkW+nWxqLqE2VOeClm1m/g+V+EWKoCSYz5TBRWzkvuEBqdwKM90Pql1cW/ak264Swf1Uoaw== X-Received: by 2002:aa7:94bb:0:b0:626:2901:8987 with SMTP id a27-20020aa794bb000000b0062629018987mr11138007pfl.18.1679944163646; Mon, 27 Mar 2023 12:09:23 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:09:23 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 11/30] ide: Make function static Date: Tue, 28 Mar 2023 08:06:58 +1300 Message-Id: <20230328080702.11.If83ae73ee0388601fadab2035c059d2f21ad6282@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 Only one function is called from outside this file. Make all the others static. Signed-off-by: Simon Glass --- drivers/block/ide.c | 23 +++++++++++------------ include/ide.h | 11 ----------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 875192cba163..1d5e54d6eb98 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -219,8 +219,8 @@ static uchar atapi_wait_mask(int dev, ulong t, uchar mask, uchar res) /* * issue an atapi command */ -unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen, - unsigned char *buffer, int buflen) +static unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen, + unsigned char *buffer, int buflen) { unsigned char c, err, mask, res; int n; @@ -343,10 +343,9 @@ AI_OUT: #define ATAPI_DRIVE_NOT_READY 100 #define ATAPI_UNIT_ATTN 10 -unsigned char atapi_issue_autoreq(int device, - unsigned char *ccb, - int ccblen, - unsigned char *buffer, int buflen) +static unsigned char atapi_issue_autoreq(int device, unsigned char *ccb, + int ccblen, + unsigned char *buffer, int buflen) { unsigned char sense_data[18], sense_ccb[12]; unsigned char res, key, asc, ascq; @@ -421,8 +420,8 @@ error: #define ATAPI_READ_BLOCK_SIZE 2048 /* assuming CD part */ #define ATAPI_READ_MAX_BLOCK (ATAPI_READ_MAX_BYTES/ATAPI_READ_BLOCK_SIZE) -ulong atapi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, - void *buffer) +static ulong atapi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, + void *buffer) { struct blk_desc *block_dev = dev_get_uclass_plat(dev); int device = block_dev->devnum; @@ -810,8 +809,8 @@ static void ide_input_data(int dev, ulong *sect_buf, int words) } } -ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, - void *buffer) +static ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, + void *buffer) { struct blk_desc *block_dev = dev_get_uclass_plat(dev); int device = block_dev->devnum; @@ -930,8 +929,8 @@ IDE_READ_E: return n; } -ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, - const void *buffer) +static ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, + const void *buffer) { struct blk_desc *block_dev = dev_get_uclass_plat(dev); int device = block_dev->devnum; diff --git a/include/ide.h b/include/ide.h index b586ba3df4bf..2c25e74ede08 100644 --- a/include/ide.h +++ b/include/ide.h @@ -11,17 +11,6 @@ #define IDE_BUS(dev) (dev / (CONFIG_SYS_IDE_MAXDEVICE / CONFIG_SYS_IDE_MAXBUS)) -/* - * Function Prototypes - */ - -struct blk_desc; -struct udevice; -ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, - void *buffer); -ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, - const void *buffer); - /** * ide_set_reset() - Assert or de-assert reset for the IDE device * From patchwork Mon Mar 27 19:06:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761920 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=obv7eB1r; 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 4Plj8n02dvz1yXv for ; Tue, 28 Mar 2023 06:11:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 384B586160; Mon, 27 Mar 2023 21:10:36 +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="obv7eB1r"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7356786121; Mon, 27 Mar 2023 21:09:32 +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-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) (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 5208A860F5 for ; Mon, 27 Mar 2023 21:09:28 +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-pg1-x534.google.com with SMTP id bn14so5780324pgb.11 for ; Mon, 27 Mar 2023 12:09:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944166; 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=snpYkfxlUng0cmnaqaRmj+PF7FkiX5LsZC9LAFVEeHY=; b=obv7eB1rOdJpBTRtb/piYUQJkeT+fY8E5Gk3WmdBmzaYjPzqWYQpZ2I1ZpaUlLXUt0 K/e+bdYQJLxLI0B8aSe6UwngBojVDhvlUDKAeT4x3CItFtch7p5C2aTKb+3NTalgjwsK FrF1DMOtMcSdeboq2MWw6uT2apTNgc31UmfH8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944166; 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=snpYkfxlUng0cmnaqaRmj+PF7FkiX5LsZC9LAFVEeHY=; b=huhpOEdlJRSfe5fzys3jbHk0NdAsFzk4IL09rO9dXbXYw3k68rvKBskhGlBMvBRTyc hSBn/eBUK5UunmWwQoz+S7WjBCITtIBOyq5SKLZlca85vhZIT3M+yVkIcajRQwMDVaZy 9LlAfKIQzqTOmsW9nzLMP5vnL5XbgMvLvvcSQXEFwAh4/IHPkjf8Sdx3UYb+LpHQViWF lsPY9DuwZPipxR1hUK0O/tL5VRAqyRc+jJfcVhoCyZAmASNB1qQ6F55VVEQEuUq4TWc6 VtsGVFSRIrcEPBlT/d+Mh0UYQDfXH5EM8bhRcEbp6XrVnuUfMkeys8ZqwCfokwNIOu/R Z48Q== X-Gm-Message-State: AAQBX9cqz17FydhUvd0JxgjQF9t5QrRaH2wwwHEbfQOSX77QokYs2fc/ rIVSAE0mjyu6aLWcc3m0704rd7OuafyM6DYhz4U= X-Google-Smtp-Source: AK7set+yxp/qABRqFCDzvSpbk2GvrnVAIP02ApjiIDxgFZEW/vmf6sziIj56NezdWH5mDsyC/Zq9Kw== X-Received: by 2002:a62:6d87:0:b0:62b:38ed:6507 with SMTP id i129-20020a626d87000000b0062b38ed6507mr9890400pfc.20.1679944166545; Mon, 27 Mar 2023 12:09:26 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:09:26 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 12/30] ide: Change the retries variable Date: Tue, 28 Mar 2023 08:06:59 +1300 Message-Id: <20230328080702.12.I3bd4fe0dd4c87ed27bcc3a4d77acd4cf6da1f856@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 Use a 'tries' variable which starts at the number of tries we want to do, rather than a 'retries' one that stops at either 1 or 2. This will make it easier to refactor the code to avoid the horrible #ifdefs Signed-off-by: Simon Glass --- drivers/block/ide.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 1d5e54d6eb98..782780fd302b 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -557,7 +557,7 @@ static void ide_ident(struct blk_desc *dev_desc) hd_driveid_t iop; #ifdef CONFIG_ATAPI bool is_atapi = false; - int retries = 0; + int tries = 1; #endif int device; @@ -570,10 +570,10 @@ static void ide_ident(struct blk_desc *dev_desc) dev_desc->uclass_id = UCLASS_IDE; #ifdef CONFIG_ATAPI - retries = 0; + tries = 2; /* Warning: This will be tricky to read */ - while (retries <= 1) { + while (tries) { /* check signature */ if ((ide_inb(device, ATA_SECT_CNT) == 0x01) && (ide_inb(device, ATA_SECT_NUM) == 0x01) && @@ -624,7 +624,7 @@ static void ide_ident(struct blk_desc *dev_desc) */ ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device)); - retries++; + tries--; #else return; #endif @@ -634,7 +634,7 @@ static void ide_ident(struct blk_desc *dev_desc) break; } /* see above - ugly to read */ - if (retries == 2) /* Not found */ + if (!tries) /* Not found */ return; #endif From patchwork Mon Mar 27 19:07:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761922 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=dnshz0ea; 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 4Plj9R5MMPz1yXv for ; Tue, 28 Mar 2023 06:11:55 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5714386144; Mon, 27 Mar 2023 21:10:42 +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="dnshz0ea"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 63DD2860FE; Mon, 27 Mar 2023 21:09:36 +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-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) (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 726D886116 for ; Mon, 27 Mar 2023 21:09:30 +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-pg1-x52f.google.com with SMTP id h31so5793097pgl.6 for ; Mon, 27 Mar 2023 12:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944169; 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=Gm/Ely+I9NDuPugJvnJq4c7s5oASzmzXqxp16+SiUrA=; b=dnshz0eaxv8YVC2H5vMsxs0MU0+d3QvBlL0WzDxeAicna4gPE+7aL5mx8LU4dhlz5q /pecLcoLdpeDd9oQqzWOKC5vxO9gZVQ5C+ePvdV7NVVrLtoEKskrKKONq7PAZA4RcykQ bfyzS8p0GAoov6yKgJEPP0faG88pCsIg7kM58= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944169; 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=Gm/Ely+I9NDuPugJvnJq4c7s5oASzmzXqxp16+SiUrA=; b=jc0aOIc1eMwbr1u5MgFAoPNQHPuZmUWgWj3Au/E8aF287MAt/FQ0M0YgKbCL46maHA 0lWDx597OCiBKUWxnJ5NDJ4LhAjS60h4Z9M2TzRDEeFD5D7x0DsK0ZzYamuABJ090aK0 WB2xS1nG8TlEJnMUwMwsJ3Pd7kf6RqKf5EiDpgs8O0dGM3+li4kKmcnBxosuuSFBXQRO XRk5Zwgfk4ZgvKPsBKOJE7OQTnaEvbwb+A7X6LywE84MCPyKuLfIF8b48aV4zdZLEgP6 nmDNweITHVTVg32iul8xhQ2g+UYZ53UFObTqnCAEtXM6+e9MPWUZ8X3+1ectXmZB5Sdv /F+w== X-Gm-Message-State: AO0yUKUU3+VsC7rjHWmZJY4amnWn8HwfBUmj6Bl5RgIeqccfNHwYAsEy 0N+3MDrp+ec0FwfHxbN5dIQi6BRRmdJ6yBgoDYM= X-Google-Smtp-Source: AKy350aMnJoHHZGBEb0YCNm6krqCYA1tIDgsn0hJqFvJhqE77bY285pCmTwNjTxg3RZLljV2vYDk+g== X-Received: by 2002:a62:1941:0:b0:5e2:434d:116b with SMTP id 62-20020a621941000000b005e2434d116bmr11345305pfz.23.1679944169694; Mon, 27 Mar 2023 12:09:29 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:09:29 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 13/30] ide: Refactor confusing loop code Date: Tue, 28 Mar 2023 08:07:00 +1300 Message-Id: <20230328080702.13.I3fb513baaa29087251762a44f7de79ac27ea892e@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 This code is hard to follow as it uses #ifdef in a strange way. Adjust it to avoid the preprocessor. Drop the special return for the non-ATAPI case since we can rely on tries becoming 0 and exiting the loop. Signed-off-by: Simon Glass --- drivers/block/ide.c | 43 +++++++++++++++---------------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 782780fd302b..2f45bb6bffb2 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -555,10 +555,8 @@ static void ide_ident(struct blk_desc *dev_desc) { unsigned char c; hd_driveid_t iop; -#ifdef CONFIG_ATAPI bool is_atapi = false; int tries = 1; -#endif int device; device = dev_desc->devnum; @@ -568,17 +566,16 @@ static void ide_ident(struct blk_desc *dev_desc) */ ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device)); dev_desc->uclass_id = UCLASS_IDE; -#ifdef CONFIG_ATAPI + if (IS_ENABLED(CONFIG_ATAPI)) + tries = 2; - tries = 2; - - /* Warning: This will be tricky to read */ while (tries) { /* check signature */ - if ((ide_inb(device, ATA_SECT_CNT) == 0x01) && - (ide_inb(device, ATA_SECT_NUM) == 0x01) && - (ide_inb(device, ATA_CYL_LOW) == 0x14) && - (ide_inb(device, ATA_CYL_HIGH) == 0xEB)) { + if (IS_ENABLED(CONFIG_ATAPI) && + ide_inb(device, ATA_SECT_CNT) == 0x01 && + ide_inb(device, ATA_SECT_NUM) == 0x01 && + ide_inb(device, ATA_CYL_LOW) == 0x14 && + ide_inb(device, ATA_CYL_HIGH) == 0xeb) { /* ATAPI Signature found */ is_atapi = true; /* @@ -590,9 +587,7 @@ static void ide_ident(struct blk_desc *dev_desc) * to become ready */ c = ide_wait(device, ATAPI_TIME_OUT); - } else -#endif - { + } else { /* * Start Ident Command */ @@ -606,8 +601,7 @@ static void ide_ident(struct blk_desc *dev_desc) if (((c & ATA_STAT_DRQ) == 0) || ((c & (ATA_STAT_FAULT | ATA_STAT_ERR)) != 0)) { -#ifdef CONFIG_ATAPI - { + if (IS_ENABLED(CONFIG_ATAPI)) { /* * Need to soft reset the device * in case it's an ATAPI... @@ -618,25 +612,18 @@ static void ide_ident(struct blk_desc *dev_desc) mdelay(100); ide_outb(device, ATA_COMMAND, 0x08); mdelay(500); + /* Select device */ + ide_outb(device, ATA_DEV_HD, + ATA_LBA | ATA_DEVICE(device)); } - /* - * Select device - */ - ide_outb(device, ATA_DEV_HD, - ATA_LBA | ATA_DEVICE(device)); tries--; -#else - return; -#endif - } -#ifdef CONFIG_ATAPI - else + } else { break; - } /* see above - ugly to read */ + } + } if (!tries) /* Not found */ return; -#endif ide_input_swap_data(device, (ulong *)&iop, ATA_SECTORWORDS); From patchwork Mon Mar 27 19:07:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761925 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=DEiDXBwx; 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 4PljBG0pPtz1yXv for ; Tue, 28 Mar 2023 06:12:38 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9804986153; Mon, 27 Mar 2023 21:10:59 +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="DEiDXBwx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 62D9B86103; Mon, 27 Mar 2023 21:09:44 +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-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) (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 62DD48612C for ; Mon, 27 Mar 2023 21:09:34 +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-pj1-x1034.google.com with SMTP id f6-20020a17090ac28600b0023b9bf9eb63so10007807pjt.5 for ; Mon, 27 Mar 2023 12:09:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944172; 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=zcjtqY0plNWfHJxRLGt+xAERQb10gMdkpoovQkf8oZs=; b=DEiDXBwxOzteqCWf/OpAeU8+etx9ze9skZjLma6YQvWJeSKbGhO+wnSwNLLRB9x2Ft YYYi4GKL1o0DY43RWz1lIwBcmTHQjDHrs7/G0ywOKxYmEBT2BAUIfoJjY6cNARFCLrdr C4gfEb8rO+qPK1j5L1HfGj2InQ7fqhvLDvqWo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944172; 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=zcjtqY0plNWfHJxRLGt+xAERQb10gMdkpoovQkf8oZs=; b=KWV7c4IIXh4opTa5sKbr7dhOuLF4dSXoLF2CtCsPlNxMS/Ushd1CPp3fkVHvmXFdJM +Z3WRUs5pjSeOhj+RYJSXh1s5SHU2uvvsirTYivSvWCFRgLn/llGGCMsdMIPohzCgkAh R8IFJ4II4nvhKOcsgFNForUOWejv2T1ysmmA3YDscY4dM7S8MNLjGkFUpRp8z0LImg8z nT/WWyQDxFVpqc61Euz/WzrdMQy+RcXolyAR6mK96nhN1oQat0aiZ2rAO1PP0jIaWSOK mYfaeW9Gvy7FRS1ggZ7OU9nx6QzdTr0a0co2roUKa2tSvSwkpI9aJbHiVVha4+XXEA+U 0pnw== X-Gm-Message-State: AO0yUKWCE68X4pZ8FezeXz+RFrJMYh62hCP4aTOInnqm7vvjzBEOgpeq IBTLUrjPULAbQnU9jRBriVMknk2w6p0jiX00Ch8= X-Google-Smtp-Source: AK7set+2DMttXeC73obBhz8ke5VjesgqUfNnCzLMD6Z025E3SSlMhPncwxDe5mRR76GL1fEAUjtERw== X-Received: by 2002:a05:6a20:8b9b:b0:cd:a358:bb7 with SMTP id m27-20020a056a208b9b00b000cda3580bb7mr10219375pzh.37.1679944172580; Mon, 27 Mar 2023 12:09:32 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:09:32 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 14/30] ide: Simplify success condition Date: Tue, 28 Mar 2023 08:07:01 +1300 Message-Id: <20230328080702.14.Ia3c8f329125531b39e6789a06e07c63d95961537@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 Change the if() to remove extra brackets and check for the positive case first, i.e. when a device is found. Exit the loop in that case, with the retry logic in the 'else' part. Signed-off-by: Simon Glass --- drivers/block/ide.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 2f45bb6bffb2..a51a0008cae4 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -599,27 +599,25 @@ static void ide_ident(struct blk_desc *dev_desc) c = ide_wait(device, IDE_TIME_OUT); } - if (((c & ATA_STAT_DRQ) == 0) || - ((c & (ATA_STAT_FAULT | ATA_STAT_ERR)) != 0)) { - if (IS_ENABLED(CONFIG_ATAPI)) { - /* - * Need to soft reset the device - * in case it's an ATAPI... - */ - debug("Retrying...\n"); - ide_outb(device, ATA_DEV_HD, - ATA_LBA | ATA_DEVICE(device)); - mdelay(100); - ide_outb(device, ATA_COMMAND, 0x08); - mdelay(500); - /* Select device */ - ide_outb(device, ATA_DEV_HD, - ATA_LBA | ATA_DEVICE(device)); - } - tries--; - } else { + if ((c & ATA_STAT_DRQ) && + !(c & (ATA_STAT_FAULT | ATA_STAT_ERR))) { break; + } else if (IS_ENABLED(CONFIG_ATAPI)) { + /* + * Need to soft reset the device + * in case it's an ATAPI... + */ + debug("Retrying...\n"); + ide_outb(device, ATA_DEV_HD, + ATA_LBA | ATA_DEVICE(device)); + mdelay(100); + ide_outb(device, ATA_COMMAND, 0x08); + mdelay(500); + /* Select device */ + ide_outb(device, ATA_DEV_HD, + ATA_LBA | ATA_DEVICE(device)); } + tries--; } if (!tries) /* Not found */ From patchwork Mon Mar 27 19:07:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761923 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=RVKS9GLc; 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 4Plj9k4vGVz1yXv for ; Tue, 28 Mar 2023 06:12:10 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6A8FB86165; Mon, 27 Mar 2023 21:10:48 +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="RVKS9GLc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4F95D860FE; Mon, 27 Mar 2023 21:09:43 +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-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) (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 75D5086103 for ; Mon, 27 Mar 2023 21:09:37 +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-pf1-x42e.google.com with SMTP id i15so6400923pfo.8 for ; Mon, 27 Mar 2023 12:09:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944175; 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=E5U/TEVz6d/+6y7ja/OPNqRQJ181v4q1TDXUSG9l8kk=; b=RVKS9GLczf0bB32wHk7lq1YNU+S6zb6oXBqEcANO7w+wKvvrheEFfx/sTtIl3DVRmm a8eQO3hujQHsZ+zPQdbl8YNnawhnIdbXn9KSNbLg+snNmSGk9I40S0XWgdnfMTqH4Arb /H2q9p8zF6cySDiQcxGVhgS94z7zo2G+1qbDg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944175; 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=E5U/TEVz6d/+6y7ja/OPNqRQJ181v4q1TDXUSG9l8kk=; b=T+TtOHIJsy3DzhoiXe//yDacklz83ywIJUNhLRC3ey0oUDdZ9sYLJkDzZ53PbdIr/0 q+Yp9VAdmqKUzuZW8VxGdXza16O6+2NQamIivA7U6IrZz1pcLtt8AKARbSX9qk62AzIR YxRf1yrhX9VaIMrzp9AtqBsd+c9ssZ1fzp6VVqVRcZcbGzkc9P+xIgmg3QkpxDBj7KlW EdkTNfvnxs3ZoHUHA+Ee6LI12xyvESvMToG5g5IhLRLbp2IXoyFGqr8/CRFNVtNs0fEW zoMyh9+xXKDCkv5Udz2hQZ/2mog44NIxaXs1mXvAkUEI7Y/+8gvF7D04VLZbn2lDYTde IUVg== X-Gm-Message-State: AAQBX9dqGIvZMppbKAdE9MelBiTteiTVvRydJmXQPWrknMTeL5nT7tbR WVHtn6Z2TPoKYFp5h6TljvUmwdcqDlFWkvPSWCk= X-Google-Smtp-Source: AK7set8F8wmd4z96OgCsoqAaSYTPcJiREfvwNMKU6KyyEf06nX4srz/fUsIEjkTo+A0eajcnuIMpqg== X-Received: by 2002:a62:6d85:0:b0:5a8:9858:750a with SMTP id i127-20020a626d85000000b005a89858750amr10762659pfc.13.1679944175468; Mon, 27 Mar 2023 12:09:35 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:09:35 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 15/30] ide: Avoid preprocessor for CONFIG_ATAPI Date: Tue, 28 Mar 2023 08:07:02 +1300 Message-Id: <20230328080702.15.I98323d86f485e6126288fb0e69063c28a63d0079@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 Use IS_ENABLED() instead for all conditions. Signed-off-by: Simon Glass --- drivers/block/ide.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index a51a0008cae4..6c5227a5c0e2 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -465,8 +465,6 @@ static ulong atapi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, return n; } -#ifdef CONFIG_ATAPI - static void atapi_inquiry(struct blk_desc *dev_desc) { unsigned char ccb[12]; /* Command descriptor block */ @@ -549,8 +547,6 @@ static void atapi_inquiry(struct blk_desc *dev_desc) return; } -#endif /* CONFIG_ATAPI */ - static void ide_ident(struct blk_desc *dev_desc) { unsigned char c; @@ -637,13 +633,11 @@ static void ide_ident(struct blk_desc *dev_desc) else dev_desc->removable = 0; -#ifdef CONFIG_ATAPI - if (is_atapi) { + if (IS_ENABLED(CONFIG_ATAPI) && is_atapi) { dev_desc->atapi = true; atapi_inquiry(dev_desc); return; } -#endif /* CONFIG_ATAPI */ iop.lba_capacity[0] = be16_to_cpu(iop.lba_capacity[0]); iop.lba_capacity[1] = be16_to_cpu(iop.lba_capacity[1]); @@ -732,11 +726,10 @@ static void ide_init(void) if (c & (ATA_STAT_BUSY | ATA_STAT_FAULT)) { puts("not available "); debug("Status = 0x%02X ", c); -#ifndef CONFIG_ATAPI /* ATAPI Devices do not set DRDY */ - } else if ((c & ATA_STAT_READY) == 0) { + } else if (IS_ENABLED(CONFIG_ATAPI) && !(c & ATA_STAT_READY)) { + /* ATAPI Devices do not set DRDY */ puts("not available "); debug("Status = 0x%02X ", c); -#endif } else { puts("OK "); ide_bus_ok[bus] = 1; From patchwork Mon Mar 27 19:07:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761924 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=YYh7d5Rf; 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 4PljB01JPBz1yXv for ; Tue, 28 Mar 2023 06:12:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C96928616C; Mon, 27 Mar 2023 21:10:53 +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="YYh7d5Rf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 63802860FE; Mon, 27 Mar 2023 21:09:46 +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-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) (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 EE4EC86112 for ; Mon, 27 Mar 2023 21:09:41 +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-pf1-x431.google.com with SMTP id cm5so566876pfb.0 for ; Mon, 27 Mar 2023 12:09:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944179; 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=WDxkp2m54H8BAz5v3oA0qGW3dlZDirhu2KvYQnoofAM=; b=YYh7d5RfWBLzAdzK9tAjNTN4rSyzaDvvNjq6c7Myffa3uo+1Oh3kVTMG3oKPiyZFoG VrxtxB7uJQJnxuqaG4DMGIFdswk6hX3z26Zz9QNa0kcv4prpw6mTe8iyZwOavKgSaqAG uz6h+MOxxIky+q5LId5cSvTUHfNvzF8TbNvPI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944179; 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=WDxkp2m54H8BAz5v3oA0qGW3dlZDirhu2KvYQnoofAM=; b=hvu1CmLJR9zoOiuoStKLEYE2PAGtsUbIlweyW6DtJXFH4dUDe/U8gYXbg5NDNnexBg C3qHzB09BPf/2jHFYHH+3Ikoi+73LxmOUHjxcltRJ9vORcWonMXqYXRAmeiSmfNNA3dU BBh4BVOld+rScrrEnZfGkCRaBFcXs8DqDN3gDh5BFW6/R9yCHAhdPcmVhUre1ENlAMbc uFN+kJq+2Ld0hnWGO7NQfCpwYZyjojBWWZ7ap7M6g2xvYyO/YK2DAmXzv8ySDQJErw4y yn/y6NEGoATd4eKhnVTIPD8VOHA7o1jSjUX1hhvYBDJI9mU+gcFPX3jRQ0wJBsRxysDy 6B3A== X-Gm-Message-State: AAQBX9dGOlIuezz6gLc02802zxFChJo8epJfTIIbWlSokVv8woe1Wi8O e8NG553+0RyODpSFXwPU857xxRLR8jxdxA7kgCs= X-Google-Smtp-Source: AKy350ZMb9OvU96T3yw1mF6G/8rP2YyWVkhhm2lrzh9UxhiV6FZdBjdXueOF7ejvoXgoAiYkX2XKoQ== X-Received: by 2002:aa7:9821:0:b0:627:e69c:8488 with SMTP id q1-20020aa79821000000b00627e69c8488mr12345773pfl.14.1679944179012; Mon, 27 Mar 2023 12:09:39 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:09:38 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass , Heinrich Schuchardt , Mattijs Korpershoek Subject: [PATCH 16/30] ide: Avoid preprocessor for CONFIG_LBA48 Date: Tue, 28 Mar 2023 08:07:03 +1300 Message-Id: <20230328080702.16.Ic19d3ab1094a129854187823d74d6bc6a7004944@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 Use IS_ENABLED() instead for all conditions. Add the 'lba48' flag into struct blk_desc always, since it uses very little space. Use a bool so the meaning is clearer. Signed-off-by: Simon Glass Reviewed-by: Mattijs Korpershoek --- drivers/block/ide.c | 57 ++++++++++++++++----------------------------- include/blk.h | 4 +--- 2 files changed, 21 insertions(+), 40 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 6c5227a5c0e2..45201333c3c5 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -540,11 +540,9 @@ static void atapi_inquiry(struct blk_desc *dev_desc) ((unsigned long) iobuf[5] << 16) + ((unsigned long) iobuf[6] << 8) + ((unsigned long) iobuf[7]); dev_desc->log2blksz = LOG2(dev_desc->blksz); -#ifdef CONFIG_LBA48 + /* ATAPI devices cannot use 48bit addressing (ATA/ATAPI v7) */ - dev_desc->lba48 = 0; -#endif - return; + dev_desc->lba48 = false; } static void ide_ident(struct blk_desc *dev_desc) @@ -645,9 +643,9 @@ static void ide_ident(struct blk_desc *dev_desc) ((unsigned long)iop.lba_capacity[0]) | ((unsigned long)iop.lba_capacity[1] << 16); -#ifdef CONFIG_LBA48 - if (iop.command_set_2 & 0x0400) { /* LBA 48 support */ - dev_desc->lba48 = 1; + if (IS_ENABLED(CONFIG_LBA48) && (iop.command_set_2 & 0x0400)) { + /* LBA 48 support */ + dev_desc->lba48 = true; for (int i = 0; i < 4; i++) iop.lba48_capacity[i] = be16_to_cpu(iop.lba48_capacity[i]); dev_desc->lba = @@ -656,9 +654,9 @@ static void ide_ident(struct blk_desc *dev_desc) ((unsigned long long)iop.lba48_capacity[2] << 32) | ((unsigned long long)iop.lba48_capacity[3] << 48)); } else { - dev_desc->lba48 = 0; + dev_desc->lba48 = false; } -#endif /* CONFIG_LBA48 */ + /* assuming HD */ dev_desc->type = DEV_TYPE_HARDDISK; dev_desc->blksz = ATA_BLOCKSIZE; @@ -795,15 +793,13 @@ static ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, ulong n = 0; unsigned char c; unsigned char pwrsave = 0; /* power save */ + bool lba48 = false; -#ifdef CONFIG_LBA48 - unsigned char lba48 = 0; - - if (blknr & 0x0000fffff0000000ULL) { + if (IS_ENABLED(CONFIG_LBA48) && (blknr & 0x0000fffff0000000ULL)) { /* more than 28 bits used, use 48bit mode */ - lba48 = 1; + lba48 = true; } -#endif + debug("ide_read dev %d start " LBAF ", blocks " LBAF " buffer at %lX\n", device, blknr, blkcnt, (ulong) buffer); @@ -845,8 +841,7 @@ static ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, printf("IDE read: device %d not ready\n", device); break; } -#ifdef CONFIG_LBA48 - if (lba48) { + if (IS_ENABLED(CONFIG_LBA48) && lba48) { /* write high bits */ ide_outb(device, ATA_SECT_CNT, 0); ide_outb(device, ATA_LBA_LOW, (blknr >> 24) & 0xFF); @@ -858,21 +853,17 @@ static ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, ide_outb(device, ATA_LBA_HIGH, 0); #endif } -#endif ide_outb(device, ATA_SECT_CNT, 1); ide_outb(device, ATA_LBA_LOW, (blknr >> 0) & 0xFF); ide_outb(device, ATA_LBA_MID, (blknr >> 8) & 0xFF); ide_outb(device, ATA_LBA_HIGH, (blknr >> 16) & 0xFF); -#ifdef CONFIG_LBA48 - if (lba48) { + if (IS_ENABLED(CONFIG_LBA48) && lba48) { ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device)); ide_outb(device, ATA_COMMAND, ATA_CMD_PIO_READ_EXT); - } else -#endif - { + } else { ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device) | ((blknr >> 24) & 0xF)); ide_outb(device, ATA_COMMAND, ATA_CMD_PIO_READ); @@ -914,15 +905,12 @@ static ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, int device = block_dev->devnum; ulong n = 0; unsigned char c; + bool lba48 = false; -#ifdef CONFIG_LBA48 - unsigned char lba48 = 0; - - if (blknr & 0x0000fffff0000000ULL) { + if (IS_ENABLED(CONFIG_LBA48) && (blknr & 0x0000fffff0000000ULL)) { /* more than 28 bits used, use 48bit mode */ - lba48 = 1; + lba48 = true; } -#endif /* Select device */ @@ -935,8 +923,7 @@ static ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, printf("IDE read: device %d not ready\n", device); goto WR_OUT; } -#ifdef CONFIG_LBA48 - if (lba48) { + if (IS_ENABLED(CONFIG_LBA48) && lba48) { /* write high bits */ ide_outb(device, ATA_SECT_CNT, 0); ide_outb(device, ATA_LBA_LOW, (blknr >> 24) & 0xFF); @@ -948,21 +935,17 @@ static ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, ide_outb(device, ATA_LBA_HIGH, 0); #endif } -#endif ide_outb(device, ATA_SECT_CNT, 1); ide_outb(device, ATA_LBA_LOW, (blknr >> 0) & 0xFF); ide_outb(device, ATA_LBA_MID, (blknr >> 8) & 0xFF); ide_outb(device, ATA_LBA_HIGH, (blknr >> 16) & 0xFF); -#ifdef CONFIG_LBA48 - if (lba48) { + if (IS_ENABLED(CONFIG_LBA48) && lba48) { ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device)); ide_outb(device, ATA_COMMAND, ATA_CMD_PIO_WRITE_EXT); - } else -#endif - { + } else { ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device) | ((blknr >> 24) & 0xF)); ide_outb(device, ATA_COMMAND, ATA_CMD_PIO_WRITE); diff --git a/include/blk.h b/include/blk.h index 871922dcde07..2c9c7985a885 100644 --- a/include/blk.h +++ b/include/blk.h @@ -62,10 +62,8 @@ struct blk_desc { unsigned char hwpart; /* HW partition, e.g. for eMMC */ unsigned char type; /* device type */ unsigned char removable; /* removable device */ -#ifdef CONFIG_LBA48 /* device can use 48bit addr (ATA/ATAPI v7) */ - unsigned char lba48; -#endif + bool lba48; unsigned char atapi; /* Use ATAPI protocol */ lbaint_t lba; /* number of blocks */ unsigned long blksz; /* block size */ From patchwork Mon Mar 27 19:07:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761926 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=WIV1Dlm5; 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 4PljBX3DPrz1yXv for ; Tue, 28 Mar 2023 06:12:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D1E4D86141; Mon, 27 Mar 2023 21:11:06 +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="WIV1Dlm5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8E22D85AEC; Mon, 27 Mar 2023 21:09:48 +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-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (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 CFE8186123 for ; Mon, 27 Mar 2023 21:09:43 +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-pj1-x1035.google.com with SMTP id fy10-20020a17090b020a00b0023b4bcf0727so10043109pjb.0 for ; Mon, 27 Mar 2023 12:09:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944182; 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=GnUgt9IwXZsN+lFfsWG7Cu1GLBMYfBiTzeppfy4qNGA=; b=WIV1Dlm5Wr7nLdlI1Aloe61iIdSxI+zosylWwKSLjCQetkDFE4FttDmEEHfSrN1IvE 7YMLJntZZTSHj2S4KvCzTPULsaaRyr3WVBT4BU1dEiMudSynM7FRGs+clvH9QMAfZ0KF +fiuo4VPQFaAl7SWaVGJsf8EWO3aR83sMEhgk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944182; 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=GnUgt9IwXZsN+lFfsWG7Cu1GLBMYfBiTzeppfy4qNGA=; b=HVA3jHyL/07Y5ZVLTbFFW3iLxRNLhUwQGSDcniUNutXxryksGQPqKiZIsAeEGIxwMd yK2UYRbthLnb9jjxu/PWxR/YgoJkC4uDkd8V0WM6ffgPx1hZMMgFd/GADZ7jkBgeWOpI 1TH96AnQKnIm2IRdIwJrKx41zam23bsKvatMAgD1/3bEpfaougp9IsyjlR8mKkT495hB IWT2f3qadwH385nsAyZ4Q2QrhfJpOui/5RzThpM22PXaIsRzX6ubVRxOqXvMBcCOzm5L 3GWHYOqRw0Uye8cUQvRtZlFeeBWR3cGR6fPrKcW+c8tp6PeKjV9xzVFlcMUb3951vRyd 7Iow== X-Gm-Message-State: AAQBX9cV32jeXGdpu+Tt1/ZWuP9AoJl0c+JgsgqUE4xBWi8KuLK2N2eK hEqJI8+O7UjBu+hEy9xtZ2weJ/6EznZeluK/5Y8= X-Google-Smtp-Source: AKy350ZsLktdUAcwFHGB+WFixKbAkLiJgTlHVEfR110Eu+uo59Qjmfdw+HHx5ky9HBfEhK6y6BDRdw== X-Received: by 2002:a05:6a20:8c05:b0:de:808e:8f3d with SMTP id j5-20020a056a208c0500b000de808e8f3dmr9331501pzh.13.1679944181956; Mon, 27 Mar 2023 12:09:41 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:09:41 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 17/30] ide: Move bus init into a function Date: Tue, 28 Mar 2023 08:07:04 +1300 Message-Id: <20230328080702.17.I94e9d7786da73fb8050135b005330e64fd2c56b4@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 Move this code into a separate function which returns whether the bus was found, or not. Signed-off-by: Simon Glass --- drivers/block/ide.c | 87 +++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 39 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 45201333c3c5..aac4462f57b9 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -679,9 +679,55 @@ static void ide_ident(struct blk_desc *dev_desc) #endif } +/** + * ide_init_one() - Init one IDE device + * + * @bus: Bus to use + * Return: 0 iuf OK, -EIO if not available, -ETIMEDOUT if timed out + */ +static int ide_init_one(int bus) +{ + int dev = bus * CONFIG_SYS_IDE_MAXDEVICE / CONFIG_SYS_IDE_MAXBUS; + int i; + u8 c; + + printf("Bus %d: ", bus); + + /* Select device */ + mdelay(100); + ide_outb(dev, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(dev)); + mdelay(100); + i = 0; + do { + mdelay(10); + + c = ide_inb(dev, ATA_STATUS); + i++; + if (i > (ATA_RESET_TIME * 100)) { + puts("** Timeout **\n"); + return -ETIMEDOUT; + } + if (i >= 100 && !(i % 100)) + putc('.'); + } while (c & ATA_STAT_BUSY); + + if (c & (ATA_STAT_BUSY | ATA_STAT_FAULT)) { + puts("not available "); + debug("Status = 0x%02X ", c); + return -EIO; + } else if (IS_ENABLED(CONFIG_ATAPI) && !(c & ATA_STAT_READY)) { + /* ATAPI Devices do not set DRDY */ + puts("not available "); + debug("Status = 0x%02X ", c); + return -EIO; + } + puts("OK "); + + return 0; +} + static void ide_init(void) { - unsigned char c; int i, bus; schedule(); @@ -694,44 +740,7 @@ static void ide_init(void) * According to spec, this can take up to 31 seconds! */ for (bus = 0; bus < CONFIG_SYS_IDE_MAXBUS; ++bus) { - int dev = - bus * (CONFIG_SYS_IDE_MAXDEVICE / - CONFIG_SYS_IDE_MAXBUS); - - printf("Bus %d: ", bus); - - ide_bus_ok[bus] = 0; - - /* Select device */ - mdelay(100); - ide_outb(dev, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(dev)); - mdelay(100); - i = 0; - do { - mdelay(10); - - c = ide_inb(dev, ATA_STATUS); - i++; - if (i > (ATA_RESET_TIME * 100)) { - puts("** Timeout **\n"); - return; - } - if ((i >= 100) && ((i % 100) == 0)) - putc('.'); - - } while (c & ATA_STAT_BUSY); - - if (c & (ATA_STAT_BUSY | ATA_STAT_FAULT)) { - puts("not available "); - debug("Status = 0x%02X ", c); - } else if (IS_ENABLED(CONFIG_ATAPI) && !(c & ATA_STAT_READY)) { - /* ATAPI Devices do not set DRDY */ - puts("not available "); - debug("Status = 0x%02X ", c); - } else { - puts("OK "); - ide_bus_ok[bus] = 1; - } + ide_bus_ok[bus] = !ide_init_one(bus); schedule(); } From patchwork Mon Mar 27 19:07:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761927 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=YGilBWK8; 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 4PljBp04G4z1yXv for ; Tue, 28 Mar 2023 06:13:06 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B23C886167; Mon, 27 Mar 2023 21:11:11 +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="YGilBWK8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 13C5385AEC; Mon, 27 Mar 2023 21:09:51 +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-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) (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 0BB8486131 for ; Mon, 27 Mar 2023 21:09:46 +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-pg1-x529.google.com with SMTP id z18so5771012pgj.13 for ; Mon, 27 Mar 2023 12:09:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944185; 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=oZefgrOt+HgSpZcNNxHWdQ7bX8SVsQ+cFVHCbs5gQbE=; b=YGilBWK8OLX1VXrTUICmF85P/NmLHjCqpiVULwNehb0ZqSErViVknEpysGGW2rbeVR 7gNzJE9z9BijEZ1LeumkS1Y+tzpUEDJFKrdFHBCA+OyYEpQ+QPdIRaz9ZnSNA7s8nOt+ tzqQT9M69Sll2aFbC9ebfSl2FNHn0LOe4PjcM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944185; 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=oZefgrOt+HgSpZcNNxHWdQ7bX8SVsQ+cFVHCbs5gQbE=; b=6hQQz2iazWmO6OFzJy0/dLCYK2Ns7wi/711oH0VpLbEoeUjxZ29lWXCJtgjGS75RIi iIIeyvSjLoig23ow90YXcVXcL4TIp2scYJVLFIFWY6nT+iRYwIMPuDsikeu6s7TIel+7 XOlgdxbiKy19l5cErxJEYOdd+5CjyGp//E9icgEoLEQ8i3sBYOyvwolwQUiX9DKtX6Hk hzoofFKRxZCTaMb/EAnfQIHPgx2MHK5ckvuzyJepDB8OKC5oHYA5i0xd4ssrlq3KfTPy du7EBprsUe8KhIVNfCjY54ju8BnXkkELLhYVpYDGiu0WEhIYIWKPXd27/IB2vQqmNxlE A6EA== X-Gm-Message-State: AAQBX9dpak9G7kBHWlbo72nseIep9+q/ccaq3RvzAwGUhmWwVEpLfyKV lzON2JE2DZZo+ktGkjbGwn55Z3plekA9JW5lg8U= X-Google-Smtp-Source: AKy350bp4kh8G44T1XVML9Whv/bpOAk2MMVPvjPkzr92RHP5eXVG6rG6zj2slbCONYapASBWO2sZNA== X-Received: by 2002:aa7:8ec1:0:b0:622:7e20:71d with SMTP id b1-20020aa78ec1000000b006227e20071dmr11261659pfr.17.1679944184932; Mon, 27 Mar 2023 12:09:44 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:09:44 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 18/30] ide: Make ide_bus_ok[] a local variable Date: Tue, 28 Mar 2023 08:07:05 +1300 Message-Id: <20230328080702.18.Ic32649dd9c48cab6ad587151419c3e5ebf71fb90@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 This is only used in one place now, so make it a local variable. Signed-off-by: Simon Glass --- drivers/block/ide.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index aac4462f57b9..36c726225d0e 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -39,8 +39,6 @@ ulong ide_bus_offset[CONFIG_SYS_IDE_MAXBUS] = { #define ATA_CURR_BASE(dev) (CONFIG_SYS_ATA_BASE_ADDR + \ ide_bus_offset[IDE_BUS(dev)]) -static int ide_bus_ok[CONFIG_SYS_IDE_MAXBUS]; - struct blk_desc ide_dev_desc[CONFIG_SYS_IDE_MAXDEVICE]; #define IDE_TIME_OUT 2000 /* 2 sec timeout */ @@ -52,11 +50,6 @@ struct blk_desc ide_dev_desc[CONFIG_SYS_IDE_MAXDEVICE]; #ifdef CONFIG_IDE_RESET static void ide_reset(void) { - int i; - - for (i = 0; i < CONFIG_SYS_IDE_MAXBUS; ++i) - ide_bus_ok[i] = 0; - ide_set_reset(1); /* assert reset */ /* the reset signal shall be asserted for et least 25 us */ @@ -728,6 +721,7 @@ static int ide_init_one(int bus) static void ide_init(void) { + bool bus_ok[CONFIG_SYS_IDE_MAXBUS]; int i, bus; schedule(); @@ -740,7 +734,7 @@ static void ide_init(void) * According to spec, this can take up to 31 seconds! */ for (bus = 0; bus < CONFIG_SYS_IDE_MAXBUS; ++bus) { - ide_bus_ok[bus] = !ide_init_one(bus); + bus_ok[bus] = !ide_init_one(bus); schedule(); } @@ -755,7 +749,7 @@ static void ide_init(void) ide_dev_desc[i].log2blksz = LOG2_INVALID(typeof(ide_dev_desc[i].log2blksz)); ide_dev_desc[i].lba = 0; - if (!ide_bus_ok[IDE_BUS(i)]) + if (!bus_ok[IDE_BUS(i)]) continue; ide_ident(&ide_dev_desc[i]); dev_print(&ide_dev_desc[i]); 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); } } From patchwork Mon Mar 27 19:07:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761929 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=85.214.62.61; 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=a8c+k+4K; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4PljCJ57gNz1yXv for ; Tue, 28 Mar 2023 06:13:32 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2C4838617B; Mon, 27 Mar 2023 21:11:29 +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="a8c+k+4K"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ADC4486103; Mon, 27 Mar 2023 21:09:55 +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-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) (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 9C8A286112 for ; Mon, 27 Mar 2023 21:09:51 +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-pg1-x529.google.com with SMTP id z18so5771169pgj.13 for ; Mon, 27 Mar 2023 12:09:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944191; 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=j46tG20oRhhYzu+d2/k3Hm893gObDirMm4L8xRyueqM=; b=a8c+k+4KiYyhfbdrMQhZCs0T2pSwMLBA6HABdOchm4cX1NKvflDku8Y0q1peMjVHMl wHVcBAolVFhMemS6ooikGghuzszyL20cxBDRI8qClGnf1GctkMqeXyfXUF57cc1/Zewh OwkiFzdnjq+WYPf+GIpc7mBIRpp6xK7s42lUk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944191; 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=j46tG20oRhhYzu+d2/k3Hm893gObDirMm4L8xRyueqM=; b=exnJKAgyl5gaeM53SuisN7WpWv9pTIsIsfeS8Nx6/utQEBmaPN252hDLxmRGUTzULU 7ePhkQo0yo+L9/DGB2uaDf9OJn9tS81Ru0M0hAaYzcQVFvGsbMcaQEKA6wOE/whMD51O ukVz/uXKYJBQccLat5Zx9XPhtUKGE9N6wR2+P2Tpka+dpA5fEFhHhDJpurN1RWacmmab zjpnVVd+cXE8M4/Q6aqLXX7EbwTmv2RPhc5j+Y0qbIM0F6FpZYNPXGrGw4q8ulAkC3Mp F7IyZp7yEeQqRuDM4Wg//nBk/XN3maIxZplhEPepdgIEmKMmUPWp8WLiPZ1tsmLcjQOj td9A== X-Gm-Message-State: AAQBX9csuami/Owqd+MYooHQVgEkWfl/X7BYHK4N0sh7qqug53nb+7gG cC0P60jrV8j2dMhjBNwl+5HUyzr/lFiTRr8yAEY= X-Google-Smtp-Source: AKy350Y2IkC/cMi9rjIIScXsXs3whZYd39vnBk/gLtb9KWn/FsRii5B7LoKuMCILda9Bb2Vuh6Ql4w== X-Received: by 2002:a05:6a00:4e:b0:625:dcc1:620b with SMTP id i14-20020a056a00004e00b00625dcc1620bmr13602544pfk.34.1679944190810; Mon, 27 Mar 2023 12:09:50 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:09:50 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 20/30] ide: Move ide_init() entirely within ide_probe() Date: Tue, 28 Mar 2023 08:07:07 +1300 Message-Id: <20230328080702.20.I1cf8c82a72b076e0672a98eb0941faa23f48d0aa@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 Now that ide_probe() is the only caller of ide_init(), move all the code into the probe function, so it is easier to refactor it. Move ide_dev_desc[] into ide_probe() to, since it is the only user. Signed-off-by: Simon Glass --- drivers/block/ide.c | 84 ++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 46 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index ecac8b6cfd55..5fbf144da9d1 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -39,8 +39,6 @@ ulong ide_bus_offset[CONFIG_SYS_IDE_MAXBUS] = { #define ATA_CURR_BASE(dev) (CONFIG_SYS_ATA_BASE_ADDR + \ ide_bus_offset[IDE_BUS(dev)]) -struct blk_desc ide_dev_desc[CONFIG_SYS_IDE_MAXDEVICE]; - #define IDE_TIME_OUT 2000 /* 2 sec timeout */ #define ATAPI_TIME_OUT 7000 /* 7 sec timeout (5 sec seems to work...) */ @@ -719,44 +717,6 @@ static int ide_init_one(int bus) return 0; } -static void ide_init(void) -{ - bool bus_ok[CONFIG_SYS_IDE_MAXBUS]; - int i, bus; - - schedule(); - - /* ATAPI Drives seems to need a proper IDE Reset */ - ide_reset(); - - /* - * Wait for IDE to get ready. - * According to spec, this can take up to 31 seconds! - */ - for (bus = 0; bus < CONFIG_SYS_IDE_MAXBUS; ++bus) { - bus_ok[bus] = !ide_init_one(bus); - schedule(); - } - - putc('\n'); - - for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; ++i) { - ide_dev_desc[i].type = DEV_TYPE_UNKNOWN; - ide_dev_desc[i].uclass_id = UCLASS_IDE; - ide_dev_desc[i].devnum = i; - ide_dev_desc[i].part_type = PART_TYPE_UNKNOWN; - ide_dev_desc[i].blksz = 0; - ide_dev_desc[i].log2blksz = - LOG2_INVALID(typeof(ide_dev_desc[i].log2blksz)); - ide_dev_desc[i].lba = 0; - if (!bus_ok[IDE_BUS(i)]) - continue; - ide_ident(&ide_dev_desc[i]); - dev_print(&ide_dev_desc[i]); - } - schedule(); -} - static void ide_output_data(int dev, const ulong *sect_buf, int words) { uintptr_t paddr = (ATA_CURR_BASE(dev) + ATA_DATA_REG); @@ -1041,9 +1001,41 @@ BOOTDEV_HUNTER(ide_bootdev_hunter) = { static int ide_probe(struct udevice *udev) { - int i; + struct blk_desc ide_dev_desc[CONFIG_SYS_IDE_MAXDEVICE]; + bool bus_ok[CONFIG_SYS_IDE_MAXBUS]; + int i, bus; + + schedule(); + + /* ATAPI Drives seems to need a proper IDE Reset */ + ide_reset(); + + /* + * Wait for IDE to get ready. + * According to spec, this can take up to 31 seconds! + */ + for (bus = 0; bus < CONFIG_SYS_IDE_MAXBUS; ++bus) { + bus_ok[bus] = !ide_init_one(bus); + schedule(); + } - ide_init(); + putc('\n'); + + for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; ++i) { + ide_dev_desc[i].type = DEV_TYPE_UNKNOWN; + ide_dev_desc[i].uclass_id = UCLASS_IDE; + ide_dev_desc[i].devnum = i; + ide_dev_desc[i].part_type = PART_TYPE_UNKNOWN; + ide_dev_desc[i].blksz = 0; + ide_dev_desc[i].log2blksz = + LOG2_INVALID(typeof(ide_dev_desc[i].log2blksz)); + ide_dev_desc[i].lba = 0; + if (!bus_ok[IDE_BUS(i)]) + continue; + ide_ident(&ide_dev_desc[i]); + dev_print(&ide_dev_desc[i]); + } + schedule(); for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; i++) { if (ide_dev_desc[i].type != DEV_TYPE_UNKNOWN) { @@ -1075,10 +1067,6 @@ static int ide_probe(struct udevice *udev) if (ret) return ret; - 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, @@ -1089,6 +1077,10 @@ static int ide_probe(struct udevice *udev) strlcpy(desc->revision, ide_dev_desc[desc->devnum].revision, BLK_REV_SIZE); + + ret = bootdev_setup_for_dev(udev, "ide_bootdev"); + if (ret) + return log_msg_ret("bootdev", ret); } } From patchwork Mon Mar 27 19:07:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761930 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=85.214.62.61; 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=PXXWB8mE; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4PljCb72L5z1yXv for ; Tue, 28 Mar 2023 06:13:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2C98586175; Mon, 27 Mar 2023 21:11:33 +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="PXXWB8mE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CF80A86113; Mon, 27 Mar 2023 21:09:58 +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-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (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 7599185CCA for ; Mon, 27 Mar 2023 21:09:55 +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-pj1-x1035.google.com with SMTP id x15so8646919pjk.2 for ; Mon, 27 Mar 2023 12:09:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944193; 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=GYC/pD44PG61YgdKd0lHRylgWhEr9rFlF5FOu9HnorU=; b=PXXWB8mELwZbuX6A0TYRyrGc2hWMpmVFJUaaIjDo2uOCxI4U9ZxCz8rn4mOyNIx8RP vhD6RH4jDQRa+C8gP0oqWm1Jx1E5f5+SR/eTiaQxQYbXNp+4Y79CU9NVFWnehN3hvVpR OqWLKEGCp4X1eQTE3eqSeA9V3oIoLDe6/RNU0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944193; 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=GYC/pD44PG61YgdKd0lHRylgWhEr9rFlF5FOu9HnorU=; b=K5ArupA3jXUrZ1zwUE8rSHlpIUVZr9ibsg/AirwxPDYlVwULaJ5U+8yfhq1J2Fqtyx dcKhEdntNxtXoR7pa/T0DCXw/447704ed6VoJkeOQvHISDPGb5FQT3jdAP06ehzBNOT1 j3KRCxMUPydjgSGCqp51tAd57N/tL/0P+Di5iqDrlEFqMY2OHvygibk+oD8frlyruSMX 1lINvh7A8Fl+X/vnhY+hVfNhKecPjbGEdXgHTvAiTIOSOEJeCJ6oLdUNCxeyMwr+d7rE dM6Y97R5bHXuLsEf9duSMD5cny+InoszKsRWe1RM2AkX46AU7RYq35wMX1RWwieDIM3S hmZA== X-Gm-Message-State: AO0yUKVBqStD4VjRN3EN7BetZM0f3fLK7PkufNacNrL/3qr7uWi34DiE UYdikw7iPp9gfmnTVLLJa+aV4Q7wVSH6amUmt44= X-Google-Smtp-Source: AK7set9ccBv7inUHsDmTLaQFlGTMEOdQ4kxkFPhg9bqyvPtDtux9LpZlKhYW7jBUKsJy1szEFMOkFg== X-Received: by 2002:a05:6a20:24a7:b0:bf:4563:e647 with SMTP id m39-20020a056a2024a700b000bf4563e647mr11296341pzd.40.1679944193692; Mon, 27 Mar 2023 12:09:53 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:09:53 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 21/30] ide: Combine the two loops in ide_probe() Date: Tue, 28 Mar 2023 08:07:08 +1300 Message-Id: <20230328080702.21.If01ca48c26ae6898d1c5eb8e361ca131c1435587@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 two loops in this function operate on the same ide_dev_desc[] array. Combine them to reduce duplication. Signed-off-by: Simon Glass --- drivers/block/ide.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 5fbf144da9d1..d682d6ad9e68 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -1021,7 +1021,12 @@ static int ide_probe(struct udevice *udev) putc('\n'); - for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; ++i) { + schedule(); + + for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; i++) { + if (!bus_ok[IDE_BUS(i)]) + continue; + ide_dev_desc[i].type = DEV_TYPE_UNKNOWN; ide_dev_desc[i].uclass_id = UCLASS_IDE; ide_dev_desc[i].devnum = i; @@ -1030,14 +1035,9 @@ static int ide_probe(struct udevice *udev) ide_dev_desc[i].log2blksz = LOG2_INVALID(typeof(ide_dev_desc[i].log2blksz)); ide_dev_desc[i].lba = 0; - if (!bus_ok[IDE_BUS(i)]) - continue; ide_ident(&ide_dev_desc[i]); dev_print(&ide_dev_desc[i]); - } - schedule(); - 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; From patchwork Mon Mar 27 19:07:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761931 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=WVHAXgQg; 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 4PljCy4gmGz1yXv for ; Tue, 28 Mar 2023 06:14:06 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E71EB8617A; Mon, 27 Mar 2023 21:11:37 +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="WVHAXgQg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E4C8186112; Mon, 27 Mar 2023 21:10:19 +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-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) (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 6731F8610C for ; Mon, 27 Mar 2023 21:09:57 +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-pg1-x529.google.com with SMTP id z18so5771355pgj.13 for ; Mon, 27 Mar 2023 12:09:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944197; 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=65RpmdkIRDKBEhWpplUGf/7JUPS1NT5bkAlKVp/mjGo=; b=WVHAXgQgoiFl/SD8AOlhsLGfy365D4VYH6auP5m7fTtQ5SZYCCndRlSP7ldE2MXw8N eM+E95Qw8sUM9B6b8ozSq6naiEBhRI/yTcPlleADJq4FEDqUHm0TtF/zIkfFVYN8jNo9 vapd1mRz/tmesA2LTgFcJyRphleqlxDaqPfIc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944197; 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=65RpmdkIRDKBEhWpplUGf/7JUPS1NT5bkAlKVp/mjGo=; b=U6WZ8bYIhe/vJfMUxKf2Z2g7mo+rgNvdym1WAqCGV5m0fH8P7gAr/wQJOUKviuf8Jx d6AGrXYckUAd2vr6mELZVb8ndlyaC8W0s/FGxbtDYYYOYEDAW3wXkeAr7U3ylUnMCJzH 18iYh5FZmS3bhpnZ3yfoy1G9wputRgsF1JEM4FgVtoUeOxzbOJnWIzFvOaLC+naiNfw1 VJ75zgb0hVndwpLzSng40x9VvsJcgsTL/bOR+zOfdoBQUQQ//LCexg6yD0hO3b3mmtNU sqUO4Dx/wDaoQxOG/kGzzEuCH163CMJHuOHCdOwTjD1tPtMQ9g548BQCxsZXsWOc/mcV 7/fQ== X-Gm-Message-State: AAQBX9fg+YOi3l0qP4mY9p8YBUB83oOvOdUNuzb9mcyMR6jLOuTnE3eD xKvLOQY2hkuUFq1/qKLID88RlaEO//dPyUj4vWs= X-Google-Smtp-Source: AKy350aekrAB7Rsqg+xMIqh5ToU5ZtkAVZm0nwI8dL69yTJ0gwsjK2OozFDTLVXs1xv4VwuGzR4+eQ== X-Received: by 2002:a62:585:0:b0:592:de72:4750 with SMTP id 127-20020a620585000000b00592de724750mr11078234pff.23.1679944196599; Mon, 27 Mar 2023 12:09:56 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:09:56 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 22/30] ide: Use desc consistently for struct blk_desc Date: Tue, 28 Mar 2023 08:07:09 +1300 Message-Id: <20230328080702.22.Ibaf9dc107590864d7f1fc0788ba1cf43e2adfcfd@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 Most of the code uses 'desc' as the variable name for a blk descriptor. Change ide to do the same. Tidy up some extra brackets and types while we are here. Leave the code in ide_probe() alone since it is about to be refactored. Signed-off-by: Simon Glass --- drivers/block/ide.c | 101 +++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 54 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index d682d6ad9e68..835e781fccbe 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -414,8 +414,8 @@ error: static ulong atapi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) { - struct blk_desc *block_dev = dev_get_uclass_plat(dev); - int device = block_dev->devnum; + struct blk_desc *desc = dev_get_uclass_plat(dev); + int device = desc->devnum; ulong n = 0; unsigned char ccb[12]; /* Command descriptor block */ ulong cnt; @@ -456,15 +456,15 @@ static ulong atapi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, return n; } -static void atapi_inquiry(struct blk_desc *dev_desc) +static void atapi_inquiry(struct blk_desc *desc) { unsigned char ccb[12]; /* Command descriptor block */ unsigned char iobuf[64]; /* temp buf */ unsigned char c; int device; - device = dev_desc->devnum; - dev_desc->type = DEV_TYPE_UNKNOWN; /* not yet valid */ + device = desc->devnum; + desc->type = DEV_TYPE_UNKNOWN; /* not yet valid */ memset(ccb, 0, sizeof(ccb)); memset(iobuf, 0, sizeof(iobuf)); @@ -478,20 +478,20 @@ static void atapi_inquiry(struct blk_desc *dev_desc) return; /* copy device ident strings */ - ident_cpy((unsigned char *)dev_desc->vendor, &iobuf[8], 8); - ident_cpy((unsigned char *)dev_desc->product, &iobuf[16], 16); - ident_cpy((unsigned char *)dev_desc->revision, &iobuf[32], 5); + ident_cpy((u8 *)desc->vendor, &iobuf[8], 8); + ident_cpy((u8 *)desc->product, &iobuf[16], 16); + ident_cpy((u8 *)desc->revision, &iobuf[32], 5); - dev_desc->lun = 0; - dev_desc->lba = 0; - dev_desc->blksz = 0; - dev_desc->log2blksz = LOG2_INVALID(typeof(dev_desc->log2blksz)); - dev_desc->type = iobuf[0] & 0x1f; + desc->lun = 0; + desc->lba = 0; + desc->blksz = 0; + desc->log2blksz = LOG2_INVALID(typeof(desc->log2blksz)); + desc->type = iobuf[0] & 0x1f; if ((iobuf[1] & 0x80) == 0x80) - dev_desc->removable = 1; + desc->removable = 1; else - dev_desc->removable = 0; + desc->removable = 0; memset(ccb, 0, sizeof(ccb)); memset(iobuf, 0, sizeof(iobuf)); @@ -524,19 +524,17 @@ static void atapi_inquiry(struct blk_desc *dev_desc) iobuf[0], iobuf[1], iobuf[2], iobuf[3], iobuf[4], iobuf[5], iobuf[6], iobuf[7]); - dev_desc->lba = ((unsigned long) iobuf[0] << 24) + - ((unsigned long) iobuf[1] << 16) + - ((unsigned long) iobuf[2] << 8) + ((unsigned long) iobuf[3]); - dev_desc->blksz = ((unsigned long) iobuf[4] << 24) + - ((unsigned long) iobuf[5] << 16) + - ((unsigned long) iobuf[6] << 8) + ((unsigned long) iobuf[7]); - dev_desc->log2blksz = LOG2(dev_desc->blksz); + desc->lba = (ulong)iobuf[0] << 24 | (ulong)iobuf[1] << 16 | + (ulong)iobuf[2] << 8 | (ulong)iobuf[3]; + desc->blksz = (ulong)iobuf[4] << 24 | (ulong)iobuf[5] << 16 | + (ulong)iobuf[6] << 8 | (ulong)iobuf[7]; + desc->log2blksz = LOG2(desc->blksz); /* ATAPI devices cannot use 48bit addressing (ATA/ATAPI v7) */ - dev_desc->lba48 = false; + desc->lba48 = false; } -static void ide_ident(struct blk_desc *dev_desc) +static void ide_ident(struct blk_desc *desc) { unsigned char c; hd_driveid_t iop; @@ -544,13 +542,13 @@ static void ide_ident(struct blk_desc *dev_desc) int tries = 1; int device; - device = dev_desc->devnum; + device = desc->devnum; printf(" Device %d: ", device); /* Select device */ ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device)); - dev_desc->uclass_id = UCLASS_IDE; + desc->uclass_id = UCLASS_IDE; if (IS_ENABLED(CONFIG_ATAPI)) tries = 2; @@ -610,49 +608,44 @@ static void ide_ident(struct blk_desc *dev_desc) ide_input_swap_data(device, (ulong *)&iop, ATA_SECTORWORDS); - ident_cpy((unsigned char *)dev_desc->revision, iop.fw_rev, - sizeof(dev_desc->revision)); - ident_cpy((unsigned char *)dev_desc->vendor, iop.model, - sizeof(dev_desc->vendor)); - ident_cpy((unsigned char *)dev_desc->product, iop.serial_no, - sizeof(dev_desc->product)); + ident_cpy((u8 *)desc->revision, iop.fw_rev, sizeof(desc->revision)); + ident_cpy((u8 *)desc->vendor, iop.model, sizeof(desc->vendor)); + ident_cpy((u8 *)desc->product, iop.serial_no, sizeof(desc->product)); if ((iop.config & 0x0080) == 0x0080) - dev_desc->removable = 1; + desc->removable = 1; else - dev_desc->removable = 0; + desc->removable = 0; if (IS_ENABLED(CONFIG_ATAPI) && is_atapi) { - dev_desc->atapi = true; - atapi_inquiry(dev_desc); + desc->atapi = true; + atapi_inquiry(desc); return; } iop.lba_capacity[0] = be16_to_cpu(iop.lba_capacity[0]); iop.lba_capacity[1] = be16_to_cpu(iop.lba_capacity[1]); - dev_desc->lba = - ((unsigned long)iop.lba_capacity[0]) | - ((unsigned long)iop.lba_capacity[1] << 16); + desc->lba = (ulong)iop.lba_capacity[0] | + (ulong)iop.lba_capacity[1] << 16; if (IS_ENABLED(CONFIG_LBA48) && (iop.command_set_2 & 0x0400)) { /* LBA 48 support */ - dev_desc->lba48 = true; + desc->lba48 = true; for (int i = 0; i < 4; i++) iop.lba48_capacity[i] = be16_to_cpu(iop.lba48_capacity[i]); - dev_desc->lba = - ((unsigned long long)iop.lba48_capacity[0] | - ((unsigned long long)iop.lba48_capacity[1] << 16) | - ((unsigned long long)iop.lba48_capacity[2] << 32) | - ((unsigned long long)iop.lba48_capacity[3] << 48)); + desc->lba = (unsigned long long)iop.lba48_capacity[0] | + (unsigned long long)iop.lba48_capacity[1] << 16 | + (unsigned long long)iop.lba48_capacity[2] << 32 | + (unsigned long long)iop.lba48_capacity[3] << 48; } else { - dev_desc->lba48 = false; + desc->lba48 = false; } /* assuming HD */ - dev_desc->type = DEV_TYPE_HARDDISK; - dev_desc->blksz = ATA_BLOCKSIZE; - dev_desc->log2blksz = LOG2(dev_desc->blksz); - dev_desc->lun = 0; /* just to fill something in... */ + desc->type = DEV_TYPE_HARDDISK; + desc->blksz = ATA_BLOCKSIZE; + desc->log2blksz = LOG2(desc->blksz); + desc->lun = 0; /* just to fill something in... */ #if 0 /* only used to test the powersaving mode, * if enabled, the drive goes after 5 sec @@ -751,8 +744,8 @@ static void ide_input_data(int dev, ulong *sect_buf, int words) static ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, void *buffer) { - struct blk_desc *block_dev = dev_get_uclass_plat(dev); - int device = block_dev->devnum; + struct blk_desc *desc = dev_get_uclass_plat(dev); + int device = desc->devnum; ulong n = 0; unsigned char c; unsigned char pwrsave = 0; /* power save */ @@ -864,8 +857,8 @@ IDE_READ_E: static ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, const void *buffer) { - struct blk_desc *block_dev = dev_get_uclass_plat(dev); - int device = block_dev->devnum; + struct blk_desc *desc = dev_get_uclass_plat(dev); + int device = desc->devnum; ulong n = 0; unsigned char c; bool lba48 = false; From patchwork Mon Mar 27 19:07:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761940 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=85.214.62.61; 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=iXgPa9KB; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4PljHz4hpHz1yYb for ; Tue, 28 Mar 2023 06:17:35 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7C41886126; Mon, 27 Mar 2023 21:17:23 +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="iXgPa9KB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9DA0586116; Mon, 27 Mar 2023 21:17:13 +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-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) (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 5EEFC8613B for ; Mon, 27 Mar 2023 21:10:01 +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-pf1-x42d.google.com with SMTP id bt19so6410803pfb.3 for ; Mon, 27 Mar 2023 12:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944199; 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=b/xMSnMomkUsRCQXcpL8yz7axiH5dYMjq29tVT/+xac=; b=iXgPa9KBdCq2+417xwNlKXaTK+LDDZr45EWy0u7P0qhi23nnQAjYMjXaisPYbEQm3V YG4d8RKGRU2unUfqRFA7GSZ0jqkIgEBf+oV7YeCGW8CpPMmyUeGv0TUgAyXEhRO66wHq +s1D4JYQjhuuRSXHplAtMDvTvPRnF21iDEhz0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944199; 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=b/xMSnMomkUsRCQXcpL8yz7axiH5dYMjq29tVT/+xac=; b=OnlyTlP8wDWNgNdvpSiCokwwLqs3Y/mRae/RSH2Fd0XIPkSjKqnlArk2zwAm8IcNyr 90OXTBcRWBzyNYMDMZcTLp5fidlMTh6OurTBTZLJSBk7tlxxa1w0VE4tGbSxR6IVKuNl OwxKTHlrs+PkOFDmGl+ikMSy6I2C33wGFs1hdpEunUp0cBWWwLw8jAq6kUC3oj1BR1JT UO/vsYK3dA06raDi8+90vlkq8jqIhZBO0nFPamoOPZsGRUo6ywbYz1WHEKF7U1GoYEFS 48CkCbiU0Ae07RZk/UXpGCAon8T+B7yeOJswtsK8PO2TLDCFDE7egGTfSk/Ylg+Rlvgn bbsA== X-Gm-Message-State: AAQBX9dY+8vCbyImpRVQltn5T1QgLwHvZUb3ugd4uPUaReJGRr2fjiLz o4AmPV6LrtWQ1kNi3dgD49ObTbyY7FhPUuFe/r8= X-Google-Smtp-Source: AKy350YMVqOxrS9vbfJbjzDahMqrDjsASe1vnFTjQ6AxVm1qR6HvFX8wVYTkGGpNEOwto0F/1H8bLg== X-Received: by 2002:a62:84d4:0:b0:625:500c:35bd with SMTP id k203-20020a6284d4000000b00625500c35bdmr13947741pfd.6.1679944199484; Mon, 27 Mar 2023 12:09:59 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:09:59 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 23/30] ide: Make ide_ident() return an error code Date: Tue, 28 Mar 2023 08:07:10 +1300 Message-Id: <20230328080702.23.I327e17dca1267ba431a5a1b6529ecb97a4e873d8@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 Update ide_ident() to indicate whether it finds a device or not. Use that to decide whether to create a block device for it, rather than looking DEV_TYPE_UNKNOWN. Signed-off-by: Simon Glass --- drivers/block/ide.c | 101 +++++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 48 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 835e781fccbe..16b119ecbe10 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -534,15 +534,21 @@ static void atapi_inquiry(struct blk_desc *desc) desc->lba48 = false; } -static void ide_ident(struct blk_desc *desc) +/** + * ide_ident() - Identify an IDE device + * + * @device: Device number to use + * @desc: Block descriptor to fill in + * Returns: 0 if OK, -ENOENT if no device is found + */ +static int ide_ident(int device, struct blk_desc *desc) { unsigned char c; hd_driveid_t iop; bool is_atapi = false; int tries = 1; - int device; - device = desc->devnum; + desc->devnum = device; printf(" Device %d: ", device); /* Select device @@ -604,7 +610,7 @@ static void ide_ident(struct blk_desc *desc) } if (!tries) /* Not found */ - return; + return -ENOENT; ide_input_swap_data(device, (ulong *)&iop, ATA_SECTORWORDS); @@ -620,7 +626,7 @@ static void ide_ident(struct blk_desc *desc) if (IS_ENABLED(CONFIG_ATAPI) && is_atapi) { desc->atapi = true; atapi_inquiry(desc); - return; + return 0; } iop.lba_capacity[0] = be16_to_cpu(iop.lba_capacity[0]); @@ -661,6 +667,8 @@ static void ide_ident(struct blk_desc *desc) udelay(50); c = ide_wait(device, IDE_TIME_OUT); /* can't take over 500 ms */ #endif + + return 0; } /** @@ -1017,64 +1025,61 @@ static int ide_probe(struct udevice *udev) schedule(); for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; i++) { + struct blk_desc *desc; + struct udevice *blk; + lbaint_t size; + char name[20]; + int blksz; + int ret; + if (!bus_ok[IDE_BUS(i)]) continue; ide_dev_desc[i].type = DEV_TYPE_UNKNOWN; ide_dev_desc[i].uclass_id = UCLASS_IDE; - ide_dev_desc[i].devnum = i; ide_dev_desc[i].part_type = PART_TYPE_UNKNOWN; ide_dev_desc[i].blksz = 0; ide_dev_desc[i].log2blksz = LOG2_INVALID(typeof(ide_dev_desc[i].log2blksz)); ide_dev_desc[i].lba = 0; - ide_ident(&ide_dev_desc[i]); + ret = ide_ident(i, &ide_dev_desc[i]); dev_print(&ide_dev_desc[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; + if (ret) + continue; - sprintf(name, "blk#%d", i); + sprintf(name, "blk#%d", i); - blksz = ide_dev_desc[i].blksz; - size = blksz * ide_dev_desc[i].lba; + blksz = ide_dev_desc[i].blksz; + size = blksz * ide_dev_desc[i].lba; - /* - * With CDROM, if there is no CD inserted, blksz will - * be zero, don't bother to create IDE block device. - */ - if (!blksz) - continue; - ret = blk_create_devicef(udev, "ide_blk", name, - UCLASS_IDE, i, - blksz, size, &blk_dev); - if (ret) - return ret; - - ret = blk_probe_or_unbind(blk_dev); - if (ret) - return 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); - - ret = bootdev_setup_for_dev(udev, "ide_bootdev"); - if (ret) - return log_msg_ret("bootdev", ret); - } + /* + * With CDROM, if there is no CD inserted, blksz will + * be zero, don't bother to create IDE block device. + */ + if (!blksz) + continue; + ret = blk_create_devicef(udev, "ide_blk", name, UCLASS_IDE, i, + blksz, size, &blk); + if (ret) + return ret; + + ret = blk_probe_or_unbind(blk); + if (ret) + return ret; + + /* fill in device vendor/product/rev strings */ + desc = dev_get_uclass_plat(blk); + 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); + + ret = bootdev_setup_for_dev(udev, "ide_bootdev"); + if (ret) + return log_msg_ret("bootdev", ret); } return 0; From patchwork Mon Mar 27 19:07:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761945 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=ejY/7O82; 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 4PljW31cvDz1yXv for ; Tue, 28 Mar 2023 06:27:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3AD9A85727; Mon, 27 Mar 2023 21:27:01 +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="ejY/7O82"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5AB0185782; Mon, 27 Mar 2023 21:26:55 +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-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) (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 36BC586143 for ; Mon, 27 Mar 2023 21:10:06 +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-x632.google.com with SMTP id f22so5279989plr.0 for ; Mon, 27 Mar 2023 12:10:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944202; 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=zzM0plFM0t4R2yA/TKcJOtDjfK4nECJBmXJ4htupImw=; b=ejY/7O82E3ggPAfGikWY79oFNhA+ytx+jB/rVWGdgX9cEeQZOaiSzdX4qtYrtAzGYh hvZ8tVazQ4VuYwONoJO6hr5gdZH2h+FNiK34QNe+CwvW9Us8n9AEyQeooylLjUNAgEB0 VpTNQsiPuiGYbivgM2g/ViHJONq2kd01CDTEI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944202; 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=zzM0plFM0t4R2yA/TKcJOtDjfK4nECJBmXJ4htupImw=; b=Kyxk6tmG7xAhnngz6F/LB3OEUMM/rzZJrIocZqAc/s4/s3TR0L+ZiBm/kq3UOJLzVB +JDBBnqOhC5rzOzc+Ite5dzV2WQjhSZ4g5Q5+76Qg8eOaio3h4XrNdcsFznlQYavH4mV nLhXU1VTaM94UTubUZSYD877yUWv6kaVVG9gqTPHldPOEu4/vkKMm/uZoQP8ESZ9rGej yE6cvaboBJ2UeGV3FlxkbnUUfrWW7fQWXRD18oido8CY+k8aJLdJWR7/theRslrriDKz 78A7TD8blGWl44cZKaF/i1zTWoUSFCe+DSbYXvGctLwZpLVb1nzdg9NQsE5kp55DHDi1 SLNQ== X-Gm-Message-State: AO0yUKWWOYWGFIdF9bTGWlAIMf81XR7922pqB96cz2obWm7md/H2pHSi ih1hfBH4nYmZXVCBZlxmkmvvJ2vUfTdd7ZMUbDM= X-Google-Smtp-Source: AK7set/yRUH37NnNByr8yhEAUOrj283PNlVvxxA7X/31yWBBFLIo9XZiJh3MxW6qmDXDgXbBjMawLQ== X-Received: by 2002:a05:6a20:a82a:b0:cc:5f8f:4f7a with SMTP id cb42-20020a056a20a82a00b000cc5f8f4f7amr11216999pzb.27.1679944202539; Mon, 27 Mar 2023 12:10:02 -0700 (PDT) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id d9-20020aa78e49000000b005cd81a74821sm15653334pfr.152.2023.03.27.12.10.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:10:02 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 24/30] ide: Move all blk_desc init into ide_ident() Date: Tue, 28 Mar 2023 08:07:11 +1300 Message-Id: <20230328080702.24.I5d0c7475d7dd4cf685b2718db15a3944f2b4d40b@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 Rather than having the caller fill some of this in, do it all in the ide_ident() function, since it knows all the values. Signed-off-by: Simon Glass --- drivers/block/ide.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 16b119ecbe10..b1c897d6a41b 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -548,13 +548,16 @@ static int ide_ident(int device, struct blk_desc *desc) bool is_atapi = false; int tries = 1; + memset(desc, '\0', sizeof(*desc)); desc->devnum = device; + desc->type = DEV_TYPE_UNKNOWN; + desc->uclass_id = UCLASS_IDE; + desc->log2blksz = LOG2_INVALID(typeof(desc->log2blksz)); printf(" Device %d: ", device); /* Select device */ ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device)); - desc->uclass_id = UCLASS_IDE; if (IS_ENABLED(CONFIG_ATAPI)) tries = 2; @@ -1035,13 +1038,6 @@ static int ide_probe(struct udevice *udev) if (!bus_ok[IDE_BUS(i)]) continue; - ide_dev_desc[i].type = DEV_TYPE_UNKNOWN; - ide_dev_desc[i].uclass_id = UCLASS_IDE; - ide_dev_desc[i].part_type = PART_TYPE_UNKNOWN; - ide_dev_desc[i].blksz = 0; - ide_dev_desc[i].log2blksz = - LOG2_INVALID(typeof(ide_dev_desc[i].log2blksz)); - ide_dev_desc[i].lba = 0; ret = ide_ident(i, &ide_dev_desc[i]); dev_print(&ide_dev_desc[i]); From patchwork Mon Mar 27 19:07:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761944 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=lNQ2uA0S; 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 4PljVp0rWWz1yXv for ; Tue, 28 Mar 2023 06:26:58 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C365485C14; Mon, 27 Mar 2023 21:26:51 +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="lNQ2uA0S"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 61766860ED; Mon, 27 Mar 2023 21:26:50 +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-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) (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 3C1188612E for ; Mon, 27 Mar 2023 21:10:08 +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-pj1-x102c.google.com with SMTP id j13so8648961pjd.1 for ; Mon, 27 Mar 2023 12:10:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944205; 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=lzuJMm6weO/BpPzsEFUZBwctvkqAHqJrMjQfaHWiksg=; b=lNQ2uA0SaKWAOIDRE2X2M2XSeuJF2/b0PdzjZpXL8Cq5h4wMEokfMCnXdz+8N1LOwG d9YuHhJ7hsb74KyxEl8XeuwVuF1qnyJSwI31rLFnNMoAmw9hebvn/xXawAYkaMMpTpQd PwlD4rs3/gK+V9Ul75cLxxyz5fgbXf1Dg+dYI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944205; 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=lzuJMm6weO/BpPzsEFUZBwctvkqAHqJrMjQfaHWiksg=; b=rP04zJwDHk596sw1n+HST+O5B+bKO2xzkDXIXkqI51Xv47x0P8p3StAZbR2DMcqkOZ tv35gXiX41mxZRG3tRUbtmmRhC6lCfrlEqafGrF2/CVFmw26FgSTQE7EOfT9kVqKiOzR dLvE0biv4nBL9EcKzTyKbbE6WudSVL+G42WLplomeXYHELTMbf+pP6Zo2aNYBbyN8D68 G8+aajHF8oZqYWB2FZlefYxuGSBx6abDQ2H+JTGNDmfev1WxYa+vlf0q8D3cZ7hhzXFl UlVduVuMqeZwdrpWEIptvEb7Sqkc6XHj9xqDp0bputJfVHKJCvi7YZ4jdRIu27dmXsFU 0G9A== X-Gm-Message-State: AO0yUKW12cxMfo72Q1mfe3QeGK1bpgcRo2sznV3hpcKjsBlDhSYVum3Q zmpTcKIgh+Zpb60rI4S6vhmKzq13S14bo9aUb78= X-Google-Smtp-Source: AK7set8tk3ylrqhosu8mAC2ZqYSm0Jm04xNzi5oKg55nsoUfnHhsP36Fa3uc4nVqVgc3UYQOtceR2Q== X-Received: by 2002:a05:6a20:7a29:b0:db:d8f4:af91 with SMTP id t41-20020a056a207a2900b000dbd8f4af91mr11742855pzh.33.1679944205494; Mon, 27 Mar 2023 12:10:05 -0700 (PDT) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id d9-20020aa78e49000000b005cd81a74821sm15653334pfr.152.2023.03.27.12.10.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:10:05 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 25/30] ide: Use a single local blk_desc for ide_ident() Date: Tue, 28 Mar 2023 08:07:12 +1300 Message-Id: <20230328080702.25.I1b925510f46bd57ad33fde63531c4ef9b78eb0f1@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 We only use one member of the ide_dev_desc[] array at a time and it does not stick around outside ide_probe(). Use a single element instead. Copy over the missing members of blk_desc at the same, since this was missing from the previous code. Signed-off-by: Simon Glass Fixes: 68e6f221ed0 ("block: ide: Fix block read/write with driver model") --- drivers/block/ide.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index b1c897d6a41b..4c2a6a8e5309 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -1005,7 +1005,6 @@ BOOTDEV_HUNTER(ide_bootdev_hunter) = { static int ide_probe(struct udevice *udev) { - struct blk_desc ide_dev_desc[CONFIG_SYS_IDE_MAXDEVICE]; bool bus_ok[CONFIG_SYS_IDE_MAXBUS]; int i, bus; @@ -1028,7 +1027,7 @@ static int ide_probe(struct udevice *udev) schedule(); for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; i++) { - struct blk_desc *desc; + struct blk_desc *desc, pdesc; struct udevice *blk; lbaint_t size; char name[20]; @@ -1038,16 +1037,16 @@ static int ide_probe(struct udevice *udev) if (!bus_ok[IDE_BUS(i)]) continue; - ret = ide_ident(i, &ide_dev_desc[i]); - dev_print(&ide_dev_desc[i]); + ret = ide_ident(i, &pdesc); + dev_print(&pdesc); if (ret) continue; sprintf(name, "blk#%d", i); - blksz = ide_dev_desc[i].blksz; - size = blksz * ide_dev_desc[i].lba; + blksz = pdesc.blksz; + size = blksz * pdesc.lba; /* * With CDROM, if there is no CD inserted, blksz will @@ -1066,12 +1065,13 @@ static int ide_probe(struct udevice *udev) /* fill in device vendor/product/rev strings */ desc = dev_get_uclass_plat(blk); - 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); + strlcpy(desc->vendor, pdesc.vendor, BLK_VEN_SIZE); + strlcpy(desc->product, pdesc.product, BLK_PRD_SIZE); + strlcpy(desc->revision, pdesc.revision, BLK_REV_SIZE); + desc->removable = pdesc.removable; + desc->atapi = pdesc.atapi; + desc->lba48 = pdesc.lba48; + desc->type = pdesc.type; ret = bootdev_setup_for_dev(udev, "ide_bootdev"); if (ret) From patchwork Mon Mar 27 19:07:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761932 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=85.214.62.61; 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=NOIb7aVD; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4PljDV13vLz1yXv for ; Tue, 28 Mar 2023 06:14:34 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DC2BB8617F; Mon, 27 Mar 2023 21:11:51 +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="NOIb7aVD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 008FC86119; Mon, 27 Mar 2023 21:10:27 +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-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) (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 5C56185AEC for ; Mon, 27 Mar 2023 21:10:10 +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-pj1-x102f.google.com with SMTP id o6-20020a17090a9f8600b0023f32869993so12816724pjp.1 for ; Mon, 27 Mar 2023 12:10:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944208; 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=AoBJ28QbP7QpDgqhI0GyzxF8MttgBLSPBevuTG9mAzk=; b=NOIb7aVDXLyRtJTRdQyeVFx3oE5qgHAKrdnKCBBq+cN6jFZ5Zkg7bV+RWlDxlCbwad 2z+92YqoMXNaznkIov+UYw3okbxlxUu3vOb2Fag252Wvi+0HCoAUYdRmbqiTY7LY1l3Q 5FeoYeMOIRbmyQwKUvc+hdQs8r+/r8505gJhQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944208; 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=AoBJ28QbP7QpDgqhI0GyzxF8MttgBLSPBevuTG9mAzk=; b=jHuiSbqezoqlUupuYFgbnw09c2cRICH3cCKT2U1fLxMf1etAqL21kvXsMM6Snwd93w ZBc70ur8awRroJHZGQN1ED17K4BykRKtI4MMNOyTEO3HFPLe8I9S0YQrK8lrxiBVpQZY kNtcS1I+wvCyw58afMiuRI0+T/ygMq8I9pvvQBiRPi+IUPHP03qc9bYe8ikW8MdnsMRi OwI9BKpxdV2om5v7oCQi9vDpMuwGxR+byxEVggEr0p0T/hYrds9p2gCfvBZ13HurWYF/ Q6LfVaLLa2P5oZydPpSyuthHeOQWLx3GdFMFssO2IvH+KcBx2KTQiP/8Cp6W1mOuGrE9 sU2g== X-Gm-Message-State: AO0yUKUUB8uwUt0iqETFYg1TlKXDuKwXxGaSRPDkh5bDehJ3JCt1Hd0c SgdV/gKdamuB9RRPF6l0ocoIJjn1WkwOCXXKHUs= X-Google-Smtp-Source: AK7set+V3qYp2rx9KcE9hwgb30qHY97qFDq+RO6qcNp5RKeRn9B6f38Y9amGBBc9eHvDZKsyGkNAmw== X-Received: by 2002:a05:6a20:3f0c:b0:db:4c00:7918 with SMTP id az12-20020a056a203f0c00b000db4c007918mr10928538pzb.0.1679944208430; Mon, 27 Mar 2023 12:10:08 -0700 (PDT) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id d9-20020aa78e49000000b005cd81a74821sm15653334pfr.152.2023.03.27.12.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:10:08 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 26/30] ide: Correct LBA setting Date: Tue, 28 Mar 2023 08:07:13 +1300 Message-Id: <20230328080702.26.I5c93e458e2f7205b69ffef473ac7154a675fc9bd@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 Fix a longstanding bug where the LBA is calculated as the size of the media instead of the number of blocks. This was perhaps not noticed earlier since it prints the correct value first, before setting the wrong value. Drop the unnecessary blksz variable while we are here. Signed-off-by: Simon Glass Fixes: 68e6f221ed0 ("block: ide: Fix block read/write with driver model") --- drivers/block/ide.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 4c2a6a8e5309..72216540d040 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -1029,9 +1029,7 @@ static int ide_probe(struct udevice *udev) for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; i++) { struct blk_desc *desc, pdesc; struct udevice *blk; - lbaint_t size; char name[20]; - int blksz; int ret; if (!bus_ok[IDE_BUS(i)]) @@ -1045,17 +1043,14 @@ static int ide_probe(struct udevice *udev) sprintf(name, "blk#%d", i); - blksz = pdesc.blksz; - size = blksz * pdesc.lba; - /* * With CDROM, if there is no CD inserted, blksz will * be zero, don't bother to create IDE block device. */ - if (!blksz) + if (!pdesc.blksz) continue; ret = blk_create_devicef(udev, "ide_blk", name, UCLASS_IDE, i, - blksz, size, &blk); + pdesc.blksz, pdesc.lba, &blk); if (ret) return ret; From patchwork Mon Mar 27 19:07:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761938 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=85.214.62.61; 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=ion/uMul; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4PljHT3FFTz1yYb for ; Tue, 28 Mar 2023 06:17:09 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4FA7686168; Mon, 27 Mar 2023 21:17:06 +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="ion/uMul"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 71F3E86113; Mon, 27 Mar 2023 21:16:57 +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-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) (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 1B2EA86145 for ; Mon, 27 Mar 2023 21:10:14 +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-pj1-x102f.google.com with SMTP id h12-20020a17090aea8c00b0023d1311fab3so10020246pjz.1 for ; Mon, 27 Mar 2023 12:10:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944211; 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=tV4eNbjdHWpdZteGaJqb2ONafY7JK2RpeFE/7wPF8A4=; b=ion/uMuluatks88jaPORzBiLc66xnWG1JpC6reUh+h4eTrfEAlrNDHgCC3eNYaMEKl Ukmg6oG8gG7ep8R2vQbL0Mk/2QHp4Ve9Q+0z1LraqCZqTD5ljenf99kQUAT4sJKKlRAo s5s0yUU1CmvcClvt1tYdeHldqH4xlSEATYXoo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944211; 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=tV4eNbjdHWpdZteGaJqb2ONafY7JK2RpeFE/7wPF8A4=; b=m7H59YaK/2swy82dlgvzH5LhYNvH6PFJbzps2ncZ80Bt1qgjCcBKKH3VHEqk9l97tu K+a2iD7pJo6lR25k82eRDS9ygBg+c10zshtWxogJ/8U6wE2M+2T0kgnct9MfpVr5pKqS CoKOHu8MNaK2owXqbip27Q2pQWsC/xlzN6/HRsOt/9l1DtrAc+zgqzhpX6Ze9ovo9onE 2mHoGwaNwxVHDL1sT3540vhpUrmXet57qvSPGsXKfrVxLE3mD4O35Iivohh8AGvmeSpO BALEXp0RhAjyadJiOmp/AoRjqNxbaj2J5n01/2jmdAZXSvvFWETwbq+H9Syy2ZxZCL1h anjA== X-Gm-Message-State: AO0yUKX6NmBHGvEoCWZmU2DydfrqgTFZEWZRLDGGp0+A4uIJbPHVDGtI Pzhe372WZfvWFeNFHbz6jBk2aMQj68T5RwCWfRk= X-Google-Smtp-Source: AK7set8KTT0cVKI6AVGRQ3POcXqsIfkaZOuN6IGTp2eU6a7Tc+sLUop1bpCbWLhqVgZvwkKQ4iOybg== X-Received: by 2002:a05:6a20:8089:b0:d6:b1b5:9917 with SMTP id c9-20020a056a20808900b000d6b1b59917mr10796859pza.57.1679944211466; Mon, 27 Mar 2023 12:10:11 -0700 (PDT) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id d9-20020aa78e49000000b005cd81a74821sm15653334pfr.152.2023.03.27.12.10.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:10:11 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 27/30] ide: Tidy up ide_reset() Date: Tue, 28 Mar 2023 08:07:14 +1300 Message-Id: <20230328080702.27.I8b48a2c1e95c41b3ed1d864645e097ec2857645a@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 Avoid using #ifdef and use a single function declaration, so it is easier to read. Signed-off-by: Simon Glass --- drivers/block/ide.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 72216540d040..fb409338783c 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -45,24 +45,23 @@ ulong ide_bus_offset[CONFIG_SYS_IDE_MAXBUS] = { #define IDE_SPIN_UP_TIME_OUT 5000 /* 5 sec spin-up timeout */ -#ifdef CONFIG_IDE_RESET static void ide_reset(void) { - ide_set_reset(1); /* assert reset */ + if (IS_ENABLED(CONFIG_IDE_RESET)) { + /* assert reset */ + ide_set_reset(1); - /* the reset signal shall be asserted for et least 25 us */ - udelay(25); + /* the reset signal shall be asserted for et least 25 us */ + udelay(25); - schedule(); + schedule(); - /* de-assert RESET signal */ - ide_set_reset(0); + /* de-assert RESET signal */ + ide_set_reset(0); - mdelay(250); + mdelay(250); + } } -#else -#define ide_reset() /* dummy */ -#endif /* CONFIG_IDE_RESET */ static void ide_outb(int dev, int port, unsigned char val) { From patchwork Mon Mar 27 19:07:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761939 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=RYHsdcBq; 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 4PljHk6jHMz1yYb for ; Tue, 28 Mar 2023 06:17:22 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 239E1860ED; Mon, 27 Mar 2023 21:17:15 +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="RYHsdcBq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3305F8611E; Mon, 27 Mar 2023 21:17:01 +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-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) (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 960D48614E for ; Mon, 27 Mar 2023 21:10:16 +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-pg1-x536.google.com with SMTP id q206so5782895pgq.9 for ; Mon, 27 Mar 2023 12:10:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944214; 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=WJNRtP7pObVgDoDqjDsk9j02F3blClvwRMlAFm78XD4=; b=RYHsdcBqLd8/xeU/66vAVi2M05aHdTkk73QDtvmj+OoXqDDx9Od0yIP2cpAtC52nZn 1qlW2bfUaUxexVuBjsj4+kxwE7EeGYy/FtHUCVRyhkK/hf6OlRfSr2zPqJV+uQq0tNbW yK5B2PbV19ebuhJwJGaL17rGTXGpCqRr8T2kU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944214; 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=WJNRtP7pObVgDoDqjDsk9j02F3blClvwRMlAFm78XD4=; b=e9V70WsFS7vEQ044Zexqeamu1LTTlDUDxvPVtac8Qu7FuRuoeXw9yEbpfOODMAl4Wm uBRuaHDYknxa6JgVarqXgO0zcXR+yQV5dxgXFSwbrRNsYksqtEaso0b8vvQcomo4xCOq aCBLrNe8nko+oLRflE7kQJjnvGPnrA8IGHIE2/4B6A9iYMvZwEK4UTcTYLH46Azg/vcz lkwQ9gE/ngcEq2hru7Klda+7y3+Hg+1WlxBwBb6qi8lec7Fu26cPaqgefHHvH8nVBqAL tFtnuxtqyGcdG55ERJIWQEyBvpD3oLWcdAk2ErYwZPzky4A2ksnMmpuwtQT9ndkdijQR r2AQ== X-Gm-Message-State: AAQBX9dDXLGyUQWwZX8Q3rX8wFRQ71GHUuJ6E4RYsbjbjBgtMy+tWYU9 3/wNxZNesplqtEDJFgeb7XY3CYFZ/WQcOZnPsl0= X-Google-Smtp-Source: AKy350byucmeRIhrTy/hTCSBC9bPOVpIfsATDAEZWZX8th2mqkiClOz4dOMBRHMoQZHbH3I8q9nVIg== X-Received: by 2002:aa7:942e:0:b0:62a:c1fa:b253 with SMTP id y14-20020aa7942e000000b0062ac1fab253mr12654155pfo.31.1679944214386; Mon, 27 Mar 2023 12:10:14 -0700 (PDT) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id d9-20020aa78e49000000b005cd81a74821sm15653334pfr.152.2023.03.27.12.10.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:10:14 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 28/30] ide: Convert to use log_debug() Date: Tue, 28 Mar 2023 08:07:15 +1300 Message-Id: <20230328080702.28.I75da219973c04b92905469bcd0b20b7fdb4fc923@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 Avoid the use of the function name in a few of the debug() calls, since this causes a checkpatch warning. Convert all other calls too. Use lower-case hex consistently. Signed-off-by: Simon Glass --- drivers/block/ide.c | 80 ++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index fb409338783c..37236f6058b4 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -65,8 +65,8 @@ static void ide_reset(void) static void ide_outb(int dev, int port, unsigned char val) { - debug("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n", - dev, port, val, ATA_CURR_BASE(dev) + port); + log_debug("(dev= %d, port= %#x, val= 0x%02x) : @ 0x%08lx\n", + dev, port, val, ATA_CURR_BASE(dev) + port); outb(val, ATA_CURR_BASE(dev) + port); } @@ -77,8 +77,8 @@ static unsigned char ide_inb(int dev, int port) val = inb(ATA_CURR_BASE(dev) + port); - debug("ide_inb (dev= %d, port= 0x%x) : @ 0x%08lx -> 0x%02x\n", - dev, port, ATA_CURR_BASE(dev) + port, val); + log_debug("(dev= %d, port= %#x) : @ 0x%08lx -> 0x%02x\n", + dev, port, ATA_CURR_BASE(dev) + port, val); return val; } @@ -87,7 +87,7 @@ static void ide_input_swap_data(int dev, ulong *sect_buf, int words) uintptr_t paddr = (ATA_CURR_BASE(dev) + ATA_DATA_REG); ushort *dbuf = (ushort *)sect_buf; - debug("in input swap data base for read is %p\n", (void *)paddr); + log_debug("in input swap data base for read is %p\n", (void *)paddr); while (words--) { EIEIO; @@ -158,7 +158,7 @@ static void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts) dbuf = (ushort *)sect_buf; - debug("in output data shorts base for read is %p\n", (void *)paddr); + log_debug("in output data shorts base for read is %p\n", (void *)paddr); while (shorts--) { EIEIO; @@ -173,7 +173,7 @@ static void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts) dbuf = (ushort *)sect_buf; - debug("in input data shorts base for read is %p\n", (void *)paddr); + log_debug("in input data shorts base for read is %p\n", (void *)paddr); while (shorts--) { EIEIO; @@ -222,7 +222,7 @@ static unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen, ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device)); c = atapi_wait_mask(device, ATAPI_TIME_OUT, mask, res); if ((c & mask) != res) { - printf("ATAPI_ISSUE: device %d not ready status %X\n", device, + printf("ATAPI_ISSUE: device %d not ready status %x\n", device, c); err = 0xFF; goto AI_OUT; @@ -268,8 +268,8 @@ static unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen, if ((c & mask) != res) { if (c & ATA_STAT_ERR) { err = (ide_inb(device, ATA_ERROR_REG)) >> 4; - debug("atapi_issue 1 returned sense key %X status %02X\n", - err, c); + log_debug("1 returned sense key %x status %02x\n", + err, c); } else { printf("ATAPI_ISSUE: (no DRQ) after sending ccb (%x) status 0x%02x\n", ccb[0], c); @@ -292,20 +292,21 @@ static unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen, goto AI_OUT; } if (n != buflen) { - debug("WARNING, transfer bytes %d not equal with requested %d\n", - n, buflen); + log_debug("WARNING, transfer bytes %d not equal with requested %d\n", + n, buflen); } if (n != 0) { /* data transfer */ - debug("ATAPI_ISSUE: %d Bytes to transfer\n", n); + log_debug("ATAPI_ISSUE: %d Bytes to transfer\n", n); /* we transfer shorts */ n >>= 1; /* ok now decide if it is an in or output */ if ((ide_inb(device, ATA_SECT_CNT) & 0x02) == 0) { - debug("Write to device\n"); + log_debug("Write to device\n"); ide_output_data_shorts(device, (unsigned short *)buffer, n); } else { - debug("Read from device @ %p shorts %d\n", buffer, n); + log_debug("Read from device @ %p shorts %d\n", buffer, + n); ide_input_data_shorts(device, (unsigned short *)buffer, n); } @@ -316,8 +317,7 @@ static unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen, c = atapi_wait_mask(device, ATAPI_TIME_OUT, mask, res); if ((c & ATA_STAT_ERR) == ATA_STAT_ERR) { err = (ide_inb(device, ATA_ERROR_REG) >> 4); - debug("atapi_issue 2 returned sense key %X status %X\n", err, - c); + log_debug("2 returned sense key %x status %x\n", err, c); } else { err = 0; } @@ -352,7 +352,7 @@ retry: if (res == 0xFF) return 0xFF; /* error */ - debug("(auto_req)atapi_issue returned sense key %X\n", res); + log_debug("(auto_req)atapi_issue returned sense key %x\n", res); memset(sense_ccb, 0, sizeof(sense_ccb)); memset(sense_data, 0, sizeof(sense_data)); @@ -364,9 +364,9 @@ retry: asc = (sense_data[12]); ascq = (sense_data[13]); - debug("ATAPI_CMD_REQ_SENSE returned %x\n", res); - debug(" Sense page: %02X key %02X ASC %02X ASCQ %02X\n", - sense_data[0], key, asc, ascq); + log_debug("ATAPI_CMD_REQ_SENSE returned %x\n", res); + log_debug(" Sense page: %02X key %02X ASC %02X ASCQ %02X\n", + sense_data[0], key, asc, ascq); if ((key == 0)) return 0; /* ok device ready */ @@ -390,14 +390,14 @@ retry: goto error; } if (asc == 0x3a) { - debug("Media not present\n"); + log_debug("Media not present\n"); goto error; } printf("ERROR: Unknown Sense key %02X ASC %02X ASCQ %02X\n", key, asc, ascq); error: - debug("ERROR Sense key %02X ASC %02X ASCQ %02X\n", key, asc, ascq); + log_debug("ERROR Sense key %02X ASC %02X ASCQ %02X\n", key, asc, ascq); return 0xFF; } @@ -419,8 +419,8 @@ static ulong atapi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, unsigned char ccb[12]; /* Command descriptor block */ ulong cnt; - debug("atapi_read dev %d start " LBAF " blocks " LBAF - " buffer at %lX\n", device, blknr, blkcnt, (ulong) buffer); + log_debug("%d start " LBAF " blocks " LBAF " buffer at %lx\n", device, + blknr, blkcnt, (ulong)buffer); do { if (blkcnt > ATAPI_READ_MAX_BLOCK) @@ -472,7 +472,7 @@ static void atapi_inquiry(struct blk_desc *desc) ccb[4] = 40; /* allocation Legnth */ c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *)iobuf, 40); - debug("ATAPI_CMD_INQUIRY returned %x\n", c); + log_debug("ATAPI_CMD_INQUIRY returned %x\n", c); if (c != 0) return; @@ -499,7 +499,7 @@ static void atapi_inquiry(struct blk_desc *desc) c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *)iobuf, 0); - debug("ATAPI_CMD_START_STOP returned %x\n", c); + log_debug("ATAPI_CMD_START_STOP returned %x\n", c); if (c != 0) return; @@ -507,7 +507,7 @@ static void atapi_inquiry(struct blk_desc *desc) memset(iobuf, 0, sizeof(iobuf)); c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *)iobuf, 0); - debug("ATAPI_CMD_UNIT_TEST_READY returned %x\n", c); + log_debug("ATAPI_CMD_UNIT_TEST_READY returned %x\n", c); if (c != 0) return; @@ -515,13 +515,13 @@ static void atapi_inquiry(struct blk_desc *desc) memset(iobuf, 0, sizeof(iobuf)); ccb[0] = ATAPI_CMD_READ_CAP; c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *)iobuf, 8); - debug("ATAPI_CMD_READ_CAP returned %x\n", c); + log_debug("ATAPI_CMD_READ_CAP returned %x\n", c); if (c != 0) return; - debug("Read Cap: LBA %02X%02X%02X%02X blksize %02X%02X%02X%02X\n", - iobuf[0], iobuf[1], iobuf[2], iobuf[3], - iobuf[4], iobuf[5], iobuf[6], iobuf[7]); + log_debug("Read Cap: LBA %02X%02X%02X%02X blksize %02X%02X%02X%02X\n", + iobuf[0], iobuf[1], iobuf[2], iobuf[3], + iobuf[4], iobuf[5], iobuf[6], iobuf[7]); desc->lba = (ulong)iobuf[0] << 24 | (ulong)iobuf[1] << 16 | (ulong)iobuf[2] << 8 | (ulong)iobuf[3]; @@ -598,7 +598,7 @@ static int ide_ident(int device, struct blk_desc *desc) * Need to soft reset the device * in case it's an ATAPI... */ - debug("Retrying...\n"); + log_debug("Retrying...\n"); ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device)); mdelay(100); @@ -707,12 +707,12 @@ static int ide_init_one(int bus) if (c & (ATA_STAT_BUSY | ATA_STAT_FAULT)) { puts("not available "); - debug("Status = 0x%02X ", c); + log_debug("Status = 0x%02X ", c); return -EIO; } else if (IS_ENABLED(CONFIG_ATAPI) && !(c & ATA_STAT_READY)) { /* ATAPI Devices do not set DRDY */ puts("not available "); - debug("Status = 0x%02X ", c); + log_debug("Status = 0x%02X ", c); return -EIO; } puts("OK "); @@ -741,7 +741,7 @@ static void ide_input_data(int dev, ulong *sect_buf, int words) dbuf = (ushort *)sect_buf; - debug("in input data base for read is %p\n", (void *)paddr); + log_debug("in input data base for read is %p\n", (void *)paddr); while (words--) { EIEIO; @@ -766,8 +766,8 @@ static ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, lba48 = true; } - debug("ide_read dev %d start " LBAF ", blocks " LBAF " buffer at %lX\n", - device, blknr, blkcnt, (ulong) buffer); + log_debug("dev %d start " LBAF ", blocks " LBAF " buffer at %lx\n", + device, blknr, blkcnt, (ulong)buffer); /* Select device */ @@ -791,10 +791,10 @@ static ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, goto IDE_READ_E; } if ((c & ATA_STAT_ERR) == ATA_STAT_ERR) { - printf("No Powersaving mode %X\n", c); + printf("No Powersaving mode %x\n", c); } else { c = ide_inb(device, ATA_SECT_CNT); - debug("Powersaving %02X\n", c); + log_debug("Powersaving %02X\n", c); if (c == 0) pwrsave = 1; } From patchwork Mon Mar 27 19:07:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761933 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=l5PDGhSz; 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 4PljDl2ll3z1yXv for ; Tue, 28 Mar 2023 06:14:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 532CD86190; Mon, 27 Mar 2023 21:11:54 +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="l5PDGhSz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0A69A86119; Mon, 27 Mar 2023 21:10:29 +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-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) (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 9AF4286158 for ; Mon, 27 Mar 2023 21:10:19 +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-pf1-x431.google.com with SMTP id u20so6386806pfk.12 for ; Mon, 27 Mar 2023 12:10:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944218; 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=zciE5qBajOrdY25X+wpVPzvDVw47/6gQVJxHEdnnM44=; b=l5PDGhSz/S989k1IU7l6B3WIE1fD/b0V94aJTTnqUfBVczrV4WoV1xImzd9yU7qb/W +u+EgCtO/wKQ/R46PsdyXNQZnSxAi00DRhdakt0T23HvpV4BkGI9mQ3eUAmNZbwuMs1r XbNp0BgkAAaKgLlvR9dOWaHa+YyozlSzMe98o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944218; 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=zciE5qBajOrdY25X+wpVPzvDVw47/6gQVJxHEdnnM44=; b=ctzo9QO4RciZSAoh3AN/nilriO6uNnxiptERvCfRDTCtDwHPNIlc4gwIjRDTchM+ap YWA3LsfdbQU2jjCXn/MnUQPVjOF+gBIJ7BHyp7yDb4xniwAmsQCNlYSkbiGhB3XBgy+B RzVRUqj+Kx16UIvlLzdq/5ezrO6SIT9/LOx/oeeqMK1bpW8W0YoSq6HT0Edc8RTRzZQT 4MXtGySO1XKUal9tyTk9j+Gtb1GGqGadkgcoxDwmfr0P96S1HAku4Bty2Z7b/dUjEgDw CZy6yPItpeaqaomfI3KmG3YZ0rl/zCh+bcCyJ3n62kZr0A2F12SF2Lyp8zQA/UO+gQpA p9fg== X-Gm-Message-State: AAQBX9d2/oc4VnGLSY85jQxJ7WruEcHRgsIFvEAELK3w+EwjjJwlOktC jSJn9c46oqcG3j2WhViCraODYeMDkDbo/FSZPvQ= X-Google-Smtp-Source: AKy350bZsjJui0fgLScchqQ8+bfDauWLtSlAJu7GccVeoEX635GTD11ppcSgIjEq7RpFF01G84azpA== X-Received: by 2002:a62:3855:0:b0:627:e6a2:a85b with SMTP id f82-20020a623855000000b00627e6a2a85bmr11708174pfa.2.1679944217640; Mon, 27 Mar 2023 12:10:17 -0700 (PDT) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id d9-20020aa78e49000000b005cd81a74821sm15653334pfr.152.2023.03.27.12.10.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:10:17 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 29/30] ide: Simplify expressions and hex values Date: Tue, 28 Mar 2023 08:07:16 +1300 Message-Id: <20230328080702.29.I2918ee19878bc28af26f5d6bc0d413c8c0470f8a@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 code has quite a few unnecessary brackets and comparisons to zero, etc. Fix these up as well as some upper-case hex values and use of 0x in printf() strings. Signed-off-by: Simon Glass --- drivers/block/ide.c | 115 +++++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 59 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index 37236f6058b4..af0c951eb890 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -108,7 +108,7 @@ static uchar ide_wait(int dev, ulong t) while ((c = ide_inb(dev, ATA_STATUS)) & ATA_STAT_BUSY) { udelay(100); - if (delay-- == 0) + if (!delay--) break; } return c; @@ -153,7 +153,7 @@ OUT: * we have our own transfer functions, 2 bytes alligned */ static void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts) { - uintptr_t paddr = (ATA_CURR_BASE(dev) + ATA_DATA_REG); + uintptr_t paddr = ATA_CURR_BASE(dev) + ATA_DATA_REG; ushort *dbuf; dbuf = (ushort *)sect_buf; @@ -168,7 +168,7 @@ static void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts) static void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts) { - uintptr_t paddr = (ATA_CURR_BASE(dev) + ATA_DATA_REG); + uintptr_t paddr = ATA_CURR_BASE(dev) + ATA_DATA_REG; ushort *dbuf; dbuf = (ushort *)sect_buf; @@ -195,12 +195,12 @@ static uchar atapi_wait_mask(int dev, ulong t, uchar mask, uchar res) /* prevents to read the status before valid */ c = ide_inb(dev, ATA_DEV_CTL); - while (((c = ide_inb(dev, ATA_STATUS)) & mask) != res) { + while (c = ide_inb(dev, ATA_STATUS) & mask, c != res) { /* break if error occurs (doesn't make sense to wait more) */ if ((c & ATA_STAT_ERR) == ATA_STAT_ERR) break; udelay(100); - if (delay-- == 0) + if (!delay--) break; } return c; @@ -224,16 +224,15 @@ static unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen, if ((c & mask) != res) { printf("ATAPI_ISSUE: device %d not ready status %x\n", device, c); - err = 0xFF; + err = 0xff; goto AI_OUT; } /* write taskfile */ ide_outb(device, ATA_ERROR_REG, 0); /* no DMA, no overlaped */ ide_outb(device, ATA_SECT_CNT, 0); ide_outb(device, ATA_SECT_NUM, 0); - ide_outb(device, ATA_CYL_LOW, (unsigned char) (buflen & 0xFF)); - ide_outb(device, ATA_CYL_HIGH, - (unsigned char) ((buflen >> 8) & 0xFF)); + ide_outb(device, ATA_CYL_LOW, (unsigned char)(buflen & 0xff)); + ide_outb(device, ATA_CYL_HIGH, (unsigned char)((buflen >> 8) & 0xff)); ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device)); ide_outb(device, ATA_COMMAND, ATA_CMD_PACKET); @@ -244,9 +243,9 @@ static unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen, c = atapi_wait_mask(device, ATAPI_TIME_OUT, mask, res); if ((c & mask) != res) { /* DRQ must be 1, BSY 0 */ - printf("ATAPI_ISSUE: Error (no IRQ) before sending ccb dev %d status 0x%02x\n", + printf("ATAPI_ISSUE: Error (no IRQ) before sending ccb dev %d status %#02x\n", device, c); - err = 0xFF; + err = 0xff; goto AI_OUT; } @@ -271,9 +270,9 @@ static unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen, log_debug("1 returned sense key %x status %02x\n", err, c); } else { - printf("ATAPI_ISSUE: (no DRQ) after sending ccb (%x) status 0x%02x\n", + printf("ATAPI_ISSUE: (no DRQ) after sending ccb (%x) status %#02x\n", ccb[0], c); - err = 0xFF; + err = 0xff; } goto AI_OUT; } @@ -286,7 +285,7 @@ static unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen, err = 0xff; goto AI_OUT; } - if ((n == 0) && (buflen < 0)) { + if (!n && buflen < 0) { printf("ERROR, transfer bytes %d requested %d\n", n, buflen); err = 0xff; goto AI_OUT; @@ -295,12 +294,12 @@ static unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen, log_debug("WARNING, transfer bytes %d not equal with requested %d\n", n, buflen); } - if (n != 0) { /* data transfer */ + if (n) { /* data transfer */ log_debug("ATAPI_ISSUE: %d Bytes to transfer\n", n); /* we transfer shorts */ n >>= 1; /* ok now decide if it is an in or output */ - if ((ide_inb(device, ATA_SECT_CNT) & 0x02) == 0) { + if (!(ide_inb(device, ATA_SECT_CNT) & 0x02)) { log_debug("Write to device\n"); ide_output_data_shorts(device, (unsigned short *)buffer, n); @@ -346,11 +345,11 @@ static unsigned char atapi_issue_autoreq(int device, unsigned char *ccb, retry: res = atapi_issue(device, ccb, ccblen, buffer, buflen); - if (res == 0) + if (!res) return 0; /* Ok */ - if (res == 0xFF) - return 0xFF; /* error */ + if (res == 0xff) + return 0xff; /* error */ log_debug("(auto_req)atapi_issue returned sense key %x\n", res); @@ -360,7 +359,7 @@ retry: sense_ccb[4] = 18; /* allocation Length */ res = atapi_issue(device, sense_ccb, 12, sense_data, 18); - key = (sense_data[2] & 0xF); + key = (sense_data[2] & 0xf); asc = (sense_data[12]); ascq = (sense_data[13]); @@ -368,10 +367,10 @@ retry: log_debug(" Sense page: %02X key %02X ASC %02X ASCQ %02X\n", sense_data[0], key, asc, ascq); - if ((key == 0)) + if (!key) return 0; /* ok device ready */ - if ((key == 6) || (asc == 0x29) || (asc == 0x28)) { /* Unit Attention */ + if (key == 6 || asc == 0x29 || asc == 0x28) { /* Unit Attention */ if (unitattn-- > 0) { mdelay(200); goto retry; @@ -379,7 +378,7 @@ retry: printf("Unit Attention, tried %d\n", ATAPI_UNIT_ATTN); goto error; } - if ((asc == 0x4) && (ascq == 0x1)) { + if (asc == 0x4 && ascq == 0x1) { /* not ready, but will be ready soon */ if (notready-- > 0) { mdelay(200); @@ -398,7 +397,7 @@ retry: ascq); error: log_debug("ERROR Sense key %02X ASC %02X ASCQ %02X\n", key, asc, ascq); - return 0xFF; + return 0xff; } /* @@ -430,27 +429,25 @@ static ulong atapi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, ccb[0] = ATAPI_CMD_READ_12; ccb[1] = 0; /* reserved */ - ccb[2] = (unsigned char) (blknr >> 24) & 0xFF; /* MSB Block */ - ccb[3] = (unsigned char) (blknr >> 16) & 0xFF; /* */ - ccb[4] = (unsigned char) (blknr >> 8) & 0xFF; - ccb[5] = (unsigned char) blknr & 0xFF; /* LSB Block */ - ccb[6] = (unsigned char) (cnt >> 24) & 0xFF; /* MSB Block cnt */ - ccb[7] = (unsigned char) (cnt >> 16) & 0xFF; - ccb[8] = (unsigned char) (cnt >> 8) & 0xFF; - ccb[9] = (unsigned char) cnt & 0xFF; /* LSB Block */ + ccb[2] = (unsigned char)(blknr >> 24) & 0xff; /* MSB Block */ + ccb[3] = (unsigned char)(blknr >> 16) & 0xff; /* */ + ccb[4] = (unsigned char)(blknr >> 8) & 0xff; + ccb[5] = (unsigned char)blknr & 0xff; /* LSB Block */ + ccb[6] = (unsigned char)(cnt >> 24) & 0xff; /* MSB Block cnt */ + ccb[7] = (unsigned char)(cnt >> 16) & 0xff; + ccb[8] = (unsigned char)(cnt >> 8) & 0xff; + ccb[9] = (unsigned char)cnt & 0xff; /* LSB Block */ ccb[10] = 0; /* reserved */ ccb[11] = 0; /* reserved */ if (atapi_issue_autoreq(device, ccb, 12, (unsigned char *)buffer, - cnt * ATAPI_READ_BLOCK_SIZE) - == 0xFF) { + cnt * ATAPI_READ_BLOCK_SIZE) == 0xff) return n; - } n += cnt; blkcnt -= cnt; blknr += cnt; - buffer += (cnt * ATAPI_READ_BLOCK_SIZE); + buffer += cnt * ATAPI_READ_BLOCK_SIZE; } while (blkcnt > 0); return n; } @@ -473,7 +470,7 @@ static void atapi_inquiry(struct blk_desc *desc) c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *)iobuf, 40); log_debug("ATAPI_CMD_INQUIRY returned %x\n", c); - if (c != 0) + if (c) return; /* copy device ident strings */ @@ -487,7 +484,7 @@ static void atapi_inquiry(struct blk_desc *desc) desc->log2blksz = LOG2_INVALID(typeof(desc->log2blksz)); desc->type = iobuf[0] & 0x1f; - if ((iobuf[1] & 0x80) == 0x80) + if (iobuf[1] & 0x80) desc->removable = 1; else desc->removable = 0; @@ -500,7 +497,7 @@ static void atapi_inquiry(struct blk_desc *desc) c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *)iobuf, 0); log_debug("ATAPI_CMD_START_STOP returned %x\n", c); - if (c != 0) + if (c) return; memset(ccb, 0, sizeof(ccb)); @@ -508,7 +505,7 @@ static void atapi_inquiry(struct blk_desc *desc) c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *)iobuf, 0); log_debug("ATAPI_CMD_UNIT_TEST_READY returned %x\n", c); - if (c != 0) + if (c) return; memset(ccb, 0, sizeof(ccb)); @@ -516,7 +513,7 @@ static void atapi_inquiry(struct blk_desc *desc) ccb[0] = ATAPI_CMD_READ_CAP; c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *)iobuf, 8); log_debug("ATAPI_CMD_READ_CAP returned %x\n", c); - if (c != 0) + if (c) return; log_debug("Read Cap: LBA %02X%02X%02X%02X blksize %02X%02X%02X%02X\n", @@ -620,7 +617,7 @@ static int ide_ident(int device, struct blk_desc *desc) ident_cpy((u8 *)desc->vendor, iop.model, sizeof(desc->vendor)); ident_cpy((u8 *)desc->product, iop.serial_no, sizeof(desc->product)); - if ((iop.config & 0x0080) == 0x0080) + if (iop.config & 0x0080) desc->removable = 1; else desc->removable = 0; @@ -707,12 +704,12 @@ static int ide_init_one(int bus) if (c & (ATA_STAT_BUSY | ATA_STAT_FAULT)) { puts("not available "); - log_debug("Status = 0x%02X ", c); + log_debug("Status = %#02X ", c); return -EIO; } else if (IS_ENABLED(CONFIG_ATAPI) && !(c & ATA_STAT_READY)) { /* ATAPI Devices do not set DRDY */ puts("not available "); - log_debug("Status = 0x%02X ", c); + log_debug("Status = %#02X ", c); return -EIO; } puts("OK "); @@ -795,7 +792,7 @@ static ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, } else { c = ide_inb(device, ATA_SECT_CNT); log_debug("Powersaving %02X\n", c); - if (c == 0) + if (!c) pwrsave = 1; } @@ -810,19 +807,19 @@ static ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, if (IS_ENABLED(CONFIG_LBA48) && lba48) { /* write high bits */ ide_outb(device, ATA_SECT_CNT, 0); - ide_outb(device, ATA_LBA_LOW, (blknr >> 24) & 0xFF); + ide_outb(device, ATA_LBA_LOW, (blknr >> 24) & 0xff); #ifdef CONFIG_SYS_64BIT_LBA - ide_outb(device, ATA_LBA_MID, (blknr >> 32) & 0xFF); - ide_outb(device, ATA_LBA_HIGH, (blknr >> 40) & 0xFF); + ide_outb(device, ATA_LBA_MID, (blknr >> 32) & 0xff); + ide_outb(device, ATA_LBA_HIGH, (blknr >> 40) & 0xff); #else ide_outb(device, ATA_LBA_MID, 0); ide_outb(device, ATA_LBA_HIGH, 0); #endif } ide_outb(device, ATA_SECT_CNT, 1); - ide_outb(device, ATA_LBA_LOW, (blknr >> 0) & 0xFF); - ide_outb(device, ATA_LBA_MID, (blknr >> 8) & 0xFF); - ide_outb(device, ATA_LBA_HIGH, (blknr >> 16) & 0xFF); + ide_outb(device, ATA_LBA_LOW, (blknr >> 0) & 0xff); + ide_outb(device, ATA_LBA_MID, (blknr >> 8) & 0xff); + ide_outb(device, ATA_LBA_HIGH, (blknr >> 16) & 0xff); if (IS_ENABLED(CONFIG_LBA48) && lba48) { ide_outb(device, ATA_DEV_HD, @@ -831,7 +828,7 @@ static ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, } else { ide_outb(device, ATA_DEV_HD, ATA_LBA | - ATA_DEVICE(device) | ((blknr >> 24) & 0xF)); + ATA_DEVICE(device) | ((blknr >> 24) & 0xf)); ide_outb(device, ATA_COMMAND, ATA_CMD_PIO_READ); } @@ -892,19 +889,19 @@ static ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, if (IS_ENABLED(CONFIG_LBA48) && lba48) { /* write high bits */ ide_outb(device, ATA_SECT_CNT, 0); - ide_outb(device, ATA_LBA_LOW, (blknr >> 24) & 0xFF); + ide_outb(device, ATA_LBA_LOW, (blknr >> 24) & 0xff); #ifdef CONFIG_SYS_64BIT_LBA - ide_outb(device, ATA_LBA_MID, (blknr >> 32) & 0xFF); - ide_outb(device, ATA_LBA_HIGH, (blknr >> 40) & 0xFF); + ide_outb(device, ATA_LBA_MID, (blknr >> 32) & 0xff); + ide_outb(device, ATA_LBA_HIGH, (blknr >> 40) & 0xff); #else ide_outb(device, ATA_LBA_MID, 0); ide_outb(device, ATA_LBA_HIGH, 0); #endif } ide_outb(device, ATA_SECT_CNT, 1); - ide_outb(device, ATA_LBA_LOW, (blknr >> 0) & 0xFF); - ide_outb(device, ATA_LBA_MID, (blknr >> 8) & 0xFF); - ide_outb(device, ATA_LBA_HIGH, (blknr >> 16) & 0xFF); + ide_outb(device, ATA_LBA_LOW, (blknr >> 0) & 0xff); + ide_outb(device, ATA_LBA_MID, (blknr >> 8) & 0xff); + ide_outb(device, ATA_LBA_HIGH, (blknr >> 16) & 0xff); if (IS_ENABLED(CONFIG_LBA48) && lba48) { ide_outb(device, ATA_DEV_HD, @@ -913,7 +910,7 @@ static ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, } else { ide_outb(device, ATA_DEV_HD, ATA_LBA | - ATA_DEVICE(device) | ((blknr >> 24) & 0xF)); + ATA_DEVICE(device) | ((blknr >> 24) & 0xf)); ide_outb(device, ATA_COMMAND, ATA_CMD_PIO_WRITE); } From patchwork Mon Mar 27 19:07:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1761934 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=85.214.62.61; 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=LA7kRCpH; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4PljFH29btz1yYb for ; Tue, 28 Mar 2023 06:15:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 83E0885BD0; Mon, 27 Mar 2023 21:12:42 +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="LA7kRCpH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C3F1986149; Mon, 27 Mar 2023 21:10:37 +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-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) (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 8174185CCA for ; Mon, 27 Mar 2023 21:10:22 +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-pj1-x1031.google.com with SMTP id mp3-20020a17090b190300b0023fcc8ce113so12799480pjb.4 for ; Mon, 27 Mar 2023 12:10:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679944220; 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=tKmOBDeJ6cMGdyZetQ/hZ8kizt/5fQ1uZvgOIWQfSvY=; b=LA7kRCpHKUnvOLEpMfqkfPYrNPuxEVVyoRUwIMFlLSFxTsfVxoMU50VqrAyZ921I+F PA3ZpgYS2dDBjvZbtoicrAOB+BkJiD9yC3rsvskTyy1onpTldViDX6Y5JejeaMC4tl/A 7uAF60REvSC/tQzV4kOIcLRtdd8QxEYa80zv4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679944220; 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=tKmOBDeJ6cMGdyZetQ/hZ8kizt/5fQ1uZvgOIWQfSvY=; b=2OF3DdOUQDG1JfHsW8NeHA5CWSiS9p84nIDllK8X8SVHwIk48yffFzYjeXK8OvccCa cK97Cy57zHC3eRAli6cy+tSInUbi9t83h4APzPJzsM3yeyZENAommqTZnC+gSQhzcfU5 vc6zhCdw2Z63FE2/6ikPKQk6UjFW66j0yqBuvakVYauDmtThdoDIYzmCGBPXuzbe49u/ YKAOkUXVByVoDUWEs8nXnTlOJf+0MmHB7I26MyYGrqdHUURSwXzGj/5g/u18CLnCJEm7 1ETT5MsRyi+XrBnG8e9XD4Q4Y9MPnLs91o4PJ0DXPfNGsGr8OnOy66zG+9NAL53VIJX6 ieBA== X-Gm-Message-State: AO0yUKUMWP4UYGajG6uLy2Xxi6W0QY3c+4bWYmF5+iBK7OMuiauFSDFT UvJBA43/bcVLki2ersOLEhOW72V7KSGGBHcObcc= X-Google-Smtp-Source: AK7set9ZPs0Dn62yJgNtzzxzmVhOLHputt8qK4KG1PSWZsHdg10LzRG9qqC+X0kkYDCJoTi7lb9BhA== X-Received: by 2002:a05:6a20:6a9d:b0:d9:957f:612a with SMTP id bi29-20020a056a206a9d00b000d9957f612amr11537705pzb.29.1679944220576; Mon, 27 Mar 2023 12:10:20 -0700 (PDT) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id d9-20020aa78e49000000b005cd81a74821sm15653334pfr.152.2023.03.27.12.10.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 12:10:20 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH 30/30] ide: Make use of U-Boot types Date: Tue, 28 Mar 2023 08:07:17 +1300 Message-Id: <20230328080702.30.Id5035bbf8213f53a9ebfbddfe5c471d324ceae62@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 Use standard U-Boot types in the file to make the code less verbose. Signed-off-by: Simon Glass --- drivers/block/ide.c | 79 +++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 42 deletions(-) diff --git a/drivers/block/ide.c b/drivers/block/ide.c index af0c951eb890..89201dd4d229 100644 --- a/drivers/block/ide.c +++ b/drivers/block/ide.c @@ -63,7 +63,7 @@ static void ide_reset(void) } } -static void ide_outb(int dev, int port, unsigned char val) +static void ide_outb(int dev, int port, u8 val) { log_debug("(dev= %d, port= %#x, val= 0x%02x) : @ 0x%08lx\n", dev, port, val, ATA_CURR_BASE(dev) + port); @@ -71,7 +71,7 @@ static void ide_outb(int dev, int port, unsigned char val) outb(val, ATA_CURR_BASE(dev) + port); } -static unsigned char ide_inb(int dev, int port) +static u8 ide_inb(int dev, int port) { uchar val; @@ -119,10 +119,9 @@ static uchar ide_wait(int dev, ulong t) * terminate the string * "len" is the size of available memory including the terminating '\0' */ -static void ident_cpy(unsigned char *dst, unsigned char *src, - unsigned int len) +static void ident_cpy(u8 *dst, u8 *src, uint len) { - unsigned char *end, *last; + u8 *end, *last; last = dst; end = src + len - 1; @@ -209,10 +208,9 @@ static uchar atapi_wait_mask(int dev, ulong t, uchar mask, uchar res) /* * issue an atapi command */ -static unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen, - unsigned char *buffer, int buflen) +static u8 atapi_issue(int device, u8 *ccb, int ccblen, u8 *buffer, int buflen) { - unsigned char c, err, mask, res; + u8 c, err, mask, res; int n; /* Select device @@ -231,8 +229,8 @@ static unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen, ide_outb(device, ATA_ERROR_REG, 0); /* no DMA, no overlaped */ ide_outb(device, ATA_SECT_CNT, 0); ide_outb(device, ATA_SECT_NUM, 0); - ide_outb(device, ATA_CYL_LOW, (unsigned char)(buflen & 0xff)); - ide_outb(device, ATA_CYL_HIGH, (unsigned char)((buflen >> 8) & 0xff)); + ide_outb(device, ATA_CYL_LOW, (u8)(buflen & 0xff)); + ide_outb(device, ATA_CYL_HIGH, (u8)((buflen >> 8) & 0xff)); ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device)); ide_outb(device, ATA_COMMAND, ATA_CMD_PACKET); @@ -250,7 +248,7 @@ static unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen, } /* write command block */ - ide_output_data_shorts(device, (unsigned short *)ccb, ccblen / 2); + ide_output_data_shorts(device, (ushort *)ccb, ccblen / 2); /* ATAPI Command written wait for completition */ mdelay(5); /* device must set bsy */ @@ -301,13 +299,11 @@ static unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen, /* ok now decide if it is an in or output */ if (!(ide_inb(device, ATA_SECT_CNT) & 0x02)) { log_debug("Write to device\n"); - ide_output_data_shorts(device, (unsigned short *)buffer, - n); + ide_output_data_shorts(device, (ushort *)buffer, n); } else { log_debug("Read from device @ %p shorts %d\n", buffer, n); - ide_input_data_shorts(device, (unsigned short *)buffer, - n); + ide_input_data_shorts(device, (ushort *)buffer, n); } } mdelay(5); /* seems that some CD ROMs need this... */ @@ -332,12 +328,11 @@ AI_OUT: #define ATAPI_DRIVE_NOT_READY 100 #define ATAPI_UNIT_ATTN 10 -static unsigned char atapi_issue_autoreq(int device, unsigned char *ccb, - int ccblen, - unsigned char *buffer, int buflen) +static u8 atapi_issue_autoreq(int device, u8 *ccb, int ccblen, u8 *buffer, + int buflen) { - unsigned char sense_data[18], sense_ccb[12]; - unsigned char res, key, asc, ascq; + u8 sense_data[18], sense_ccb[12]; + u8 res, key, asc, ascq; int notready, unitattn; unitattn = ATAPI_UNIT_ATTN; @@ -415,7 +410,7 @@ static ulong atapi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, struct blk_desc *desc = dev_get_uclass_plat(dev); int device = desc->devnum; ulong n = 0; - unsigned char ccb[12]; /* Command descriptor block */ + u8 ccb[12]; /* Command descriptor block */ ulong cnt; log_debug("%d start " LBAF " blocks " LBAF " buffer at %lx\n", device, @@ -429,19 +424,19 @@ static ulong atapi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, ccb[0] = ATAPI_CMD_READ_12; ccb[1] = 0; /* reserved */ - ccb[2] = (unsigned char)(blknr >> 24) & 0xff; /* MSB Block */ - ccb[3] = (unsigned char)(blknr >> 16) & 0xff; /* */ - ccb[4] = (unsigned char)(blknr >> 8) & 0xff; - ccb[5] = (unsigned char)blknr & 0xff; /* LSB Block */ - ccb[6] = (unsigned char)(cnt >> 24) & 0xff; /* MSB Block cnt */ - ccb[7] = (unsigned char)(cnt >> 16) & 0xff; - ccb[8] = (unsigned char)(cnt >> 8) & 0xff; - ccb[9] = (unsigned char)cnt & 0xff; /* LSB Block */ + ccb[2] = (u8)(blknr >> 24) & 0xff; /* MSB Block */ + ccb[3] = (u8)(blknr >> 16) & 0xff; /* */ + ccb[4] = (u8)(blknr >> 8) & 0xff; + ccb[5] = (u8)blknr & 0xff; /* LSB Block */ + ccb[6] = (u8)(cnt >> 24) & 0xff; /* MSB Block cnt */ + ccb[7] = (u8)(cnt >> 16) & 0xff; + ccb[8] = (u8)(cnt >> 8) & 0xff; + ccb[9] = (u8)cnt & 0xff; /* LSB Block */ ccb[10] = 0; /* reserved */ ccb[11] = 0; /* reserved */ if (atapi_issue_autoreq(device, ccb, 12, - (unsigned char *)buffer, + (u8 *)buffer, cnt * ATAPI_READ_BLOCK_SIZE) == 0xff) return n; n += cnt; @@ -454,9 +449,9 @@ static ulong atapi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, static void atapi_inquiry(struct blk_desc *desc) { - unsigned char ccb[12]; /* Command descriptor block */ - unsigned char iobuf[64]; /* temp buf */ - unsigned char c; + u8 ccb[12]; /* Command descriptor block */ + u8 iobuf[64]; /* temp buf */ + u8 c; int device; device = desc->devnum; @@ -467,7 +462,7 @@ static void atapi_inquiry(struct blk_desc *desc) ccb[0] = ATAPI_CMD_INQUIRY; ccb[4] = 40; /* allocation Legnth */ - c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *)iobuf, 40); + c = atapi_issue_autoreq(device, ccb, 12, (u8 *)iobuf, 40); log_debug("ATAPI_CMD_INQUIRY returned %x\n", c); if (c) @@ -494,7 +489,7 @@ static void atapi_inquiry(struct blk_desc *desc) ccb[0] = ATAPI_CMD_START_STOP; ccb[4] = 0x03; /* start */ - c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *)iobuf, 0); + c = atapi_issue_autoreq(device, ccb, 12, (u8 *)iobuf, 0); log_debug("ATAPI_CMD_START_STOP returned %x\n", c); if (c) @@ -502,7 +497,7 @@ static void atapi_inquiry(struct blk_desc *desc) memset(ccb, 0, sizeof(ccb)); memset(iobuf, 0, sizeof(iobuf)); - c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *)iobuf, 0); + c = atapi_issue_autoreq(device, ccb, 12, (u8 *)iobuf, 0); log_debug("ATAPI_CMD_UNIT_TEST_READY returned %x\n", c); if (c) @@ -511,7 +506,7 @@ static void atapi_inquiry(struct blk_desc *desc) memset(ccb, 0, sizeof(ccb)); memset(iobuf, 0, sizeof(iobuf)); ccb[0] = ATAPI_CMD_READ_CAP; - c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *)iobuf, 8); + c = atapi_issue_autoreq(device, ccb, 12, (u8 *)iobuf, 8); log_debug("ATAPI_CMD_READ_CAP returned %x\n", c); if (c) return; @@ -539,10 +534,10 @@ static void atapi_inquiry(struct blk_desc *desc) */ static int ide_ident(int device, struct blk_desc *desc) { - unsigned char c; hd_driveid_t iop; bool is_atapi = false; int tries = 1; + u8 c; memset(desc, '\0', sizeof(*desc)); desc->devnum = device; @@ -753,10 +748,10 @@ static ulong ide_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, { struct blk_desc *desc = dev_get_uclass_plat(dev); int device = desc->devnum; - ulong n = 0; - unsigned char c; - unsigned char pwrsave = 0; /* power save */ bool lba48 = false; + ulong n = 0; + u8 pwrsave = 0; /* power save */ + u8 c; if (IS_ENABLED(CONFIG_LBA48) && (blknr & 0x0000fffff0000000ULL)) { /* more than 28 bits used, use 48bit mode */ @@ -867,8 +862,8 @@ static ulong ide_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, struct blk_desc *desc = dev_get_uclass_plat(dev); int device = desc->devnum; ulong n = 0; - unsigned char c; bool lba48 = false; + u8 c; if (IS_ENABLED(CONFIG_LBA48) && (blknr & 0x0000fffff0000000ULL)) { /* more than 28 bits used, use 48bit mode */