From patchwork Mon Aug 24 15:12:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 510084 X-Patchwork-Delegate: trini@ti.com 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 0B452140280 for ; Tue, 25 Aug 2015 01:14:27 +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=mRE+fUQe; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D72324B6AF; Mon, 24 Aug 2015 17:14:21 +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 gx0IR5HomnzP; Mon, 24 Aug 2015 17:14:21 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8F59A4B6B4; Mon, 24 Aug 2015 17:14:11 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9EE994B6CA for ; Mon, 24 Aug 2015 17:13:53 +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 pK7qjIUpkdM0 for ; Mon, 24 Aug 2015 17:13:53 +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-ig0-f173.google.com (mail-ig0-f173.google.com [209.85.213.173]) by theia.denx.de (Postfix) with ESMTPS id 048864B692 for ; Mon, 24 Aug 2015 17:13:44 +0200 (CEST) Received: by igcse8 with SMTP id se8so49582563igc.1 for ; Mon, 24 Aug 2015 08:13:43 -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=lylrT2w1edKAPzzm5hbiaUQmmP5m5j1jZf+FQ5tlr5U=; b=mRE+fUQeMZT1CdN86NpGHOYCMr0WLIlVMhdx3YyjgUhEKoqI1pcByN5EBDU3SrGt9y Ir6TJmcyzp1uDrOSQuO109eDkJmU7QpD2z1M1UTJGcOPKM4R8bQOLqUKRYM45vDIMGqT fBRn04KGrvPHZICRCjJZK/4DgthLjt1yUUNiZ5y4RYzhU5wCQBjvfBRNTCenVcAIBQvt n7UUdV+RxEaiPbSUMix/nGKT02JSsBe8xdLCIUmnwRyyNzfXCytjZRwcFMtH4rfMOcNN AHrGK+mMSEOAfeL9Bd3QqaeJZdDq5/25HPcUKlgsflOLP5TW6ae6qdWbdgUEdmpsDxyq uurA== 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=lylrT2w1edKAPzzm5hbiaUQmmP5m5j1jZf+FQ5tlr5U=; b=bMdyj499Jt78r6seJDm4g/Lqmc6L1HVJzmhUKQvHrvstWV1DhAvs7e0JYuSjW+krtB z9ONyfleOq8pKD0L+/Nh38KuKCgZBroaFOK0C2+v7/ymEfQJ+/ZdUGYHsqw+FelLDvNu WNkz40zkGlQmlpg8VAFdZW9q5jH/O1OksUVLcPXRI945BACCmf9lAmFuNlrObfAfNMc0 H4/rAX+Yu/XNHHLDjR18ePUl/NwnK6mdVMZYbzkVtEhcgdZmuLpFb2P6FGcuirPN5ilO cdMqxSkwn3lFs7LHiqpvBDmhRjmTF2xKSQPuSODMCnSFUCraaikwWa2MjrQ6PKaY5IxY O4kA== X-Gm-Message-State: ALoCoQl90OiwYT3jzPXK22iRLbLNCWqeFiT95bB2LgDRUOfHsSrW9exZBG+0rt8+Dj+TKdkB3dsW X-Received: by 10.50.60.100 with SMTP id g4mr13618883igr.41.1440429223166; Mon, 24 Aug 2015 08:13:43 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by smtp.gmail.com with ESMTPSA id d3sm9013832igx.5.2015.08.24.08.13.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Aug 2015 08:13:40 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 850E722164B; Mon, 24 Aug 2015 09:13:33 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 24 Aug 2015 09:12:24 -0600 Message-Id: <1440429171-2555-7-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.5.0.457.gab17608 In-Reply-To: <1440429171-2555-1-git-send-email-sjg@chromium.org> References: <1440429171-2555-1-git-send-email-sjg@chromium.org> Cc: huangtao , Andre Przywara , cwx Subject: [U-Boot] [PATCH v4 06/33] 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 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 4f060ee..eefd1cb 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)