public inbox for kernelnewbies@kernelnewbies.org
 help / color / mirror / Atom feed
* Build mainline driver for another Kernel Version
@ 2023-05-17  8:16 Lucas Tanure
  2023-05-17  8:22 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Lucas Tanure @ 2023-05-17  8:16 UTC (permalink / raw)
  To: kernelnewbies

Hi,

Can I build a driver in the mainline kernel to a previous kernel version?

Like, in the mainline kernel, I have a Z driver, and I want to use
that driver for my current stable driver in my embedded system with
version kernel 5.15. Is there a procedure to build a kernel driver
against other specific kernel headers?

Thanks
Lucas

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Build mainline driver for another Kernel Version
  2023-05-17  8:16 Build mainline driver for another Kernel Version Lucas Tanure
@ 2023-05-17  8:22 ` Greg KH
  2023-05-17  8:47   ` Lucas Tanure
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2023-05-17  8:22 UTC (permalink / raw)
  To: Lucas Tanure; +Cc: kernelnewbies

On Wed, May 17, 2023 at 09:16:45AM +0100, Lucas Tanure wrote:
> Hi,
> 
> Can I build a driver in the mainline kernel to a previous kernel version?

Not easily, and you really do not want to do that as the whole kernel
source, drivers included, are a snapshot in time and depend on each
other.

> Like, in the mainline kernel, I have a Z driver, and I want to use
> that driver for my current stable driver in my embedded system with
> version kernel 5.15. Is there a procedure to build a kernel driver
> against other specific kernel headers?

Update to a newer kernel version, it will be much easier and simpler
overall.

Drivers consume _everything_ from the core kernel, and are not
stand-alone at all.  They depend on everything else, trying to pick one
out and put it into a different kernel is not how Linux works at all,
sorry.

What prevents you from just using a newer kernel?

thanks,

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Build mainline driver for another Kernel Version
  2023-05-17  8:22 ` Greg KH
@ 2023-05-17  8:47   ` Lucas Tanure
  2023-05-17  8:56     ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Lucas Tanure @ 2023-05-17  8:47 UTC (permalink / raw)
  To: Greg KH; +Cc: kernelnewbies

On Wed, May 17, 2023 at 9:22 AM Greg KH <greg@kroah.com> wrote:
>
> On Wed, May 17, 2023 at 09:16:45AM +0100, Lucas Tanure wrote:
> > Hi,
> >
> > Can I build a driver in the mainline kernel to a previous kernel version?
>
> Not easily, and you really do not want to do that as the whole kernel
> source, drivers included, are a snapshot in time and depend on each
> other.
>
> > Like, in the mainline kernel, I have a Z driver, and I want to use
> > that driver for my current stable driver in my embedded system with
> > version kernel 5.15. Is there a procedure to build a kernel driver
> > against other specific kernel headers?
>
> Update to a newer kernel version, it will be much easier and simpler
> overall.
>
> Drivers consume _everything_ from the core kernel, and are not
> stand-alone at all.  They depend on everything else, trying to pick one
> out and put it into a different kernel is not how Linux works at all,
> sorry.
>
> What prevents you from just using a newer kernel?
>
> thanks,
>
> greg k-h

It's not me or my team; it's every client for the company I work for
that uses different kernel versions.
And I am investigating how we can upstream our driver in the future
and provide our driver to all customers having to support many
different kernel versions.

I think the only way is to have a few kernel branches with different
kernel versions, but our driver is updated in those branches.
Any better idea?

Thanks!
Lucas

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Build mainline driver for another Kernel Version
  2023-05-17  8:47   ` Lucas Tanure
@ 2023-05-17  8:56     ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2023-05-17  8:56 UTC (permalink / raw)
  To: Lucas Tanure; +Cc: kernelnewbies

On Wed, May 17, 2023 at 09:47:21AM +0100, Lucas Tanure wrote:
> On Wed, May 17, 2023 at 9:22 AM Greg KH <greg@kroah.com> wrote:
> >
> > On Wed, May 17, 2023 at 09:16:45AM +0100, Lucas Tanure wrote:
> > > Hi,
> > >
> > > Can I build a driver in the mainline kernel to a previous kernel version?
> >
> > Not easily, and you really do not want to do that as the whole kernel
> > source, drivers included, are a snapshot in time and depend on each
> > other.
> >
> > > Like, in the mainline kernel, I have a Z driver, and I want to use
> > > that driver for my current stable driver in my embedded system with
> > > version kernel 5.15. Is there a procedure to build a kernel driver
> > > against other specific kernel headers?
> >
> > Update to a newer kernel version, it will be much easier and simpler
> > overall.
> >
> > Drivers consume _everything_ from the core kernel, and are not
> > stand-alone at all.  They depend on everything else, trying to pick one
> > out and put it into a different kernel is not how Linux works at all,
> > sorry.
> >
> > What prevents you from just using a newer kernel?
> >
> > thanks,
> >
> > greg k-h
> 
> It's not me or my team; it's every client for the company I work for
> that uses different kernel versions.

Then get the driver code merged upstream so that it is present in all
kernel versions.

> And I am investigating how we can upstream our driver in the future
> and provide our driver to all customers having to support many
> different kernel versions.

Yes, that is the correct solution.

> I think the only way is to have a few kernel branches with different
> kernel versions, but our driver is updated in those branches.
> Any better idea?

Get your code upstream :)


You can create a stand-alone driver, that attempts to work for all
kernel versions (or a limited set of versions), with proper use of
macros and #ifdef in .h files.  But it's a lot of work and energy and
waste of time.  It's cheaper and faster overall to get your code merged
upstream so you don't have to do any of that at all, as that is the
proper solution for what Linux expects.

And again, it saves you money, which is a good thing to tell your
manager.

thanks,

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-17  8:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-17  8:16 Build mainline driver for another Kernel Version Lucas Tanure
2023-05-17  8:22 ` Greg KH
2023-05-17  8:47   ` Lucas Tanure
2023-05-17  8:56     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox