From patchwork Tue Nov 20 15:59:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1000568 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42zr4h2tj7z9s8F for ; Wed, 21 Nov 2018 02:59:48 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730179AbeKUC3f (ORCPT ); Tue, 20 Nov 2018 21:29:35 -0500 Received: from mga07.intel.com ([134.134.136.100]:25306 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728834AbeKUC3e (ORCPT ); Tue, 20 Nov 2018 21:29:34 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 07:59:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,257,1539673200"; d="scan'208";a="282706095" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 20 Nov 2018 07:59:26 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5FAE38D; Tue, 20 Nov 2018 17:59:25 +0200 (EET) From: Andy Shevchenko To: Darren Hart , platform-driver-x86@vger.kernel.org, "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, Jonathan Cameron , Wolfram Sang , Mika Westerberg , linux-i2c@vger.kernel.org, Hans de Goede , Heikki Krogerus , linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 01/15] platform/x86: intel_cht_int33fe: Remove duplicate NULL check Date: Tue, 20 Nov 2018 17:59:10 +0200 Message-Id: <20181120155924.10773-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> References: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Since i2c_unregister_device() became NULL-aware we may remove duplicate NULL check. Signed-off-by: Andy Shevchenko --- drivers/platform/x86/intel_cht_int33fe.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/intel_cht_int33fe.c b/drivers/platform/x86/intel_cht_int33fe.c index 464fe93657b5..431151d4e611 100644 --- a/drivers/platform/x86/intel_cht_int33fe.c +++ b/drivers/platform/x86/intel_cht_int33fe.c @@ -213,8 +213,7 @@ static int cht_int33fe_probe(struct platform_device *pdev) i2c_unregister_device(data->fusb302); out_unregister_max17047: - if (data->max17047) - i2c_unregister_device(data->max17047); + i2c_unregister_device(data->max17047); device_connections_remove(data->connections); @@ -227,8 +226,7 @@ static int cht_int33fe_remove(struct platform_device *pdev) i2c_unregister_device(data->pi3usb30532); i2c_unregister_device(data->fusb302); - if (data->max17047) - i2c_unregister_device(data->max17047); + i2c_unregister_device(data->max17047); device_connections_remove(data->connections); From patchwork Tue Nov 20 15:59:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1000579 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42zr6D3Kbpz9s1c for ; Wed, 21 Nov 2018 03:01:08 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728413AbeKUC3V (ORCPT ); Tue, 20 Nov 2018 21:29:21 -0500 Received: from mga05.intel.com ([192.55.52.43]:27492 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728829AbeKUC3T (ORCPT ); Tue, 20 Nov 2018 21:29:19 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 07:59:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,257,1539673200"; d="scan'208";a="109858807" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 20 Nov 2018 07:59:26 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 6ACA0399; Tue, 20 Nov 2018 17:59:25 +0200 (EET) From: Andy Shevchenko To: Darren Hart , platform-driver-x86@vger.kernel.org, "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, Jonathan Cameron , Wolfram Sang , Mika Westerberg , linux-i2c@vger.kernel.org, Hans de Goede , Heikki Krogerus , linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 02/15] platform/x86: intel_cht_int33fe: Accept errors of i2c_acpi_new_device() Date: Tue, 20 Nov 2018 17:59:11 +0200 Message-Id: <20181120155924.10773-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> References: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org In the future i2c_acpi_new_device() will return error pointer in some cases. Prepare i2c-multi-instantiate driver to support that. Signed-off-by: Andy Shevchenko --- drivers/platform/x86/intel_cht_int33fe.c | 28 +++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/intel_cht_int33fe.c b/drivers/platform/x86/intel_cht_int33fe.c index 431151d4e611..367d6e304ade 100644 --- a/drivers/platform/x86/intel_cht_int33fe.c +++ b/drivers/platform/x86/intel_cht_int33fe.c @@ -168,8 +168,14 @@ static int cht_int33fe_probe(struct platform_device *pdev) board_info.dev_name = "max17047"; board_info.properties = max17047_props; data->max17047 = i2c_acpi_new_device(dev, 1, &board_info); - if (!data->max17047) - return -EPROBE_DEFER; /* Wait for i2c-adapter to load */ + if (IS_ERR(data->max17047)) + ret = PTR_ERR(data->max17047); + else if (!data->max17047) + ret = -EPROBE_DEFER; /* Wait for i2c-adapter to load */ + else + ret = 0; + if (ret) + return ret; } data->connections[0].endpoint[0] = "port0"; @@ -194,7 +200,13 @@ static int cht_int33fe_probe(struct platform_device *pdev) board_info.irq = fusb302_irq; data->fusb302 = i2c_acpi_new_device(dev, 2, &board_info); - if (!data->fusb302) + if (IS_ERR(data->fusb302)) + ret = PTR_ERR(data->fusb302); + else if (!data->fusb302) + ret = -EPROBE_DEFER; /* Wait for the i2c-adapter to load */ + else + ret = 0; + if (ret) goto out_unregister_max17047; memset(&board_info, 0, sizeof(board_info)); @@ -202,7 +214,13 @@ static int cht_int33fe_probe(struct platform_device *pdev) strlcpy(board_info.type, "pi3usb30532", I2C_NAME_SIZE); data->pi3usb30532 = i2c_acpi_new_device(dev, 3, &board_info); - if (!data->pi3usb30532) + if (IS_ERR(data->pi3usb30532)) + ret = PTR_ERR(data->pi3usb30532); + else if (!data->pi3usb30532) + ret = -EPROBE_DEFER; /* Wait for the i2c-adapter to load */ + else + ret = 0; + if (ret) goto out_unregister_fusb302; platform_set_drvdata(pdev, data); @@ -217,7 +235,7 @@ static int cht_int33fe_probe(struct platform_device *pdev) device_connections_remove(data->connections); - return -EPROBE_DEFER; /* Wait for the i2c-adapter to load */ + return ret; } static int cht_int33fe_remove(struct platform_device *pdev) From patchwork Tue Nov 20 15:59:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1000580 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42zr6K067wz9s7T for ; Wed, 21 Nov 2018 03:01:13 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728849AbeKUC3T (ORCPT ); Tue, 20 Nov 2018 21:29:19 -0500 Received: from mga07.intel.com ([134.134.136.100]:25306 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728413AbeKUC3S (ORCPT ); Tue, 20 Nov 2018 21:29:18 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 07:59:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,257,1539673200"; d="scan'208";a="282706096" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 20 Nov 2018 07:59:26 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 756283E3; Tue, 20 Nov 2018 17:59:25 +0200 (EET) From: Andy Shevchenko To: Darren Hart , platform-driver-x86@vger.kernel.org, "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, Jonathan Cameron , Wolfram Sang , Mika Westerberg , linux-i2c@vger.kernel.org, Hans de Goede , Heikki Krogerus , linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 03/15] platform/x86: i2c-multi-instantiate: Accept errors of i2c_acpi_new_device() Date: Tue, 20 Nov 2018 17:59:12 +0200 Message-Id: <20181120155924.10773-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> References: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org In the future i2c_acpi_new_device() will return error pointer in some cases. Prepare i2c-multi-instantiate driver to support that. Signed-off-by: Andy Shevchenko --- drivers/platform/x86/i2c-multi-instantiate.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c index 5456581b473c..e3345da82c84 100644 --- a/drivers/platform/x86/i2c-multi-instantiate.c +++ b/drivers/platform/x86/i2c-multi-instantiate.c @@ -72,9 +72,14 @@ static int i2c_multi_inst_probe(struct platform_device *pdev) board_info.irq = ret; } multi->clients[i] = i2c_acpi_new_device(dev, i, &board_info); - if (!multi->clients[i]) { - dev_err(dev, "Error creating i2c-client, idx %d\n", i); + if (IS_ERR(multi->clients[i])) + ret = PTR_ERR(multi->clients[i]); + else if (!multi->clients[i]) ret = -ENODEV; + else + ret = 0; + if (ret) { + dev_err(dev, "Error creating i2c-client, idx %d\n", i); goto error; } } From patchwork Tue Nov 20 15:59:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1000581 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42zr6L0811z9s7T for ; Wed, 21 Nov 2018 03:01:14 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728588AbeKUCbB (ORCPT ); Tue, 20 Nov 2018 21:31:01 -0500 Received: from mga03.intel.com ([134.134.136.65]:26867 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725925AbeKUC3S (ORCPT ); Tue, 20 Nov 2018 21:29:18 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 07:59:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,257,1539673200"; d="scan'208";a="92628351" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 20 Nov 2018 07:59:26 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7EDFF4D6; Tue, 20 Nov 2018 17:59:25 +0200 (EET) From: Andy Shevchenko To: Darren Hart , platform-driver-x86@vger.kernel.org, "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, Jonathan Cameron , Wolfram Sang , Mika Westerberg , linux-i2c@vger.kernel.org, Hans de Goede , Heikki Krogerus , linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 04/15] platform/x86: i2c-mutli-instantiate: Defer probe when no adapter found Date: Tue, 20 Nov 2018 17:59:13 +0200 Message-Id: <20181120155924.10773-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> References: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Likewise the rest of the i2c_acpi_new_device() users, defer the probe of the i2c-multi-intantiate driver in case adapter is not yet found. Signed-off-by: Andy Shevchenko --- drivers/platform/x86/i2c-multi-instantiate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c index e3345da82c84..16a0eabe1e31 100644 --- a/drivers/platform/x86/i2c-multi-instantiate.c +++ b/drivers/platform/x86/i2c-multi-instantiate.c @@ -75,7 +75,7 @@ static int i2c_multi_inst_probe(struct platform_device *pdev) if (IS_ERR(multi->clients[i])) ret = PTR_ERR(multi->clients[i]); else if (!multi->clients[i]) - ret = -ENODEV; + ret = -EPROBE_DEFER; /* Wait for i2c-adapter to load */ else ret = 0; if (ret) { From patchwork Tue Nov 20 15:59:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1000569 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42zr4n5HtDz9s8F for ; Wed, 21 Nov 2018 02:59:53 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730131AbeKUC31 (ORCPT ); Tue, 20 Nov 2018 21:29:27 -0500 Received: from mga07.intel.com ([134.134.136.100]:25307 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729306AbeKUC30 (ORCPT ); Tue, 20 Nov 2018 21:29:26 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 07:59:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,257,1539673200"; d="scan'208";a="93533535" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 20 Nov 2018 07:59:30 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 887684FB; Tue, 20 Nov 2018 17:59:25 +0200 (EET) From: Andy Shevchenko To: Darren Hart , platform-driver-x86@vger.kernel.org, "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, Jonathan Cameron , Wolfram Sang , Mika Westerberg , linux-i2c@vger.kernel.org, Hans de Goede , Heikki Krogerus , linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 05/15] i2c: acpi: Return error pointers from i2c_acpi_new_device() Date: Tue, 20 Nov 2018 17:59:14 +0200 Message-Id: <20181120155924.10773-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> References: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The caller would like to know the reason why the i2c_acpi_new_device() fails. For example, if adapter is not available, it might be in the future and we would like to re-probe the clients again. But at the same time we would like to bail out if the error seems unrecoverable, such as out of memory condition. To achieve this, return error pointer in some cases. Signed-off-by: Andy Shevchenko --- drivers/i2c/i2c-core-acpi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index 32affd3fa8bd..af4b5bd5d973 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -387,6 +387,7 @@ struct notifier_block i2c_acpi_notifier = { * Also see i2c_new_device, which this function calls to create the i2c-client. * * Returns a pointer to the new i2c-client, or NULL if the adapter is not found. + * In some cases might return an error pointer. */ struct i2c_client *i2c_acpi_new_device(struct device *dev, int index, struct i2c_board_info *info) @@ -399,7 +400,7 @@ struct i2c_client *i2c_acpi_new_device(struct device *dev, int index, adev = ACPI_COMPANION(dev); if (!adev) - return NULL; + return ERR_PTR(-ENODEV); memset(&lookup, 0, sizeof(lookup)); lookup.info = info; @@ -409,9 +410,11 @@ struct i2c_client *i2c_acpi_new_device(struct device *dev, int index, ret = acpi_dev_get_resources(adev, &resource_list, i2c_acpi_fill_info, &lookup); acpi_dev_free_resource_list(&resource_list); + if (ret < 0) + return ERR_PTR(ret); - if (ret < 0 || !info->addr) - return NULL; + if (!info->addr) + return ERR_PTR(-EADDRNOTAVAIL); adapter = i2c_acpi_find_adapter_by_handle(lookup.adapter_handle); if (!adapter) From patchwork Tue Nov 20 15:59:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1000573 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42zr5V2C8nz9s7T for ; Wed, 21 Nov 2018 03:00:30 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729774AbeKUC3Y (ORCPT ); Tue, 20 Nov 2018 21:29:24 -0500 Received: from mga05.intel.com ([192.55.52.43]:27492 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729285AbeKUC3W (ORCPT ); Tue, 20 Nov 2018 21:29:22 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 07:59:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,257,1539673200"; d="scan'208";a="109858812" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 20 Nov 2018 07:59:30 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 927EA507; Tue, 20 Nov 2018 17:59:25 +0200 (EET) From: Andy Shevchenko To: Darren Hart , platform-driver-x86@vger.kernel.org, "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, Jonathan Cameron , Wolfram Sang , Mika Westerberg , linux-i2c@vger.kernel.org, Hans de Goede , Heikki Krogerus , linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 06/15] i2c: acpi: Assign fwnode for devices created via i2c_acpi_new_device() Date: Tue, 20 Nov 2018 17:59:15 +0200 Message-Id: <20181120155924.10773-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> References: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org i2c_acpi_new_device() doesn't assign fwnode like it's done, for example, in i2c_acpi_register_devices() path. Assign fwnode in i2c_acpi_new_device() as it's done elsewhere. Signed-off-by: Andy Shevchenko --- drivers/i2c/i2c-core-acpi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index af4b5bd5d973..478862abb82a 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -420,6 +420,7 @@ struct i2c_client *i2c_acpi_new_device(struct device *dev, int index, if (!adapter) return NULL; + info->fwnode = acpi_fwnode_handle(adev); return i2c_new_device(adapter, info); } EXPORT_SYMBOL_GPL(i2c_acpi_new_device); From patchwork Tue Nov 20 15:59:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1000575 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42zr5m39Qgz9s8F for ; Wed, 21 Nov 2018 03:00:44 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729471AbeKUC3X (ORCPT ); Tue, 20 Nov 2018 21:29:23 -0500 Received: from mga14.intel.com ([192.55.52.115]:50164 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729286AbeKUC3W (ORCPT ); Tue, 20 Nov 2018 21:29:22 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 07:59:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,257,1539673200"; d="scan'208";a="97742356" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 20 Nov 2018 07:59:30 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id A2CD4532; Tue, 20 Nov 2018 17:59:25 +0200 (EET) From: Andy Shevchenko To: Darren Hart , platform-driver-x86@vger.kernel.org, "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, Jonathan Cameron , Wolfram Sang , Mika Westerberg , linux-i2c@vger.kernel.org, Hans de Goede , Heikki Krogerus , linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 07/15] i2c: acpi: Use ACPI_FAILURE instead of !ACPI_SUCCESS Date: Tue, 20 Nov 2018 17:59:16 +0200 Message-Id: <20181120155924.10773-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> References: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Convert to use ACPI_FAILURE instead of !ACPI_SUCCESS. Signed-off-by: Andy Shevchenko --- drivers/i2c/i2c-core-acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index 478862abb82a..99553b1469b4 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -65,7 +65,7 @@ static int i2c_acpi_fill_info(struct acpi_resource *ares, void *data) status = acpi_get_handle(lookup->device_handle, sb->resource_source.string_ptr, &lookup->adapter_handle); - if (!ACPI_SUCCESS(status)) + if (ACPI_FAILURE(status)) return 1; info->addr = sb->slave_address; From patchwork Tue Nov 20 15:59:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1000577 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42zr5t5kSpz9s1c for ; Wed, 21 Nov 2018 03:00:50 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729456AbeKUC3X (ORCPT ); Tue, 20 Nov 2018 21:29:23 -0500 Received: from mga07.intel.com ([134.134.136.100]:25307 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729269AbeKUC3W (ORCPT ); Tue, 20 Nov 2018 21:29:22 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 07:59:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,257,1539673200"; d="scan'208";a="282706104" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 20 Nov 2018 07:59:30 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id AFDDF973; Tue, 20 Nov 2018 17:59:25 +0200 (EET) From: Andy Shevchenko To: Darren Hart , platform-driver-x86@vger.kernel.org, "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, Jonathan Cameron , Wolfram Sang , Mika Westerberg , linux-i2c@vger.kernel.org, Hans de Goede , Heikki Krogerus , linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 08/15] i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper Date: Tue, 20 Nov 2018 17:59:17 +0200 Message-Id: <20181120155924.10773-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> References: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Besides current two users one more is coming. Definitely makes sense to introduce a helper. No functional change intended. Signed-off-by: Andy Shevchenko --- drivers/i2c/i2c-core-acpi.c | 31 +++++++++++++++++++------------ include/linux/acpi.h | 11 +++++++++++ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index 99553b1469b4..59b8b191d752 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -45,6 +45,23 @@ struct i2c_acpi_lookup { u32 min_speed; }; +bool i2c_acpi_get_i2c_resource(struct acpi_resource *ares, + struct acpi_resource_i2c_serialbus **i2c) +{ + struct acpi_resource_i2c_serialbus *sb; + + if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) + return false; + + sb = &ares->data.i2c_serial_bus; + if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_I2C) + return false; + + *i2c = sb; + return true; +} +EXPORT_SYMBOL_GPL(i2c_acpi_get_i2c_resource); + static int i2c_acpi_fill_info(struct acpi_resource *ares, void *data) { struct i2c_acpi_lookup *lookup = data; @@ -52,11 +69,7 @@ static int i2c_acpi_fill_info(struct acpi_resource *ares, void *data) struct acpi_resource_i2c_serialbus *sb; acpi_status status; - if (info->addr || ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) - return 1; - - sb = &ares->data.i2c_serial_bus; - if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_I2C) + if (info->addr || !i2c_acpi_get_i2c_resource(ares, &sb)) return 1; if (lookup->index != -1 && lookup->n++ != lookup->index) @@ -529,13 +542,7 @@ i2c_acpi_space_handler(u32 function, acpi_physical_address command, goto err; } - if (!value64 || ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) { - ret = AE_BAD_PARAMETER; - goto err; - } - - sb = &ares->data.i2c_serial_bus; - if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_I2C) { + if (!value64 || !i2c_acpi_get_i2c_resource(ares, &sb)) { ret = AE_BAD_PARAMETER; goto err; } diff --git a/include/linux/acpi.h b/include/linux/acpi.h index ed80f147bd50..6afc6e3c4c5c 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1054,6 +1054,17 @@ static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) } #endif +#if defined(CONFIG_ACPI) && IS_ENABLED(CONFIG_I2C) +bool i2c_acpi_get_i2c_resource(struct acpi_resource *ares, + struct acpi_resource_i2c_serialbus **i2c); +#else +static inline bool i2c_acpi_get_i2c_resource(struct acpi_resource *ares, + struct acpi_resource_i2c_serialbus **i2c) +{ + return false; +} +#endif + /* Device properties */ #ifdef CONFIG_ACPI From patchwork Tue Nov 20 15:59:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1000574 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42zr5c5X82z9s8F for ; Wed, 21 Nov 2018 03:00:36 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729269AbeKUC3X (ORCPT ); Tue, 20 Nov 2018 21:29:23 -0500 Received: from mga14.intel.com ([192.55.52.115]:50164 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728829AbeKUC3W (ORCPT ); Tue, 20 Nov 2018 21:29:22 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 07:59:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,257,1539673200"; d="scan'208";a="97742355" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 20 Nov 2018 07:59:30 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id BD312A82; Tue, 20 Nov 2018 17:59:25 +0200 (EET) From: Andy Shevchenko To: Darren Hart , platform-driver-x86@vger.kernel.org, "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, Jonathan Cameron , Wolfram Sang , Mika Westerberg , linux-i2c@vger.kernel.org, Hans de Goede , Heikki Krogerus , linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 09/15] platform/x86: i2c-multi-instantiate: Count I2cSerialBus() resources Date: Tue, 20 Nov 2018 17:59:18 +0200 Message-Id: <20181120155924.10773-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> References: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Instead of relying on hard coded and thus expected number of I2C clients, count the real amount provided by firmware. This allows to support non-fixed amount of the slaves. Signed-off-by: Andy Shevchenko --- drivers/platform/x86/i2c-multi-instantiate.c | 34 ++++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c index 16a0eabe1e31..d17686e10d08 100644 --- a/drivers/platform/x86/i2c-multi-instantiate.c +++ b/drivers/platform/x86/i2c-multi-instantiate.c @@ -12,6 +12,7 @@ #include #include #include +#include struct i2c_inst_data { const char *type; @@ -23,6 +24,31 @@ struct i2c_multi_inst_data { struct i2c_client *clients[0]; }; +static int i2c_multi_inst_count(struct acpi_resource *ares, void *data) +{ + struct acpi_resource_i2c_serialbus *sb; + int *count = data; + + if (i2c_acpi_get_i2c_resource(ares, &sb)) + *count = *count + 1; + + return 1; +} + +static int i2c_multi_inst_count_resources(struct acpi_device *adev) +{ + LIST_HEAD(r); + int count = 0; + int ret; + + ret = acpi_dev_get_resources(adev, &r, i2c_multi_inst_count, &count); + if (ret < 0) + return ret; + + acpi_dev_free_resource_list(&r); + return count; +} + static int i2c_multi_inst_probe(struct platform_device *pdev) { struct i2c_multi_inst_data *multi; @@ -44,15 +70,17 @@ static int i2c_multi_inst_probe(struct platform_device *pdev) adev = ACPI_COMPANION(dev); /* Count number of clients to instantiate */ - for (i = 0; inst_data[i].type; i++) {} + ret = i2c_multi_inst_count_resources(adev); + if (ret < 0) + return ret; multi = devm_kmalloc(dev, - offsetof(struct i2c_multi_inst_data, clients[i]), + offsetof(struct i2c_multi_inst_data, clients[ret]), GFP_KERNEL); if (!multi) return -ENOMEM; - multi->num_clients = i; + multi->num_clients = ret; for (i = 0; i < multi->num_clients; i++) { memset(&board_info, 0, sizeof(board_info)); From patchwork Tue Nov 20 15:59:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1000571 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42zr5M2XFzz9s7T for ; Wed, 21 Nov 2018 03:00:23 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729890AbeKUC3Y (ORCPT ); Tue, 20 Nov 2018 21:29:24 -0500 Received: from mga04.intel.com ([192.55.52.120]:9790 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729181AbeKUC3V (ORCPT ); Tue, 20 Nov 2018 21:29:21 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 07:59:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,257,1539673200"; d="scan'208";a="281543618" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 20 Nov 2018 07:59:30 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id CA9F6AC0; Tue, 20 Nov 2018 17:59:25 +0200 (EET) From: Andy Shevchenko To: Darren Hart , platform-driver-x86@vger.kernel.org, "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, Jonathan Cameron , Wolfram Sang , Mika Westerberg , linux-i2c@vger.kernel.org, Hans de Goede , Heikki Krogerus , linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 10/15] platform/x86: i2c-multi-instantiate: Distinguish IRQ resource type Date: Tue, 20 Nov 2018 17:59:19 +0200 Message-Id: <20181120155924.10773-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> References: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org As a preparatory patch switch the driver to distinguish IRQ resource type. For now, only GpioInt() is supported. Signed-off-by: Andy Shevchenko --- drivers/platform/x86/i2c-multi-instantiate.c | 27 +++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c index d17686e10d08..336ef28e072d 100644 --- a/drivers/platform/x86/i2c-multi-instantiate.c +++ b/drivers/platform/x86/i2c-multi-instantiate.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -14,9 +15,14 @@ #include #include +#define IRQ_RESOURCE_TYPE GENMASK(1, 0) +#define IRQ_RESOURCE_NONE 0 +#define IRQ_RESOURCE_GPIO 1 + struct i2c_inst_data { const char *type; - int gpio_irq_idx; + unsigned int flags; + int irq_idx; }; struct i2c_multi_inst_data { @@ -88,16 +94,19 @@ static int i2c_multi_inst_probe(struct platform_device *pdev) snprintf(name, sizeof(name), "%s-%s", match->id, inst_data[i].type); board_info.dev_name = name; - board_info.irq = 0; - if (inst_data[i].gpio_irq_idx != -1) { - ret = acpi_dev_gpio_irq_get(adev, - inst_data[i].gpio_irq_idx); + switch (inst_data[i].flags & IRQ_RESOURCE_TYPE) { + case IRQ_RESOURCE_GPIO: + ret = acpi_dev_gpio_irq_get(adev, inst_data[i].irq_idx); if (ret < 0) { dev_err(dev, "Error requesting irq at index %d: %d\n", - inst_data[i].gpio_irq_idx, ret); + inst_data[i].irq_idx, ret); goto error; } board_info.irq = ret; + break; + default: + board_info.irq = 0; + break; } multi->clients[i] = i2c_acpi_new_device(dev, i, &board_info); if (IS_ERR(multi->clients[i])) @@ -134,9 +143,9 @@ static int i2c_multi_inst_remove(struct platform_device *pdev) } static const struct i2c_inst_data bsg1160_data[] = { - { "bmc150_accel", 0 }, - { "bmc150_magn", -1 }, - { "bmg160", -1 }, + { "bmc150_accel", IRQ_RESOURCE_GPIO, 0 }, + { "bmc150_magn" }, + { "bmg160" }, {} }; From patchwork Tue Nov 20 15:59:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1000578 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42zr666kMPz9s1c for ; Wed, 21 Nov 2018 03:01:02 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725903AbeKUCap (ORCPT ); Tue, 20 Nov 2018 21:30:45 -0500 Received: from mga02.intel.com ([134.134.136.20]:62286 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729323AbeKUC3X (ORCPT ); Tue, 20 Nov 2018 21:29:23 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 07:59:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,257,1539673200"; d="scan'208";a="109708259" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 20 Nov 2018 07:59:30 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id DC206DB3; Tue, 20 Nov 2018 17:59:25 +0200 (EET) From: Andy Shevchenko To: Darren Hart , platform-driver-x86@vger.kernel.org, "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, Jonathan Cameron , Wolfram Sang , Mika Westerberg , linux-i2c@vger.kernel.org, Hans de Goede , Heikki Krogerus , linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 11/15] platform/x86: i2c-multi-instantiate: Introduce IOAPIC IRQ support Date: Tue, 20 Nov 2018 17:59:20 +0200 Message-Id: <20181120155924.10773-12-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> References: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org If ACPI table provides an Interrupt() resource we may consider to use it instead of GpioInt() one. Here we leave an error condition, when getting IRQ resource, to the driver to decide how to proceed, because some drivers may consider IRQ resource optional. Signed-off-by: Andy Shevchenko --- drivers/platform/x86/i2c-multi-instantiate.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c index 336ef28e072d..3334fafb4d8c 100644 --- a/drivers/platform/x86/i2c-multi-instantiate.c +++ b/drivers/platform/x86/i2c-multi-instantiate.c @@ -18,6 +18,7 @@ #define IRQ_RESOURCE_TYPE GENMASK(1, 0) #define IRQ_RESOURCE_NONE 0 #define IRQ_RESOURCE_GPIO 1 +#define IRQ_RESOURCE_APIC 2 struct i2c_inst_data { const char *type; @@ -104,6 +105,14 @@ static int i2c_multi_inst_probe(struct platform_device *pdev) } board_info.irq = ret; break; + case IRQ_RESOURCE_APIC: + ret = platform_get_irq(pdev, inst_data[i].irq_idx); + if (ret < 0) { + dev_dbg(dev, "Error requesting irq at index %d: %d\n", + inst_data[i].irq_idx, ret); + } + board_info.irq = ret; + break; default: board_info.irq = 0; break; From patchwork Tue Nov 20 15:59:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1000572 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42zr5M72vWz9s8F for ; Wed, 21 Nov 2018 03:00:23 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729863AbeKUC3Y (ORCPT ); Tue, 20 Nov 2018 21:29:24 -0500 Received: from mga14.intel.com ([192.55.52.115]:50164 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729295AbeKUC3W (ORCPT ); Tue, 20 Nov 2018 21:29:22 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 07:59:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,257,1539673200"; d="scan'208";a="97742357" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 20 Nov 2018 07:59:30 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id E937BDBF; Tue, 20 Nov 2018 17:59:25 +0200 (EET) From: Andy Shevchenko To: Darren Hart , platform-driver-x86@vger.kernel.org, "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, Jonathan Cameron , Wolfram Sang , Mika Westerberg , linux-i2c@vger.kernel.org, Hans de Goede , Heikki Krogerus , linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 12/15] platform/x86: i2c-multi-instantiate: Allow to have same slaves Date: Tue, 20 Nov 2018 17:59:21 +0200 Message-Id: <20181120155924.10773-13-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> References: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Currently the driver will not enumerate the devices where I2C slaves are of the same type. Add an instance number to make them unique. Signed-off-by: Andy Shevchenko --- drivers/platform/x86/i2c-multi-instantiate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c index 3334fafb4d8c..1e078a961245 100644 --- a/drivers/platform/x86/i2c-multi-instantiate.c +++ b/drivers/platform/x86/i2c-multi-instantiate.c @@ -92,8 +92,8 @@ static int i2c_multi_inst_probe(struct platform_device *pdev) for (i = 0; i < multi->num_clients; i++) { memset(&board_info, 0, sizeof(board_info)); strlcpy(board_info.type, inst_data[i].type, I2C_NAME_SIZE); - snprintf(name, sizeof(name), "%s-%s", match->id, - inst_data[i].type); + snprintf(name, sizeof(name), "%s-%s.%d", match->id, + inst_data[i].type, i); board_info.dev_name = name; switch (inst_data[i].flags & IRQ_RESOURCE_TYPE) { case IRQ_RESOURCE_GPIO: From patchwork Tue Nov 20 15:59:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1000567 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42zr4S2yLhz9sB7 for ; Wed, 21 Nov 2018 02:59:36 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729324AbeKUC3X (ORCPT ); Tue, 20 Nov 2018 21:29:23 -0500 Received: from mga04.intel.com ([192.55.52.120]:9790 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729283AbeKUC3W (ORCPT ); Tue, 20 Nov 2018 21:29:22 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 07:59:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,257,1539673200"; d="scan'208";a="87897998" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 20 Nov 2018 07:59:30 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 01C44DCA; Tue, 20 Nov 2018 17:59:25 +0200 (EET) From: Andy Shevchenko To: Darren Hart , platform-driver-x86@vger.kernel.org, "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, Jonathan Cameron , Wolfram Sang , Mika Westerberg , linux-i2c@vger.kernel.org, Hans de Goede , Heikki Krogerus , linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 13/15] ACPI / scan: Create platform device for INT3515 ACPI nodes Date: Tue, 20 Nov 2018 17:59:22 +0200 Message-Id: <20181120155924.10773-14-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> References: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The ACPI device with INT3515 _HID is representing a complex USB PD hardware infrastructure which includes several I2C slave ICs. We add an ID to the I2C multi instantiate list to enumerate all I2C slaves correctly. Signed-off-by: Andy Shevchenko --- drivers/acpi/scan.c | 1 + drivers/platform/x86/i2c-multi-instantiate.c | 9 +++++++++ drivers/usb/typec/tps6598x.c | 8 ++++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index bd1c59fb0e17..e9eda5558c1f 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1541,6 +1541,7 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device) static const struct acpi_device_id i2c_multi_instantiate_ids[] = { {"BSG1160", }, {"INT33FE", }, + {"INT3515", }, {} }; diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c index 1e078a961245..efaf34cbbc7b 100644 --- a/drivers/platform/x86/i2c-multi-instantiate.c +++ b/drivers/platform/x86/i2c-multi-instantiate.c @@ -158,12 +158,21 @@ static const struct i2c_inst_data bsg1160_data[] = { {} }; +static const struct i2c_inst_data int3515_data[] = { + { "tps6598x", IRQ_RESOURCE_APIC, 0 }, + { "tps6598x", IRQ_RESOURCE_APIC, 1 }, + { "tps6598x", IRQ_RESOURCE_APIC, 2 }, + { "tps6598x", IRQ_RESOURCE_APIC, 3 }, + {} +}; + /* * Note new device-ids must also be added to i2c_multi_instantiate_ids in * drivers/acpi/scan.c: acpi_device_enumeration_by_parent(). */ static const struct acpi_device_id i2c_multi_inst_acpi_ids[] = { { "BSG1160", (unsigned long)bsg1160_data }, + { "INT3515", (unsigned long)int3515_data }, { } }; MODULE_DEVICE_TABLE(acpi, i2c_multi_inst_acpi_ids); diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c index c84c8c189e90..1c0033ad8738 100644 --- a/drivers/usb/typec/tps6598x.c +++ b/drivers/usb/typec/tps6598x.c @@ -501,19 +501,19 @@ static int tps6598x_remove(struct i2c_client *client) return 0; } -static const struct acpi_device_id tps6598x_acpi_match[] = { - { "INT3515", 0 }, +static const struct i2c_device_id tps6598x_id[] = { + { "tps6598x" }, { } }; -MODULE_DEVICE_TABLE(acpi, tps6598x_acpi_match); +MODULE_DEVICE_TABLE(i2c, tps6598x_id); static struct i2c_driver tps6598x_i2c_driver = { .driver = { .name = "tps6598x", - .acpi_match_table = tps6598x_acpi_match, }, .probe_new = tps6598x_probe, .remove = tps6598x_remove, + .id_table = tps6598x_id, }; module_i2c_driver(tps6598x_i2c_driver); From patchwork Tue Nov 20 15:59:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1000576 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42zr5p44fkz9s7T for ; Wed, 21 Nov 2018 03:00:46 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727674AbeKUCac (ORCPT ); Tue, 20 Nov 2018 21:30:32 -0500 Received: from mga18.intel.com ([134.134.136.126]:58105 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729363AbeKUC3X (ORCPT ); Tue, 20 Nov 2018 21:29:23 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 07:59:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,257,1539673200"; d="scan'208";a="106214826" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 20 Nov 2018 07:59:30 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 0EB65FF8; Tue, 20 Nov 2018 17:59:26 +0200 (EET) From: Andy Shevchenko To: Darren Hart , platform-driver-x86@vger.kernel.org, "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, Jonathan Cameron , Wolfram Sang , Mika Westerberg , linux-i2c@vger.kernel.org, Hans de Goede , Heikki Krogerus , linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Steven Presser Subject: [PATCH v1 14/15] ACPI / scan: Create platform device for BOSC0200 ACPI nodes Date: Tue, 20 Nov 2018 17:59:23 +0200 Message-Id: <20181120155924.10773-15-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> References: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org On some laptops the ACPI device with BOSC0200 _HID is representing two accelerometers under one node. We add an ID to the I2C multi instantiate list to enumerate all I2C slaves correctly. For reference here is the relevant DSDT blurb from the Yoga 11e: Device (ACC) { Name (_ADR, Zero) // _ADR: Address Name (_HID, "BOSC0200") // _HID: Hardware ID Name (_CID, "BOSC0200") // _CID: Compatible ID Name (_DDN, "Accelerometer") // _DDN: DOS Device Name Name (_UID, One) // _UID: Unique ID Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings { Name (RBUF, ResourceTemplate () { I2cSerialBusV2 (0x0019, ControllerInitiated, 0x00061A80, AddressingMode7Bit, "\\_SB.PCI0.I2C3", 0x00, ResourceConsumer, , Exclusive, ) I2cSerialBusV2 (0x0018, ControllerInitiated, 0x00061A80, AddressingMode7Bit, "\\_SB.PCI0.I2C3", 0x00, ResourceConsumer, , Exclusive, ) }) Return (RBUF) /* \_SB_.PCI0.I2C3.ACC_._CRS.RBUF */ } Reported-by: Jeremy Cline Cc: Steven Presser Signed-off-by: Andy Shevchenko --- drivers/acpi/scan.c | 1 + drivers/iio/accel/bmc150-accel-i2c.c | 1 - drivers/platform/x86/i2c-multi-instantiate.c | 7 +++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index e9eda5558c1f..e46c877fa9f1 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1539,6 +1539,7 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device) * which i2c_device_id to use for each resource. */ static const struct acpi_device_id i2c_multi_instantiate_ids[] = { + {"BOSC0200", }, {"BSG1160", }, {"INT33FE", }, {"INT3515", }, diff --git a/drivers/iio/accel/bmc150-accel-i2c.c b/drivers/iio/accel/bmc150-accel-i2c.c index 8ffc308d5fd0..9d22a4d9d568 100644 --- a/drivers/iio/accel/bmc150-accel-i2c.c +++ b/drivers/iio/accel/bmc150-accel-i2c.c @@ -64,7 +64,6 @@ static const struct acpi_device_id bmc150_accel_acpi_match[] = { {"BMA250E", bma250e}, {"BMA222E", bma222e}, {"BMA0280", bma280}, - {"BOSC0200"}, { }, }; MODULE_DEVICE_TABLE(acpi, bmc150_accel_acpi_match); diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c index efaf34cbbc7b..c90137d30a98 100644 --- a/drivers/platform/x86/i2c-multi-instantiate.c +++ b/drivers/platform/x86/i2c-multi-instantiate.c @@ -151,6 +151,12 @@ static int i2c_multi_inst_remove(struct platform_device *pdev) return 0; } +static const struct i2c_inst_data bosc0200_data[] = { + { "bmc150_accel" }, + { "bmc150_accel" }, + {} +}; + static const struct i2c_inst_data bsg1160_data[] = { { "bmc150_accel", IRQ_RESOURCE_GPIO, 0 }, { "bmc150_magn" }, @@ -171,6 +177,7 @@ static const struct i2c_inst_data int3515_data[] = { * drivers/acpi/scan.c: acpi_device_enumeration_by_parent(). */ static const struct acpi_device_id i2c_multi_inst_acpi_ids[] = { + { "BOSC0200", (unsigned long)bosc0200_data }, { "BSG1160", (unsigned long)bsg1160_data }, { "INT3515", (unsigned long)int3515_data }, { } From patchwork Tue Nov 20 15:59:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1000570 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42zr4z2y2Kz9s1c for ; Wed, 21 Nov 2018 03:00:03 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728834AbeKUC3o (ORCPT ); Tue, 20 Nov 2018 21:29:44 -0500 Received: from mga04.intel.com ([192.55.52.120]:9790 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729285AbeKUC3Z (ORCPT ); Tue, 20 Nov 2018 21:29:25 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 07:59:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,257,1539673200"; d="scan'208";a="281543633" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 20 Nov 2018 07:59:33 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1B8B1142D; Tue, 20 Nov 2018 17:59:26 +0200 (EET) From: Andy Shevchenko To: Darren Hart , platform-driver-x86@vger.kernel.org, "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, Jonathan Cameron , Wolfram Sang , Mika Westerberg , linux-i2c@vger.kernel.org, Hans de Goede , Heikki Krogerus , linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 15/15] iio: inv_mpu6050: Use i2c_acpi_get_i2c_resource() helper Date: Tue, 20 Nov 2018 17:59:24 +0200 Message-Id: <20181120155924.10773-16-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> References: <20181120155924.10773-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org ACPI provides a generic helper to get I2C Serial Bus resources. Use it instead of open coded variant. Signed-off-by: Andy Shevchenko --- drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c index d78a10403bac..a961b5a06fe6 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c @@ -91,18 +91,14 @@ static int asus_acpi_get_sensor_info(struct acpi_device *adev, static int acpi_i2c_check_resource(struct acpi_resource *ares, void *data) { + struct acpi_resource_i2c_serialbus *sb; u32 *addr = data; - if (ares->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) { - struct acpi_resource_i2c_serialbus *sb; - - sb = &ares->data.i2c_serial_bus; - if (sb->type == ACPI_RESOURCE_SERIAL_TYPE_I2C) { - if (*addr) - *addr |= (sb->slave_address << 16); - else - *addr = sb->slave_address; - } + if (i2c_acpi_get_i2c_resource(ares, &sb)) { + if (*addr) + *addr |= (sb->slave_address << 16); + else + *addr = sb->slave_address; } /* Tell the ACPI core that we already copied this address */