Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3138252pxb; Mon, 9 Nov 2020 03:45:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzn1xDa+cd3W7a4nWjQlwEMstF5HeYqYE4vMVRi1jMz3+1Qfajvg8gQ2w5M82cucmwwdG0J X-Received: by 2002:a17:906:9902:: with SMTP id zl2mr14250154ejb.510.1604922311150; Mon, 09 Nov 2020 03:45:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604922311; cv=none; d=google.com; s=arc-20160816; b=ul4eOl10T6CKaCBV83na/P/stgSCQgCilnKiCwAr9SeROknClJLH5/L7Mplaxi0lIX sm7YnTWfCYTumnPJCaqH27TBiBMXgSAT2Pe0fYOTmOyKveXmKo8jzLkPvDf4UM6yJMPO rviUWfUanXguDvzZKDKbu903jBXAb0w2hmHS+MJpvhH7kCfu7w344/tfxXg+g46rUk1C N7BGWlZvQJ/pPb6UqftySwRZ0nE76YCVkzH6VwwVJY6Vb+tnl31mtqIj04P35xVV+oin k6tcPN0eHi4W3XSPbfvE+1VoanzcCvIF0TjVleytb5p81zny+O8r+6IqdLn+iDbjN05y lLoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=giOAbvvkjX66gUb2He/SdCtlL8SdD+wVXjo0Oag+VQw=; b=xQTXWqx96OdyLo+JJYot0KqMpIT32Gojn4vY7uHBEeqiN8xbEIeArr4GUcF9crAzyd 6rhuHNV2RKXv3AVm1/NQNTghJKUCVrAI7TFZcN/JhArMs1IJCN8jbUm1i+vTfdHmuc2H A/7luv/LXdNxL13hK+UhT8uo2x1sV4feK2zZPP3D5gnTjW4K8kiI6sBXpCnurD9rhjFb Z5y59erPRkE+elbcFkQ4iiqzCJl3DdqNeRtumkmC2aE5C18OBCK8nXc6RQEPiZYUKafP MgaHQr243PzPlnyrT4DVXw0BaCkCiYMXM6D5MkLiCcw3M1C8bTdb3AspkcBbulZW1eLG 6b4w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v1si7951571ejd.624.2020.11.09.03.44.45; Mon, 09 Nov 2020 03:45:11 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729320AbgKILnS (ORCPT + 99 others); Mon, 9 Nov 2020 06:43:18 -0500 Received: from smtp2207-205.mail.aliyun.com ([121.197.207.205]:43025 "EHLO smtp2207-205.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727311AbgKILnS (ORCPT ); Mon, 9 Nov 2020 06:43:18 -0500 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.07436321|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.119563-0.00233504-0.878102;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047199;MF=frank@allwinnertech.com;NM=1;PH=DS;RN=11;RT=11;SR=0;TI=SMTPD_---.IuVCLW3_1604922186; Received: from allwinnertech.com(mailfrom:frank@allwinnertech.com fp:SMTPD_---.IuVCLW3_1604922186) by smtp.aliyun-inc.com(10.147.44.129); Mon, 09 Nov 2020 19:43:12 +0800 From: Frank Lee To: anarsoul@gmail.com, tiny.windzz@gmail.com, rui.zhang@intel.com, daniel.lezcano@linaro.org, amitk@kernel.org, mripard@kernel.org, wens@csie.org Cc: linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Yangtao Li Subject: [PATCH] thermal: sun8i: Use bitmap API instead of open code Date: Mon, 9 Nov 2020 19:43:02 +0800 Message-Id: <20201109114302.22740-1-frank@allwinnertech.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yangtao Li The bitmap_* API is the standard way to access data in the bitfield. So convert irq_ack to return an unsigned long, and make things to use bitmap API. Signed-off-by: Yangtao Li --- v2: Make irq_ack to return an unsigned long --- drivers/thermal/sun8i_thermal.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c index f8b13071a6f4..8c80bd06dd9f 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -8,6 +8,7 @@ * Based on the work of Josef Gajdusek */ +#include #include #include #include @@ -74,7 +75,7 @@ struct ths_thermal_chip { int (*calibrate)(struct ths_device *tmdev, u16 *caldata, int callen); int (*init)(struct ths_device *tmdev); - int (*irq_ack)(struct ths_device *tmdev); + unsigned long (*irq_ack)(struct ths_device *tmdev); int (*calc_temp)(struct ths_device *tmdev, int id, int reg); }; @@ -146,9 +147,10 @@ static const struct regmap_config config = { .max_register = 0xfc, }; -static int sun8i_h3_irq_ack(struct ths_device *tmdev) +static unsigned long sun8i_h3_irq_ack(struct ths_device *tmdev) { - int i, state, ret = 0; + unsigned long irq_bitmap = 0; + int i, state; regmap_read(tmdev->regmap, SUN8I_THS_IS, &state); @@ -156,16 +158,17 @@ static int sun8i_h3_irq_ack(struct ths_device *tmdev) if (state & SUN8I_THS_DATA_IRQ_STS(i)) { regmap_write(tmdev->regmap, SUN8I_THS_IS, SUN8I_THS_DATA_IRQ_STS(i)); - ret |= BIT(i); + bitmap_set(&irq_bitmap, i, 1); } } - return ret; + return irq_bitmap; } -static int sun50i_h6_irq_ack(struct ths_device *tmdev) +static unsigned long sun50i_h6_irq_ack(struct ths_device *tmdev) { - int i, state, ret = 0; + unsigned long irq_bitmap = 0; + int i, state; regmap_read(tmdev->regmap, SUN50I_H6_THS_DIS, &state); @@ -173,24 +176,22 @@ static int sun50i_h6_irq_ack(struct ths_device *tmdev) if (state & SUN50I_H6_THS_DATA_IRQ_STS(i)) { regmap_write(tmdev->regmap, SUN50I_H6_THS_DIS, SUN50I_H6_THS_DATA_IRQ_STS(i)); - ret |= BIT(i); + bitmap_set(&irq_bitmap, i, 1); } } - return ret; + return irq_bitmap; } static irqreturn_t sun8i_irq_thread(int irq, void *data) { struct ths_device *tmdev = data; - int i, state; - - state = tmdev->chip->irq_ack(tmdev); + unsigned long irq_bitmap = tmdev->chip->irq_ack(tmdev); + int i; - for (i = 0; i < tmdev->chip->sensor_num; i++) { - if (state & BIT(i)) - thermal_zone_device_update(tmdev->sensor[i].tzd, - THERMAL_EVENT_UNSPECIFIED); + for_each_set_bit(i, &irq_bitmap, tmdev->chip->sensor_num) { + thermal_zone_device_update(tmdev->sensor[i].tzd, + THERMAL_EVENT_UNSPECIFIED); } return IRQ_HANDLED; -- 2.28.0