Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1954207pxj; Sun, 16 May 2021 09:21:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+tCk5hV9nMOmvjz1b4shHN+WqjyYDgbSKeKlomZSWzkdy2gp7Y83B5+PTqHWzh2z7460e X-Received: by 2002:a05:6e02:1bcb:: with SMTP id x11mr50166265ilv.87.1621182106304; Sun, 16 May 2021 09:21:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621182106; cv=none; d=google.com; s=arc-20160816; b=usMV7zFV6WBMvAZTlnV8YzdkVNPbkvfIeg3M2t81Ko/KihGlOdyx1YiOxcGABEEiUB MBhyTNgrSuKvGp2seHJ5SgRx06J5iaZJQD8bonMdeH/8FGNbvNQJg235uliPijpreAE8 HsO4DC5OfYuFumLNuVJ1Z2TxsZAfQaNLvMQXRK+JZ7wrx6o6aRXTD42A26pIjPekugvm Nv59kBuoR/DfmpWDJWuHkchPV5yuqVfIazvUk1uomdiGr7gBep0/+viP34RLiAGuTTXR HPGHLOS6Prf3P0j+RuGmoCNI6Lygoo7pfk/P2Atkjnsyv+H50yLGpTlSbaizs8bcoAyK L2Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=x1Ow6S7A+I7m2yTxIuW0rRUBNu9w3iQXEhXsU2d61mk=; b=zOZUhZsD1tIKxVzvInxPZOf0FHdyygl6iSDMOE1mMbzr+y4VxFYedLAZbjjD2ojJmg qQ3FzKWgm2jzespVHBEa7YaP1jRAeVM0jJSUgboedkJQUVO07FauXlrpcNNvSaQZlUdZ 8AYKHV14cVwJzlSVhizeQ9hmhclyEvhW+vassuXkCdJPFDby5uUUUAlyticrP5TO7pxH YGnLbK+WVLRWtq/bInaur5TjkOryOr1X8g6eVpu//C8aEXBbyFdxA+1K5U53lW4ln1Dq YPSSXF9QITDKUxA4dBmtGxhWZxJk4iD6+DO4DxU/4Ay4XffpL7opazipfe/xH6SaLlwI cxiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lwK2y20R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a5si6444757ilh.94.2021.05.16.09.21.31; Sun, 16 May 2021 09:21:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lwK2y20R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231612AbhEPKz4 (ORCPT + 99 others); Sun, 16 May 2021 06:55:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:47714 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230156AbhEPKzI (ORCPT ); Sun, 16 May 2021 06:55:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2738A61206; Sun, 16 May 2021 10:53:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621162433; bh=nW7fKI5PUZp/UFI+qdts0R8ZO5545PmLjbtP18ZvdUY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lwK2y20RmkTHDsgizXnSMAd6PWGlj5TCMzfS72fOYQSXFDUIiJZbphFFFLl8Ri+x4 kodfzbhHL/J3Dhd4sVdcHtycssqt7FnSN9W8RbmjgvgmKIKthwkYRdHa11AQ8mOOyS X2x2z6Rg2aYOdPJj07Gn/P6u1l7taF+7gV95IrI1v+GMW3Mn6UGBi6CQsmFZhrpBAr W5DIbegL0Ihpwz+CprlNP1qKI8vaMGhZdaTWjHpTNu90CqTMJFdy++92ENL2T2Xa+l ZPzsgSv3HCe5qP6gsQ/bw5Pgt/jI0X5t/X7M5CElWWwRdm2mqoWXMlGTLUWeld8LVy dyMByQCKcYxrQ== Received: by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1liEP9-003s8i-4w; Sun, 16 May 2021 12:53:51 +0200 From: Mauro Carvalho Chehab To: gregkh@linuxfoundation.org Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , "Pavel Machek" , Mauro Carvalho Chehab , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 12/17] staging: nuc-wmi: better detect NUC6/NUC7 devices Date: Sun, 16 May 2021 12:53:40 +0200 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Mauro Carvalho Chehab Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There's no documented way to detect if the WMI API is valid, as, when it is not valid, it just returns 4 zeros. However, as having a value of 0x00 for the blinking state is not valid, we can check for it at detection time, in order to disable LEDs control on devices that won't support it. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/nuc-led/nuc-wmi.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/staging/nuc-led/nuc-wmi.c b/drivers/staging/nuc-led/nuc-wmi.c index 5bc4dcec3ea8..1a6e2b17c888 100644 --- a/drivers/staging/nuc-led/nuc-wmi.c +++ b/drivers/staging/nuc-led/nuc-wmi.c @@ -312,6 +312,13 @@ static int nuc_wmi_query_leds_nuc6(struct device *dev) return ret; } + /* + * Detect if NUC6/NUC7 supports the WMI API by checking the + * returned blink state, as valid values range from 0x01 to 0x07. + */ + if (output[1] == 0x00) + return -ENODEV; + led = &priv->led[priv->num_leds]; led->id = POWER_LED; led->color_type = LED_BLUE_AMBER; @@ -325,6 +332,14 @@ static int nuc_wmi_query_leds_nuc6(struct device *dev) dev_warn(dev, "Get S0 Ring: error %d\n", ret); return ret; } + + /* + * Detect if NUC6/NUC7 supports the WMI API by checking the + * returned blink state, as valid values range from 0x01 to 0x07. + */ + if (output[1] == 0x00) + return -ENODEV; + led = &priv->led[priv->num_leds]; led->id = RING_LED; led->color_type = LED_BLUE_AMBER; -- 2.31.1