Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp870733ybb; Fri, 20 Mar 2020 09:24:36 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuKWPkcb9fUUIPbaEH0fAxjscrHGCeO5bNt9aaOD1kMrElYRubNKzSUTcPbaO4Ejf1svran X-Received: by 2002:a9d:3b09:: with SMTP id z9mr7682752otb.195.1584721476183; Fri, 20 Mar 2020 09:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584721476; cv=none; d=google.com; s=arc-20160816; b=mIhSO48tanzv6a3gAYyfOF860MskIUuTLadLUprQ3QOISeRMTKon8p68L0VWKo4Q4n 5iqheZkmVKBmTKfE6bPTyikpNN3BXI/IAW5KB3e2VarE+/JY3jFRuaVCEFSYeOCyVElF TpqaAclcPSqwQeUdMCiQ+AXbMR+7zX9STpyEVmtSrD2VCBLN1D0TsiMXe4lDwqw7jAtl Hya8hfumAEU7aLQDe1hta86j/x1gF46epse0DB8yjJNxndGrQycqGualD+lqVQkic0VJ 0y8wyJSNcueU7RdoBm9BOsrQYJU7lXBeQp+PQEDVU2cyWAI1kyjl69B8VOQ1dTQCCPZD hLAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date; bh=Soyl5wknranvBv2KNYBWngxLwVkUTDsoSpLCZeD/izY=; b=d20GxZ46RUMfB1lvQmQaXjYz36IyVdtjBg1APozihgS9wnID4sNXFhRKoG7oiRXcW3 GISisrF4SsbF8oO4n3h1NXMlRW6L2ce+PCDasbkCmj4/k70kpHm6EXHK4ed+T/rDpCMw 5w5N33fqqT2y0EO5ICpko5WGWRD7k6ZG4cIQWUAHFXv8HooiYk/QuvZhnrLQAYKECprB oo6z1Yl8LnqLi/okZlzPX1SS3HjIY7WB0aaZOMlO3r+v78d5cTEuAIa0Xkz3DjGX9voD jLhOX1KSnq7nMOs+NB9Hprwzu+cxGsiRHDfbbEA0dTrVUkK+nrTMGovh3lkiULu8VkY/ ufuw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g13si3196557otg.49.2020.03.20.09.24.20; Fri, 20 Mar 2020 09:24:36 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727278AbgCTQX5 (ORCPT + 99 others); Fri, 20 Mar 2020 12:23:57 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:42389 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726983AbgCTQX5 (ORCPT ); Fri, 20 Mar 2020 12:23:57 -0400 Received: from mail.cetitecgmbh.com ([87.190.42.90]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MAfpQ-1j8gbb1Rma-00B7jU for ; Fri, 20 Mar 2020 17:23:55 +0100 Received: from pflvmailgateway.corp.cetitec.com (unknown [127.0.0.1]) by mail.cetitecgmbh.com (Postfix) with ESMTP id 2847E650374 for ; Fri, 20 Mar 2020 16:23:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at cetitec.com Received: from mail.cetitecgmbh.com ([127.0.0.1]) by pflvmailgateway.corp.cetitec.com (pflvmailgateway.corp.cetitec.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9s7jkSY0cOXX for ; Fri, 20 Mar 2020 17:23:54 +0100 (CET) Received: from pfwsexchange.corp.cetitec.com (unknown [10.10.1.99]) by mail.cetitecgmbh.com (Postfix) with ESMTPS id BF14C64F9D2 for ; Fri, 20 Mar 2020 17:23:54 +0100 (CET) Received: from pflmari.corp.cetitec.com (10.8.5.41) by PFWSEXCHANGE.corp.cetitec.com (10.10.1.99) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 20 Mar 2020 17:23:54 +0100 Received: by pflmari.corp.cetitec.com (Postfix, from userid 1000) id 2255B80500; Fri, 20 Mar 2020 17:11:46 +0100 (CET) Date: Fri, 20 Mar 2020 17:11:46 +0100 From: Alex Riesen To: Kieran Bingham CC: Geert Uytterhoeven , Mauro Carvalho Chehab , Hans Verkuil , "Laurent Pinchart" , Rob Herring , Mark Rutland , Kuninori Morimoto , , , , , Subject: [PATCH v3 03/11] media: adv748x: reduce amount of code for bitwise modifications of device registers Message-ID: <88950969b1d16ff5fcd1b3458356c4cf5a9e6cff.1584720678.git.alexander.riesen@cetitec.com> Mail-Followup-To: Alex Riesen , Kieran Bingham , Geert Uytterhoeven , Mauro Carvalho Chehab , Hans Verkuil , Laurent Pinchart , Rob Herring , Mark Rutland , Kuninori Morimoto , devel@driverdev.osuosl.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org References: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-Originating-IP: [10.8.5.41] X-ClientProxiedBy: PFWSEXCHANGE.corp.cetitec.com (10.10.1.99) To PFWSEXCHANGE.corp.cetitec.com (10.10.1.99) X-EsetResult: clean, is OK X-EsetId: 37303A290D7F536A6D7662 X-Provags-ID: V03:K1:ICWOq73QjzJJPYKLAkxROtwaU+CssEQhOxvaEKwGULnHCJi2455 +v6QdiZCsslmG+ByBoYgXfQTKrOeFc4EMDQBrZ02cIpZBHDkULROrKUZOuldGSwoxUZc+H1 8tI6msOzlioWS6+37x3JdKK8xZPRyhZC0+W8m/lzp0Yy6C2z9oYAjORG2hQkGfG/WL3/POJ mkbCLa5ULUg3byjQASSDA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:SVZ2eVQIBH0=:g+KMbwTs4+nqsAbq/ls8vG /QfPBMnl0pZNHZLWAqk7wdFv5K2Y4FVxW76doTlvmaPxj4XEJo4wJiALrEiv8mwKZNYpu0PSl 19TOdqP+Sft5z7q4EQlkpLGOBtWmiQtq0/g3vOEZzxjbd1CDgYMy0VyuRwQeknSGfIr6YBVVU EWaFlO31KFB253jvuiEa6JAvslPMaX73CNUYdZzkvKNgNfauVS7my9hV1nnuNF+5tr+HRxjDr 5T/Iz8vs1xW2ykZawUPA2tcsKIF3npuHQKp0sy0JIlK/NSdh3AxVB5ECnwnoSD2cjvSbLcvzy h46M+KM1nDpYDb2jkBHTQ8/dcs/qOWJ5I9rNFiED+4m6rjSQa+P31gmQtk5BFXrU07xq1uM7Q /tNE9NojFb+mWw7K1RsPFaB8H220DoUbmyVUCGqHyPLuRVDMuuDKa9tvWaJX0Wzt+omAc4aGn /hE4FVPoZzMZsRJuIS+w9Iqjixc01e/clnQNlKBKL7uukvrPYagRor9MtO+Wwp5ksiwI0yecu P3T5JDjyBpD7CmRSTzkEFUpiVwD2VcpIUR/106FVzZ3NvqCO/LnHQl7PoZoz246CyJ7MUqB1m gdOAHpqsuSjm5QLipc9LMVe23RrmqlvlGeKL1hdm12ve54qHoOnJfBzK1pL6CqXK/8g9jEP/g RCM/ksYd+j0sKB1AUZqONo40beKcYdQj8QxqZrf3cfYoouk2m4Yy5SdILLEpH2e0dRE8GkDRE VuVuE09GDArXx5uuQmhrRCLC4xNp0S8egziGlU8e0WeClsKREjYpIIuHF5YGzamopPGCTT2nm yhweNjYHrzTVWSN2npsdJGTC40AYh44PBu2aL2Buc1ZpdlRuoI06hkDCa7njWbrQMfNYcdF Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The regmap provides a convenient utility for this. The hdmi_* and dpll_* register modification macros added for symmetry with the existing operations (io_*, sdp_*). Signed-off-by: Alexander Riesen Reviewed-by: Laurent Pinchart -- v3: remove _update name in favor of existing _clrset --- drivers/media/i2c/adv748x/adv748x-core.c | 6 ++++++ drivers/media/i2c/adv748x/adv748x.h | 14 +++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c index 5c59aad319d1..8580e6624276 100644 --- a/drivers/media/i2c/adv748x/adv748x-core.c +++ b/drivers/media/i2c/adv748x/adv748x-core.c @@ -133,6 +133,12 @@ static int adv748x_write_check(struct adv748x_state *state, u8 page, u8 reg, return *error; } +int adv748x_update_bits(struct adv748x_state *state, u8 page, u8 reg, u8 mask, + u8 value) +{ + return regmap_update_bits(state->regmap[page], reg, mask, value); +} + /* adv748x_write_block(): Write raw data with a maximum of I2C_SMBUS_BLOCK_MAX * size to one or more registers. * diff --git a/drivers/media/i2c/adv748x/adv748x.h b/drivers/media/i2c/adv748x/adv748x.h index 09aab4138c3f..0a9d78c2870b 100644 --- a/drivers/media/i2c/adv748x/adv748x.h +++ b/drivers/media/i2c/adv748x/adv748x.h @@ -393,25 +393,33 @@ int adv748x_write(struct adv748x_state *state, u8 page, u8 reg, u8 value); int adv748x_write_block(struct adv748x_state *state, int client_page, unsigned int init_reg, const void *val, size_t val_len); +int adv748x_update_bits(struct adv748x_state *state, u8 page, u8 reg, + u8 mask, u8 value); #define io_read(s, r) adv748x_read(s, ADV748X_PAGE_IO, r) #define io_write(s, r, v) adv748x_write(s, ADV748X_PAGE_IO, r, v) -#define io_clrset(s, r, m, v) io_write(s, r, (io_read(s, r) & ~(m)) | (v)) +#define io_clrset(s, r, m, v) adv748x_update_bits(s, ADV748X_PAGE_IO, r, m, v) #define hdmi_read(s, r) adv748x_read(s, ADV748X_PAGE_HDMI, r) #define hdmi_read16(s, r, m) (((hdmi_read(s, r) << 8) | hdmi_read(s, (r)+1)) & (m)) #define hdmi_write(s, r, v) adv748x_write(s, ADV748X_PAGE_HDMI, r, v) +#define hdmi_clrset(s, r, m, v) \ + adv748x_update_bits(s, ADV748X_PAGE_HDMI, r, m, v) + +#define dpll_read(s, r) adv748x_read(s, ADV748X_PAGE_DPLL, r) +#define dpll_clrset(s, r, m, v) \ + adv748x_update_bits(s, ADV748X_PAGE_DPLL, r, m, v) #define repeater_read(s, r) adv748x_read(s, ADV748X_PAGE_REPEATER, r) #define repeater_write(s, r, v) adv748x_write(s, ADV748X_PAGE_REPEATER, r, v) #define sdp_read(s, r) adv748x_read(s, ADV748X_PAGE_SDP, r) #define sdp_write(s, r, v) adv748x_write(s, ADV748X_PAGE_SDP, r, v) -#define sdp_clrset(s, r, m, v) sdp_write(s, r, (sdp_read(s, r) & ~(m)) | (v)) +#define sdp_clrset(s, r, m, v) adv748x_update_bits(s, ADV748X_PAGE_SDP, r, m, v) #define cp_read(s, r) adv748x_read(s, ADV748X_PAGE_CP, r) #define cp_write(s, r, v) adv748x_write(s, ADV748X_PAGE_CP, r, v) -#define cp_clrset(s, r, m, v) cp_write(s, r, (cp_read(s, r) & ~(m)) | (v)) +#define cp_clrset(s, r, m, v) adv748x_update_bits(s, ADV748X_PAGE_CP, r, m, v) #define tx_read(t, r) adv748x_read(t->state, t->page, r) #define tx_write(t, r, v) adv748x_write(t->state, t->page, r, v) -- 2.25.1.25.g9ecbe7eb18