Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp884924rdg; Fri, 11 Aug 2023 03:08:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEicUxODc4Cxb/WlL7+j14BbMe8NgBzv+Tce/6D2W5t5wes9bi8Rr7Ik3AeS8YoduZ2TyP9 X-Received: by 2002:a17:907:780d:b0:99b:e36a:41cf with SMTP id la13-20020a170907780d00b0099be36a41cfmr1347724ejc.70.1691748519254; Fri, 11 Aug 2023 03:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691748519; cv=none; d=google.com; s=arc-20160816; b=PMkMBWyKEwJdzGcuwNFBI63xyfnAQ6ysvLhWqq6SVaa4PyMm3va6dYobqeJEm+nZS8 q7xot3rzFxAjRgEqO+1SzXe/qkRWtwnC4O9cKEUxfuPfTvrAZ+OKTEIGyVF8J7X//93G x6l04f9L/1QgpPnndHvXLz+X3BtMRaFOqtRgih6JIAe/MhMh3wBh/bz5yVDVcUpxmF9h EQU6MCNhEWvxn8IYX6ibAwswlMbhS0UQBw1M7IWEk+LS1ge9XIkpt2w8zGZH2Y/3+oMY FaWOlh1dzU1YlflXb0lU7qco4gsatw4bmOSOe+8nQfSjbkwX2uSh80j/byV51XSTsz0+ hsWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=IegI1xMdsc2LbG5gi3POTB1R0rxsBy6HTY5odKeKCt4=; fh=u3TIf4a1SESbdZwPBlUNbiczlNEPtz5piRyU3oqul/c=; b=i/pIz/e8wpAVy8ZjansshhLBnyy2E38fivn1ggd+abrECfgJ3/iTcNJdvRGzmTeXwR pxpCTYpzPLTbjTTACnEBycOEQAccEUQ4oHoUVnMh7td/JltnQLgOMvp2+fY/lHT2v45c 5uzmdK1l/ZajAwW+KONMWqWhoB3dV0JSXvja+0MmYaF28FoiADdrqYkMFaVEsDP5o86Y bug1YNEYmGL2gd5z1dQbXAIgEsauYPxPBCvJi3WeB5jIVKR6lylRyrsHaMjqlF0o/N0l K3jA5cMgfDWLUR6Jo3qbTDDebwRamohGfEjKYp76qgmbiboxrK/OgGjXCpTv3TINSEhz gnJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FpeTja50; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pg4-20020a170907204400b00992a0f83dfcsi3218017ejb.471.2023.08.11.03.08.13; Fri, 11 Aug 2023 03:08:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FpeTja50; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233527AbjHKJq1 (ORCPT + 99 others); Fri, 11 Aug 2023 05:46:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233345AbjHKJqZ (ORCPT ); Fri, 11 Aug 2023 05:46:25 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BBC12728; Fri, 11 Aug 2023 02:46:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691747184; x=1723283184; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=GfM6LFRnkm8QU2AlvTqOJ4q6NoQlTqqbu9cz4ujRsCY=; b=FpeTja50Wb8B9n9sghwl09hGSiRz8DiSVaTn0noE2VT+ZqcGFBCMs0KQ 9yhInJfgcq6fy3wXAOqwaZYrRx6IWchzUSka4l4dVtnOgPqnvy80Zi2Rq MWxDqnmQKcXDeVpUKKQwqz7jswn/dycxGcF6PlHdEFHX5HryqvWY1+Tgb U74qOWQ/DktElCGX6Qd3Ns3SFJR4VCWSDQBRiwaW3fXsYR6HmyWgNjOYZ np54sZSq/VZmkh6hcjBAqn/8q8HyVRVHAESVVu1azhxwasfKfsqkhztPY MySdrAGC7St8bzxFUBeb+fPdu4iK4UnmLtdcV267nPzq5udIxJE0GzPr9 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10798"; a="369111748" X-IronPort-AV: E=Sophos;i="6.01,165,1684825200"; d="scan'208";a="369111748" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2023 02:46:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10798"; a="979184854" X-IronPort-AV: E=Sophos;i="6.01,165,1684825200"; d="scan'208";a="979184854" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga006.fm.intel.com with ESMTP; 11 Aug 2023 02:46:21 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qUOip-009A3Y-35; Fri, 11 Aug 2023 12:46:19 +0300 Date: Fri, 11 Aug 2023 12:46:19 +0300 From: Andy Shevchenko To: Mehdi Djait Cc: jic23@kernel.org, mazziesaccount@gmail.com, krzysztof.kozlowski+dt@linaro.org, robh+dt@kernel.org, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH v7 5/7] iio: accel: kionix-kx022a: Refactor driver and add chip_info structure Message-ID: References: <8fb74f21bda4949a862bcb4bb1ed4f0acb135948.1691607526.git.mehdi.djait.k@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8fb74f21bda4949a862bcb4bb1ed4f0acb135948.1691607526.git.mehdi.djait.k@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 09, 2023 at 09:11:36PM +0200, Mehdi Djait wrote: > Add the chip_info structure to the driver's private data to hold all > the device specific infos. > Refactor the kx022a driver implementation to make it more generic and > extensible. ... > + chip_info = device_get_match_data(&i2c->dev); > + if (!chip_info) { > + const struct i2c_device_id *id = i2c_client_get_device_id(i2c); Missing blank line. > + chip_info = (const struct kx022a_chip_info *)id->driver_data; > + if (!chip_info) > + return -EINVAL; > + } ... > - if (val > KX022A_FIFO_LENGTH) > - val = KX022A_FIFO_LENGTH; > + val = min_t(unsigned int, data->chip_info->fifo_length, val); min_t() is a beast. Please, use min() if no special requirement for min_t() here, otherwise explain why. ... > + data->fifo_buffer = kmalloc(data->chip_info->fifo_length * > + KX022A_FIFO_SAMPLES_SIZE_BYTES, GFP_KERNEL); kmalloc_array() > + if (!data->fifo_buffer) > + return -ENOMEM; -- With Best Regards, Andy Shevchenko