From patchwork Mon Aug 12 23:52:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 11091003 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7B7151395 for ; Mon, 12 Aug 2019 23:53:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A4CA285D6 for ; Mon, 12 Aug 2019 23:53:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A8CA285DA; Mon, 12 Aug 2019 23:53:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 214CC285D6 for ; Mon, 12 Aug 2019 23:53:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727004AbfHLXxJ (ORCPT ); Mon, 12 Aug 2019 19:53:09 -0400 Received: from enpas.org ([46.38.239.100]:55736 "EHLO mail.enpas.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726600AbfHLXxI (ORCPT ); Mon, 12 Aug 2019 19:53:08 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail.enpas.org (Postfix) with ESMTPSA id 51EB01006F0; Mon, 12 Aug 2019 23:53:06 +0000 (UTC) From: Max Staudt To: linux-i2c@vger.kernel.org, linux-hwmon@vger.kernel.org, Wolfram Sang , Jean Delvare , Guenter Roeck Cc: linux-m68k@vger.kernel.org, linux-kernel@vger.kernel.org, glaubitz@physik.fu-berlin.de, Max Staudt Subject: [PATCH v2 3/4] hwmon/ltc2990: Add platform_data support Date: Tue, 13 Aug 2019 01:52:36 +0200 Message-Id: <20190812235237.21797-3-max@enpas.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190812235237.21797-1-max@enpas.org> References: <20190812235237.21797-1-max@enpas.org> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This allows code using i2c_new_device() to specify a measurement mode. Signed-off-by: Max Staudt Reviewed-by: Geert Uytterhoeven --- drivers/hwmon/ltc2990.c | 9 +++++++++ include/linux/platform_data/ltc2990.h | 11 +++++++++++ 2 files changed, 20 insertions(+) create mode 100644 include/linux/platform_data/ltc2990.h diff --git a/drivers/hwmon/ltc2990.c b/drivers/hwmon/ltc2990.c index f9431ad43..f19b9c50c 100644 --- a/drivers/hwmon/ltc2990.c +++ b/drivers/hwmon/ltc2990.c @@ -14,6 +14,7 @@ #include #include #include +#include #define LTC2990_STATUS 0x00 #define LTC2990_CONTROL 0x01 @@ -206,6 +207,7 @@ static int ltc2990_i2c_probe(struct i2c_client *i2c, int ret; struct device *hwmon_dev; struct ltc2990_data *data; + struct ltc2990_platform_data *pdata = dev_get_platdata(&i2c->dev); struct device_node *of_node = i2c->dev.of_node; if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA | @@ -227,6 +229,13 @@ static int ltc2990_i2c_probe(struct i2c_client *i2c, if (data->mode[0] & ~LTC2990_MODE0_MASK || data->mode[1] & ~LTC2990_MODE1_MASK) return -EINVAL; + } else if (pdata) { + data->mode[0] = pdata->meas_mode[0]; + data->mode[1] = pdata->meas_mode[1]; + + if (data->mode[0] & ~LTC2990_MODE0_MASK || + data->mode[1] & ~LTC2990_MODE1_MASK) + return -EINVAL; } else { ret = i2c_smbus_read_byte_data(i2c, LTC2990_CONTROL); if (ret < 0) diff --git a/include/linux/platform_data/ltc2990.h b/include/linux/platform_data/ltc2990.h new file mode 100644 index 000000000..7ec89e784 --- /dev/null +++ b/include/linux/platform_data/ltc2990.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef LTC2990_PDATA_H +#define LTC2990_PDATA_H + +#include + +struct ltc2990_platform_data { + u8 meas_mode[2]; +}; + +#endif /* LTC2990_PDATA_H */