Skip to contentSkip to conversation

Clean-up idea: IIO Headers

DISCUSSION Alison Schofield 2 participants 6 messages Feb 25, 2017 – Feb 27, 2017

lore
Share & tools
lore
#0 lore raw

Hi Outreachy Applicants,

Here is a clean-up task for staging/iio you might like to try.

Staging IIO Header file (re-)organization:

Guidelines to follow:

(Reference https://kernelnewbies.org/KernelHeaders)

Three cases you may find:
1) If it's a single source file, its header info should be in that source file. *** Do this!

2) Interfaces between source files in a single module can have a header file in same dir as the source files.
*** Leave this alone.

3) Interfaces shared between modules go in a header file in include/linux/iio *** Leave this alone. We will do this when the driver is moving out of staging

Here's an example patchset:
https://groups.google.com/forum/#!searchin/outreachy-kernel/header$20file$20ad5933%7Csort:relevance/outreachy-kernel/THYpgGyOgsI/iz8lrqwfDAAJ

Note that when you pull the header file in, there's a customary order to it that the drivers in staging may not be following. In the example one above, I moved the #defines to be before the chip structure definitions. So, you'll do best if you look at similar drivers in the same directory upstream, to see how they order their header information. Always good to look at a few, because one may not be the perfect role model.

It is customary to alphabetize the #includes, and to separate the kernel and IIO subsystem #includes with a blank line. So, although we wouldn't send in a patch just to alphabetize #includes, while you are moving them to the .c file, and while you are checking that they are actually needed, sure - go ahead and alphabetize them. (Example patch didn't alphabetize, you'll do better ;)

To verify the patch(set), I'd suggest applying it to a clean tree and rebuilding.

Questions? Just ask on this thread.

alisons

#1 lore raw
Quoted 25 lines · Alison Schofield

Hi Outreachy Applicants,

Here is a clean-up task for staging/iio you might like to try.

Staging IIO Header file (re-)organization:

Guidelines to follow:

(Reference https://kernelnewbies.org/KernelHeaders)

Three cases you may find:
1) If it's a single source file, its header info should be in that source file. *** Do this!

2) Interfaces between source files in a single module can have a header file in same dir as the source files.
*** Leave this alone.

3) Interfaces shared between modules go in a header file in include/linux/iio *** Leave this alone. We will do this when the driver is moving out of staging

Here's an example patchset:
https://groups.google.com/forum/#!searchin/outreachy-kernel/header$20file$20ad5933%7Csort:relevance/outreachy-kernel/THYpgGyOgsI/iz8lrqwfDAAJ

Quoted 6 lines

Note that when you pull the header file in, there's a customary order to it that the drivers in staging may not be following. In the example one above, I moved the #defines to be before the chip structure definitions. So, you'll do best if you look at similar drivers in the same directory upstream, to see how they order their header information. Always good to look at a few, because one may not be the perfect role model.

Hi Alison,

I noticed in looking at the iio/accel driver upstream, there are no comments around register definitions. In the staging driver, all of the header files I've looked at have a comment for each definition. Are comments something that should be pushed forward? Even though the register names are descriptive, it seems wrong to take out comments.

Best,
Katie

Quoted 21 lines

It is customary to alphabetize the #includes, and to separate the kernel and IIO subsystem #includes with a blank line. So, although we wouldn't send in a patch just to alphabetize #includes, while you are moving them to the .c file, and while you are checking that they are actually needed, sure - go ahead and alphabetize them. (Example patch didn't alphabetize, you'll do better ;)

To verify the patch(set), I'd suggest applying it to a clean tree and rebuilding.

Questions? Just ask on this thread.

alisons

Signature · 5 lines
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 post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170225014231.GA3395%40d830.WORKGROUP.
For more options, visit https://groups.google.com/d/optout.
#2 lore raw
Quoted 35 lines · Katie Dunne
Quoted 25 lines · Alison Schofield

Hi Outreachy Applicants,

Here is a clean-up task for staging/iio you might like to try.

Staging IIO Header file (re-)organization:

Guidelines to follow:

(Reference https://kernelnewbies.org/KernelHeaders)

Three cases you may find:
1) If it's a single source file, its header info should be in that source file. *** Do this!

2) Interfaces between source files in a single module can have a header file in same dir as the source files.
*** Leave this alone.

3) Interfaces shared between modules go in a header file in include/linux/iio *** Leave this alone. We will do this when the driver is moving out of staging

Here's an example patchset:
https://groups.google.com/forum/#!searchin/outreachy-kernel/header$20file$20ad5933%7Csort:relevance/outreachy-kernel/THYpgGyOgsI/iz8lrqwfDAAJ

