From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47D1EC38142 for ; Mon, 23 Jan 2023 18:25:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233195AbjAWSYg (ORCPT ); Mon, 23 Jan 2023 13:24:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233882AbjAWSYX (ORCPT ); Mon, 23 Jan 2023 13:24:23 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B0ED6A75 for ; Mon, 23 Jan 2023 10:24:22 -0800 (PST) X-IronPort-AV: E=McAfee;i="6500,9779,10599"; a="412339601" X-IronPort-AV: E=Sophos;i="5.97,240,1669104000"; d="scan'208";a="412339601" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2023 10:24:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10599"; a="769999550" X-IronPort-AV: E=Sophos;i="5.97,240,1669104000"; d="scan'208";a="769999550" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga002.fm.intel.com with ESMTP; 23 Jan 2023 10:24:00 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1pK1U6-00Ds4p-0u; Mon, 23 Jan 2023 20:23:58 +0200 Date: Mon, 23 Jan 2023 20:23:57 +0200 From: Andy Shevchenko To: Hans de Goede Cc: Mauro Carvalho Chehab , Sakari Ailus , Tsuchiya Yuto , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: Re: [PATCH 28/57] media: Add ovxxxx_16bit_addr_reg_helpers.h Message-ID: References: <20230123125205.622152-1-hdegoede@redhat.com> <20230123125205.622152-29-hdegoede@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230123125205.622152-29-hdegoede@redhat.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org On Mon, Jan 23, 2023 at 01:51:36PM +0100, Hans de Goede wrote: > The following drivers under drivers/media/i2c: ov08x40.c, ov13858.c, > ov13b10.c, ov2680.c, ov2685.c, ov2740.c, ov4689.c, ov5670.c, > ov5675.c, ov5695.c, ov8856.c, ov9282.c and ov9734.c, > > as well as various "atomisp" sensor drivers in drivers/staging, *all* > use register access helpers with the following function prototypes: > > int ovxxxx_read_reg(struct ovxxxx_dev *sensor, u16 reg, > unsigned int len, u32 *val); > > int ovxxxx_write_reg(struct ovxxxx_dev *sensor, u16 reg, > unsigned int len, u32 val); > > To read/write registers on Omnivision OVxxxx image sensors wich expect > a 16 bit register address in big-endian format and which have 1-3 byte > wide registers, in big-endian format (for the higher width registers). > > Add a new ovxxxx_16bit_addr_reg_helpers.h header file with static inline > versions of these register access helpers, so that this code duplication > can be removed. A couple more comments. ... > +#define ovxxxx_write_reg8(s, r, v) ovxxxx_write_reg(s, r, 1, v) > +#define ovxxxx_write_reg16(s, r, v) ovxxxx_write_reg(s, r, 2, v) > +#define ovxxxx_write_reg24(s, r, v) ovxxxx_write_reg(s, r, 3, v) Btw, we probably can use _Generic() for these... ... > +static inline int ovxxxx_mod_reg(struct i2c_client *client, u16 reg, u8 mask, u8 val) Can we actually s/mod/update/ as it's more regular when we talk about IO accessor APIs? -- With Best Regards, Andy Shevchenko