]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
Merge tag 'driver-core-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 28 Jan 2025 20:25:12 +0000 (12:25 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 28 Jan 2025 20:25:12 +0000 (12:25 -0800)
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 ->d_name
  octeontx2: don't mess with ->d_parent or ->d_parent->d_name
  arm_scmi: don't mess with ->d_parent->d_name
  slub: don't mess with ->d_name
  sof-client-ipc-flood-test: don't mess with ->d_name
  qat: don't mess with ->d_name
  xhci: don't mess with ->d_iname
  mtu3: don't mess wiht ->d_iname
  greybus/camera - stop messing with ->d_iname
  mediatek: stop messing with ->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
  ...

29 files changed:
1  2 
Documentation/userspace-api/ioctl/ioctl-number.rst
MAINTAINERS
arch/powerpc/platforms/powernv/opal.c
drivers/block/sunvdc.c
drivers/gpu/drm/mediatek/mtk_drm_drv.c
drivers/hwmon/hwmon.c
drivers/i2c/i2c-core-base.c
drivers/leds/leds-turris-omnia.c
drivers/media/pci/mgb4/mgb4_core.c
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/of/unittest-data/tests-platform.dtsi
drivers/pwm/core.c
drivers/scsi/qla4xxx/ql4_os.c
drivers/scsi/scsi_transport_iscsi.c
drivers/tty/serial/serial_core.c
drivers/usb/mtu3/mtu3_debugfs.c
drivers/usb/typec/class.c
include/linux/device/bus.h
include/scsi/scsi_transport_iscsi.h
kernel/bpf/btf.c
kernel/module/sysfs.c
mm/slub.c
net/mac80211/debugfs_netdev.c
net/wireless/core.c
rust/kernel/device.rs
rust/kernel/lib.rs
rust/kernel/miscdevice.rs
rust/kernel/sync.rs
rust/kernel/types.rs

diff --cc MAINTAINERS
Simple merge
Simple merge
Simple merge
Simple merge
index c24ccefb015ee2310dd41f4e5c967ff373b8e665,7c810893bfa332721d242f6c4a83f6217f22a6fc..e2c2a2ef1c12c36fa9f94bb219c5df85af273841
@@@ -1310,15 -1308,6 +1310,15 @@@ new_device_store(struct device *dev, st
  }
  static DEVICE_ATTR_WO(new_device);
  