Quoted 6 lines

Note that when you pull the header file in, there's a customary order to it that the drivers in staging may not be following. In the example one above, I moved the #defines to be before the chip structure definitions. So, you'll do best if you look at similar drivers in the same directory upstream, to see how they order their header information. Always good to look at a few, because one may not be the perfect role model.

Hi Alison,

Quoted 9 lines

I noticed in looking at the iio/accel driver upstream, there are no comments around register definitions. In the staging driver, all of the header files I've looked at have a comment for each definition. Are comments something that should be pushed forward? Even though the register names are descriptive, it seems wrong to take out comments.

Best,
Katie

Thanks for pointing that out Katie.
You are right. Let's not remove any comments in the reorg. Caveat - if they are poorly aligned/spelled/formatted as you move them, then you have another patch in your set to correct that!

alisons

Quoted 21 lines
Quoted 21 lines

It is customary to alphabetize the #includes, and to separate the kernel and IIO subsystem #includes with a blank line. So, although we wouldn't send in a patch just to alphabetize #includes, while you are moving them to the .c file, and while you are checking that they are actually needed, sure - go ahead and alphabetize them. (Example patch didn't alphabetize, you'll do better ;)

To verify the patch(set), I'd suggest applying it to a clean tree and rebuilding.

Questions? Just ask on this thread.

alisons

Signature · 5 lines
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 post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170225014231.GA3395%40d830.WORKGROUP.
For more options, visit https://groups.google.com/d/optout.
#3 lore raw
Quoted 45 lines · Alison Schofield
Quoted 35 lines · Katie Dunne
Quoted 25 lines · Alison Schofield

Hi Outreachy Applicants,

Here is a clean-up task for staging/iio you might like to try.

Staging IIO Header file (re-)organization:

Guidelines to follow:

(Reference https://kernelnewbies.org/KernelHeaders)

Three cases you may find:
1) If it's a single source file, its header info should be in that source file. *** Do this!

2) Interfaces between source files in a single module can have a header file in same dir as the source files.
*** Leave this alone.

3) Interfaces shared between modules go in a header file in include/linux/iio *** Leave this alone. We will do this when the driver is moving out of staging

Here's an example patchset:
https://groups.google.com/forum/#!searchin/outreachy-kernel/header$20file$20ad5933%7Csort:relevance/outreachy-kernel/THYpgGyOgsI/iz8lrqwfDAAJ

Quoted 6 lines

Note that when you pull the header file in, there's a customary order to it that the drivers in staging may not be following. In the example one above, I moved the #defines to be before the chip structure definitions. So, you'll do best if you look at similar drivers in the same directory upstream, to see how they order their header information. Always good to look at a few, because one may not be the perfect role model.

Hi Alison,

Quoted 9 lines

I noticed in looking at the iio/accel driver upstream, there are no comments around register definitions. In the staging driver, all of the header files I've looked at have a comment for each definition. Are comments something that should be pushed forward? Even though the register names are descriptive, it seems wrong to take out comments.

Best,
Katie

Quoted 7 lines

Thanks for pointing that out Katie.
You are right. Let's not remove any comments in the reorg. Caveat - if they are poorly aligned/spelled/formatted as you move them, then you have another patch in your set to correct that!

alisons

I also notice you deleted an unnecessary include (asm/div64). How do you find unused includes? What I have found online is that no tools work perfectly, and the best solutions are scripts that remove one include at time and compile at each step, which sounds terrible.

Katie

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines

It is customary to alphabetize the #includes, and to separate the kernel and IIO subsystem #includes with a blank line. So, although we wouldn't send in a patch just to alphabetize #includes, while you are moving them to the .c file, and while you are checking that they are actually needed, sure - go ahead and alphabetize them. (Example patch didn't alphabetize, you'll do better ;)

To verify the patch(set), I'd suggest applying it to a clean tree and rebuilding.

Questions? Just ask on this thread.

alisons

Signature · 5 lines
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 post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170225014231.GA3395%40d830.WORKGROUP.
For more options, visit https://groups.google.com/d/optout.
#4 lore raw
Quoted 51 lines · Katie Dunne
Quoted 50 lines · Alison Schofield
Quoted 35 lines · Katie Dunne
Quoted 25 lines · Alison Schofield

Hi Outreachy Applicants,

Here is a clean-up task for staging/iio you might like to try.

Staging IIO Header file (re-)organization:

Guidelines to follow:

(Reference https://kernelnewbies.org/KernelHeaders)

Three cases you may find:
1) If it's a single source file, its header info should be in that source file. *** Do this!

