Re: [PATCH 07/17] staging: nuc-wmi: add basic support for NUC6 WMI

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

 



On Sun, May 16, 2021 at 12:53:35PM +0200, Mauro Carvalho Chehab wrote:
> +static int nuc_wmi_query_leds_nuc6(struct device *dev)
> +{
> +	// FIXME: add a check for the specific models that are known to work
> +	struct nuc_wmi *priv = dev_get_drvdata(dev);
> +	u8 cmd, input[NUM_INPUT_ARGS] = { 0 };
> +	u8 output[NUM_OUTPUT_ARGS];
> +	struct nuc_nmi_led *led;
> +	int ret;
> +
> +	cmd = LED_OLD_GET_STATUS;
> +	input[0] = LED_OLD_GET_S0_POWER;
> +	ret = nuc_nmi_cmd(dev, cmd, input, output);
> +	if (ret) {
> +		dev_warn(dev, "Get S0 Power: error %d\n", ret);
> +		return ret;
> +	}
> +
> +	led = &priv->led[priv->num_leds];
> +	led->id = POWER_LED;
> +	led->color_type = LED_BLUE_AMBER;
> +	led->avail_indicators = LED_IND_POWER_STATE;
> +	led->indicator = fls(led->avail_indicators);
> +	priv->num_leds++;
> +
> +	cmd = LED_OLD_GET_STATUS;
> +	input[0] = LED_OLD_GET_S0_RING;
> +	ret = nuc_nmi_cmd(dev, cmd, input, output);
> +	if (ret) {
> +		dev_warn(dev, "Get S0 Ring: error %d\n", ret);
> +		return ret;
> +	}
> +	led = &priv->led[priv->num_leds];
> +	led->id = RING_LED;
> +	led->color_type = LED_BLUE_AMBER;
> +	led->avail_indicators = LED_IND_SOFTWARE;
> +	led->indicator = fls(led->avail_indicators);
> +	priv->num_leds++;
> +
> +	return ret;

return 0;

> +}
> +
>  static int nuc_wmi_query_leds(struct device *dev, enum led_api_rev *api_rev)
>  {
>  	struct nuc_wmi *priv = dev_get_drvdata(dev);
>  	u8 input[NUM_INPUT_ARGS] = { 0 };
>  	u8 output[NUM_OUTPUT_ARGS];
> -	int id, ret, ver = LED_API_UNKNOWN;
> +	int id, ret, ver = LED_API_UNKNOWN, nuc_ver = 0;
>  	u8 leds;
> +	const char *dmi_name;
> +
> +	dmi_name = dmi_get_system_info(DMI_PRODUCT_NAME);
> +	if (!dmi_name || !*dmi_name)
> +		dmi_name = dmi_get_system_info(DMI_BOARD_NAME);
> +
> +	if (strncmp(dmi_name, "NUC", 3))
> +		return -ENODEV;
> +
> +	dmi_name +=3;
> +	while (*dmi_name) {
> +		if (*dmi_name < '0' || *dmi_name > '9')
> +			break;
> +		nuc_ver = (*dmi_name - '0') + nuc_ver * 10;
> +		dmi_name++;
> +	}
> +
> +	if (nuc_ver < 6)
> +		return -ENODEV;
> +
> +	if (nuc_ver < 8) {
> +		*api_rev = LED_API_NUC6;
> +		return nuc_wmi_query_leds_nuc6(dev);
> +	}
>  
> -	/*
> -	 * List all LED types support in the platform
> -	 *
> -	 * Should work with both NUC8iXXX and NUC10iXXX
> -	 *
> -	 * FIXME: Should add a fallback code for it to work with older NUCs,
> -	 * as LED_QUERY returns an error on older devices like Skull Canyon.
> -	 */
>  	input[0] = LED_QUERY_LIST_ALL;
>  	ret = nuc_nmi_cmd(dev, LED_QUERY, input, output);
> -	if (ret == -ENOENT) {
> -		ver = LED_API_NUC6;
> -	} else if (ret) {
> +	if (ret) {
>  		dev_warn(dev, "error %d while listing all LEDs\n", ret);
>  		return ret;
>  	} else {
>  		leds = output[0];
>  	}

Delete the else and pull the assignment in a tab.

>  
> -	if (ver != LED_API_NUC6) {
> -		ret = nuc_nmi_cmd(dev, LED_VERSION_CONTROL, input, output);
> -		ver = output[0] | output[1] << 16;
> -		if (!ver)
> -			ver = LED_API_REV_0_64;
> -		else if (ver == 0x0126)
> -			ver = LED_API_REV_1_0;
> -	}
> +	ret = nuc_nmi_cmd(dev, LED_VERSION_CONTROL, input, output);
> +	ver = output[0] | output[1] << 16;
> +	if (!ver)
> +		*api_rev = LED_API_REV_0_64;
> +	else if (ver == 0x0126)
> +		*api_rev = LED_API_REV_1_0;
>  

regards,
dan carpenter



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux