From patchwork Mon Oct 1 17:55:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 977348 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42P96Z4Tndz9s4V for ; Tue, 2 Oct 2018 04:00:06 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 4930FC21F35; Mon, 1 Oct 2018 17:58:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C9ABFC21F82; Mon, 1 Oct 2018 17:56:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 04802C21DFD; Mon, 1 Oct 2018 17:56:01 +0000 (UTC) Received: from mail-it1-f202.google.com (mail-it1-f202.google.com [209.85.166.202]) by lists.denx.de (Postfix) with ESMTPS id C3919C21DD9 for ; Mon, 1 Oct 2018 17:55:56 +0000 (UTC) Received: by mail-it1-f202.google.com with SMTP id y142-v6so8139477itb.7 for ; Mon, 01 Oct 2018 10:55:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=iwgLjc6zqvCPLL0tYFXq2QsCq89UMqo/HpTneqXB+5M=; b=kt9ji4Kl4AgklV0MoJd2vF4ZGJtS62Mcg+69rEMs6BAsMyTYWfyF0O6hGVAu6WhcXi pkL3I8C068lD/FvNqI637I6QHp3USttgbUJisxJWVPOgOEN/1uEnMxrDL3n2JsKxSRSN NJmebA8Sb7IVuKFeDbLjxaDSKehV/nnjLaZjKVFrJtXSBMjGrYCwEU9KV5oNhS4sw64m en3Xfq+zb2VUtcPgSAisZPkxVDtTYJmubUCmCix+lmf3s/bJoPlEuT206VTokGzyA6hr 7d4nCynvQ1ImYY9d9oMVQb3FZeg44nBAjMGtQPT3J/6gRsE2TKBNi/+diad8FHOs0riQ TNFQ== X-Gm-Message-State: ABuFfojK6cF+7igbx7OsSYh8VSx0XZqvaG4U3wpH3N2FGk2gVux1gBkE u/1DuYdNBvgIPfYp+XYX/tAWu3U= X-Google-Smtp-Source: ACcGV60GIJ/XwPHgJtGKi2IXPo6Uo2GwH5l0mbjp+jRxAgG0YQ9qnlsn9C5SBlbZVyvnbV93kCD6ybc= X-Received: by 2002:a24:254a:: with SMTP id g71-v6mr11129465itg.33.1538416555856; Mon, 01 Oct 2018 10:55:55 -0700 (PDT) Date: Mon, 1 Oct 2018 11:55:19 -0600 In-Reply-To: <20181001175520.239554-1-sjg@chromium.org> Message-Id: <20181001175520.239554-15-sjg@chromium.org> Mime-Version: 1.0 References: <20181001175520.239554-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Jagan Teki Subject: [U-Boot] [PATCH 14/15] dm: spi: Clean up detection of sandbox SPI emulator X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Now that we don't have to deal with the command-line flag we can simplify the code for detecting the emulator. Remove the lookup based on the SPI specification, relying just on the device tree to locate the emulator. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- arch/sandbox/include/asm/state.h | 1 - drivers/mtd/spi/sandbox.c | 18 ++++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index d1baba1c3ae..1ccc8e02b9f 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -36,7 +36,6 @@ enum state_terminal_raw { }; struct sandbox_spi_info { - const char *spec; struct udevice *emul; }; diff --git a/drivers/mtd/spi/sandbox.c b/drivers/mtd/spi/sandbox.c index 514484eba06..7fef754c634 100644 --- a/drivers/mtd/spi/sandbox.c +++ b/drivers/mtd/spi/sandbox.c @@ -115,24 +115,22 @@ static int sandbox_sf_probe(struct udevice *dev) const struct spi_flash_info *data; struct sandbox_spi_flash_plat_data *pdata = dev_get_platdata(dev); struct sandbox_state *state = state_get_current(); + struct dm_spi_slave_platdata *slave_plat; struct udevice *bus = dev->parent; const char *spec = NULL; + struct udevice *emul; int ret = 0; int cs = -1; - int i; debug("%s: bus %d, looking for emul=%p: ", __func__, bus->seq, dev); - if (bus->seq >= 0 && bus->seq < CONFIG_SANDBOX_SPI_MAX_BUS) { - for (i = 0; i < CONFIG_SANDBOX_SPI_MAX_CS; i++) { - if (state->spi[bus->seq][i].emul == dev) - cs = i; - } - } - if (cs == -1) { + ret = sandbox_spi_get_emul(state, bus, dev, &emul); + if (ret) { printf("Error: Unknown chip select for device '%s'\n", - dev->name); - return -EINVAL; + dev->name); + return ret; } + slave_plat = dev_get_parent_platdata(dev); + cs = slave_plat->cs; debug("found at cs %d\n", cs); if (!pdata->filename) {