From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (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 53A4328137E for ; Fri, 4 Jul 2025 07:42:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751614979; cv=none; b=tfxesFnZDm06CWoDUzgf3Wcaatt9LDMKZoBapR1ipm5bWsexbXvJVHDrTg48O66dMVwDJBoy2vIXGx5ZLxnIUL/IBr5i8c/snuL54C/K/aVXcEmApAESPw1Hx5bs/+oUvjiDa4+YgucHc30XwHD1vE9iyNIAMl6A1dJYIVYCmuI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751614979; c=relaxed/simple; bh=EyQLopdaeuTERfCjyDX1RB58tHyhweNO8CjnstLUYcY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=T/94CEJwrDrckwrd3OppoUDxRHayvLGYA3uqbN166Wy7+vOzxPAoDFX16gqSyGo8GOOcy6eqe37PRczOy3dvKZGk+jmc5YnbLU0h0dzYNJ8P9aKqU1NBxR4QMK8YNwOveoypqk+IeCafMb2pxEciP6R/l/pSUA9k+wVqqbdRFfY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Yh0OHdj2; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Yh0OHdj2" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-453018b4ddeso3574915e9.3 for ; Fri, 04 Jul 2025 00:42:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1751614975; x=1752219775; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=camNvxFIEl2ZnilHFyd5vJLomyvuXbAyAAA9+dCBwRk=; b=Yh0OHdj2x/5dobS3e0IYb/wzFPkD/Q/j+gomI/PCukTIfTUxk0NxPqmst+J/zFYtDi rbjo6S/jAgyjH5zmTL53J36J9Nzru1a8TcfZDIR4U4JcdothxycXX28ntOc14wvSxlMT Yj8t7j/4yIvkzqeYV/NAoNrdUJLDjX3TX40cAYE0YRa3mW/QzADjMvcn9Ul+QBtOUUWi fOazyaV2UiCprvYVhUQtIdXPUfP7fz88YRZi+9Lzd+zYz7GO0Kx5fWg8Ukgd197khViV YjrCnfMAStcbQNMk14kq7/KvNGMS7yDLj6Q6KyDfqQQxI/DYlNiFGfSI3ExzWwr83Leo k8IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751614975; x=1752219775; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=camNvxFIEl2ZnilHFyd5vJLomyvuXbAyAAA9+dCBwRk=; b=jwsmi8BUe73k1y5+akInQ481w1UAbS9Um+DNwbXH6R1M3r91jzYGNaLto6hP+lUlvC g0X7c1aYTwkUWz1sJfYAw1TUwqGdsC+nsB0Urlk/iSCt64i7ivasX0tmzcVZE1qMj5Ie U55E7H0M9KP9XkJ296OHa3IsBENp7j7WdXu0njalAl2oG1uFrrlNWCERMWeDoUxGgiyQ rv6cPN9xZNymIK0INT2VdBXHUS3JoWVcJ/6+zU0pgA8YX0CfLN7a/184K9D+SHqFdtOw MMFhsPplbtqvvB3uyPnvnkjht2iFWHFUd3JEp+NbJjRKsIVUHupee6t8xmHP1+n5uPQ+ K1vw== X-Forwarded-Encrypted: i=1; AJvYcCV8IQ/Vp41VuZklDl+g2DS5Jlt32SiI2O+FPsrpI6DC3353m2ZyaD4bmyydrzEV9EASFNEY2OEJCBTmPlkk+A==@vger.kernel.org X-Gm-Message-State: AOJu0YwrEMiBNtgBjCOUj4KzNK5aP2uSMou09B68aPmLTGWLQPSfVTh7 YZPwm8X7yh6bj4etl0CwPRS1jVfblsxYW5S04z1R6kcOn7UUJb6pz/fjO7FxhddnjZjHQu3saZn GvfWVRcdMUwDQMo/n3w== X-Google-Smtp-Source: AGHT+IEaYSraVJ6sZtkAl+0ugpmkdJfooBiBpMK4mkQLrv/OlSZBW7BofC2dgtjJxBr8tWhlM0xayMRReusEiag= X-Received: from wmbfp26.prod.google.com ([2002:a05:600c:699a:b0:450:d398:f3ff]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:8218:b0:450:d3b9:a5fc with SMTP id 5b1f17b1804b1-454b31134d2mr15309935e9.27.1751614974821; Fri, 04 Jul 2025 00:42:54 -0700 (PDT) Date: Fri, 4 Jul 2025 07:42:53 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250703-topics-tyr-request_irq-v6-0-74103bdc7c52@collabora.com> <20250703-topics-tyr-request_irq-v6-2-74103bdc7c52@collabora.com> Message-ID: Subject: Re: [PATCH v6 2/6] rust: irq: add flags module From: Alice Ryhl To: Daniel Sedlak Cc: Daniel Almeida , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , Benno Lossin , Bjorn Helgaas , "Krzysztof =?utf-8?Q?Wilczy=C5=84ski?=" , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-pci@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Fri, Jul 04, 2025 at 08:14:11AM +0200, Daniel Sedlak wrote: > Hi Daniel, > > On 7/3/25 9:30 PM, Daniel Almeida wrote: > > +/// Flags to be used when registering IRQ handlers. > > +/// > > +/// They can be combined with the operators `|`, `&`, and `!`. > > +#[derive(Clone, Copy, PartialEq, Eq)] > > +pub struct Flags(u64); > > Why not Flags(u32)? You may get rid of all unnecessary casts later, plus > save some extra bytes. It looks like the C methods take an `unsigned long`. In that case, I'd probably write the code to match that. pub struct Flags(c_ulong); and git rid of the cast when calling bindings::request_irq. As for all the constants in this file, maybe it would be nice with a private constructor that uses the same type as bindings to avoid the casts? impl Flags { const fn new(value: u32) -> Flags { ... } } /// Use the interrupt line as already configured. pub const TRIGGER_NONE: Flags = Flags::new(bindings::IRQF_TRIGGER_NONE); Not a big deal, but avoiding the cast when calling bindings::request_irq is a good idea I think. With that: Reviewed-by: Alice Ryhl Alice