From patchwork Thu Feb 3 15:59:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12734299 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 D1F5DC433EF for ; Thu, 3 Feb 2022 15:59:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242285AbiBCP7L (ORCPT ); Thu, 3 Feb 2022 10:59:11 -0500 Received: from mga07.intel.com ([134.134.136.100]:14238 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231251AbiBCP7L (ORCPT ); Thu, 3 Feb 2022 10:59:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643903951; x=1675439951; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=r3LklpumRSCVRPZ1iWKibE5YvEFhUlEi5fqm7ahAhq4=; b=FrSXgMvraotO1tc/SjEpM1PP8aQQ/V58Fc9mLfoSn8q8zY1FsF0xxElr s+rIE/9XeQD+w7iWo9Tz760Nz1rqeKZpK+3AoIX9DqKciqMcwxHnDd/QH klraeQAdBfP06pBuLHfdkWvgdzCwAN0CVdR3BEP7+6NZOifaHFtToP2qB sJzJGIxiLetSeLiyA4dE1pqEyzWj0f20VE2OWnp3CUHgolOcz9YbF/zrD GAO8qB81zbOLl6s3ONyT04TI1as+KKLBoxjb1r63cKG5BsBwU+FEuDETB 6t/ER+8Pvb/H3L2iWfDiFB0Y4o5kjEsx9s7qYE4eFE8Gowz61zsItTg6n g==; X-IronPort-AV: E=McAfee;i="6200,9189,10246"; a="311477491" X-IronPort-AV: E=Sophos;i="5.88,340,1635231600"; d="scan'208";a="311477491" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2022 07:59:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,340,1635231600"; d="scan'208";a="676807120" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 03 Feb 2022 07:59:09 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1482E18D; Thu, 3 Feb 2022 17:59:23 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen Subject: [PATCH v1 1/3] iio: imu: inv_mpu6050: Drop wrong use of ACPI_PTR() Date: Thu, 3 Feb 2022 17:59:18 +0200 Message-Id: <20220203155920.18586-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org ACPI_PTR() is more harmful than helpful. For example, in this case if CONFIG_ACPI=n, the ID table left unused which is not what we want. Instead of adding ifdeffery or attribute here and there, drop ACPI_PTR(). Fixes: 3b3870646642 ("iio: imu: inv_mpu6050: Mark acpi match table as maybe unused") Fixes: fd64df16f40e ("iio: imu: inv_mpu6050: Add SPI support for MPU6000") Signed-off-by: Andy Shevchenko --- drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 7 +++---- drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c index fe03707ec2d3..ccb06d9af760 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c @@ -3,11 +3,11 @@ * Copyright (C) 2012 Invensense, Inc. */ -#include #include #include #include #include +#include #include #include #include @@ -249,11 +249,10 @@ static const struct of_device_id inv_of_match[] = { }; MODULE_DEVICE_TABLE(of, inv_of_match); -static const struct acpi_device_id __maybe_unused inv_acpi_match[] = { +static const struct acpi_device_id inv_acpi_match[] = { {"INVN6500", INV_MPU6500}, { }, }; - MODULE_DEVICE_TABLE(acpi, inv_acpi_match); static struct i2c_driver inv_mpu_driver = { @@ -262,7 +261,7 @@ static struct i2c_driver inv_mpu_driver = { .id_table = inv_mpu_id, .driver = { .of_match_table = inv_of_match, - .acpi_match_table = ACPI_PTR(inv_acpi_match), + .acpi_match_table = inv_acpi_match, .name = "inv-mpu6050-i2c", .pm = &inv_mpu_pmops, }, diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c index 6800356b25fb..44b4f74b9256 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c @@ -2,8 +2,8 @@ /* * Copyright (C) 2015 Intel Corporation Inc. */ +#include #include -#include #include #include #include @@ -148,7 +148,7 @@ static struct spi_driver inv_mpu_driver = { .id_table = inv_mpu_id, .driver = { .of_match_table = inv_of_match, - .acpi_match_table = ACPI_PTR(inv_acpi_match), + .acpi_match_table = inv_acpi_match, .name = "inv-mpu6000-spi", .pm = &inv_mpu_pmops, }, From patchwork Thu Feb 3 15:59:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12734300 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 B84F2C4332F for ; Thu, 3 Feb 2022 15:59:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352068AbiBCP7O (ORCPT ); Thu, 3 Feb 2022 10:59:14 -0500 Received: from mga14.intel.com ([192.55.52.115]:17221 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352065AbiBCP7N (ORCPT ); Thu, 3 Feb 2022 10:59:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643903953; x=1675439953; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=blShqSweU5XjV7bGSXH3IJnrLW5XAVyCdMK90nDfDh0=; b=fCFJUampY1D1YSFPuptU6Nyz8UtgepXH4pilvbYA1kzyNqqTx6KMIQWT 4x3fx4Hy04F3iPmjVN1A4z6pajGOV3rSTk7JHHwgSkCaCTY+uReTfNTq3 2gQMjOJJEll+IvpbCbwiIvTgyEZ53KE35hlbot8mykOaKw4PWj85usCRv CknQbz0WncG9HBVg13ykDDP2xSqjgKpaFzHDo+ytVk363o9NlIV3RwWvq L25Dp13/4KgjkA643IcZHsBJeiuJmY5qAghB9grJlA9Hnve56a/Qfwwu8 WsO6FWpAJ8O4kpFRxChDKmC0TawAm9z5L3miIvVAn4Mh1P8scPWvG5itb w==; X-IronPort-AV: E=McAfee;i="6200,9189,10246"; a="248387170" X-IronPort-AV: E=Sophos;i="5.88,340,1635231600"; d="scan'208";a="248387170" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2022 07:59:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,340,1635231600"; d="scan'208";a="699353546" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 03 Feb 2022 07:59:09 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 217A042; Thu, 3 Feb 2022 17:59:24 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen Subject: [PATCH v1 2/3] iio: imu: inv_mpu6050: Check ACPI companion directly Date: Thu, 3 Feb 2022 17:59:19 +0200 Message-Id: <20220203155920.18586-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220203155920.18586-1-andriy.shevchenko@linux.intel.com> References: <20220203155920.18586-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Instead of checking for ACPI handle followed by extracting a companion device, do the latter first and use it for checks. Signed-off-by: Andy Shevchenko --- drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c index f8f0cf716bc6..9b4298095d3f 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c @@ -127,15 +127,14 @@ static int inv_mpu_process_acpi_config(struct i2c_client *client, int inv_mpu_acpi_create_mux_client(struct i2c_client *client) { struct inv_mpu6050_state *st = iio_priv(dev_get_drvdata(&client->dev)); + struct acpi_device *adev = ACPI_COMPANION(&client->dev); st->mux_client = NULL; - if (ACPI_HANDLE(&client->dev)) { + if (adev) { struct i2c_board_info info; struct i2c_client *mux_client; - struct acpi_device *adev; int ret = -1; - adev = ACPI_COMPANION(&client->dev); memset(&info, 0, sizeof(info)); dmi_check_system(inv_mpu_dev_list); From patchwork Thu Feb 3 15:59:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12734301 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 4EC3EC43217 for ; Thu, 3 Feb 2022 15:59:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352072AbiBCP7O (ORCPT ); Thu, 3 Feb 2022 10:59:14 -0500 Received: from mga14.intel.com ([192.55.52.115]:17221 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231251AbiBCP7N (ORCPT ); Thu, 3 Feb 2022 10:59:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643903953; x=1675439953; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5llCnZ5NOHSTX0eHbDBs0UZwkjIn4HngtUVZ5yJy0Jg=; b=cB2Qj0INVjxAvrmne+m5AJ/xNnEtX6gluhmp9zOgKgbRN19fTRK+pwya qOAvLWCi0yn2gYFlh1PmcW4IQm7+BKGExwmmKLzx7T3QrRsLU0wNIX9GC OXnF2e+1+ZMz3MO+QONYXHV/1s3jaAeOFB+iIIl6cXY93J3r1xXXOpqkf ctzV3mcx8yF8Lmpnu9t9GPCQzUZjz0TBngRAt47uaGfFM1qfHR23lI6cE 4I8jhod+mPMsbGW4Otem8Z2j0VxOEytmr1doGjua/bnhwLabJEiT2KFiM AldVBjG/0f519x1+qrCl/d1i1wdFLLWhxnLj/lI0K8uIEIqdXitxinob2 w==; X-IronPort-AV: E=McAfee;i="6200,9189,10246"; a="248387172" X-IronPort-AV: E=Sophos;i="5.88,340,1635231600"; d="scan'208";a="248387172" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2022 07:59:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,340,1635231600"; d="scan'208";a="699353547" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 03 Feb 2022 07:59:09 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2A87030A; Thu, 3 Feb 2022 17:59:24 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen Subject: [PATCH v1 3/3] iio: imu: inv_mpu6050: Make use of device properties Date: Thu, 3 Feb 2022 17:59:20 +0200 Message-Id: <20220203155920.18586-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220203155920.18586-1-andriy.shevchenko@linux.intel.com> References: <20220203155920.18586-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Convert the module to be property provider agnostic and allow it to be used on non-OF platforms. Signed-off-by: Andy Shevchenko --- drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 8 ++++---- drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c index ccb06d9af760..55cffb5fa115 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c @@ -9,8 +9,8 @@ #include #include #include -#include #include + #include "inv_mpu_iio.h" static const struct regmap_config inv_mpu_regmap_config = { @@ -51,7 +51,7 @@ static int inv_mpu_i2c_aux_setup(struct iio_dev *indio_dev) { struct inv_mpu6050_state *st = iio_priv(indio_dev); struct device *dev = indio_dev->dev.parent; - struct device_node *mux_node; + struct fwnode_handle *mux_node; int ret; /* @@ -65,12 +65,12 @@ static int inv_mpu_i2c_aux_setup(struct iio_dev *indio_dev) case INV_MPU9150: case INV_MPU9250: case INV_MPU9255: - mux_node = of_get_child_by_name(dev->of_node, "i2c-gate"); + mux_node = device_get_named_child_node(dev, "i2c-gate"); if (mux_node != NULL) { st->magn_disabled = true; dev_warn(dev, "disable internal use of magnetometer\n"); } - of_node_put(mux_node); + fwnode_handle_put(mux_node); break; default: break; diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c index 44b4f74b9256..26a7c2521dc4 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c @@ -4,7 +4,6 @@ */ #include #include -#include #include #include #include