Re: [PATCH] platform/x86: system76: Reducing redundant conditional judgments in system76_add()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Xi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linus/master]
[also build test WARNING on v6.11-rc4 next-20240820]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Xi-Huang/platform-x86-system76-Reducing-redundant-conditional-judgments-in-system76_add/20240820-170328
base:   linus/master
patch link:    https://lore.kernel.org/r/20240820090239.17771-1-xuiagnh%40gmail.com
patch subject: [PATCH] platform/x86: system76: Reducing redundant conditional judgments in system76_add()
config: x86_64-buildonly-randconfig-001-20240820 (https://download.01.org/0day-ci/archive/20240821/202408210506.TtQpGzMk-lkp@xxxxxxxxx/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240821/202408210506.TtQpGzMk-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408210506.TtQpGzMk-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

>> drivers/platform/x86/system76_acpi.c:762:3: warning: add explicit braces to avoid dangling else [-Wdangling-else]
     762 |                 else
         |                 ^
   1 warning generated.


vim +762 drivers/platform/x86/system76_acpi.c

   673	
   674	// Add a System76 ACPI device
   675	static int system76_add(struct acpi_device *acpi_dev)
   676	{
   677		struct system76_data *data;
   678		int err;
   679	
   680		data = devm_kzalloc(&acpi_dev->dev, sizeof(*data), GFP_KERNEL);
   681		if (!data)
   682			return -ENOMEM;
   683		acpi_dev->driver_data = data;
   684		data->acpi_dev = acpi_dev;
   685	
   686		// Some models do not run open EC firmware. Check for an ACPI method
   687		// that only exists on open EC to guard functionality specific to it.
   688		data->has_open_ec = acpi_has_method(acpi_device_handle(data->acpi_dev), "NFAN");
   689	
   690		err = system76_get(data, "INIT");
   691		if (err)
   692			return err;
   693		data->ap_led.name = "system76_acpi::airplane";
   694		data->ap_led.flags = LED_CORE_SUSPENDRESUME;
   695		data->ap_led.brightness_get = ap_led_get;
   696		data->ap_led.brightness_set_blocking = ap_led_set;
   697		data->ap_led.max_brightness = 1;
   698		data->ap_led.default_trigger = "rfkill-none";
   699		err = devm_led_classdev_register(&acpi_dev->dev, &data->ap_led);
   700		if (err)
   701			return err;
   702	
   703		data->kb_led.name = "system76_acpi::kbd_backlight";
   704		data->kb_led.flags = LED_BRIGHT_HW_CHANGED | LED_CORE_SUSPENDRESUME;
   705		data->kb_led.brightness_get = kb_led_get;
   706		data->kb_led.brightness_set_blocking = kb_led_set;
   707		if (acpi_has_method(acpi_device_handle(data->acpi_dev), "GKBK")) {
   708			// Use the new ACPI methods
   709			data->kbled_type = system76_get(data, "GKBK");
   710	
   711			switch (data->kbled_type) {
   712			case KBLED_NONE:
   713				// Nothing to do: Device will not be registered.
   714				break;
   715			case KBLED_WHITE:
   716				data->kb_led.max_brightness = 255;
   717				data->kb_toggle_brightness = 72;
   718				break;
   719			case KBLED_RGB:
   720				data->kb_led.max_brightness = 255;
   721				data->kb_led.groups = system76_kb_led_color_groups;
   722				data->kb_toggle_brightness = 72;
   723				data->kb_color = 0xffffff;
   724				system76_set(data, "SKBC", data->kb_color);
   725				break;
   726			}
   727		} else {
   728			// Use the old ACPI methods
   729			if (acpi_has_method(acpi_device_handle(data->acpi_dev), "SKBC")) {
   730				data->kbled_type = KBLED_RGB;
   731				data->kb_led.max_brightness = 255;
   732				data->kb_led.groups = system76_kb_led_color_groups;
   733				data->kb_toggle_brightness = 72;
   734				data->kb_color = 0xffffff;
   735				system76_set(data, "SKBC", data->kb_color);
   736			} else {
   737				data->kbled_type = KBLED_WHITE;
   738				data->kb_led.max_brightness = 5;
   739			}
   740		}
   741	
   742		if (data->kbled_type != KBLED_NONE) {
   743			err = devm_led_classdev_register(&acpi_dev->dev, &data->kb_led);
   744			if (err)
   745				return err;
   746		}
   747	
   748		data->input = devm_input_allocate_device(&acpi_dev->dev);
   749		if (!data->input)
   750			return -ENOMEM;
   751	
   752		data->input->name = "System76 ACPI Hotkeys";
   753		data->input->phys = "system76_acpi/input0";
   754		data->input->id.bustype = BUS_HOST;
   755		data->input->dev.parent = &acpi_dev->dev;
   756		input_set_capability(data->input, EV_KEY, KEY_SCREENLOCK);
   757	
   758		err = input_register_device(data->input);
   759		if (err)
   760			if (data->has_open_ec)
   761				goto free_error;
 > 762			else
   763				return err;
   764	
   765		if (data->has_open_ec) {
   766			err = system76_get_object(data, "NFAN", &data->nfan);
   767			if (err)
   768				goto free_error;
   769	
   770			err = system76_get_object(data, "NTMP", &data->ntmp);
   771			if (err)
   772				goto free_error;
   773	
   774			data->therm = devm_hwmon_device_register_with_info(&acpi_dev->dev,
   775				"system76_acpi", data, &thermal_chip_info, NULL);
   776			err = PTR_ERR_OR_ZERO(data->therm);
   777			if (err)
   778				goto free_error;
   779	
   780			system76_battery_init();
   781		}
   782	
   783		return 0;
   784	
   785	free_error:
   786		kfree(data->ntmp);
   787		kfree(data->nfan);
   788		return err;
   789	}
   790	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki




[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux