Skip to contentSkip to conversation

Modifying a driver on native Linux - which file should I modify?

DISCUSSION Edith Puclla 3 participants 4 messages Mar 31, 2021 – Apr 1, 2021

lore
Share & tools
lore
#0 lore raw

Hello Everyone, I am Edith from Peru, and I started to compile the Linux kernel.

I am following this
guide: https://kernelnewbies.org/Outreachyfirstpatch?action=show&redirect=OPWfirstpatch#kernel-setup-done
*Section*: Modifying a driver on native Linux

I chose to modify this driver: *xhci-hcd* but I can't find the file to add a print printk(KERN_DEBUG "I can modify the Linux kernel!\n").

I look at all the files located in the same path of the Makefile after
executing: git grep xhci-hcd -- '*Makefile'

Could you please tell me which file could I modify for that driver?

Thank you in advance!

Edith

#1 lore raw
Quoted 7 lines · Edith Puclla

Hello Everyone, I am Edith from Peru, and I started to compile the Linux kernel.

I am following this
guide: https://kernelnewbies.org/Outreachyfirstpatch?action=show&redirect=OPWfirstpatch#kernel-setup-done
*Section*: Modifying a driver on native Linux

Quoted 7 lines

I chose to modify this driver: *xhci-hcd* but I can't find the file to add a print printk(KERN_DEBUG "I can modify the Linux kernel!\n").

I look at all the files located in the same path of the Makefile after
executing: git grep xhci-hcd -- '*Makefile'

Could you please tell me which file could I modify for that driver?

The Linux Makefiles are written in a rather terse way that isn't necessarily the easiest to understand for someone who's not familiar with them.

$ git grep xhci-hcd -- '*Makefile'
drivers/usb/host/Makefile:xhci-hcd-y := xhci.o xhci-mem.o xhci-ext-caps.o
drivers/usb/host/Makefile:xhci-hcd-y += xhci-ring.o xhci-hub.o xhci-dbg.o
drivers/usb/host/Makefile:xhci-hcd-y += xhci-trace.o
drivers/usb/host/Makefile:      xhci-hcd-y += xhci-dbgcap.o xhci-dbgtty.o
drivers/usb/host/Makefile:      xhci-hcd-y              += xhci-debugfs.o
drivers/usb/host/Makefile:obj-$(CONFIG_USB_XHCI_HCD)    += xhci-hcd.o

'xhci-hcd-y' is the list of .o files which make up the final link step to make xhci-hcd.o. Is that enough information for you to figure out which file to modify?

(I'm trying to get you past the immediate problem you're hitting, which isn't terribly important, without just giving you the answer)

The other thing you can do is build the kernel with 'make V=1', which tells you what the build system is doing instead of the shortened output.

#2 lore raw

Thank you, what I understand is that I could modify xhci.c for example, adding a printk, the idea is to add a change, compile the kernel and then reset the changes. Is what I understand form the tutorial, let me know if I am wrong.

Quoted 40 lines · Matthew Wilcox
Quoted 5 lines · Edith Puclla

Hello Everyone, I am Edith from Peru, and I started to compile the Linux kernel.

I am following this
guide:

https://kernelnewbies.org/Outreachyfirstpatch?action=show&redirect=OPWfirstpatch#kernel-setup-done

Quoted 3 lines

*Section*: Modifying a driver on native Linux

I chose to modify this driver: *xhci-hcd* but I can't find the file to

add

Quoted 6 lines

a print printk(KERN_DEBUG "I can modify the Linux kernel!\n").

I look at all the files located in the same path of the Makefile after
executing: git grep xhci-hcd -- '*Makefile'

Could you please tell me which file could I modify for that driver?

The Linux Makefiles are written in a rather terse way that isn't necessarily the easiest to understand for someone who's not familiar with them.

$ git grep xhci-hcd -- '*Makefile'
drivers/usb/host/Makefile:xhci-hcd-y := xhci.o xhci-mem.o xhci-ext-caps.o
drivers/usb/host/Makefile:xhci-hcd-y += xhci-ring.o xhci-hub.o xhci-dbg.o
drivers/usb/host/Makefile:xhci-hcd-y += xhci-trace.o
drivers/usb/host/Makefile: xhci-hcd-y += xhci-dbgcap.o xhci-dbgtty.o
drivers/usb/host/Makefile: xhci-hcd-y += xhci-debugfs.o
drivers/usb/host/Makefile:obj-$(CONFIG_USB_XHCI_HCD) += xhci-hcd.o

'xhci-hcd-y' is the list of .o files which make up the final link step to make xhci-hcd.o. Is that enough information for you to figure out which file to modify?

(I'm trying to get you past the immediate problem you're hitting, which isn't terribly important, without just giving you the answer)

The other thing you can do is build the kernel with 'make V=1', which tells you what the build system is doing instead of the shortened output.

#3 lore raw
Quoted 4 lines · Edith Puclla

Thank you, what I understand is that I could modify xhci.c for example, adding a  printk, the idea is to add a change, compile the kernel and then reset the changes. Is what I understand form the tutorial, let me know if I am wrong.

Please do not top post. Put your comment under the comment you are replying to, so that the person looking at the message can understand the context.

julia

Quoted 64 lines

El martes, 30 de marzo de 2021 a las 23:49:03 UTC-5, Matthew Wilcox escribió:
On Tue, Mar 30, 2021 at 09:37:15PM -0700, Edith Puclla wrote:
> Hello Everyone, I am Edith from Peru, and I started to compile
the Linux
> kernel.
>
> I am following this
> guide:https://kernelnewbies.org/Outreachyfirstpatch?action=show&redirect=OPWfirst patch#kernel-setup-done
> *Section*: Modifying a driver on native Linux
>
> I chose to modify this driver: *xhci-hcd* but I can't find the
file to add
> a print printk(KERN_DEBUG "I can modify the Linux kernel!\n").
>
> I look at all the files located in the same path of the
Makefile after
> executing: git grep xhci-hcd -- '*Makefile'
>
> Could you please tell me which file could I modify for that
driver?

The Linux Makefiles are written in a rather terse way that isn't necessarily the easiest to understand for someone who's not familiar
with them.

$ git grep xhci-hcd -- '*Makefile' drivers/usb/host/Makefile:xhci-hcd-y := xhci.o xhci-mem.o xhci-ext-caps.o drivers/usb/host/Makefile:xhci-hcd-y += xhci-ring.o xhci-hub.o xhci-dbg.o
drivers/usb/host/Makefile:xhci-hcd-y += xhci-trace.o drivers/usb/host/Makefile: xhci-hcd-y += xhci-dbgcap.o xhci-dbgtty.o
drivers/usb/host/Makefile: xhci-hcd-y += xhci-debugfs.o drivers/usb/host/Makefile:obj-$(CONFIG_USB_XHCI_HCD) += xhci-hcd.o

'xhci-hcd-y' is the list of .o files which make up the final link step
to make xhci-hcd.o. Is that enough information for you to figure out
which file to modify?

(I'm trying to get you past the immediate problem you're hitting, which
isn't terribly important, without just giving you the answer)

The other thing you can do is build the kernel with 'make V=1', which tells
you what the build system is doing instead of the shortened output.

--
You received this message because you are subscribed to the Google Groups
"outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/6f63edb0-7bf7-442e-8027- 04df9e7d6e58n%40googlegroups.com.