From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-io1-f48.google.com (mail-io1-f48.google.com [209.85.166.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD0A0173 for ; Mon, 19 Jul 2021 17:55:07 +0000 (UTC) Received: by mail-io1-f48.google.com with SMTP id p186so20956905iod.13 for ; Mon, 19 Jul 2021 10:55:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0ZjMO+W4wuo+djUT9uwnrCr5tvNqbyTwVgrD5Xsdzs8=; b=fmZvaL6sHrwkDXPqqmYX28Pz8ngsOvsV7Ko50ioRL7WiaBazi2DfOKxPklq48fOv1H xabbtaeUc2RiobhCnfrQ7mPzL+DGqi4bilNwaTMfsqRKrZE+L1No5W/BSuGIIKiNIU/S rGLLnthr72A+uDbaWKfb651DEPsdp3YWhpziyKAYV9QC2GZWs1JJ0HU9WT1BeLo2b/Hx vV2fkYeqs5EihUW5Ewbz84YUUogz9bUoEvxNsjE77VzpoB0rOXrLOmvQtoACTHZCEJ/g baK/FhpeY53iIFPrFKMyfLuMBgguMFHC09mE1hfuYpLjeOIDDsJz4M/5fCdmQadM5IAP wVTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0ZjMO+W4wuo+djUT9uwnrCr5tvNqbyTwVgrD5Xsdzs8=; b=YYTd3IiwJ9W6McUkXHYGK8onrjobKtRLnrU9ZK54gDaFR0qSUuWQf1EcebJXNXreeU 2XQI+K7Ug0Gz+evJ55GNJqLFYFrR/Y7ZOGAomWrXjSe/8prhZjZUPK7TWQfByyyceVRY E7jbsyGsJ5CIVwOY93U7Dggo7FF8APs8G/RZGUbYteQO8imS1uEV/cx4TuuH/8BUH4zt TN8Ar481dM6kfXWA2/X+0Gkfm+zBKaBY4On6MaweJR/0G0XusQYtH/Qk66BaYwMW8X22 gSUPxGQATW2ilpf1cASe6UYCMQT/FzW28PDTHXi/ZB5MXclCK50SOrveDnobPfdbgDFM Xk2g== X-Gm-Message-State: AOAM531nBLUtCePJSo83dRnULiy3x+5lQPU2pTHsTqsw8PaJ1Ys1cFUD pkWra/GJZlEyxno7NYCyb6Jb1Q//d90eyAnIUYs= X-Google-Smtp-Source: ABdhPJx39JplDuGf6LMG1lIRryK4Xkdt7SWvnXkv7G90X6HU5SExYRljlLlqyhbOO4t2a0re/AM8IKAD1cPPStplO1s= X-Received: by 2002:a02:2b21:: with SMTP id h33mr22379567jaa.31.1626717306958; Mon, 19 Jul 2021 10:55:06 -0700 (PDT) Precedence: bulk X-Mailing-List: ksummit@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20210707203827.GI18396@quack2.suse.cz> <26cd8155-a85c-01e9-bfac-af4bbd15f273@oracle.com> In-Reply-To: From: Miguel Ojeda Date: Mon, 19 Jul 2021 19:54:55 +0200 Message-ID: Subject: Re: [TECH TOPIC] Rust for Linux To: Vegard Nossum Cc: Wedson Almeida Filho , Linus Walleij , Greg KH , Bartosz Golaszewski , Kees Cook , Jan Kara , James Bottomley , Julia Lawall , Laurent Pinchart , Roland Dreier , ksummit@lists.linux.dev, Viresh Kumar Content-Type: text/plain; charset="UTF-8" On Mon, Jul 19, 2021 at 7:45 PM Miguel Ojeda wrote: > > However, the offset given is not a compile-time constant here, thus > the runtime-check is used. Or we could provide an `unsafe fn` which > means the caller would be responsible to guarantee the precondition. > But see next point. To clarify, by offset here I mean the actual offset passed to the function, i.e. the second parameter `woffset` (notice the `w`), not `offset` in the value parameter: pl061.base.try_writeb((value as u8) << offset, woffset)?; > (Actually, from a quick look, there are 3 or so `try_*()` that could > be using the non-`try_*()` version) e.g. let _ = pl061.base.try_writeb(gpioie, GPIOIE); could be: pl061.base.writeb(gpioie, GPIOIE); because `GPIOIE` is known at compile-time (vs. the ones with `woffset`). Cheers, Miguel