2) Interfaces between source files in a single module can have a header file in same dir as the source files.
*** Leave this alone.

3) Interfaces shared between modules go in a header file in include/linux/iio *** Leave this alone. We will do this when the driver is moving out of staging

Here's an example patchset:
https://groups.google.com/forum/#!searchin/outreachy-kernel/header$20file$20ad5933%7Csort:relevance/outreachy-kernel/THYpgGyOgsI/iz8lrqwfDAAJ

Quoted 6 lines

Note that when you pull the header file in, there's a customary order to it that the drivers in staging may not be following. In the example one above, I moved the #defines to be before the chip structure definitions. So, you'll do best if you look at similar drivers in the same directory upstream, to see how they order their header information. Always good to look at a few, because one may not be the perfect role model.

Hi Alison,

Quoted 9 lines

I noticed in looking at the iio/accel driver upstream, there are no comments around register definitions. In the staging driver, all of the header files I've looked at have a comment for each definition. Are comments something that should be pushed forward? Even though the register names are descriptive, it seems wrong to take out comments.

Best,
Katie

Thanks for pointing that out Katie.
You are right. Let's not remove any comments in the reorg. Caveat - if they are poorly aligned/spelled/formatted as you move them, then you have another patch in your set to correct that!

Quoted 8 lines
Quoted 2 lines

alisons

I also notice you deleted an unnecessary include (asm/div64). How do you find unused includes? What I have found online is that no tools work perfectly, and the best solutions are scripts that remove one include at time and compile at each step, which sounds terrible.

Katie

Katie,

My recollection is that I recognized it as unneeded and then did one compile at a time to try any others I questioned.

I don't know of a tool or script to share.

BTW - unneeded #includes aren't always a mistake in the original driver. I believe that some header files have evolved to include other header files, and so over time the #include list for a particular driver can have a redundancy. Sorry - that's all so vague...again, someone else might shed further light on it.

BTW BTW - i think we're OK with these IIO drivers, but I imagine you could also have ARCH build dependencies. Something to watch out for and also something that gets caught by 0 day build testers who will grab your patch and build it.

alisons

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines

It is customary to alphabetize the #includes, and to separate the kernel and IIO subsystem #includes with a blank line. So, although we wouldn't send in a patch just to alphabetize #includes, while you are moving them to the .c file, and while you are checking that they are actually needed, sure - go ahead and alphabetize them. (Example patch didn't alphabetize, you'll do better ;)

To verify the patch(set), I'd suggest applying it to a clean tree and rebuilding.

Questions? Just ask on this thread.

alisons

Signature · 5 lines
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 post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170225014231.GA3395%40d830.WORKGROUP.
For more options, visit https://groups.google.com/d/optout.
#5 lore raw
In reply to Alison Schofield
Quoted 6 lines · Alison Schofield

Hi Outreachy Applicants,

Here is a clean-up task for staging/iio you might like to try.

Staging IIO Header file (re-)organization:

Quoted 7 lines

Guidelines to follow:

(Reference https://kernelnewbies.org/KernelHeaders)

Three cases you may find:
1) If it's a single source file, its header info should be in that source file. *** Do this!

Update - (thanks Lars)

The platform data struct needs to stay in the separate header file until the driver is moved out of staging. If this is your case, you can move the other contents but will need to leave the platform data in the .h file. When the driver is moved out of staging the header will go into the global include/linux/platform_data/ folder.

You can see examples of this in the outreachy mailing list already.

Quoted 32 lines

2) Interfaces between source files in a single module can have a header file in same dir as the source files.
*** Leave this alone.

3) Interfaces shared between modules go in a header file in include/linux/iio *** Leave this alone. We will do this when the driver is moving out of staging

Here's an example patchset:
https://groups.google.com/forum/#!searchin/outreachy-kernel/header$20file$20ad5933%7Csort:relevance/outreachy-kernel/THYpgGyOgsI/iz8lrqwfDAAJ

Note that when you pull the header file in, there's a customary order to it that the drivers in staging may not be following. In the example one above, I moved the #defines to be before the chip structure definitions. So, you'll do best if you look at similar drivers in the same directory upstream, to see how they order their header information. Always good to look at a few, because one may not be the perfect role model.

It is customary to alphabetize the #includes, and to separate the kernel and IIO subsystem #includes with a blank line. So, although we wouldn't send in a patch just to alphabetize #includes, while you are moving them to the .c file, and while you are checking that they are actually needed, sure - go ahead and alphabetize them. (Example patch didn't alphabetize, you'll do better ;)

To verify the patch(set), I'd suggest applying it to a clean tree and rebuilding.

Questions? Just ask on this thread.

alisons