From patchwork Mon Aug 31 09:08:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11745933 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD17413B6 for ; Mon, 31 Aug 2020 09:08:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C034620936 for ; Mon, 31 Aug 2020 09:08:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728310AbgHaJIZ (ORCPT ); Mon, 31 Aug 2020 05:08:25 -0400 Received: from mga18.intel.com ([134.134.136.126]:5851 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727984AbgHaJIR (ORCPT ); Mon, 31 Aug 2020 05:08:17 -0400 IronPort-SDR: 1CmONOxCBFpw/yQa904zPft7JHBE3HhQ3H7tMw8t0BjYcN1P6kUV85j8/U/9vsMI798h1MK4Uo TXcEYSLQydEg== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="144613467" X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="144613467" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 02:08:16 -0700 IronPort-SDR: /RCPWoiG/VFWw7ijVbGi0zCkQHFJuWUTXhTJiireBHbiczHJhqsv8ipezevhnyJCim28Ry/ipe /WFFyWb4QekA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="476649701" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 31 Aug 2020 02:08:15 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3447816D; Mon, 31 Aug 2020 12:08:13 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , linux-iio@vger.kernel.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: Andy Shevchenko Subject: [PATCH v1 1/8] iio: accel: bma220: Fix returned codes from bma220_init(), bma220_deinit() Date: Mon, 31 Aug 2020 12:08:06 +0300 Message-Id: <20200831090813.78841-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Potentially bma220_init() and bma220_deinit() may return positive codes. Fix the logic to return proper error codes instead. Signed-off-by: Andy Shevchenko --- drivers/iio/accel/bma220_spi.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c index da8b36cc8628..3247b9c8abcb 100644 --- a/drivers/iio/accel/bma220_spi.c +++ b/drivers/iio/accel/bma220_spi.c @@ -198,10 +198,12 @@ static int bma220_init(struct spi_device *spi) /* Make sure the chip is powered on */ ret = bma220_read_reg(spi, BMA220_REG_SUSPEND); + if (ret == BMA220_SUSPEND_WAKE) + ret = bma220_read_reg(spi, BMA220_REG_SUSPEND); if (ret < 0) return ret; - else if (ret == BMA220_SUSPEND_WAKE) - return bma220_read_reg(spi, BMA220_REG_SUSPEND); + if (ret == BMA220_SUSPEND_WAKE) + return -EBUSY; return 0; } @@ -212,10 +214,12 @@ static int bma220_deinit(struct spi_device *spi) /* Make sure the chip is powered off */ ret = bma220_read_reg(spi, BMA220_REG_SUSPEND); + if (ret == BMA220_SUSPEND_SLEEP) + ret = bma220_read_reg(spi, BMA220_REG_SUSPEND); if (ret < 0) return ret; - else if (ret == BMA220_SUSPEND_SLEEP) - return bma220_read_reg(spi, BMA220_REG_SUSPEND); + if (ret == BMA220_SUSPEND_SLEEP) + return -EBUSY; return 0; } @@ -245,7 +249,7 @@ static int bma220_probe(struct spi_device *spi) indio_dev->available_scan_masks = bma220_accel_scan_masks; ret = bma220_init(data->spi_device); - if (ret < 0) + if (ret) return ret; ret = iio_triggered_buffer_setup(indio_dev, iio_pollfunc_store_time, From patchwork Mon Aug 31 09:08:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11745941 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B3E1913B6 for ; Mon, 31 Aug 2020 09:08:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A2C8C20936 for ; Mon, 31 Aug 2020 09:08:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728033AbgHaJIa (ORCPT ); Mon, 31 Aug 2020 05:08:30 -0400 Received: from mga18.intel.com ([134.134.136.126]:5851 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728301AbgHaJIZ (ORCPT ); Mon, 31 Aug 2020 05:08:25 -0400 IronPort-SDR: TXNiQmrdoNu2PXPiw8/IF76NwkvPZlGcVDxeH/F7i0iiGFkcaZNlH9zs7MEebMAjV1VpeU2Wjs zBn8r6NJ2Ibw== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="144613469" X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="144613469" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 02:08:16 -0700 IronPort-SDR: J1yGO5KGKxnFLP90RxRhZ4S6EZ/UWhEdxEfMb7aQwQcdaHnNT+Ucm5f8ePCCpT/CeloIrTGGjG b5+QxGUNLgww== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="476649702" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 31 Aug 2020 02:08:15 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3F76A165; Mon, 31 Aug 2020 12:08:14 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , linux-iio@vger.kernel.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: Andy Shevchenko Subject: [PATCH v1 2/8] iio: accel: bma220: Convert to use ->read_avail() Date: Mon, 31 Aug 2020 12:08:07 +0300 Message-Id: <20200831090813.78841-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200831090813.78841-1-andriy.shevchenko@linux.intel.com> References: <20200831090813.78841-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Convert to use ->read_avail() instead of open-coded attribute handling. While here, fix the typo in array definition and append comma in case of the future extension. Signed-off-by: Andy Shevchenko --- drivers/iio/accel/bma220_spi.c | 36 ++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c index 3247b9c8abcb..cb634a3a995d 100644 --- a/drivers/iio/accel/bma220_spi.c +++ b/drivers/iio/accel/bma220_spi.c @@ -30,7 +30,6 @@ #define BMA220_SUSPEND_WAKE 0x00 #define BMA220_DEVICE_NAME "bma220" -#define BMA220_SCALE_AVAILABLE "0.623 1.248 2.491 4.983" #define BMA220_ACCEL_CHANNEL(index, reg, axis) { \ .type = IIO_ACCEL, \ @@ -55,19 +54,8 @@ enum bma220_axis { AXIS_Z, }; -static IIO_CONST_ATTR(in_accel_scale_available, BMA220_SCALE_AVAILABLE); - -static struct attribute *bma220_attributes[] = { - &iio_const_attr_in_accel_scale_available.dev_attr.attr, - NULL, -}; - -static const struct attribute_group bma220_attribute_group = { - .attrs = bma220_attributes, -}; - -static const int bma220_scale_table[][4] = { - {0, 623000}, {1, 248000}, {2, 491000}, {4, 983000} +static const int bma220_scale_table[][2] = { + {0, 623000}, {1, 248000}, {2, 491000}, {4, 983000}, }; struct bma220_data { @@ -182,10 +170,28 @@ static int bma220_write_raw(struct iio_dev *indio_dev, return -EINVAL; } +static int bma220_read_avail(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, + long mask) +{ + struct bma220_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_SCALE: + *vals = (int *)bma220_scale_table; + *type = IIO_VAL_INT_PLUS_MICRO; + *length = ARRAY_SIZE(bma220_scale_table) * 2; + return IIO_AVAIL_LIST; + default: + return -EINVAL; + } +} + static const struct iio_info bma220_info = { .read_raw = bma220_read_raw, .write_raw = bma220_write_raw, - .attrs = &bma220_attribute_group, + .read_avail = bma220_read_avail, }; static int bma220_init(struct spi_device *spi) From patchwork Mon Aug 31 09:08:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11745939 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 96F9F17D0 for ; Mon, 31 Aug 2020 09:08:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E818208DB for ; Mon, 31 Aug 2020 09:08:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726102AbgHaJIa (ORCPT ); Mon, 31 Aug 2020 05:08:30 -0400 Received: from mga05.intel.com ([192.55.52.43]:6893 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728033AbgHaJIR (ORCPT ); Mon, 31 Aug 2020 05:08:17 -0400 IronPort-SDR: QcIESwMunFHjd8Ci0JdHKphmYHBQFEBwqYXcSjSHHrwzpyM5XbCexUB9YVHPSeZqwdVeusQMr+ 1VW5zNjoEOLw== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="241747285" X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="241747285" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 02:08:16 -0700 IronPort-SDR: tldvvm5KGn7kdStVNrs5Xh2X1lbMXeTBd7NaKBD+IUzwStzb37JRJsZ4NwOvJct1meEz6B/ADE D35evcZgRZMw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="330630268" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 31 Aug 2020 02:08:15 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4D894302; Mon, 31 Aug 2020 12:08:14 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , linux-iio@vger.kernel.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: Andy Shevchenko Subject: [PATCH v1 3/8] iio: accel: bma220: Use dev_get_drvdata() directly Date: Mon, 31 Aug 2020 12:08:08 +0300 Message-Id: <20200831090813.78841-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200831090813.78841-1-andriy.shevchenko@linux.intel.com> References: <20200831090813.78841-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Instead of using to_spi_dev() + spi_get_drvdata(), use dev_get_drvdata() to make code simpler. Signed-off-by: Andy Shevchenko --- drivers/iio/accel/bma220_spi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c index cb634a3a995d..529c88fc2949 100644 --- a/drivers/iio/accel/bma220_spi.c +++ b/drivers/iio/accel/bma220_spi.c @@ -291,8 +291,7 @@ static int bma220_remove(struct spi_device *spi) #ifdef CONFIG_PM_SLEEP static int bma220_suspend(struct device *dev) { - struct bma220_data *data = - iio_priv(spi_get_drvdata(to_spi_device(dev))); + struct bma220_data *data = iio_priv(dev_get_drvdata(dev)); /* The chip can be suspended/woken up by a simple register read. */ return bma220_read_reg(data->spi_device, BMA220_REG_SUSPEND); @@ -300,8 +299,7 @@ static int bma220_suspend(struct device *dev) static int bma220_resume(struct device *dev) { - struct bma220_data *data = - iio_priv(spi_get_drvdata(to_spi_device(dev))); + struct bma220_data *data = iio_priv(dev_get_drvdata(dev)); return bma220_read_reg(data->spi_device, BMA220_REG_SUSPEND); } From patchwork Mon Aug 31 09:08:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11745935 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 29EEC1709 for ; Mon, 31 Aug 2020 09:08:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 10F0920936 for ; Mon, 31 Aug 2020 09:08:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725954AbgHaJI2 (ORCPT ); Mon, 31 Aug 2020 05:08:28 -0400 Received: from mga01.intel.com ([192.55.52.88]:58431 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728280AbgHaJIV (ORCPT ); Mon, 31 Aug 2020 05:08:21 -0400 IronPort-SDR: ZncNHNkswLmCGN2BwvHutI/G5BvPJaQYCOTiceYzA5I7r6re0qMv8yjNRUtwhuUFrNFspVr8PO Mn+ahR5NVbIQ== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="174981583" X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="174981583" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 02:08:17 -0700 IronPort-SDR: 4uvwCxdgbpA4q5u+VBFY7Vwmm3fDf9bJi9uWRiqbrWn5VHBb4+HlCmaREaAAauod5w9JAAYZ7Q 53F8t4Pz044Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="445638054" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 31 Aug 2020 02:08:15 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 52995199; Mon, 31 Aug 2020 12:08:14 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , linux-iio@vger.kernel.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: Andy Shevchenko Subject: [PATCH v1 4/8] iio: accel: bma220: Mark PM functions as __maybe_unused Date: Mon, 31 Aug 2020 12:08:09 +0300 Message-Id: <20200831090813.78841-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200831090813.78841-1-andriy.shevchenko@linux.intel.com> References: <20200831090813.78841-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Instead of using ugly ifdeffery, mark PM functions as __maybe_unused. Signed-off-by: Andy Shevchenko --- drivers/iio/accel/bma220_spi.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c index 529c88fc2949..e55c5f5dd6b4 100644 --- a/drivers/iio/accel/bma220_spi.c +++ b/drivers/iio/accel/bma220_spi.c @@ -288,8 +288,7 @@ static int bma220_remove(struct spi_device *spi) return bma220_deinit(spi); } -#ifdef CONFIG_PM_SLEEP -static int bma220_suspend(struct device *dev) +static __maybe_unused int bma220_suspend(struct device *dev) { struct bma220_data *data = iio_priv(dev_get_drvdata(dev)); @@ -297,7 +296,7 @@ static int bma220_suspend(struct device *dev) return bma220_read_reg(data->spi_device, BMA220_REG_SUSPEND); } -static int bma220_resume(struct device *dev) +static __maybe_unused int bma220_resume(struct device *dev) { struct bma220_data *data = iio_priv(dev_get_drvdata(dev)); @@ -306,11 +305,6 @@ static int bma220_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(bma220_pm_ops, bma220_suspend, bma220_resume); -#define BMA220_PM_OPS (&bma220_pm_ops) -#else -#define BMA220_PM_OPS NULL -#endif - static const struct spi_device_id bma220_spi_id[] = { {"bma220", 0}, {} @@ -328,7 +322,7 @@ MODULE_DEVICE_TABLE(spi, bma220_spi_id); static struct spi_driver bma220_driver = { .driver = { .name = "bma220_spi", - .pm = BMA220_PM_OPS, + .pm = &bma220_pm_ops, .acpi_match_table = ACPI_PTR(bma220_acpi_id), }, .probe = bma220_probe, From patchwork Mon Aug 31 09:08:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11745937 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5E2A81667 for ; Mon, 31 Aug 2020 09:08:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D64C208DB for ; Mon, 31 Aug 2020 09:08:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727984AbgHaJI3 (ORCPT ); Mon, 31 Aug 2020 05:08:29 -0400 Received: from mga14.intel.com ([192.55.52.115]:4952 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726102AbgHaJIS (ORCPT ); Mon, 31 Aug 2020 05:08:18 -0400 IronPort-SDR: tlwJoegQ4QilfVWsfdxupVjp0agYyLXg9M/9rMJCghBgW0Ile5cWFkP3LPa8zYvhACpJqtqovh OgWXt2J53A/g== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="156194074" X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="156194074" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 02:08:17 -0700 IronPort-SDR: yhkEvU2fz4xplUgOenK6O9OBWsUC20D+Wh2HW0BZAOmaGfxq9fY3kv7X4lcJaZAhqXCbrDSl8l BJxbv25+YtBQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="300978867" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 31 Aug 2020 02:08:15 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 60E4E4F2; Mon, 31 Aug 2020 12:08:14 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , linux-iio@vger.kernel.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: Andy Shevchenko Subject: [PATCH v1 5/8] iio: accel: bma220: Drop ACPI_PTR() and accompanying ifdeffery Date: Mon, 31 Aug 2020 12:08:10 +0300 Message-Id: <20200831090813.78841-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200831090813.78841-1-andriy.shevchenko@linux.intel.com> References: <20200831090813.78841-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The driver is quite likely used only on ACPI based platforms and rarely build with CONFIG_ACPI=n. Even though, the few dozens of bytes is better than ugly ifdeffery and inclusion of heavy header. As a result, replace acpi.h with mod_devicetable.h. Signed-off-by: Andy Shevchenko --- drivers/iio/accel/bma220_spi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c index e55c5f5dd6b4..105c1dece890 100644 --- a/drivers/iio/accel/bma220_spi.c +++ b/drivers/iio/accel/bma220_spi.c @@ -5,8 +5,8 @@ * Copyright (c) 2016, Intel Corporation. */ -#include #include +#include #include #include #include @@ -310,20 +310,18 @@ static const struct spi_device_id bma220_spi_id[] = { {} }; -#ifdef CONFIG_ACPI static const struct acpi_device_id bma220_acpi_id[] = { {"BMA0220", 0}, {} }; MODULE_DEVICE_TABLE(spi, bma220_spi_id); -#endif static struct spi_driver bma220_driver = { .driver = { .name = "bma220_spi", .pm = &bma220_pm_ops, - .acpi_match_table = ACPI_PTR(bma220_acpi_id), + .acpi_match_table = bma220_acpi_id, }, .probe = bma220_probe, .remove = bma220_remove, From patchwork Mon Aug 31 09:08:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11745945 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83AA113B6 for ; Mon, 31 Aug 2020 09:08:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7299220936 for ; Mon, 31 Aug 2020 09:08:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728292AbgHaJIa (ORCPT ); Mon, 31 Aug 2020 05:08:30 -0400 Received: from mga05.intel.com ([192.55.52.43]:6895 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728298AbgHaJIZ (ORCPT ); Mon, 31 Aug 2020 05:08:25 -0400 IronPort-SDR: OBsRFUerX1qYP7ZrU9ZPTrFhsTWusPYzYnMu6NZmdQtlI2qLfpLtby91SPP2PqhE/a3ZlIyIwF 8AMS4/OxtdMA== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="241747289" X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="241747289" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 02:08:19 -0700 IronPort-SDR: MrSX938BfpmsnBoVuoy60s4iZbvjInNu574pEoTKLAXx7X5UjkUkxQcWGcB93IYFtL13UH/eK0 pNupyzGLADYg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="330630289" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 31 Aug 2020 02:08:17 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 65EB840D; Mon, 31 Aug 2020 12:08:14 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , linux-iio@vger.kernel.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: Andy Shevchenko Subject: [PATCH v1 6/8] iio: accel: bma220: Group IIO headers together Date: Mon, 31 Aug 2020 12:08:11 +0300 Message-Id: <20200831090813.78841-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200831090813.78841-1-andriy.shevchenko@linux.intel.com> References: <20200831090813.78841-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Group IIO headers together and follow the common pattern of header inclusion, i.e. more generic first. Signed-off-by: Andy Shevchenko --- drivers/iio/accel/bma220_spi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c index 105c1dece890..1a2cf486e546 100644 --- a/drivers/iio/accel/bma220_spi.c +++ b/drivers/iio/accel/bma220_spi.c @@ -8,10 +8,11 @@ #include #include #include +#include + #include #include #include -#include #include #include From patchwork Mon Aug 31 09:08:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11745943 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C4001709 for ; Mon, 31 Aug 2020 09:08:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58B3E208CA for ; Mon, 31 Aug 2020 09:08:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728280AbgHaJIa (ORCPT ); Mon, 31 Aug 2020 05:08:30 -0400 Received: from mga01.intel.com ([192.55.52.88]:58432 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728292AbgHaJIZ (ORCPT ); Mon, 31 Aug 2020 05:08:25 -0400 IronPort-SDR: STLay4dxQShfUTIibGRl6hBHsxGmEDd05wxIcn/RyrPmx4re8Ld+7vl1srjq8jCR2+zjH9Ifvn E4N2/XGRSm3Q== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="174981584" X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="174981584" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 02:08:19 -0700 IronPort-SDR: Te014Qfta5FWEB8Umt88y16eEW7Ef3nS6Kbxtr4rRPws3K+nlLUaBY0w4h+K/kmQlthemyTuPT Oc/so0lFwWRQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="333274179" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 31 Aug 2020 02:08:17 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7546753F; Mon, 31 Aug 2020 12:08:14 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , linux-iio@vger.kernel.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: Andy Shevchenko Subject: [PATCH v1 7/8] iio: accel: bma220: Use BIT() and GENMASK() macros Date: Mon, 31 Aug 2020 12:08:12 +0300 Message-Id: <20200831090813.78841-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200831090813.78841-1-andriy.shevchenko@linux.intel.com> References: <20200831090813.78841-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Code is better to read when numbers of bit are explicitly used. Signed-off-by: Andy Shevchenko --- drivers/iio/accel/bma220_spi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c index 1a2cf486e546..a766a0e13efb 100644 --- a/drivers/iio/accel/bma220_spi.c +++ b/drivers/iio/accel/bma220_spi.c @@ -5,6 +5,7 @@ * Copyright (c) 2016, Intel Corporation. */ +#include #include #include #include @@ -24,8 +25,8 @@ #define BMA220_REG_SUSPEND 0x18 #define BMA220_CHIP_ID 0xDD -#define BMA220_READ_MASK 0x80 -#define BMA220_RANGE_MASK 0x03 +#define BMA220_READ_MASK BIT(7) +#define BMA220_RANGE_MASK GENMASK(1, 0) #define BMA220_DATA_SHIFT 2 #define BMA220_SUSPEND_SLEEP 0xFF #define BMA220_SUSPEND_WAKE 0x00 From patchwork Mon Aug 31 09:08:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11745947 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D39AE1744 for ; Mon, 31 Aug 2020 09:08:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BCCAD208DB for ; Mon, 31 Aug 2020 09:08:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728298AbgHaJIa (ORCPT ); Mon, 31 Aug 2020 05:08:30 -0400 Received: from mga04.intel.com ([192.55.52.120]:4410 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728290AbgHaJIZ (ORCPT ); Mon, 31 Aug 2020 05:08:25 -0400 IronPort-SDR: myodC5bQWo4DHE5Dv4BSlXYK40iboQvhT4pmJtxwvqIxNgMVk5neNGr2W0ACpjIwn15aFc7QCy ONHuhLx16foA== X-IronPort-AV: E=McAfee;i="6000,8403,9729"; a="154339307" X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="154339307" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2020 02:08:19 -0700 IronPort-SDR: 2nOkjHSKgCF3H4DN8PSnePXN+52eGtIy+3seGRr/P7gjMV2piRyWuKujNUFF5nKuDRI2VaRasd 6u/0+KShK9yA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,375,1592895600"; d="scan'208";a="340588817" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 31 Aug 2020 02:08:17 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7AE0D536; Mon, 31 Aug 2020 12:08:14 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , linux-iio@vger.kernel.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: Andy Shevchenko Subject: [PATCH v1 8/8] iio: accel: bma220: Remove unneeded blank lines Date: Mon, 31 Aug 2020 12:08:13 +0300 Message-Id: <20200831090813.78841-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200831090813.78841-1-andriy.shevchenko@linux.intel.com> References: <20200831090813.78841-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org There are few blank lines that split structure definitions with their users. Remove them to increase readability. While here, update copyright year. Signed-off-by: Andy Shevchenko --- drivers/iio/accel/bma220_spi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c index a766a0e13efb..4a8862ba366c 100644 --- a/drivers/iio/accel/bma220_spi.c +++ b/drivers/iio/accel/bma220_spi.c @@ -2,7 +2,7 @@ /** * BMA220 Digital triaxial acceleration sensor driver * - * Copyright (c) 2016, Intel Corporation. + * Copyright (c) 2016,2020 Intel Corporation. */ #include @@ -304,7 +304,6 @@ static __maybe_unused int bma220_resume(struct device *dev) return bma220_read_reg(data->spi_device, BMA220_REG_SUSPEND); } - static SIMPLE_DEV_PM_OPS(bma220_pm_ops, bma220_suspend, bma220_resume); static const struct spi_device_id bma220_spi_id[] = { @@ -316,7 +315,6 @@ static const struct acpi_device_id bma220_acpi_id[] = { {"BMA0220", 0}, {} }; - MODULE_DEVICE_TABLE(spi, bma220_spi_id); static struct spi_driver bma220_driver = { @@ -329,7 +327,6 @@ static struct spi_driver bma220_driver = { .remove = bma220_remove, .id_table = bma220_spi_id, }; - module_spi_driver(bma220_driver); MODULE_AUTHOR("Tiberiu Breana ");