<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/rust/kernel/miscdevice.rs, branch v6.14</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v6.14</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v6.14'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2025-01-28T20:25:12Z</updated>
<entry>
<title>Merge tag 'driver-core-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core</title>
<updated>2025-01-28T20:25:12Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2025-01-28T20:25:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2ab002c755bfa88777e3f2db884d531f3010736c'/>
<id>urn:sha1:2ab002c755bfa88777e3f2db884d531f3010736c</id>
<content type='text'>
Pull driver core and debugfs updates from Greg KH:
 "Here is the big set of driver core and debugfs updates for 6.14-rc1.

  Included in here is a bunch of driver core, PCI, OF, and platform rust
  bindings (all acked by the different subsystem maintainers), hence the
  merge conflict with the rust tree, and some driver core api updates to
  mark things as const, which will also require some fixups due to new
  stuff coming in through other trees in this merge window.

  There are also a bunch of debugfs updates from Al, and there is at
  least one user that does have a regression with these, but Al is
  working on tracking down the fix for it. In my use (and everyone
  else's linux-next use), it does not seem like a big issue at the
  moment.

  Here's a short list of the things in here:

   - driver core rust bindings for PCI, platform, OF, and some i/o
     functions.

     We are almost at the "write a real driver in rust" stage now,
     depending on what you want to do.

   - misc device rust bindings and a sample driver to show how to use
     them

   - debugfs cleanups in the fs as well as the users of the fs api for
     places where drivers got it wrong or were unnecessarily doing
     things in complex ways.

   - driver core const work, making more of the api take const * for
     different parameters to make the rust bindings easier overall.

   - other small fixes and updates

  All of these have been in linux-next with all of the aforementioned
  merge conflicts, and the one debugfs issue, which looks to be resolved
  "soon""

* tag 'driver-core-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (95 commits)
  rust: device: Use as_char_ptr() to avoid explicit cast
  rust: device: Replace CString with CStr in property_present()
  devcoredump: Constify 'struct bin_attribute'
  devcoredump: Define 'struct bin_attribute' through macro
  rust: device: Add property_present()
  saner replacement for debugfs_rename()
  orangefs-debugfs: don't mess with -&gt;d_name
  octeontx2: don't mess with -&gt;d_parent or -&gt;d_parent-&gt;d_name
  arm_scmi: don't mess with -&gt;d_parent-&gt;d_name
  slub: don't mess with -&gt;d_name
  sof-client-ipc-flood-test: don't mess with -&gt;d_name
  qat: don't mess with -&gt;d_name
  xhci: don't mess with -&gt;d_iname
  mtu3: don't mess wiht -&gt;d_iname
  greybus/camera - stop messing with -&gt;d_iname
  mediatek: stop messing with -&gt;d_iname
  netdevsim: don't embed file_operations into your structs
  b43legacy: make use of debugfs_get_aux()
  b43: stop embedding struct file_operations into their objects
  carl9170: stop embedding file_operations into their objects
  ...
</content>
</entry>
<entry>
<title>rust: kernel: change `ForeignOwnable` pointer to mut</title>
<updated>2025-01-13T22:45:31Z</updated>
<author>
<name>Tamir Duberstein</name>
<email>tamird@gmail.com</email>
</author>
<published>2024-11-20T11:46:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=14686571a914833e38eef0f907202f58df4ffcd2'/>
<id>urn:sha1:14686571a914833e38eef0f907202f58df4ffcd2</id>
<content type='text'>
It is slightly more convenient to operate on mut pointers, and this also
properly conveys the desired ownership semantics of the trait.

Reviewed-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Reviewed-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
Signed-off-by: Tamir Duberstein &lt;tamird@gmail.com&gt;
Acked-by: Danilo Krummrich &lt;dakr@kernel.org&gt;
Link: https://lore.kernel.org/r/20241120-borrow-mut-v6-4-80dbadd00951@gmail.com
[ Reworded title slightly. - Miguel ]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
<entry>
<title>miscdevice: rust: use build_error! macro instead of function</title>
<updated>2025-01-10T12:23:57Z</updated>
<author>
<name>Alice Ryhl</name>
<email>aliceryhl@google.com</email>
</author>
<published>2025-01-10T10:14:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=bf2aa7df2687a24ebb52cec4a24443121ac3126d'/>
<id>urn:sha1:bf2aa7df2687a24ebb52cec4a24443121ac3126d</id>
<content type='text'>
The function called build_error is an implementation detail of the macro
of the same name. Thus, update miscdevice to use the macro rather than
the function. See [1] for more information on this.

These use the macro with the kernel:: prefix as it has not yet been
added to the prelude.

Reported-by: Stephen Rothwell &lt;sfr@canb.auug.org.au&gt;
Link: https://lore.kernel.org/r/20250110162828.38614c1b@canb.auug.org.au
Link: https://lore.kernel.org/all/20241123222849.350287-2-ojeda@kernel.org/ [1]
Signed-off-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Acked-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Link: https://lore.kernel.org/r/20250110101459.536726-1-aliceryhl@google.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>rust: add `build_error!` to the prelude</title>
<updated>2025-01-09T23:19:09Z</updated>
<author>
<name>Miguel Ojeda</name>
<email>ojeda@kernel.org</email>
</author>
<published>2024-11-23T22:28:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4401565fe92be6ee54a68ea58d80a4076007d5eb'/>
<id>urn:sha1:4401565fe92be6ee54a68ea58d80a4076007d5eb</id>
<content type='text'>
The sibling `build_assert!` is already in the prelude, it makes sense
that a "core"/"language" facility like this is part of the prelude and
users should not be defining their own one (thus there should be no risk
of future name collisions and we would want to be aware of them anyway).

Thus add `build_error!` into the prelude.

Reviewed-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Link: https://lore.kernel.org/r/20241123222849.350287-3-ojeda@kernel.org
[ Applied the change to the new miscdevice cases. - Miguel ]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: use the `build_error!` macro, not the hidden function</title>
<updated>2025-01-09T23:19:05Z</updated>
<author>
<name>Miguel Ojeda</name>
<email>ojeda@kernel.org</email>
</author>
<published>2024-11-23T22:28:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=15f2f9313a394f97fb9443271721e9ff1c8d4be4'/>
<id>urn:sha1:15f2f9313a394f97fb9443271721e9ff1c8d4be4</id>
<content type='text'>
Code and some examples were using the function, rather than the macro. The
macro is what is documented.

Thus move users to the macro.

Reviewed-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Link: https://lore.kernel.org/r/20241123222849.350287-1-ojeda@kernel.org
[ Applied the change to the new miscdevice cases. - Miguel ]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: map `long` to `isize` and `char` to `u8`</title>
<updated>2024-12-16T20:49:33Z</updated>
<author>
<name>Gary Guo</name>
<email>gary@garyguo.net</email>
</author>
<published>2024-09-13T21:29:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1bae8729e50a900f41e9a1c17ae81113e4cf62b8'/>
<id>urn:sha1:1bae8729e50a900f41e9a1c17ae81113e4cf62b8</id>
<content type='text'>
The following FFI types are replaced compared to `core::ffi`:

1. `char` type is now always mapped to `u8`, since kernel uses
   `-funsigned-char` on the C code. `core::ffi` maps it to platform
   default ABI, which can be either signed or unsigned.

2. `long` is now always mapped to `isize`. It's very common in the
   kernel to use `long` to represent a pointer-sized integer, and in
   fact `intptr_t` is a typedef of `long` in the kernel. Enforce this
   mapping rather than mapping to `i32/i64` depending on platform can
   save us a lot of unnecessary casts.

Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
Reviewed-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Link: https://lore.kernel.org/r/20240913213041.395655-5-gary@garyguo.net
[ Moved `uaccess` changes from the next commit, since they were
  irrefutable patterns that Rust &gt;= 1.82.0 warns about. Reworded
  slightly and reformatted a few documentation comments. Rebased on
  top of `rust-next`. Added the removal of two casts to avoid Clippy
  warnings. - Miguel ]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: finish using custom FFI integer types</title>
<updated>2024-12-16T20:48:45Z</updated>
<author>
<name>Miguel Ojeda</name>
<email>ojeda@kernel.org</email>
</author>
<published>2024-12-15T21:43:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=27c7518e7f1ccaaa43eb5f25dc362779d2dc2ccb'/>
<id>urn:sha1:27c7518e7f1ccaaa43eb5f25dc362779d2dc2ccb</id>
<content type='text'>
In the last kernel cycle we migrated most of the `core::ffi` cases in
commit d072acda4862 ("rust: use custom FFI integer types"):

    Currently FFI integer types are defined in libcore. This commit
    creates the `ffi` crate and asks bindgen to use that crate for FFI
    integer types instead of `core::ffi`.

    This commit is preparatory and no type changes are made in this
    commit yet.

Finish now the few remaining/new cases so that we perform the actual
remapping in the next commit as planned.

Acked-by: Jocelyn Falempe &lt;jfalempe@redhat.com&gt; # drm
Link: https://lore.kernel.org/rust-for-linux/CANiq72m_rg42SvZK=bF2f0yEoBLVA33UBhiAsv8THhVu=G2dPA@mail.gmail.com/
Link: https://lore.kernel.org/all/cc9253fa-9d5f-460b-9841-94948fb6580c@redhat.com/
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: miscdevice: add fops-&gt;show_fdinfo() hook</title>
<updated>2024-12-16T15:12:57Z</updated>
<author>
<name>Alice Ryhl</name>
<email>aliceryhl@google.com</email>
</author>
<published>2024-12-03T12:34:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5bcc8bfe841b29f7d62f4bb7738bb085ecc51aad'/>
<id>urn:sha1:5bcc8bfe841b29f7d62f4bb7738bb085ecc51aad</id>
<content type='text'>
File descriptors should generally provide a fops-&gt;show_fdinfo() hook for
debugging purposes. Thus, add such a hook to the miscdevice
abstractions.

Signed-off-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Link: https://lore.kernel.org/r/20241203-miscdevice-showfdinfo-v1-1-7e990732d430@google.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>rust: miscdevice: Provide accessor to pull out miscdevice::this_device</title>
<updated>2024-12-16T15:12:34Z</updated>
<author>
<name>Lee Jones</name>
<email>lee@kernel.org</email>
</author>
<published>2024-12-10T09:39:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=284ae0be4dcafff0a154c1e69e7430c144a7ddc2'/>
<id>urn:sha1:284ae0be4dcafff0a154c1e69e7430c144a7ddc2</id>
<content type='text'>
There are situations where a pointer to a `struct device` will become
necessary (e.g. for calling into dev_*() functions).  This accessor
allows callers to pull this out from the `struct miscdevice`.

Signed-off-by: Lee Jones &lt;lee@kernel.org&gt;
Signed-off-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Tested-by: Lee Jones &lt;lee@kernel.org&gt;
Reviewed-by: Danilo Krummrich &lt;dakr@kernel.org&gt;
Link: https://lore.kernel.org/r/20241210-miscdevice-file-param-v3-3-b2a79b666dc5@google.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>rust: miscdevice: access the `struct miscdevice` from fops-&gt;open()</title>
<updated>2024-12-16T15:12:30Z</updated>
<author>
<name>Alice Ryhl</name>
<email>aliceryhl@google.com</email>
</author>
<published>2024-12-10T09:39:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=88441d5c6d17211bcbd5b429205b09c25598f756'/>
<id>urn:sha1:88441d5c6d17211bcbd5b429205b09c25598f756</id>
<content type='text'>
Providing access to the underlying `struct miscdevice` is useful for
various reasons. For example, this allows you access the miscdevice's
internal `struct device` for use with the `dev_*` printing macros.

Note that since the underlying `struct miscdevice` could get freed at
any point after the fops-&gt;open() call (if misc_deregister is called),
only the open call is given access to it. To use `dev_*` printing macros
from other fops hooks, take a refcount on `miscdevice-&gt;this_device` to
keep it alive. See the linked thread for further discussion on the
lifetime of `struct miscdevice`.

Link: https://lore.kernel.org/r/2024120951-botanist-exhale-4845@gregkh
Signed-off-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Reviewed-by: Lee Jones &lt;lee@kernel.org&gt;
Tested-by: Lee Jones &lt;lee@kernel.org&gt;
Reviewed-by: Danilo Krummrich &lt;dakr@kernel.org&gt;
Link: https://lore.kernel.org/r/20241210-miscdevice-file-param-v3-2-b2a79b666dc5@google.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
