Subject: Re: [PATCH v5 4/8] leds: trigger: netdev: rename and expose NETDEV trigger enum and struct

From: kernel test robot <[email-masked]>
Date: Thu, 18 Nov 2021 23:28:27 +0800

Hi Ansuel,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net/master]
[also build test ERROR on linus/master v5.16-rc1 next-20211118]
[cannot apply to pavel-leds/for-next robh/for-next net-next/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Ansuel-Smith/Adds-support-for-PHY-LEDs-with-offload-triggers/20211112-233807
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 5833291ab6de9c3e2374336b51c814e515e8f3a5
config: x86_64-randconfig-a006-20211115 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/4aa7005c8428f867be20ecd0afe4bc2ccdf6da4a
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Ansuel-Smith/Adds-support-for-PHY-LEDs-with-offload-triggers/20211112-233807
        git checkout 4aa7005c8428f867be20ecd0afe4bc2ccdf6da4a
        # save the attached .config to linux build tree
        mkdir build_dir
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/gpu/drm/amd/amdgpu/ drivers/gpu/drm/i915/ drivers/leds/trigger/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email-masked]>

All errors (new ones prefixed by >>):

   drivers/leds/trigger/ledtrig-netdev.c:45:39: warning: 'struct led_netdev_data' declared inside parameter list will not be visible outside of this definition or declaration
      45 | static void set_baseline_state(struct led_netdev_data *trigger_data)
         |                                       ^~~~~~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c: In function 'set_baseline_state':
>> drivers/leds/trigger/ledtrig-netdev.c:48:46: error: dereferencing pointer to incomplete type 'struct led_netdev_data'
      48 |  struct led_classdev *led_cdev = trigger_data->led_cdev;
         |                                              ^~
   drivers/leds/trigger/ledtrig-netdev.c:59:16: error: 'TRIGGER_NETDEV_LINK' undeclared (first use in this function)
      59 |   if (test_bit(TRIGGER_NETDEV_LINK, &trigger_data->mode))
         |                ^~~~~~~~~~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c:59:16: note: each undeclared identifier is reported only once for each function it appears in
   drivers/leds/trigger/ledtrig-netdev.c:68:16: error: 'TRIGGER_NETDEV_TX' undeclared (first use in this function)
      68 |   if (test_bit(TRIGGER_NETDEV_TX, &trigger_data->mode) ||
         |                ^~~~~~~~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c:69:16: error: 'TRIGGER_NETDEV_RX' undeclared (first use in this function)
      69 |       test_bit(TRIGGER_NETDEV_RX, &trigger_data->mode))
         |                ^~~~~~~~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c: In function 'device_name_show':
   drivers/leds/trigger/ledtrig-netdev.c:80:28: error: dereferencing pointer to incomplete type 'struct led_netdev_data'
      80 |  spin_lock_bh(&trigger_data->lock);
         |                            ^~
   drivers/leds/trigger/ledtrig-netdev.c: In function 'device_name_store':
   drivers/leds/trigger/ledtrig-netdev.c:96:40: error: dereferencing pointer to incomplete type 'struct led_netdev_data'
      96 |  cancel_delayed_work_sync(&trigger_data->work);
         |                                        ^~
   drivers/leds/trigger/ledtrig-netdev.c:120:21: error: passing argument 1 of 'set_baseline_state' from incompatible pointer type [-Werror=incompatible-pointer-types]
     120 |  set_baseline_state(trigger_data);
         |                     ^~~~~~~~~~~~
         |                     |
         |                     struct led_netdev_data *
   drivers/leds/trigger/ledtrig-netdev.c:45:56: note: expected 'struct led_netdev_data *' but argument is of type 'struct led_netdev_data *'
      45 | static void set_baseline_state(struct led_netdev_data *trigger_data)
         |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c: In function 'netdev_led_attr_show':
   drivers/leds/trigger/ledtrig-netdev.c:136:9: error: 'TRIGGER_NETDEV_LINK' undeclared (first use in this function)
     136 |   bit = TRIGGER_NETDEV_LINK;
         |         ^~~~~~~~~~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c:139:9: error: 'TRIGGER_NETDEV_TX' undeclared (first use in this function)
     139 |   bit = TRIGGER_NETDEV_TX;
         |         ^~~~~~~~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c:142:9: error: 'TRIGGER_NETDEV_RX' undeclared (first use in this function)
     142 |   bit = TRIGGER_NETDEV_RX;
         |         ^~~~~~~~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c:148:57: error: dereferencing pointer to incomplete type 'struct led_netdev_data'
     148 |  return sprintf(buf, "%u\n", test_bit(bit, &trigger_data->mode));
         |                                                         ^~
   drivers/leds/trigger/ledtrig-netdev.c: In function 'netdev_led_attr_store':
   drivers/leds/trigger/ledtrig-netdev.c:165:9: error: 'TRIGGER_NETDEV_LINK' undeclared (first use in this function)
     165 |   bit = TRIGGER_NETDEV_LINK;
         |         ^~~~~~~~~~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c:168:9: error: 'TRIGGER_NETDEV_TX' undeclared (first use in this function)
     168 |   bit = TRIGGER_NETDEV_TX;
         |         ^~~~~~~~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c:171:9: error: 'TRIGGER_NETDEV_RX' undeclared (first use in this function)
     171 |   bit = TRIGGER_NETDEV_RX;
         |         ^~~~~~~~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c:177:40: error: dereferencing pointer to incomplete type 'struct led_netdev_data'
     177 |  cancel_delayed_work_sync(&trigger_data->work);
         |                                        ^~
   drivers/leds/trigger/ledtrig-netdev.c:184:21: error: passing argument 1 of 'set_baseline_state' from incompatible pointer type [-Werror=incompatible-pointer-types]
     184 |  set_baseline_state(trigger_data);
         |                     ^~~~~~~~~~~~
         |                     |
         |                     struct led_netdev_data *
   drivers/leds/trigger/ledtrig-netdev.c:45:56: note: expected 'struct led_netdev_data *' but argument is of type 'struct led_netdev_data *'
      45 | static void set_baseline_state(struct led_netdev_data *trigger_data)
         |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c: In function 'interval_show':
   drivers/leds/trigger/ledtrig-netdev.c:237:52: error: dereferencing pointer to incomplete type 'struct led_netdev_data'
     237 |          jiffies_to_msecs(atomic_read(&trigger_data->interval)));
         |                                                    ^~
   drivers/leds/trigger/ledtrig-netdev.c: In function 'interval_store':
   drivers/leds/trigger/ledtrig-netdev.c:254:41: error: dereferencing pointer to incomplete type 'struct led_netdev_data'
     254 |   cancel_delayed_work_sync(&trigger_data->work);
         |                                         ^~
   drivers/leds/trigger/ledtrig-netdev.c:257:22: error: passing argument 1 of 'set_baseline_state' from incompatible pointer type [-Werror=incompatible-pointer-types]
     257 |   set_baseline_state(trigger_data); /* resets timer */
         |                      ^~~~~~~~~~~~
         |                      |
         |                      struct led_netdev_data *
   drivers/leds/trigger/ledtrig-netdev.c:45:56: note: expected 'struct led_netdev_data *' but argument is of type 'struct led_netdev_data *'
      45 | static void set_baseline_state(struct led_netdev_data *trigger_data)
         |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
   In file included from include/linux/atomic/atomic-instrumented.h:20,
                    from include/linux/atomic.h:82,
                    from drivers/leds/trigger/ledtrig-netdev.c:13:
   drivers/leds/trigger/ledtrig-netdev.c: In function 'netdev_trig_notify':