- static int __i2c_find_user_addr(struct device *dev, void *addrp)
++static int __i2c_find_user_addr(struct device *dev, const void *addrp)
 +{
 +      struct i2c_client *client = i2c_verify_client(dev);
 +      unsigned short addr = *(unsigned short *)addrp;
 +
 +      return client && client->flags & I2C_CLIENT_USER &&
 +             i2c_encode_flags_to_addr(client) == addr;
 +}
 +
  /*
   * And of course let the users delete the devices they instantiated, if
   * they got it wrong. This interface can only be used to delete devices
index 7d3b24c8ecae548640f6722f848dd7f2d9d43b8a,2de825ac08b3d7470f06ba4102b19897a8e68aa5..4fe1a9c0bc1ba3158ab4e3d077c6c65782eddb31
@@@ -435,34 -445,7 +435,34 @@@ static int omnia_mcu_get_features(cons
        if (err)
                return err;
  
 -      return le16_to_cpu(reply);
 +      return reply;
 +}
 +
- static int omnia_match_mcu_client(struct device *dev, void *data)
++static int omnia_match_mcu_client(struct device *dev, const void *data)
 +{
 +      struct i2c_client *client;
 +
 +      client = i2c_verify_client(dev);
 +      if (!client)
 +              return 0;
 +
 +      return client->addr == OMNIA_MCU_I2C_ADDR;
 +}
 +
 +static int omnia_find_mcu_and_get_features(struct device *dev)
 +{
 +      struct device *mcu_dev;
 +      int ret;
 +
 +      mcu_dev = device_find_child(dev->parent, NULL, omnia_match_mcu_client);
 +      if (!mcu_dev)
 +              return -ENODEV;
 +
 +      ret = omnia_mcu_get_features(i2c_verify_client(mcu_dev));
 +
 +      put_device(mcu_dev);
 +
 +      return ret;
  }
  
  static int omnia_leds_probe(struct i2c_client *client)
Simple merge
index cd310b26b50c811dbfe3526cf8994d18f9926aa8,2caaf1c10ee6f86dedfdc250bdebb655fe1ffe46..4171f43cf01cc7ded1a7ac2ad71afee1030248ef
                                        reg = <0x100>;
                                };
                        };
+                       test-device@2 {
+                               compatible = "test,rust-device";
+                               reg = <0x2>;
+                       };
                };
 +
 +              platform-tests-2 {
 +                      // No #address-cells or #size-cells
 +                      node {
 +                              #address-cells = <1>;
 +                              #size-cells = <1>;
 +
 +                              test-device@100 {
 +                                      compatible = "test-sub-device";
 +                                      reg = <0x100 1>;
 +                              };
 +                      };
 +              };
        };
  };
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index f99616499e2e054c9c6f62ecc51d4b2c06a5b7eb,254017b58b645d4afcf6876d29bcc2e2113a8dc4..b401ff4b02d2904d3b5fca93e10e188ddcbaf787
@@@ -190,8 -196,8 +190,8 @@@ static int add_notes_attrs(struct modul
                        nattr->attr.mode = 0444;
                        nattr->size = info->sechdrs[i].sh_size;
                        nattr->private = (void *)info->sechdrs[i].sh_addr;
-                       nattr->read = sysfs_bin_attr_simple_read;
+                       nattr->read_new = sysfs_bin_attr_simple_read;
 -                      ++nattr;
 +                      *(gattr++) = nattr++;
                }
                ++loaded;
        }
diff --cc mm/slub.c
Simple merge
Simple merge
Simple merge
Simple merge
index 545d1170ee6358e185b48ce10493fc61c646155c,b11fa08de3c0f41d2e6ae18d91c41149287aa024..496ed32b0911a9fdbce5d26738b9cf7ef910b269
  
  #![no_std]
  #![feature(arbitrary_self_types)]
 -#![feature(coerce_unsized)]
 -#![feature(dispatch_from_dyn)]
 +#![cfg_attr(CONFIG_RUSTC_HAS_COERCE_POINTEE, feature(derive_coerce_pointee))]
 +#![cfg_attr(not(CONFIG_RUSTC_HAS_COERCE_POINTEE), feature(coerce_unsized))]
 +#![cfg_attr(not(CONFIG_RUSTC_HAS_COERCE_POINTEE), feature(dispatch_from_dyn))]
 +#![cfg_attr(not(CONFIG_RUSTC_HAS_COERCE_POINTEE), feature(unsize))]
  #![feature(inline_const)]
  #![feature(lint_reasons)]
 -#![feature(unsize)]
+ // Stable in Rust 1.83
+ #![feature(const_maybe_uninit_as_mut_ptr)]
+ #![feature(const_mut_refs)]
+ #![feature(const_ptr_write)]
+ #![feature(const_refs_to_cell)]
  
  // Ensure conditional compilation based on the kernel configuration works;
  // otherwise we may silently break things like initcall handling.
@@@ -33,10 -37,12 +38,13 @@@ pub use ffi
  pub mod alloc;
  #[cfg(CONFIG_BLOCK)]
  pub mod block;
 -mod build_assert;
 +#[doc(hidden)]
 +pub mod build_assert;
  pub mod cred;
  pub mod device;
+ pub mod device_id;
+ pub mod devres;
+ pub mod driver;
  pub mod error;
  #[cfg(CONFIG_RUST_FW_LOADER_ABSTRACTIONS)]
  pub mod firmware;
index b3a6cc50b240e9373a7d4e9959fabb42235a794f,dfb363630c70b7187cae91f692d38bcf42d56a0a..e14433b2ab9d8fa391474b2ad7e3ed55c64b4d91
  
  use crate::{
      bindings,
+     device::Device,
      error::{to_result, Error, Result, VTABLE_DEFAULT_ERROR},
 +    ffi::{c_int, c_long, c_uint, c_ulong},
+     fs::File,
      prelude::*,
+     seq_file::SeqFile,
      str::CStr,
      types::{ForeignOwnable, Opaque},
  };
@@@ -132,8 -151,17 +147,17 @@@ pub trait MiscDevice: Sized 
          _cmd: u32,
          _arg: usize,
      ) -> Result<isize> {
 -        kernel::build_error!(VTABLE_DEFAULT_ERROR)
 +        build_error!(VTABLE_DEFAULT_ERROR)
      }
 -        kernel::build_error!(VTABLE_DEFAULT_ERROR)
+     /// Show info for this fd.
+     fn show_fdinfo(
+         _device: <Self::Ptr as ForeignOwnable>::Borrowed<'_>,
+         _m: &SeqFile,
+         _file: &File,
+     ) {
++        build_error!(VTABLE_DEFAULT_ERROR)
+     }
  }
  
  const fn create_vtable<T: MiscDevice>() -> &'static bindings::file_operations {
@@@ -188,8 -230,12 +226,12 @@@ unsafe extern "C" fn fops_open<T: MiscD
          Err(err) => return err.to_errno(),
      };
  
-     // SAFETY: The open call of a file owns the private data.
-     unsafe { (*file).private_data = ptr.into_foreign() };
+     // This overwrites the private data with the value specified by the user, changing the type of
+     // this file's private data. All future accesses to the private data is performed by other
+     // fops_* methods in this file, which all correctly cast the private data to the new type.
+     //
+     // SAFETY: The open call of a file can access the private data.
 -    unsafe { (*raw_file).private_data = ptr.into_foreign().cast_mut() };
++    unsafe { (*raw_file).private_data = ptr.into_foreign() };
  
      0
  }
@@@ -225,7 -274,12 +270,12 @@@ unsafe extern "C" fn fops_ioctl<T: Misc
      // SAFETY: Ioctl calls can borrow the private data of the file.
      let device = unsafe { <T::Ptr as ForeignOwnable>::borrow(private) };
  
-     match T::ioctl(device, cmd, arg) {
+     // SAFETY:
+     // * The file is valid for the duration of this call.
+     // * There is no active fdget_pos region on the file on this thread.
+     let file = unsafe { File::from_raw_file(file) };
 -    match T::ioctl(device, file, cmd, arg as usize) {
++    match T::ioctl(device, file, cmd, arg) {
          Ok(ret) => ret as c_long,
          Err(err) => err.to_errno() as c_long,
      }
@@@ -245,7 -299,12 +295,12 @@@ unsafe extern "C" fn fops_compat_ioctl<
      // SAFETY: Ioctl calls can borrow the private data of the file.
      let device = unsafe { <T::Ptr as ForeignOwnable>::borrow(private) };
  
-     match T::compat_ioctl(device, cmd, arg) {
+     // SAFETY:
+     // * The file is valid for the duration of this call.
+     // * There is no active fdget_pos region on the file on this thread.
+     let file = unsafe { File::from_raw_file(file) };
 -    match T::compat_ioctl(device, file, cmd, arg as usize) {
++    match T::compat_ioctl(device, file, cmd, arg) {
          Ok(ret) => ret as c_long,
          Err(err) => err.to_errno() as c_long,
      }
Simple merge
Simple merge