From patchwork Thu Mar 24 00:40:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 64285 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp347095lbc; Wed, 23 Mar 2016 17:41:04 -0700 (PDT) X-Received: by 10.98.67.139 with SMTP id l11mr8445548pfi.112.1458780061288; Wed, 23 Mar 2016 17:41:01 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qx12si7793466pab.169.2016.03.23.17.41.01; Wed, 23 Mar 2016 17:41:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753736AbcCXAlA (ORCPT + 7 others); Wed, 23 Mar 2016 20:41:00 -0400 Received: from mail-ob0-f169.google.com ([209.85.214.169]:35485 "EHLO mail-ob0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753656AbcCXAk7 (ORCPT ); Wed, 23 Mar 2016 20:40:59 -0400 Received: by mail-ob0-f169.google.com with SMTP id fp4so26060310obb.2; Wed, 23 Mar 2016 17:40:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6aHbI1kQ2PBlgJ7pAjvp/mT/mbGPcoIlwOMVce3GMf0=; b=ieBt9raR457tNMGUk38EkQhvzspCzvHoRW7DS+XOhjUbg9FbWUGxPa4z7KdCfEBZ0Q 9z3pjrqbRw11Q1TPakzbEV+2RJpH6L5hp68bXhlNJHM1/YGs/v5J7bK556v8OgxExc0w wqHk1jbPXtEBwc+W2x6KsIy5PFkYU0OVDMRwbinZb5qGdz9w6fIbQZYAtW7/gu36BUsG bsz5GgCE8a6lF1s5SqjfV0EagjsugWZvFxeJ3JG4sVx5VjjpglljtJXI2D8wuJPEtZKR 6LbRt4D93uoeJR3ApYVF2hKrlNqw2u/k0ioQdnmYbR3eR+Gzq2AhwVtQuAiBKxnqibb1 3tnQ== X-Gm-Message-State: AD7BkJK98551JMFSRoVku9wFaXZRZ53HEoHndFid/Q4a68goLYRgz4B5EeM5tV70IKOOtA== X-Received: by 10.182.210.234 with SMTP id mx10mr3052600obc.47.1458780058126; Wed, 23 Mar 2016 17:40:58 -0700 (PDT) Received: from rob-hp-laptop.herring.priv (72-48-98-129.dyn.grandenetworks.net. [72.48.98.129]) by smtp.googlemail.com with ESMTPSA id c7sm1516559otb.24.2016.03.23.17.40.57 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 23 Mar 2016 17:40:57 -0700 (PDT) From: Rob Herring To: David Gibson Cc: devicetree-compiler@vger.kernel.org, devicetree@vger.kernel.org Subject: [RFC 3/3] checks: Add unit-address checks for PCI buses Date: Wed, 23 Mar 2016 19:40:21 -0500 Message-Id: <1458780021-5052-3-git-send-email-robh@kernel.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1458780021-5052-1-git-send-email-robh@kernel.org> References: <1458780021-5052-1-git-send-email-robh@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org PCI device unit addresses are in the form DD or DD,F where DD is the device 0-0x1f and F is the function 0-7. Add checks that the unit address matches this form. Signed-off-by: Rob Herring --- checks.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/checks.c b/checks.c index 82a7f38..1d0fcfb 100644 --- a/checks.c +++ b/checks.c @@ -549,10 +549,30 @@ static bool is_pci_bridge(struct node *node) return false; } +static void pci_unit_addr(struct check *c, struct node *dt, struct node *node) +{ + const char *unitname = get_unitname(node); + unsigned int dev, func; + int ret; + + ret = sscanf(unitname, "%2x,%1x", &dev, &func); + if (ret >= 1) { + if (dev > 0x1f) + FAIL(c, "Node %s PCI device number out of range", + node->fullpath); + } + if (ret == 2) { + if (func > 7) + FAIL(c, "Node %s PCI function number out of range", + node->fullpath); + } +} + struct bus_type pci_bus_type = { .expected_addr_cells = 3, .expected_size_cells = 2, .is_type = is_pci_bridge, + .check_unit_addr = pci_unit_addr, }; static bool is_simple_bridge(struct node *node)