>> include/linux/container_of.h:19:47: error: dereferencing pointer to incomplete type 'struct led_netdev_data'
      19 |  static_assert(__same_type(*(ptr), ((type *)0)->member) || \
         |                                               ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
      78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
         |                                                        ^~~~
   include/linux/container_of.h:19:2: note: in expansion of macro 'static_assert'
      19 |  static_assert(__same_type(*(ptr), ((type *)0)->member) || \
         |  ^~~~~~~~~~~~~
   include/linux/container_of.h:19:16: note: in expansion of macro '__same_type'
      19 |  static_assert(__same_type(*(ptr), ((type *)0)->member) || \
         |                ^~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c:281:3: note: in expansion of macro 'container_of'
     281 |   container_of(nb, struct led_netdev_data, notifier);
         |   ^~~~~~~~~~~~
   include/linux/compiler_types.h:276:27: error: expression in static assertion is not an integer
     276 | #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
         |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
      78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
         |                                                        ^~~~
   include/linux/container_of.h:19:2: note: in expansion of macro 'static_assert'
      19 |  static_assert(__same_type(*(ptr), ((type *)0)->member) || \
         |  ^~~~~~~~~~~~~
   include/linux/container_of.h:19:16: note: in expansion of macro '__same_type'
      19 |  static_assert(__same_type(*(ptr), ((type *)0)->member) || \
         |                ^~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c:281:3: note: in expansion of macro 'container_of'
     281 |   container_of(nb, struct led_netdev_data, notifier);
         |   ^~~~~~~~~~~~
   In file included from <command-line>:
   include/linux/compiler_types.h:140:35: error: invalid use of undefined type 'struct led_netdev_data'
     140 | #define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
         |                                   ^~~~~~~~~~~~~~~~~~
   include/linux/stddef.h:17:32: note: in expansion of macro '__compiler_offsetof'
      17 | #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
         |                                ^~~~~~~~~~~~~~~~~~~
   include/linux/container_of.h:22:21: note: in expansion of macro 'offsetof'
      22 |  ((type *)(__mptr - offsetof(type, member))); })
         |                     ^~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c:281:3: note: in expansion of macro 'container_of'
     281 |   container_of(nb, struct led_netdev_data, notifier);
         |   ^~~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c:316:21: error: passing argument 1 of 'set_baseline_state' from incompatible pointer type [-Werror=incompatible-pointer-types]
     316 |  set_baseline_state(trigger_data);
         |                     ^~~~~~~~~~~~
         |                     |
         |                     struct led_netdev_data *
   drivers/leds/trigger/ledtrig-netdev.c:45:56: note: expected 'struct led_netdev_data *' but argument is of type 'struct led_netdev_data *'
      45 | static void set_baseline_state(struct led_netdev_data *trigger_data)
         |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
   In file included from include/linux/atomic/atomic-instrumented.h:20,
                    from include/linux/atomic.h:82,
                    from drivers/leds/trigger/ledtrig-netdev.c:13:
   drivers/leds/trigger/ledtrig-netdev.c: In function 'netdev_trig_work':
>> include/linux/container_of.h:19:47: error: dereferencing pointer to incomplete type 'struct led_netdev_data'
      19 |  static_assert(__same_type(*(ptr), ((type *)0)->member) || \
         |                                               ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
      78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
         |                                                        ^~~~
   include/linux/container_of.h:19:2: note: in expansion of macro 'static_assert'
      19 |  static_assert(__same_type(*(ptr), ((type *)0)->member) || \
         |  ^~~~~~~~~~~~~
   include/linux/container_of.h:19:16: note: in expansion of macro '__same_type'
      19 |  static_assert(__same_type(*(ptr), ((type *)0)->member) || \
         |                ^~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c:327:3: note: in expansion of macro 'container_of'
     327 |   container_of(work, struct led_netdev_data, work.work);
         |   ^~~~~~~~~~~~
   include/linux/compiler_types.h:276:27: error: expression in static assertion is not an integer
     276 | #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
         |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
      78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
         |                                                        ^~~~
   include/linux/container_of.h:19:2: note: in expansion of macro 'static_assert'
      19 |  static_assert(__same_type(*(ptr), ((type *)0)->member) || \
         |  ^~~~~~~~~~~~~
   include/linux/container_of.h:19:16: note: in expansion of macro '__same_type'
      19 |  static_assert(__same_type(*(ptr), ((type *)0)->member) || \
         |                ^~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c:327:3: note: in expansion of macro 'container_of'
     327 |   container_of(work, struct led_netdev_data, work.work);
         |   ^~~~~~~~~~~~
   In file included from <command-line>:
   include/linux/compiler_types.h:140:35: error: invalid use of undefined type 'struct led_netdev_data'
     140 | #define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
         |                                   ^~~~~~~~~~~~~~~~~~
   include/linux/stddef.h:17:32: note: in expansion of macro '__compiler_offsetof'
      17 | #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
         |                                ^~~~~~~~~~~~~~~~~~~
   include/linux/container_of.h:22:21: note: in expansion of macro 'offsetof'
      22 |  ((type *)(__mptr - offsetof(type, member))); })
         |                     ^~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c:327:3: note: in expansion of macro 'container_of'
     327 |   container_of(work, struct led_netdev_data, work.work);
         |   ^~~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c:341:16: error: 'TRIGGER_NETDEV_TX' undeclared (first use in this function)
     341 |  if (!test_bit(TRIGGER_NETDEV_TX, &trigger_data->mode) &&
         |                ^~~~~~~~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c:342:16: error: 'TRIGGER_NETDEV_RX' undeclared (first use in this function)
     342 |      !test_bit(TRIGGER_NETDEV_RX, &trigger_data->mode))
         |                ^~~~~~~~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c:355:21: error: 'TRIGGER_NETDEV_LINK' undeclared (first use in this function)
     355 |   invert = test_bit(TRIGGER_NETDEV_LINK, &trigger_data->mode);
         |                     ^~~~~~~~~~~~~~~~~~~
   drivers/leds/trigger/ledtrig-netdev.c: In function 'netdev_trig_activate':
   drivers/leds/trigger/ledtrig-netdev.c:375:32: error: invalid application of 'sizeof' to incomplete type 'struct led_netdev_data'
     375 |  trigger_data = kzalloc(sizeof(struct led_netdev_data), GFP_KERNEL);
         |                                ^~~~~~
   In file included from include/linux/wait.h:9,
                    from include/linux/pid.h:6,
                    from include/linux/sched.h:14,
                    from include/linux/ratelimit.h:6,
                    from include/linux/dev_printk.h:16,
                    from include/linux/device.h:15,
                    from drivers/leds/trigger/ledtrig-netdev.c:15:
   drivers/leds/trigger/ledtrig-netdev.c:379:30: error: dereferencing pointer to incomplete type 'struct led_netdev_data'
     379 |  spin_lock_init(&trigger_data->lock);
         |                              ^~
   include/linux/spinlock.h:333:38: note: in definition of macro 'spin_lock_init'
     333 |  __raw_spin_lock_init(spinlock_check(lock),  \
         |                                      ^~~~
   drivers/leds/trigger/ledtrig-netdev.c: In function 'netdev_trig_deactivate':
   drivers/leds/trigger/ledtrig-netdev.c:407:45: error: dereferencing pointer to incomplete type 'struct led_netdev_data'
     407 |  unregister_netdevice_notifier(&trigger_data->notifier);
         |                                             ^~
   drivers/leds/trigger/ledtrig-netdev.c: In function 'interval_show':
   drivers/leds/trigger/ledtrig-netdev.c:238:1: error: control reaches end of non-void function [-Werror=return-type]
     238 | }
         | ^
   drivers/leds/trigger/ledtrig-netdev.c: In function 'netdev_led_attr_show':
   drivers/leds/trigger/ledtrig-netdev.c:149:1: error: control reaches end of non-void function [-Werror=return-type]
     149 | }
         | ^
   cc1: some warnings being treated as errors

vim +48 drivers/leds/trigger/ledtrig-netdev.c

06f502f57d0d77 Ben Whitten  2017-12-10  44  
06f502f57d0d77 Ben Whitten  2017-12-10  45  static void set_baseline_state(struct led_netdev_data *trigger_data)
06f502f57d0d77 Ben Whitten  2017-12-10  46  {
06f502f57d0d77 Ben Whitten  2017-12-10  47  	int current_brightness;
06f502f57d0d77 Ben Whitten  2017-12-10 @48  	struct led_classdev *led_cdev = trigger_data->led_cdev;
06f502f57d0d77 Ben Whitten  2017-12-10  49  
06f502f57d0d77 Ben Whitten  2017-12-10  50  	current_brightness = led_cdev->brightness;
06f502f57d0d77 Ben Whitten  2017-12-10  51  	if (current_brightness)
06f502f57d0d77 Ben Whitten  2017-12-10  52  		led_cdev->blink_brightness = current_brightness;
06f502f57d0d77 Ben Whitten  2017-12-10  53  	if (!led_cdev->blink_brightness)
06f502f57d0d77 Ben Whitten  2017-12-10  54  		led_cdev->blink_brightness = led_cdev->max_brightness;
06f502f57d0d77 Ben Whitten  2017-12-10  55  
df437de7347286 Ansuel Smith 2021-11-12  56  	if (!trigger_data->carrier_link_up) {
06f502f57d0d77 Ben Whitten  2017-12-10  57  		led_set_brightness(led_cdev, LED_OFF);
df437de7347286 Ansuel Smith 2021-11-12  58  	} else {
4aa7005c8428f8 Ansuel Smith 2021-11-12  59  		if (test_bit(TRIGGER_NETDEV_LINK, &trigger_data->mode))
06f502f57d0d77 Ben Whitten  2017-12-10  60  			led_set_brightness(led_cdev,
06f502f57d0d77 Ben Whitten  2017-12-10  61  					   led_cdev->blink_brightness);
06f502f57d0d77 Ben Whitten  2017-12-10  62  		else
06f502f57d0d77 Ben Whitten  2017-12-10  63  			led_set_brightness(led_cdev, LED_OFF);
06f502f57d0d77 Ben Whitten  2017-12-10  64  
06f502f57d0d77 Ben Whitten  2017-12-10  65  		/* If we are looking for RX/TX start periodically
06f502f57d0d77 Ben Whitten  2017-12-10  66  		 * checking stats
06f502f57d0d77 Ben Whitten  2017-12-10  67  		 */
4aa7005c8428f8 Ansuel Smith 2021-11-12  68  		if (test_bit(TRIGGER_NETDEV_TX, &trigger_data->mode) ||
4aa7005c8428f8 Ansuel Smith 2021-11-12  69  		    test_bit(TRIGGER_NETDEV_RX, &trigger_data->mode))
06f502f57d0d77 Ben Whitten  2017-12-10  70  			schedule_delayed_work(&trigger_data->work, 0);
06f502f57d0d77 Ben Whitten  2017-12-10  71  	}
06f502f57d0d77 Ben Whitten  2017-12-10  72  }
06f502f57d0d77 Ben Whitten  2017-12-10  73  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email-masked]