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");