From patchwork Thu Dec 31 04:09:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1421476 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=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: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: 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=i6wGrb34; 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D5vpj1hQ4z9sRN for ; Thu, 31 Dec 2020 15:11:09 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CCAA882615; Thu, 31 Dec 2020 05:10:41 +0100 (CET) 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="i6wGrb34"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B14B082611; Thu, 31 Dec 2020 05:10:30 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) (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 596AA82540 for ; Thu, 31 Dec 2020 05:10:25 +0100 (CET) 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-il1-x132.google.com with SMTP id 75so16438391ilv.13 for ; Wed, 30 Dec 2020 20:10:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=U/T44pNbUpBhyMbmSzLhpRlrYBUTEIgU5jasNxe80kg=; b=i6wGrb34bgVPzZ3XXRhjBJo1gUjzjvPSU5/GhHIpR1go1N0IzWqY/ipI3mL8T6OMK5 1HDoFvdc6KYOSCWF3hT3S7EREp4wEboq+yU5e6jNpHX1iXZNnrk7x67P5pZEy9nI/2SG 7uTePKQ4WC0oRFpyHD0Pr4Q6NqGLn1U+VL4KQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U/T44pNbUpBhyMbmSzLhpRlrYBUTEIgU5jasNxe80kg=; b=N+/WNcr1kCUjtV9o9DkLYJFkVaCggD87AvHuJaKUp8UBD79YIfR2HwptRQY22mzkb7 RiUjHvF2PREZfI0RuCVeF3PytV3ToY1ukIsiZSpS+Y0xTzG7owKzHR1eCM8vOC0C3S8S ULJ5qL5no4EATUGcB0LJJyUFtyBqlUD4RgJv3TJQgWPvkCksvcn/ne7sq3m3a40SiRHf PbMIRpPJfkdE+dX1CU18K0YUSFtFn5krfTeaSRHvtMvlcj3Fdh+cL6EeNrXe3JoKcGIL ic8lveV74yhCKz+RbOlobo+KSDpJBXkVX3ro7+L/cz2GMBg6EpmwJ4cWUJLIdbK0tOvD T4PQ== X-Gm-Message-State: AOAM533o7qNs9xdxeXYTJ77SUk51Mf9FWbpLj28lwoulORnrp2ek83XQ LmZQWcKF14HdtCFMRP5l0+IX//L7ZFz46s+d X-Google-Smtp-Source: ABdhPJxWfonPQ3I2nQJ+9AAyH0Q2GFfataqKfex0WWgWQEX8ESukRegdu80OWtVmETX4Y9qluAXQwg== X-Received: by 2002:a92:1e08:: with SMTP id e8mr6605194ile.16.1609387824006; Wed, 30 Dec 2020 20:10:24 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id 14sm31959026ilz.7.2020.12.30.20.10.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Dec 2020 20:10:23 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Marek Vasut , Walter Lozano , Bernhard Messerklinger , Heinrich Schuchardt , Bin Meng , Tom Rini , Simon Glass , Anatolij Gustschin , Jean-Jacques Hiblot , Pavel Herrmann , Sean Anderson Subject: [PATCH 04/30] dm: core: Allow dropping run-time binding of devices Date: Wed, 30 Dec 2020 21:09:34 -0700 Message-Id: <20201230210941.4.I2883cc0cb1edf613bf2dfb30e4bf982cf03daafc@changeid> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog In-Reply-To: <20201231041000.660925-1-sjg@chromium.org> References: <20201231041000.660925-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean With OF_PLATDATA_INST devices are bound at build time. we should not allow binding of devices at runtime. Add an option to control this. Update the driver model core so that it does not bind devices. Update device_bind() to return an error if called. Signed-off-by: Simon Glass --- drivers/core/device.c | 38 +++++++++++++++++++++----------------- dts/Kconfig | 16 ++++++++++++++++ 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/drivers/core/device.c b/drivers/core/device.c index aeab3836ed7..cdcf5f43ad2 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -44,6 +44,9 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv, bool auto_seq = true; void *ptr; + if (CONFIG_IS_ENABLED(OF_PLATDATA_NO_BIND)) + return -ENOSYS; + if (devp) *devp = NULL; if (!name) @@ -382,26 +385,27 @@ int device_of_to_plat(struct udevice *dev) if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID) return 0; - /* Ensure all parents have ofdata */ - if (dev->parent) { - ret = device_of_to_plat(dev->parent); + if (!CONFIG_IS_ENABLED(OF_PLATDATA_NO_BIND)) { + /* Ensure all parents have ofdata */ + if (dev->parent) { + ret = device_of_to_plat(dev->parent); + if (ret) + goto fail; + + /* + * The device might have already been probed during + * the call to device_probe() on its parent device + * (e.g. PCI bridge devices). Test the flags again + * so that we don't mess up the device. + */ + if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID) + return 0; + } + + ret = device_alloc_priv(dev); if (ret) goto fail; - - /* - * The device might have already been probed during - * the call to device_probe() on its parent device - * (e.g. PCI bridge devices). Test the flags again - * so that we don't mess up the device. - */ - if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID) - return 0; } - - ret = device_alloc_priv(dev); - if (ret) - goto fail; - drv = dev->driver; assert(drv); diff --git a/dts/Kconfig b/dts/Kconfig index e861ea48d01..645a2d2b84d 100644 --- a/dts/Kconfig +++ b/dts/Kconfig @@ -371,6 +371,14 @@ config SPL_OF_PLATDATA_INST Declare devices as udevice instances so that they do not need to be bound when U-Boot starts. This can save time and code space. +config SPL_OF_PLATDATA_NO_BIND + bool "Don't allow run-time binding of devices" + depends on SPL_OF_PLATDATA_INST + default y + help + This removes the ability to bind devices at run time, thus saving + some code space in U-Boot. + endif config TPL_OF_PLATDATA @@ -411,6 +419,14 @@ config TPL_OF_PLATDATA_INST Declare devices as udevice instances so that they do not need to be bound when U-Boot starts. This can save time and code space. +config TPL_OF_PLATDATA_NO_BIND + bool "Don't allow run-time binding of devices" + depends on TPL_OF_PLATDATA_INST + default y + help + This removes the ability to bind devices at run time, thus saving + some code space in U-Boot. + endif endmenu