Re: [PATCH v1 1/3] driver core: Split device data types to device/types.h
From: Andy Shevchenko
Date: Tue Feb 24 2026 - 09:02:04 EST
On Tue, Feb 24, 2026 at 01:21:10PM +0100, Rafael J. Wysocki wrote:
> On Tue, Feb 24, 2026 at 10:05 AM Andy Shevchenko
> <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> > On Mon, Feb 23, 2026 at 09:53:17PM +0100, Rafael J. Wysocki wrote:
> > > On Mon, Feb 23, 2026 at 9:44 PM Andy Shevchenko
> > > <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> > > >
> > > > device.h is a huge header which is hard to follow and easy to miss
> > > > something. Improve that by splitting device data types to device/types.h.
> > > >
> > > > In particular this helps to speedup the build of the code that includes
> > > > device.h solely for a device data types.
> > > >
> > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> > >
> > > But why do you want to move the struct device definition out of device.h?
> >
> > Because it's a data type, and we have many drivers that may require it
> > (embed the struct device), but no device.h API is called directly —
> > only via a certain framework).
> >
> > device.h also includes many unrelated headers in such a case.
>
> Why is this a problem?
>
> Could those headers be moved to different header files instead?
>
> device.h is mostly about the struct device definition and the other
> stuff in it is more or less additional. Why do you want to make it
> the other way around?
It's a common trend in the kernel to split out _types.h and _api.h
(among possibly others). I follow this trend with a correction on
the folder versus prefix. That's why device/types.h.
$ git diff $A..$B --diff-filter=A --name-only -- include/ | grep _types.h
In v6.19:
include/linux/fs/super_types.h
include/linux/irq_work_types.h
include/linux/ns/ns_common_types.h
include/linux/ns/nstree_types.h
include/linux/rseq_types.h
In v6.17:
include/linux/unwind_deferred_types.h
include/linux/unwind_user_types.h
In v6.15
include/linux/resctrl_types.h
In v6.11
include/linux/cpumask_types.h
In v6.8
include/linux/hrtimer_types.h
include/linux/irqflags_types.h
include/linux/mutex_types.h
include/linux/nodemask_types.h
include/linux/pid_types.h
include/linux/plist_types.h
include/linux/posix-timers_types.h
include/linux/refcount_types.h
include/linux/seccomp_types.h
include/linux/sem_types.h
include/linux/seqlock_types.h
include/linux/syscall_user_dispatch_types.h
include/linux/timer_types.h
include/linux/timerqueue_types.h
include/linux/uidgid_types.h
include/linux/workqueue_types.h
In v6.4
include/linux/objtool_types.h
In v6.1
include/linux/cfi_types.h
include/linux/kmsan_types.h
In v6.0
include/linux/gfp_types.h
include/linux/io_uring_types.h
--
With Best Regards,
Andy Shevchenko