From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Hc5YGcJT" Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 283DED4F for ; Fri, 17 Nov 2023 01:39:16 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d9cb79eb417so2446323276.2 for ; Fri, 17 Nov 2023 01:39:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700213955; x=1700818755; 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=dSdTY5g6opfcl5LD544J1YVLs1Qqn6IPbTfdBkgZlAk=; b=Hc5YGcJTYsH4peBG9glkf1JKTsdn5HZ4ZRcCvkKs1p2xgByDaNB2uQZEI8rhWBFy1L BYu5u9qxAIW7KFoFyHgPyB7CDzvzlFS94JFC07KnawWPC9BEFWsBrEYubeJe6Bme0YDp RCe/f4EAkNvG5yOP/fjihCOKItJQKD/ImoKliTphIz4c18GmXv/BNC2u2yxJJT/grQUX 4VYTiLU94lzO8YnT4HKAiPzWpUq425p+hn6YkLynTJYEm7+zRdWkxs4iBezpVAuCMTcl NTmIv8s9Unmn8Pc1dob5sm9hAmb2ZHDq1E2cBXA/Q+68rIxazoZhVt8JBskbJeFWnzZ8 BMNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700213955; x=1700818755; 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=dSdTY5g6opfcl5LD544J1YVLs1Qqn6IPbTfdBkgZlAk=; b=ahsHmD+NxqVbUqj8SQ9iclLYp5V0H3eS6mUXLK09QhWNJVoVvTiO9peTLOhGwC5sj5 as9tWHWRPmQgh99+dm8DVfPUMhLV+oHFAKxMksyKNFL6eSd2hq2zh2f1qAvidl6L8AFv dzrJnurBxwgf9vG2gWkIH6O85yBWR0oo2n4wfqg2EKZDIpc2DASGb41tQXZKzRlBLyvm snl13Mt0rnTsEEhRwPbcFUWnCQRw3gePFDE8D3OIJOYMRTHXoe/BM7qewyOCleOyS0Pk 8YGsIpgBmBrXe6S/Byniak31SkQ5TXyVs+pI96zTgpvkjwxc1YwwZSzQcqCmvKkX1fwg knNw== X-Gm-Message-State: AOJu0YxCYBBSwTCvyRWJEvt6ysVCdH1KzrEQpmDUs3imSXrY5SyYe0G5 1T7pNF4wp3CF81IeD9Y/zhJthIh5nukTeRU= X-Google-Smtp-Source: AGHT+IHMFlaClkAzqBILnoa40sm3JbIfoSrk+T6eYp3aJD4yOrSyWowj0oMmpqANkG1z5PhoONy1lZlVx8ha9rM= X-Received: from aliceryhl2.c.googlers.com ([fda3:e722:ac3:cc00:68:949d:c0a8:572]) (user=aliceryhl job=sendgmr) by 2002:a5b:203:0:b0:daf:7949:52f9 with SMTP id z3-20020a5b0203000000b00daf794952f9mr432793ybl.9.1700213955416; Fri, 17 Nov 2023 01:39:15 -0800 (PST) Date: Fri, 17 Nov 2023 09:39:08 +0000 In-Reply-To: <20231026001050.1720612-3-fujita.tomonori@gmail.com> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20231026001050.1720612-3-fujita.tomonori@gmail.com> X-Mailer: git-send-email 2.43.0.rc0.421.g78406f8d94-goog Message-ID: <20231117093908.2515105-1-aliceryhl@google.com> Subject: Re: [PATCH net-next v7 2/5] rust: net::phy add module_phy_driver macro From: Alice Ryhl To: fujita.tomonori@gmail.com Cc: andrew@lunn.ch, benno.lossin@proton.me, miguel.ojeda.sandonis@gmail.com, netdev@vger.kernel.org, rust-for-linux@vger.kernel.org, tmgross@umich.edu, wedsonaf@gmail.com, Alice Ryhl Content-Type: text/plain; charset="utf-8" FUJITA Tomonori writes: > This macro creates an array of kernel's `struct phy_driver` and > registers it. This also corresponds to the kernel's > `MODULE_DEVICE_TABLE` macro, which embeds the information for module > loading into the module binary file. > > A PHY driver should use this macro. > > Signed-off-by: FUJITA Tomonori Reviewed-by: Alice Ryhl A few minor nits: > + (drivers: [$($driver:ident),+], device_table: [$($dev:expr),+], $($f:tt)*) => { Here, you can add $(,)? to allow trailing commas when the macro is used. Like this: (drivers: [$($driver:ident),+ $(,)?], device_table: [$($dev:expr),+ $(,)?], $($f:tt)*) => { > + ::kernel::bindings::mdio_device_id { Here, I recommend `$crate` instead of `::kernel`. > +/// #[no_mangle] > +/// static __mod_mdio__phydev_device_table: [::kernel::bindings::mdio_device_id; 2] = [ > +/// ::kernel::bindings::mdio_device_id { > +/// phy_id: 0x003b1861, > +/// phy_id_mask: 0xffffffff, > +/// }, > +/// ::kernel::bindings::mdio_device_id { > +/// phy_id: 0, > +/// phy_id_mask: 0, > +/// }, > +/// ]; I'd probably put a safety comment on the `#[no_mangle]` invocation to say that "C will not read off the end of this constant since the last element is zero". Alice