All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rong Chen <rong.a.chen@intel.com>
To: Jonathan Cameron <jic23@kernel.org>,
	Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: linux-iio <linux-iio@vger.kernel.org>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Aleksei Mamlin <mamlinav@gmail.com>,
	Dan Robertson <dan@dlrobertson.com>,
	Hans de Goede <hdegoede@redhat.com>,
	Harinath Nampally <harinath922@gmail.com>,
	Jelle van der Waa <jelle@vdwaa.nl>,
	Jonathan Bakker <xc-racer2@live.ca>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Linus Walleij <linus.walleij@linaro.org>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Mike Looijmans <mike.looijmans@topic.nl>,
	Sean Nyekjaer <sean@geanix.com>,
	Tomas Melin <tomas.melin@vaisala.com>
Subject: Re: [PATCH 00/12] iio:accel: Header Cleanups.
Date: Tue, 15 Jun 2021 17:13:31 +0800	[thread overview]
Message-ID: <83fa6bcc-6946-5f79-c676-f93827c27fe1@intel.com> (raw)
In-Reply-To: <20210611211054.749c801b@jic23-huawei>



On 6/12/21 4:10 AM, Jonathan Cameron wrote:
> On Fri, 11 Jun 2021 22:36:52 +0300
> Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
>
>> On Fri, Jun 11, 2021 at 10:17 PM Jonathan Cameron <jic23@kernel.org> wrote:
>>> On Fri, 11 Jun 2021 21:35:06 +0300
>>> Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
>>>> On Fri, Jun 11, 2021 at 9:21 PM Jonathan Cameron <jic23@kernel.org> wrote:
>>>>> On Fri, 11 Jun 2021 20:48:08 +0300
>>>>> Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
>> ...
>>
>>>> But I understand you and not insisting that you have to go with it. My
>>>> point is that...
>>>>   
>>>>> I 'could' just drop the kernel.h where added on the basis we were clearly
>>>>> getting it indirectly. I've not included a whole bunch of other suggestions
>>>>> on that basis.
>>>> (Which is probably not a good idea, because explicit in this case is
>>>> better than implicit, i.e. kernel.h is not guaranteed to be included
>>>> by other headers and I have long standing work to actually make sure
>>>> that most of the headers won't require kernel.h!)
>>> I think I was unclear, what I was proposing was not to touch includes of
>>> kernel.h at all. So not make anything worse, but also not make it any better.
>>> Where added in this set, kernel.h was for things directly in kernel.h,
>>> not the files it includes.
>> Ah, that's good! That was my main point of worry.
>>
>>>>> Note I didn't include a whole bunch of other headers on the basis
>>>>> they were a bit more esoteric.
>>>>>
>>>>> To give an idea of how noisy this is here's the output another file...
>>>> ...the tool simply doesn't know anything about kernel and header
>>>> guarantees. That's why it tries play dumb.
>>>>
>>>> If you would like to continue with this, please drop the removal of
>>>> the headers that are not guaranteed to be included by others
>>>> (excluding kernel.h from the equation).
>>> This is where the confusion lies... I haven't done that (subject to bugs
>>> of course)
>>>   
>>>> Otherwise it will become
>>>> someone else's problem to _reinstantiate_ all those headers, and since
>>>> I already had a headache with panic.h, I won't repeat it. Still no tag
>>>> from me, although no explicit NAK (actually opposite, no explicit ACK
>>>> because of the dependencies), you just really need to spend more time
>>>> on this.
>>> I've not removed any headers on the basis they were guaranteed to be
>>> included by others. The tool assumes the opposite model - everything
>>> should be explicitly included directly in the file where it's used.
>>> For some files it lists 50+ headers.
>>> These patches are very conservative on that front.
>>>
>>> What I haven't done is included everything under the sun that wasn't
>>> already included.  e.g. I've not included
>>> linux/device/driver.h on the basis it is definitely included by
>>> linux/device.h and that seems very unlikely to change.
>>>
>>> There are some corner cases that are more interesting - such as whether
>>> we can rely on interrupt.h always including irqreturn.h.  Plenty of IIO
>>> drivers don't call anything in interrupt.h because of various wrappers but
>>> do use the return values. So in this case we could switch many of them
>>> to the more specific header, but I haven't done that yet.
>> I guess you may consider a guarantee there.
>>
>> Actually what kernel header mess misses right now is the list of those
>> guarantees.
>>
>> But you see there cases like
>>
>> using dev_err() and struct device * in the same C file, what do you include?
>>
>> Temptation is to go with device.h, but I would go with
>>
>> #include <linux/dev_printk.h>
>>
>> struct device;
>>
>> Not sure if that tool can handle this kind of use.
> It does.  I decided it was a step too far and didn't act on this one
> for da311.c, but here is an example of that case.
>
> drivers/iio/accel/da311.c should add these lines:
> #include "asm-generic/errno-base.h"  // for EINVAL, ENODEV, ENOMEM
> #include "asm-generic/int-ll64.h"    // for u8, u16
> #include "generated/autoconf.h"      // for CONFIG_PM_SLEEP
> #include "linux/dev_printk.h"        // for dev_err
> #include "linux/iio/types.h"         // for IIO_CHAN_INFO_RAW, IIO_CHAN_INFO...
> #include "linux/kernel.h"            // for ARRAY_SIZE
> #include "linux/pm.h"                // for SIMPLE_DEV_PM_OPS
> #include "linux/stddef.h"            // for false, true
> #include "linux/types.h"             // for bool
> #include "vdso/bits.h"               // for BIT
> struct device;
>
> If we can teach the tool (or post process it a bit) about places we
> want to do something beyond the direct (e.g. asm-generic/ernrno-base.h)
> that would make it much more useful.  Even then I think we'll want
> a human in the loop.

