From patchwork Sun Aug 30 22:55:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 512269 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 2281B140291 for ; Mon, 31 Aug 2015 08:56:44 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=nKMNLEoN; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5CE4B4B6FD; Mon, 31 Aug 2015 00:56:39 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id E4sO_ZgU717X; Mon, 31 Aug 2015 00:56:39 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6F97A4B71C; Mon, 31 Aug 2015 00:56:29 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 83A794B67F for ; Mon, 31 Aug 2015 00:56:15 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Zo7hUYWMG_5r for ; Mon, 31 Aug 2015 00:56:15 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-io0-f172.google.com (mail-io0-f172.google.com [209.85.223.172]) by theia.denx.de (Postfix) with ESMTPS id 2A6A74B6D4 for ; Mon, 31 Aug 2015 00:56:11 +0200 (CEST) Received: by iofe124 with SMTP id e124so75545662iof.1 for ; Sun, 30 Aug 2015 15:56:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=/FX9CS96RgjtQke1KM0WdpZJcB8K14T0hlfs+MxE5vY=; b=nKMNLEoNVNPqNSaU1F0EPMYgLx8pVVIDTqMdc7hwxMAW83RAxNMjFxKIIHL0yFeqdf b5YvSEqpATbIg0Vn8o9jdo7kgrRktN42Ubbz8FirYdG1VcZFxgV4sgJqTs5G/3MlB/OB KpBFwmiZr7egFfKSsFuVp03aL7B7DVS5Trz9xZ568sdEsBpLRiGjYW/b+0NyDUkXrI4C 56NF7eqhzuUmns9JUi7e/x28lrASczuxfn6uog138oRg4tPV27jwSSKqaMvKxwHer5gC kudaRyWfk9LrWxZ6g/3VwdRpsU7VAna79hNtOuAvtyMz4IND/e6uJJExUm9VYeiT+isf DdjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=/FX9CS96RgjtQke1KM0WdpZJcB8K14T0hlfs+MxE5vY=; b=mBv5ziXYoefcro5NyOiCdYfsJwsT3HATN9OgTVnUzT2vfVJMnzGKgIX/N/SYIr6KiL eAeth76D2k+SqxL4C+509xcSEnDbvi3xgodC8qOavWKY/00TtX5GKmM8oxC/U+4+wO5R DiwWus9N+EcS7WzijsxDdpamhp8EoS/blZbsceSYQkRJ7vjOC6plWviXLmwwlbCR2VSJ gEqqhAnIkq/3Dzaf7/vSGByVDcnMeGOLFR2Kq4Igu2pgojesDTqEaFEySgLvjKpfU7dS 449DKcUYvPqg0vvcqY4wvticd+IgkBr1X/aOS3QTljVgM1NhHKRU8G4TnzsAG883HLZy g3Sw== X-Gm-Message-State: ALoCoQmrRzVUVDNhY5Ca2hAgJxrjjPOLWRX51xaUKlL3RP8ulbkRJCAvJ+qlgz5Tzeq9SlclscT2 X-Received: by 10.107.154.15 with SMTP id c15mr2661591ioe.197.1440975370634; Sun, 30 Aug 2015 15:56:10 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by smtp.gmail.com with ESMTPSA id x23sm2863951ioi.41.2015.08.30.15.56.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Aug 2015 15:56:08 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 957D7221403; Sun, 30 Aug 2015 16:56:07 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Sun, 30 Aug 2015 16:55:16 -0600 Message-Id: <1440975352-28528-6-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.5.0.457.gab17608 In-Reply-To: <1440975352-28528-1-git-send-email-sjg@chromium.org> References: <1440975352-28528-1-git-send-email-sjg@chromium.org> Cc: huangtao , Andre Przywara , cwx Subject: [U-Boot] [PATCH v5 05/41] dm: Improve handling of a missing uclass X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" When a uclass definition is missing, no drivers in that uclass can operate. This can happen if a board has a strange collection of options (e.g. the driver is enabled but the uclass is not). Unfortunately this is very confusing at present. Starting up driver model results in a -ENOENT error, which is pretty generic. Quite a big of digging is needed to get to the root cause. To help with this, change the error to a very strange one with no other users in U-Boot. Also add a debug message. Signed-off-by: Simon Glass --- Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None drivers/core/device.c | 4 +++- drivers/core/uclass.c | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/core/device.c b/drivers/core/device.c index a6cd936..0ccd443 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -39,8 +39,10 @@ int device_bind(struct udevice *parent, const struct driver *drv, return -EINVAL; ret = uclass_get(drv->id, &uc); - if (ret) + if (ret) { + debug("Missing uclass for driver %s\n", drv->name); return ret; + } dev = calloc(1, sizeof(struct udevice)); if (!dev) diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index f63ff59..e800c28 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -58,7 +58,12 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp) if (!uc_drv) { debug("Cannot find uclass for id %d: please add the UCLASS_DRIVER() declaration for this UCLASS_... id\n", id); - return -ENOENT; + /* + * Use a strange error to make this case easier to find. When + * a uclass is not available it can prevent driver model from + * starting up and this failure is otherwise hard to debug. + */ + return -EPFNOSUPPORT; } uc = calloc(1, sizeof(*uc)); if (!uc)