From owner-freebsd-hackers@freebsd.org Sun Dec 17 23:04:40 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3E3BFE98D60 for ; Sun, 17 Dec 2017 23:04:40 +0000 (UTC) (envelope-from embaudarm@gmail.com) Received: from mail-ot0-x232.google.com (mail-ot0-x232.google.com [IPv6:2607:f8b0:4003:c0f::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 033F02010; Sun, 17 Dec 2017 23:04:40 +0000 (UTC) (envelope-from embaudarm@gmail.com) Received: by mail-ot0-x232.google.com with SMTP id q39so5560345otb.8; Sun, 17 Dec 2017 15:04:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=vTrMBotkBaZN81EqUEPzpNNkL3HGP7CXcSaj98Hktbs=; b=RqHLLgZWrlEkAuZH4DF8eJZp7cRkPedcOtZil5hqeh8pzByuuqeWOq93RnfbXFpd0r 0pKdh3Ql2C5jrvhQdAwT7/JAcBM1Z87PXhUnKl0D5k7T0+2bXfTfa90DBELXYm04oH7a cdAbPLI0gjtSdY1G0DPxK+QyQFQolVWh8caqnUkhNGU5PgqJd6e1hvn2+QIfORaMEMVQ F9XS8kYteheiR+zhoiUI+GCwetcm9b8+rEah3bkBLqqmaJtF1E1NxBrPUWp0OMWb7L5H y8fihqHJik/lU//4ljKCRA6IsSYU3eFaWPU88v38W19W0LSQoCSXk9Xjk/b3PAcf26q4 zh8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=vTrMBotkBaZN81EqUEPzpNNkL3HGP7CXcSaj98Hktbs=; b=MjjeKKOmQq3jiF5z1IVVaQ06Fdx5S1xzSIAxZ8rweJ8W5LtIIdvDHdC9eNifcXXDAR cRN8IVWb7wMOJvEkJkWxs9yIH63DUZO1eLy2oYvBHMnKrUrXhYTYiOQVS2BSWWHdkBVV iTw8SaSwMZOM2W4uT16RMLS+7I6fdElUWX/hcho2lISdZWGAl1kwUB1cK3+cALwbdbG5 zvkFhQ2yEQYuQhrd2U2CJ96MabxPm3dUHML3e+DpEUXu7l5IvyuGxeVZMdeJOCTVA2oq Ufn8qafVm/qAseCqhGFL957hBAjMj4C3aBJjJ14MJ6nq8AlRpVUcRlr2vfkgvLxwNlJe oCtw== X-Gm-Message-State: AKGB3mI8nyvlSTCeGQqqhFZAgQP9dLPoWVipa+KimBRA81lRkxX6NDGT 7b4iurP5cgjds1RZITWZXxwA9G7rfIedGVVdyZG5qQ== X-Google-Smtp-Source: ACJfBov0U/b68o19DFwk1+GVupJxJgvvXJq3f4rvFspEo53HVYFEl2sFPvd1S/6qTV9FjoO8gf77yZoNpJxwtAYB7p0= X-Received: by 10.157.33.134 with SMTP id s6mr14389544otb.10.1513551878836; Sun, 17 Dec 2017 15:04:38 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.39.36 with HTTP; Sun, 17 Dec 2017 15:03:58 -0800 (PST) In-Reply-To: <1513541989.95072.36.camel@freebsd.org> References: <1513541989.95072.36.camel@freebsd.org> From: Lee D Date: Sun, 17 Dec 2017 18:03:58 -0500 Message-ID: Subject: Re: How do I alloc multiple memory regions specified in a device tree? To: Ian Lepore Cc: freebsd-hackers@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Dec 2017 23:04:40 -0000 On Sun, Dec 17, 2017 at 3:19 PM, Ian Lepore wrote: > On Sun, 2017-12-17 at 15:00 -0500, Lee D wrote: >> Hi everyone. >> >> I have a device driver that must access registers in multiple memory >> ranges. How do I pull those values out of the device tree? >> >> bus_alloc_resource_any() works, but only for the first memory range. >> The second time I call it, it crashes the kernel. >> > > The 'rid' argument is the zero-based index of the register range you > want to allocate. Just increment rid from 0 through the number of > offset/length tuples in the fdt regs property. > > You can allocate all the ranges at once with bus_alloc_resources(). > For an example, see the a10fb_spec array in arm/allwinner/a10_fb.c > > -- Ian > Thank you, I see it was staring me in the face the whole time. Setting rid to the tuple index did the trick. Also thanks for the info on bus_alloc_resources(). Lee