From patchwork Wed Jun 15 11:47:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12882221 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 9CBFBC433EF for ; Wed, 15 Jun 2022 11:47:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240406AbiFOLrv (ORCPT ); Wed, 15 Jun 2022 07:47:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237723AbiFOLru (ORCPT ); Wed, 15 Jun 2022 07:47:50 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9171E25EAE; Wed, 15 Jun 2022 04:47:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655293668; x=1686829668; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=QbIkcyUw/L14+nIayRRYoRVuzlGbZsXJBtcZC1EJL9o=; b=YHpKRDPJyQnqZEzFRFYRevwBwirC+xV1rwYc/00wzqiDanFyrfqTGsAt jAH+vGLh9+k3GCaXCRiC7EC4i+Znw9ZliCeDoHR9SDF3F5jDhpm4TB3Zm vWEvhwfo37rakcc3FSR6aUkzBQTrNBnVXsOGZYH9A2+fA9LEGT/g+EHr1 uJ162YbkdAcHdhZxZWcGcNzboxZMG7iCsGu5Juv0gJef6s7Jss0jv1omv T+q/wFrJ/dFftRzQYI6Kx9zcUxzSxYSYNSvnPTCyiHgmhv2dlSsR1rIUB 10iPxytcw90NMfcw8hSve7jomOLKCa4x9G2zswbklWCbYu4VTIbyBfqmQ Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10378"; a="267621696" X-IronPort-AV: E=Sophos;i="5.91,302,1647327600"; d="scan'208";a="267621696" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2022 04:47:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,302,1647327600"; d="scan'208";a="618424942" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 15 Jun 2022 04:47:46 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3C8BA18F; Wed, 15 Jun 2022 14:47:50 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Gwendal Grignou , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen Subject: [PATCH v2 1/2] iio: proximity: sx_common: Don't use IIO device for properties Date: Wed, 15 Jun 2022 14:47:45 +0300 Message-Id: <20220615114746.2767-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org It's not correct to use artificial device created by IIO core to retrieve device properties. Even ->get_default_reg() callback takes a simple struct device pointer which suggests it wants to operate on the real device. Correct this by replacing pointer to IIO device by a real device pointer in the caller of ->get_default_reg(). Signed-off-by: Andy Shevchenko Reviewed-by: Gwendal Grignou --- v2: new patch (necessary prerequisite for the following change) drivers/iio/proximity/sx_common.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/iio/proximity/sx_common.c b/drivers/iio/proximity/sx_common.c index 8ad814d96b7e..9f2e47385198 100644 --- a/drivers/iio/proximity/sx_common.c +++ b/drivers/iio/proximity/sx_common.c @@ -434,7 +434,7 @@ static void sx_common_regulator_disable(void *_data) #define SX_COMMON_SOFT_RESET 0xde -static int sx_common_init_device(struct iio_dev *indio_dev) +static int sx_common_init_device(struct device *dev, struct iio_dev *indio_dev) { struct sx_common_data *data = iio_priv(indio_dev); struct sx_common_reg_default tmp; @@ -456,8 +456,7 @@ static int sx_common_init_device(struct iio_dev *indio_dev) /* Program defaults from constant or BIOS. */ for (i = 0; i < data->chip_info->num_default_regs; i++) { - initval = data->chip_info->ops.get_default_reg(&indio_dev->dev, - i, &tmp); + initval = data->chip_info->ops.get_default_reg(dev, i, &tmp); ret = regmap_write(data->regmap, initval->reg, initval->def); if (ret) return ret; @@ -530,7 +529,7 @@ int sx_common_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); - ret = sx_common_init_device(indio_dev); + ret = sx_common_init_device(dev, indio_dev); if (ret) return dev_err_probe(dev, ret, "Unable to initialize sensor\n"); From patchwork Wed Jun 15 11:47:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12882220 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 016E2C43334 for ; Wed, 15 Jun 2022 11:47:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239272AbiFOLrv (ORCPT ); Wed, 15 Jun 2022 07:47:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234129AbiFOLru (ORCPT ); Wed, 15 Jun 2022 07:47:50 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A35A12610F; Wed, 15 Jun 2022 04:47:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655293668; x=1686829668; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ROUuMUroMsslJq/9ZSReRN0oM6mJ1TOrX9bCNwvFXL0=; b=NGl873l7fkf1rKR1gAWEI5pd5uONg39M11Py1NDY0TMYxu7IjL3mnsCS /0p5uPGyVe19NZwhRWdD8h3F9qpCdaH57NYcX9pSwdfatRytfCOoWHEOt Jx2CWkuw8tjy/XrZi+tBVIDRoOBhHdwl8KWv5FH8dpPyiGrPb/3bcxrVh YKhAsqeN/v9l6L4zglNeUyvWmFeHLugqg9Qo2Om4XIy1Uz9e4l8iebOMY RLAuYgdyzfCm696MmGZIA77HFImR11nIEzjtVrdRqeEz6HFqVQTljLZ2Q hF5JhNLrCczyKXRGE0p/6ip611H8A9BN4jxuF9Z4aGboh7dttILflZgBS Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10378"; a="342894651" X-IronPort-AV: E=Sophos;i="5.91,302,1647327600"; d="scan'208";a="342894651" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2022 04:47:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,302,1647327600"; d="scan'208";a="571788930" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 15 Jun 2022 04:47:46 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4B8FA103; Wed, 15 Jun 2022 14:47:50 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Gwendal Grignou , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen Subject: [PATCH v2 2/2] iio: proximity: sx_common: Allow IIO core to take care of firmware node Date: Wed, 15 Jun 2022 14:47:46 +0300 Message-Id: <20220615114746.2767-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220615114746.2767-1-andriy.shevchenko@linux.intel.com> References: <20220615114746.2767-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org IIO core correctly will take care of firmware node if it's not set in the driver. Drop ACPI and OF specifics from the driver and allow IIO core to handle this. Signed-off-by: Andy Shevchenko Reviewed-by: Gwendal Grignou --- v2: no changes drivers/iio/proximity/sx_common.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/iio/proximity/sx_common.c b/drivers/iio/proximity/sx_common.c index 9f2e47385198..d70a6b4f0bf8 100644 --- a/drivers/iio/proximity/sx_common.c +++ b/drivers/iio/proximity/sx_common.c @@ -5,7 +5,6 @@ * Common part of most Semtech SAR sensor. */ -#include #include #include #include @@ -519,8 +518,6 @@ int sx_common_probe(struct i2c_client *client, if (ret) return dev_err_probe(dev, ret, "error reading WHOAMI\n"); - ACPI_COMPANION_SET(&indio_dev->dev, ACPI_COMPANION(dev)); - indio_dev->dev.of_node = client->dev.of_node; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = data->chip_info->iio_channels;