[bug report] platform/x86: fujitsu-laptop: Clean up constants

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

 



Hello Michał Kępień,

The patch 819cddae7cfa: "platform/x86: fujitsu-laptop: Clean up
constants" from Feb 20, 2018, leads to the following static checker
warning:

    drivers/platform/x86/fujitsu-laptop.c:763 acpi_fujitsu_laptop_leds_register()
    warn: always true condition '(call_fext_func(device, ((1 << (12)) | (1 << (0))), 2, (1 << (16)), 0) != (1 << (31))) => (s32min-s32max != 2147483648)'

    drivers/platform/x86/fujitsu-laptop.c:816 acpi_fujitsu_laptop_add()
    warn: impossible condition '(priv->flags_supported == (1 << (31))) => (0-2147483647,18446744071562067968-u64max == 2147483648)'

drivers/platform/x86/fujitsu-laptop.c
   756          /* Support for eco led is not always signaled in bit corresponding
   757           * to the bit used to control the led. According to the DSDT table,
   758           * bit 14 seems to indicate presence of said led as well.
   759           * Confirm by testing the status.
   760           */
   761          if ((call_fext_func(device, FUNC_LEDS, 0x0, 0x0, 0x0) & BIT(14)) &&
   762              (call_fext_func(device,
   763                              FUNC_LEDS, 0x2, ECO_LED, 0x0) != UNSUPPORTED_CMD)) {
                                                                  ^^^^^^^^^^^^^^^^^^
The problem is that before UNSUPPORTED_CMD was 0x80000000 (int) but now
it's BIT(31) (unsigned long).  call_fext_func() returns an int so if
it returns 0x80000000 and that gets type promoted to unsigned long on
a 64 bit system then the sign gets extended and it becomes
0xffffffff80000000.  0xffffffff80000000 is not equal to 0x80000000 so
this condition is always true.
 
   764                  led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL);
   765                  if (!led)
   766                          return -ENOMEM;
   767  
   768                  led->name = "fujitsu::eco_led";
   769                  led->brightness_set_blocking = eco_led_set;
   770                  led->brightness_get = eco_led_get;
   771                  ret = devm_led_classdev_register(&device->dev, led);
   772                  if (ret)
   773                          return ret;
   774          }
   775  
   776          return 0;
   777  }
   778  
   779  static int acpi_fujitsu_laptop_add(struct acpi_device *device)
   780  {
   781          struct fujitsu_laptop *priv;
   782          int ret, i = 0;
   783  
   784          priv = devm_kzalloc(&device->dev, sizeof(*priv), GFP_KERNEL);
   785          if (!priv)
   786                  return -ENOMEM;
   787  
   788          WARN_ONCE(fext, "More than one FUJ02E3 ACPI device was found.  Driver may not work as intended.");
   789          fext = device;
   790  
   791          strcpy(acpi_device_name(device), ACPI_FUJITSU_LAPTOP_DEVICE_NAME);
   792          strcpy(acpi_device_class(device), ACPI_FUJITSU_CLASS);
   793          device->driver_data = priv;
   794  
   795          /* kfifo */
   796          spin_lock_init(&priv->fifo_lock);
   797          ret = kfifo_alloc(&priv->fifo, RINGBUFFERSIZE * sizeof(int),
   798                            GFP_KERNEL);
   799          if (ret)
   800                  return ret;
   801  
   802          pr_info("ACPI: %s [%s]\n",
   803                  acpi_device_name(device), acpi_device_bid(device));
   804  
   805          while (call_fext_func(device, FUNC_BUTTONS, 0x1, 0x0, 0x0) != 0 &&
   806                 i++ < MAX_HOTKEY_RINGBUFFER_SIZE)
   807                  ; /* No action, result is discarded */
   808          acpi_handle_debug(device->handle, "Discarded %i ringbuffer entries\n",
   809                            i);
   810  
   811          priv->flags_supported = call_fext_func(device, FUNC_FLAGS, 0x0, 0x0,
   812                                                 0x0);
   813  
   814          /* Make sure our bitmask of supported functions is cleared if the
   815             RFKILL function block is not implemented, like on the S7020. */
   816          if (priv->flags_supported == UNSUPPORTED_CMD)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Same but always false.

   817                  priv->flags_supported = 0;
   818  
   819          if (priv->flags_supported)
   820                  priv->flags_state = call_fext_func(device, FUNC_FLAGS, 0x4, 0x0,
   821                                                     0x0);

regards,
dan carpenter



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

  Powered by Linux