From patchwork Wed Feb 10 02:44:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 8267991 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EE9E3BEEE5 for ; Wed, 10 Feb 2016 02:44:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D2D442027D for ; Wed, 10 Feb 2016 02:44:55 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 539AA20270 for ; Wed, 10 Feb 2016 02:44:54 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4B3F2264F02; Wed, 10 Feb 2016 03:44:48 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.8 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E663D260616; Wed, 10 Feb 2016 03:44:39 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7AB92260616; Wed, 10 Feb 2016 03:44:38 +0100 (CET) Received: from relmlie3.idc.renesas.com (relmlor4.renesas.com [210.160.252.174]) by alsa0.perex.cz (Postfix) with ESMTP id C23FA2616F3 for ; Wed, 10 Feb 2016 03:44:15 +0100 (CET) Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie3.idc.renesas.com with ESMTP; 10 Feb 2016 11:44:13 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id BC12960106; Wed, 10 Feb 2016 11:44:13 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id A6531480A4; Wed, 10 Feb 2016 11:44:13 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id 94069480A3; Wed, 10 Feb 2016 11:44:13 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac4.idc.renesas.com with ESMTP id MAK31817; Wed, 10 Feb 2016 11:44:13 +0900 X-IronPort-AV: E=Sophos;i="5.22,424,1449500400"; d="scan'";a="204066411" Received: from mail-hk2apc01lp0211.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.211]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 10 Feb 2016 11:44:12 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=uEKc3pJ2h4LJDMnXSgHA11OMySujfU0/FWUq2h/j9LU=; b=VwfIX6dbnU41WS4Gqag2IZ5bhyEZpfRvtiV7vSxvVbMGmkPOeF9nCMZ6Gt/0MM+RSubd62vY20d+YdX9+gyF/qQJzc3AL3tCC2lhBxZxYK8e0F90d12VuHfn3c5/Y0yEK5kFSotq1w76S7ox/5xTx3wqOnr0d66yhPW8JPScD78= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=renesas.com; Received: from morimoto-PC.renesas.com (211.11.155.144) by SG2PR06MB1018.apcprd06.prod.outlook.com (10.161.9.26) with Microsoft SMTP Server (TLS) id 15.1.403.16; Wed, 10 Feb 2016 02:44:11 +0000 Message-ID: <87ziv9s2yf.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Mark Brown , Greg KH In-Reply-To: <871t8lthka.wl%kuninori.morimoto.gx@renesas.com> References: <871t8lthka.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Wed, 10 Feb 2016 02:44:11 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: OS2PR01CA0002.jpnprd01.prod.outlook.com (25.161.74.140) To SG2PR06MB1018.apcprd06.prod.outlook.com (25.161.9.26) X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1018; 2:JqiAGXVzBLNXgtMpkuSaOhy4/TAYLxKaicBSN7RrT8unRWlhqIgwesxLck7fi7mWPRfe+sJj5dZqzRB56wIFZjK9wcNgI3QTdUJLoozHSK9XwDuaS3Q6LaxyRaG7L3zlgbBAyeqdU3FCb1MGtlznMw==; 3:HkIlrY6OmeD9rasRGCeBEXVRnQaQJjAGpbk/+CykZVHcBJ+dh3Wb6ogX7kVH1P5uVZt5oQPtgMWg7nLjOcTTKxRWhAeseL1ynKbkuMaE8yGBfABvIMpsRFde6H1SXHc7; 25:LhQ4mDRtBmUPoVvOkXilH6rjUQ9IIRCRY8r6m+hDCO42GTyZEptXvnKuzpMmEdqB5EA9OrGGq0Fz5OL4mGX40amB15xwE9TyL8ezk4ZIlBf6IzPBO/Vh6UegG9m3H6OyH4HIFE6LrSCoIyb79bwEj1vZdljHrmIyaPbyU/ZbwHNRX1kfhpcL4E7wJYSsy4rU0+CYT2WvB0XyXQydKfPSrj1gmyDOv74a7YFbuEajpKRTpHshTzIHJYwdUFwh/1rO4DB+h8vniMQt4uOR+rOgy0v1OoHE6XLn8oP6Xpg1JgR3j0yjFJ+DN2HOsIVzaIlG X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SG2PR06MB1018; X-MS-Office365-Filtering-Correlation-Id: 9451cfbf-77b4-42a4-6258-08d331c40e93 X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1018; 20:6m9SMCfxRvZ0Tj9aMXOGsRhYZxMHsZz1cB9I9QCIjlUNWM6YlytcblHe3yKXaTaMFSIxG43SdNRhV5N4RByOnEUTbK84xB8XGEXRlKbxVuchLtGPklyPfO29cBA3vKSF96FiNgYdPy3zEqm2c+/UljI6kKU2Sihpe4NCbYjtQ2ewy1VDosEXH+1x0oMclPlZJebgjNtUHaTZhhbpdfPRjY1y4tx99RNX2JbpPtjFIUb4XpSvrd+7KbMmDTRangjeGKrVe4rHyrUb4HHAHHDbQ2bDpXKtGRfshcpAa48rW600IyPrPAjU5W0TDGYp75ACEoN2/CFFbGAmbLuCPrFZrYWn/9xoZr1BbgrBPOnkoqZxXPXWe0kD71N1LcOTpt75zoag3BkyQdBKPuLD2rayg/thrLIaNM6yKiDufWknET/lNuxqa1OQb3NXKRePllmrrQEzLrSHTboCatfJu3kh0AM+A/vSAeTMxP7MGFTpoKV0NB/ntsPRoC2WBLNSvnX3; 4:stmQOLVgP9KocP3kmO5WtlcIh/Inc6fvcLuk7eoJfD4ezVBKq/HBGDIgNtBz5XcTYFIvv6JXXj3yg9LnCHSCj87YlvHUV6euTWaZThJJT5PjHxsp1n6iv0UDSHMeCc1wvGPA9yYECSu9reFCzsolyN+Tw2UlLjf4aFDRfIN1Lk9FhAuOzRPjddrvVzpHdaKr27QUTpa74nTmlQEpJI4AAkj/goe83khTrKKaWPVezU8w84gdg+xpdx/cbEeDmXA0EsOlu0v9OJLdRz8wGKFfo2Sn3CdUE/GU3JK1siZf0RBmSwkJ+lOh+xzRZ16Ht4FWj8pedmzxgyH6QfIQ4FsHZatPQzi+OJ56EfwRKh1jfgTm5oo1InEAM0CCeFpPU5lo X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:SG2PR06MB1018; BCL:0; PCL:0; RULEID:; SRVR:SG2PR06MB1018; X-Forefront-PRVS: 0848C1A6AA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(586003)(23726003)(19580395003)(66066001)(6116002)(3846002)(19580405001)(92566002)(83506001)(1096002)(5008740100001)(5001770100001)(4326007)(4001350100001)(122386002)(5004730100002)(189998001)(40100003)(2906002)(50466002)(5001960100002)(47776003)(42186005)(53416004)(76176999)(50986999)(86362001)(77096005)(54356999)(2950100001)(46406003)(36756003)(229853001)(33646002)(87976001); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR06MB1018; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SG2PR06MB1018; 23:+YvUA5pqtBtgg2ClYGqKiE+4l/4kHFbX1xHzkCp1f?= =?us-ascii?Q?Bpdma7cFMLQEK9et5m1J0wdTp5Wfgc/GIE6VN+GDew/9TnOxRnMZJMpjSe4L?= =?us-ascii?Q?ERrix619Xp1M4+OIQzyplhuTac61eLMnUOi1M2vdz/3KRCU/vteh8ISPXmZ9?= =?us-ascii?Q?5A2dNXwsCy1duuXzofkIciA/JW0bfIGuKehC/N/PAQRplOemfVlKb08W362y?= =?us-ascii?Q?rCJIbtIM8hWxb5746Lbn35k0oMZWlWKsEHl7UW6/W+qgKh+cE6d1XeIXoqVe?= =?us-ascii?Q?LBgBhN+QlnJDZ/sKlNlwdOL0yJG/rxAE+8dhFkynctm6h5ZKmlOOTodoZfoC?= =?us-ascii?Q?ocn+c4m8bebe4WOTherr6lBoZ60iuRoPfR2HVAEgzlT/2VmqYS4zaIe/DJ0o?= =?us-ascii?Q?9K312/JnIpTKHxRjbART7rKQWKXBMg+mjb2tv1gnInBellT3oH7dS0CLRNmq?= =?us-ascii?Q?jJAPqPATSJV8PKp5hujcZ8b8y5ToO4rsCqtPGIXwH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ylx7K/thJP9luomRJkbznz5QNKxMqxdSF9A= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2016 02:44:11.1012 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB1018 Cc: Linux-ALSA , Linux-Kernel Subject: [alsa-devel] [PATCH 1/7][RFC] regmap: add regmap_raw_update_bits() and merge all regmap_update_bits_xxx() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto Current regmap has many similar update functions, but the difference is very few. This patch adds new regmap_raw_update_bits() and merge all update functions into it by macro. regmap_update_bits() regmap_update_bits_async() regmap_update_bits_check() regmap_update_bits_check_async() Signed-off-by: Kuninori Morimoto --- drivers/base/regmap/regmap.c | 113 ++++++------------------------------------- include/linux/regmap.h | 54 ++++++--------------- 2 files changed, 31 insertions(+), 136 deletions(-) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index ee54e84..c91e67b 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -2648,76 +2648,34 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg, } /** - * regmap_update_bits: Perform a read/modify/write cycle on the register map - * - * @map: Register map to update - * @reg: Register to update - * @mask: Bitmask to change - * @val: New value for bitmask - * - * Returns zero for success, a negative number on error. - */ -int regmap_update_bits(struct regmap *map, unsigned int reg, - unsigned int mask, unsigned int val) -{ - int ret; - - map->lock(map->lock_arg); - ret = _regmap_update_bits(map, reg, mask, val, NULL, false); - map->unlock(map->lock_arg); - - return ret; -} -EXPORT_SYMBOL_GPL(regmap_update_bits); - -/** - * regmap_write_bits: Perform a read/modify/write cycle on the register map - * - * @map: Register map to update - * @reg: Register to update - * @mask: Bitmask to change - * @val: New value for bitmask - * - * Returns zero for success, a negative number on error. - */ -int regmap_write_bits(struct regmap *map, unsigned int reg, - unsigned int mask, unsigned int val) -{ - int ret; - - map->lock(map->lock_arg); - ret = _regmap_update_bits(map, reg, mask, val, NULL, true); - map->unlock(map->lock_arg); - - return ret; -} -EXPORT_SYMBOL_GPL(regmap_write_bits); - -/** - * regmap_update_bits_async: Perform a read/modify/write cycle on the register - * map asynchronously + * regmap_raw_update_bits: Perform a read/modify/write cycle on the register map * * @map: Register map to update * @reg: Register to update * @mask: Bitmask to change * @val: New value for bitmask + * @change: Boolean indicating if a write was done + * @async: Boolean indicating asynchronously + * @force: Boolean indicating use force update * + * if async was true, * With most buses the read must be done synchronously so this is most * useful for devices with a cache which do not need to interact with * the hardware to determine the current register value. * * Returns zero for success, a negative number on error. */ -int regmap_update_bits_async(struct regmap *map, unsigned int reg, - unsigned int mask, unsigned int val) +int regmap_raw_update_bits(struct regmap *map, unsigned int reg, + unsigned int mask, unsigned int val, + bool *change, bool async, bool force) { int ret; map->lock(map->lock_arg); - map->async = true; + map->async = async ? true : false; - ret = _regmap_update_bits(map, reg, mask, val, NULL, false); + ret = _regmap_update_bits(map, reg, mask, val, change, force); map->async = false; @@ -2725,69 +2683,30 @@ int regmap_update_bits_async(struct regmap *map, unsigned int reg, return ret; } -EXPORT_SYMBOL_GPL(regmap_update_bits_async); - -/** - * regmap_update_bits_check: Perform a read/modify/write cycle on the - * register map and report if updated - * - * @map: Register map to update - * @reg: Register to update - * @mask: Bitmask to change - * @val: New value for bitmask - * @change: Boolean indicating if a write was done - * - * Returns zero for success, a negative number on error. - */ -int regmap_update_bits_check(struct regmap *map, unsigned int reg, - unsigned int mask, unsigned int val, - bool *change) -{ - int ret; - - map->lock(map->lock_arg); - ret = _regmap_update_bits(map, reg, mask, val, change, false); - map->unlock(map->lock_arg); - return ret; -} -EXPORT_SYMBOL_GPL(regmap_update_bits_check); +EXPORT_SYMBOL_GPL(regmap_raw_update_bits); /** - * regmap_update_bits_check_async: Perform a read/modify/write cycle on the - * register map asynchronously and report if - * updated + * regmap_write_bits: Perform a read/modify/write cycle on the register map * * @map: Register map to update * @reg: Register to update * @mask: Bitmask to change * @val: New value for bitmask - * @change: Boolean indicating if a write was done - * - * With most buses the read must be done synchronously so this is most - * useful for devices with a cache which do not need to interact with - * the hardware to determine the current register value. * * Returns zero for success, a negative number on error. */ -int regmap_update_bits_check_async(struct regmap *map, unsigned int reg, - unsigned int mask, unsigned int val, - bool *change) +int regmap_write_bits(struct regmap *map, unsigned int reg, + unsigned int mask, unsigned int val) { int ret; map->lock(map->lock_arg); - - map->async = true; - - ret = _regmap_update_bits(map, reg, mask, val, change, false); - - map->async = false; - + ret = _regmap_update_bits(map, reg, mask, val, NULL, true); map->unlock(map->lock_arg); return ret; } -EXPORT_SYMBOL_GPL(regmap_update_bits_check_async); +EXPORT_SYMBOL_GPL(regmap_write_bits); void regmap_async_complete_cb(struct regmap_async *async, int ret) { diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 1839434..0b8b76a 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -65,6 +65,15 @@ struct reg_sequence { unsigned int delay_us; }; +#define regmap_update_bits(map, reg, mask, val) \ + regmap_raw_update_bits(map, reg, mask, val, NULL, false, false) +#define regmap_update_bits_async(map, reg, mask, val)\ + regmap_raw_update_bits(map, reg, mask, val, NULL, true, false) +#define regmap_update_bits_check(map, reg, mask, val, change)\ + regmap_raw_update_bits(map, reg, mask, val, change, false, false) +#define regmap_update_bits_check_async(map, reg, mask, val, change)\ + regmap_raw_update_bits(map, reg, mask, val, change, true, false) + #ifdef CONFIG_REGMAP enum regmap_endian { @@ -691,18 +700,11 @@ int regmap_raw_read(struct regmap *map, unsigned int reg, void *val, size_t val_len); int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, size_t val_count); -int regmap_update_bits(struct regmap *map, unsigned int reg, - unsigned int mask, unsigned int val); +int regmap_raw_update_bits(struct regmap *map, unsigned int reg, + unsigned int mask, unsigned int val, + bool *change, bool async, bool force); int regmap_write_bits(struct regmap *map, unsigned int reg, unsigned int mask, unsigned int val); -int regmap_update_bits_async(struct regmap *map, unsigned int reg, - unsigned int mask, unsigned int val); -int regmap_update_bits_check(struct regmap *map, unsigned int reg, - unsigned int mask, unsigned int val, - bool *change); -int regmap_update_bits_check_async(struct regmap *map, unsigned int reg, - unsigned int mask, unsigned int val, - bool *change); int regmap_get_val_bytes(struct regmap *map); int regmap_get_max_register(struct regmap *map); int regmap_get_reg_stride(struct regmap *map); @@ -937,8 +939,9 @@ static inline int regmap_bulk_read(struct regmap *map, unsigned int reg, return -EINVAL; } -static inline int regmap_update_bits(struct regmap *map, unsigned int reg, - unsigned int mask, unsigned int val) +static inline int regmap_raw_update_bits(struct regmap *map, unsigned int reg, + unsigned int mask, unsigned int val, + bool *change, bool async, bool force) { WARN_ONCE(1, "regmap API is disabled"); return -EINVAL; @@ -951,33 +954,6 @@ static inline int regmap_write_bits(struct regmap *map, unsigned int reg, return -EINVAL; } -static inline int regmap_update_bits_async(struct regmap *map, - unsigned int reg, - unsigned int mask, unsigned int val) -{ - WARN_ONCE(1, "regmap API is disabled"); - return -EINVAL; -} - -static inline int regmap_update_bits_check(struct regmap *map, - unsigned int reg, - unsigned int mask, unsigned int val, - bool *change) -{ - WARN_ONCE(1, "regmap API is disabled"); - return -EINVAL; -} - -static inline int regmap_update_bits_check_async(struct regmap *map, - unsigned int reg, - unsigned int mask, - unsigned int val, - bool *change) -{ - WARN_ONCE(1, "regmap API is disabled"); - return -EINVAL; -} - static inline int regmap_get_val_bytes(struct regmap *map) { WARN_ONCE(1, "regmap API is disabled");