Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4517654ybl; Tue, 21 Jan 2020 22:54:32 -0800 (PST) X-Google-Smtp-Source: APXvYqzKWPVQLnm+bXFndHqBN4B2Up5RmAcHkovrPnQ2oqm3b6IamcDjQtHXqqT9fWeCVqLcZnPo X-Received: by 2002:a05:6808:84:: with SMTP id s4mr5951994oic.60.1579676072708; Tue, 21 Jan 2020 22:54:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579676072; cv=none; d=google.com; s=arc-20160816; b=pa1YxFcu66XF5jET10Qksf+V66zbU8JDzVWZf2WCFI6cgA9C51VWoX1dJzF0n9Ut4u C8WoFEp5akMXKzOLOJibDl9OfikCO6lmGupbmQH5tad/1ATTnaG1wepBSkDcdPaw3XwJ bqbuCr6QkdL46T7no4UtU/JnKOp/TX/I2iGGdjWM1hJVX34DqN2wg5llq+p0Wqj1AFaT rkIKovzFmiTO9XH5ZtvkQ3qEm5T7xDjgoHdHfe1z1W1ALae4jcyoDVV++MlVh69zBJgV q4/DsKsEKFu0mTeFVKL0TasUGpIJRGIdf/r8KJg3uQJGczX9p0OvTKh+CYR7/vi7RhL1 8EZw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Bkkv2SlP/58V7+P3Bi8i3ZC64d86zcDO203xGyHiNBg=; b=yoLC0noLLhBjG+vJlDqd0/MZmU3PZdslQc/PnknrjcN9VnEwlmS5kiSiALG1vY/g2z Sn5e11Sf4cwbO3XwNWg6Hnp/mdzSzg8gtRwusLDIIANTDeBh5pns3KBgjNsgIk9V0Sid l//bP9/XwiZinTFocOJCO934Ug9xHq6FP0PDOTW4B+LsK2/cATL23G6eMvjMJeQKrBjy JUD/yK09YcFzhVU9Ma8dS+0zxzbU3PqATF9i2aVg7dw7M8Q9+L+iKW4fwJZjVb2Otkbr 9j6FOrMQAvVxarEPGJa4NrCkf/hMq6bGDOZioCm+dBbEv+UDpZnARMWu7+LlvybeNf3R dOCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=lFTMEXVl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g138si21842940oib.190.2020.01.21.22.54.20; Tue, 21 Jan 2020 22:54:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=lFTMEXVl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728901AbgAVGx0 (ORCPT + 99 others); Wed, 22 Jan 2020 01:53:26 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:7754 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725884AbgAVGxY (ORCPT ); Wed, 22 Jan 2020 01:53:24 -0500 X-UUID: 7ea6983bb9d9486785d06bcd5b84f0db-20200122 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=Bkkv2SlP/58V7+P3Bi8i3ZC64d86zcDO203xGyHiNBg=; b=lFTMEXVlMJsyXXM9Pka6P0VqG6juX++DUWU+D3/25oO25OqA2jQgoRA+zsaekCDW/etkHGAkwXvqTqnyCg1tgKwH0tfoYzfryc1kGrCPeycSRSlDOs9Cqkworb8FtYi4HKwkSwM1Oofb2O6QyFkkEQBZvNRcG46Co+iCorZKc/o=; X-UUID: 7ea6983bb9d9486785d06bcd5b84f0db-20200122 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 2060551540; Wed, 22 Jan 2020 14:53:17 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs02n2.mediatek.inc (172.21.101.101) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 22 Jan 2020 14:52:13 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 22 Jan 2020 14:51:57 +0800 From: To: CC: , , , , , Light Hsieh Subject: [PATCH v8 1/6] pinctrl: mediatek: Check gpio pin number and use binary search in mtk_hw_pin_field_lookup() Date: Wed, 22 Jan 2020 14:53:09 +0800 Message-ID: <1579675994-7001-1-git-send-email-light.hsieh@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 660429F95FABC97ED3652C11CAB95C6BF2D0D521B77C9A655959A16674A913DA2000:8 X-MTK: N Content-Transfer-Encoding: base64 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org RnJvbTogTGlnaHQgSHNpZWggPGxpZ2h0LmhzaWVoQG1lZGlhdGVrLmNvbT4NCg0KMS4gQ2hlY2sg aWYgZ3BpbyBwaW4gbnVtYmVyIGlzIGluIHZhbGlkIHJhbmdlIHRvIHByZXZlbnQgZnJvbSBnZXQg aW52YWxpZA0KICAgcG9pbnRlciAnZGVzYycgaW4gdGhlIGZvbGxvd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