Hi,

The tool allows to correct the recommended headers, please see

https://github.com/include-what-you-use/include-what-you-use#how-to-correct-iwyu-mistakes

>
> I'm running an older version than 0-day has been using I think.
>
> +Cc 0-day person who kind of kicked this off :)
>
> Note the warning from 0-day was about a header no longer needing to be included
> (the mutex in the ADIS drivers got recently moved to a wrapper in the library).
> Those warnings are almost certain to be correct - and many of the removals
> in here are things that would have been picked up in similar circumstances.

Yes, 0day only detects useless headers experimentally, we're willing to 
extend the range
if include-what-you-use tool (or other tool) can output a more friendly 
header list.

Best Regards,
Rong Chen

>
> Note things can get a bit silly, even if technically correct...
> + it gets confused on where headers are coming from sometimes.
>
> The full include-list for drivers/iio/industrialio-core.c:
> #include <asm/bug.h>                                 // for WARN
> #include <linux/cdev.h>                              // for cdev_init, cdev_...
> #include <linux/debugfs.h>                           // for debugfs_create_dir
> #include <linux/device.h>                            // for device, device_a...
> #include <linux/err.h>                               // for IS_ERR, PTR_ERR
> #include <linux/fs.h>                                // for noop_llseek, inode
> #include <linux/idr.h>                               // for DEFINE_IDA, ida_...
> #include <linux/iio/iio-opaque.h>                    // for iio_dev_opaque
> #include <linux/iio/iio.h>                           // for iio_dev, iio_cha...
> #include <linux/iio/sysfs.h>                         // for iio_dev_attr
> #include <linux/kdev_t.h>                            // for MAJOR, MKDEV
> #include <linux/kernel.h>                            // for kasprintf, sscanf
> #include <linux/ktime.h>                             // for ktime_get_bootti...
> #include <linux/module.h>                            // for MODULE_AUTHOR
> #include <linux/mutex.h>                             // for mutex_unlock
> #include <linux/property.h>                          // for device_property_...
> #include <linux/slab.h>                              // for kfree, kzalloc
> #include <stddef.h>                                  // for NULL, size_t
> #include <stdint.h>                                  // for uintptr_t
> #include <sys/types.h>                               // for ssize_t, dev_t
> #include "asm-generic/bitops/instrumented-atomic.h"  // for clear_bit, test_...
> #include "asm-generic/errno-base.h"                  // for EINVAL, EBUSY
> #include "asm-generic/int-ll64.h"                    // for s64, u64
> #include "asm/bug.h"                                 // for BUG
> #include "asm/page_types.h"                          // for PAGE_SIZE
> #include "asm/string_64.h"                           // for memcpy
> #include "generated/autoconf.h"                      // for CONFIG_DEBUG_FS
> #include "iio_core.h"                                // for iio_ioctl_handler
> #include "iio_core_trigger.h"                        // for iio_device_regis...
> #include "linux/align.h"                             // for ALIGN
> #include "linux/bitops.h"                            // for for_each_set_bit
> #include "linux/compiler_attributes.h"               // for fallthrough
> #include "linux/compiler_types.h"                    // for __user
> #include "linux/dev_printk.h"                        // for dev_err, dev_info
> #include "linux/device/bus.h"                        // for bus_unregister
> #include "linux/export.h"                            // for EXPORT_SYMBOL_GPL
> #include "linux/gfp.h"                               // for GFP_KERNEL
> #include "linux/hrtimer.h"                           // for hrtimer_resolution
> #include "linux/iio/types.h"                         // for IIO_VAL_INT, IIO...
> #include "linux/init.h"                              // for __exit, __init
> #include "linux/ktime.h"                             // for ktime_to_ns
> #include "linux/list.h"                              // for INIT_LIST_HEAD
> #include "linux/math.h"                              // for abs
> #include "linux/math64.h"                            // for div_s64_rem, div...
> #include "linux/minmax.h"                            // for min_t
> #include "linux/of.h"                                // for of_get_property
> #include "linux/printk.h"                            // for pr_err
> #include "linux/stat.h"                              // for S_IRUGO, S_IWUSR
> #include "linux/stddef.h"                            // for false, true
> #include "linux/string.h"                            // for sysfs_streq, str...
> #include "linux/sysfs.h"                             // for sysfs_emit_at
> #include "linux/time.h"                              // for CLOCK_BOOTTIME
> #include "linux/time64.h"                            // for timespec64_to_ns
> #include "linux/timex.h"                             // for shift_right
> #include "linux/types.h"                             // for list_head, bool
> #include "linux/uaccess.h"                           // for copy_from_user
> #include "vdso/ktime.h"                              // for LOW_RES_NSEC
> struct iio_buffer;
>>> So, in short, the headers for which includes are removed in this series are
>>> not used at all in the files in question (unless I messed up of course!).
>> Cool! So, let bots and other people have more time on eyeballing this.
>> Will see how it goes.
> Sure.
>
> Jonathan


  reply	other threads:[~2021-06-15  9:13 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-11 17:13 [PATCH 00/12] iio:accel: Header Cleanups Jonathan Cameron
2021-06-11 17:13 ` [PATCH 01/12] iio:accel:adxl372: Cleanup includes Jonathan Cameron
2021-06-15 13:16   ` Lars-Peter Clausen
2021-06-11 17:13 ` [PATCH 02/12] iio:accel:bma180: Use generic device properties Jonathan Cameron
2021-06-11 21:48   ` Linus Walleij
2021-06-11 17:13 ` [PATCH 03/12] iio:accel:bosch drivers: Cleanup includes Jonathan Cameron
2021-06-11 17:13 ` [PATCH 04/12] iio:accel:miramems drivers: Cleanup headers Jonathan Cameron
2021-06-11 17:13 ` [PATCH 05/12] iio:accel:domintech: Cleanup includes Jonathan Cameron
2021-06-11 17:13 ` [PATCH 06/12] iio:accel:fxls8962af: Add a few missing includes Jonathan Cameron
2021-06-14  5:57   ` Sean Nyekjaer
2021-06-11 17:13 ` [PATCH 07/12] iio:accel:kionix drivers: Cleanup includes Jonathan Cameron
2021-06-11 17:13 ` [PATCH 08/12] iio:accel:mc3220: " Jonathan Cameron
2021-06-11 17:13 ` [PATCH 09/12] iio:accel:freescale drivers: " Jonathan Cameron
2021-06-11 17:13 ` [PATCH 10/12] iio:accel:memsic " Jonathan Cameron
2021-06-11 17:13 ` [PATCH 11/12] iio:accel:murata/vti drivers: Include cleanups for the sca**** parts Jonathan Cameron
2021-06-14  7:15   ` Tomas Melin
2021-06-11 17:13 ` [PATCH 12/12] iio:accel:sensortek drivers: Add some includes Jonathan Cameron
2021-06-11 17:48 ` [PATCH 00/12] iio:accel: Header Cleanups Andy Shevchenko
2021-06-11 18:23   ` Jonathan Cameron
2021-06-11 18:35     ` Andy Shevchenko
2021-06-11 19:19       ` Jonathan Cameron
2021-06-11 19:36         ` Andy Shevchenko
2021-06-11 20:10           ` Jonathan Cameron
2021-06-15  9:13             ` Rong Chen [this message]
2021-06-15 13:12 ` Lars-Peter Clausen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83fa6bcc-6946-5f79-c676-f93827c27fe1@intel.com \
    --to=rong.a.chen@intel.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=dan@dlrobertson.com \
    --cc=harinath922@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=jelle@vdwaa.nl \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=mamlinav@gmail.com \
    --cc=mike.looijmans@topic.nl \
    --cc=sean@geanix.com \
    --cc=tomas.melin@vaisala.com \
    --cc=xc-racer2@live.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.