From patchwork Fri Aug 6 21:13:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 493013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23FA1C4338F for ; Fri, 6 Aug 2021 21:19:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5A5361186 for ; Fri, 6 Aug 2021 21:19:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237419AbhHFVTZ (ORCPT ); Fri, 6 Aug 2021 17:19:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232112AbhHFVTY (ORCPT ); Fri, 6 Aug 2021 17:19:24 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92CDFC0613CF for ; Fri, 6 Aug 2021 14:19:07 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id d8so12669239wrm.4 for ; Fri, 06 Aug 2021 14:19:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=8oo5Jk2SD7JU2vkSTDYam8cg3/23eaYoPmN3cO5/LUE=; b=nLB+AE5HX+v7aMwZN7R6trNCSbOFE5gVNubzZS3kaGT1YJKuQcgS7W+41EpnkrchKY 2VcuFcx38/nRS8wv/rI3Pdvvn9E5oVGFGzGSl+18KvVWo17t0z9Dwh68FGsTSaanEPLq xTNAaBLtWGJ1vOpev3GRJLgyagI9ClWt+ULx5vdEKPUB3kqM2sUBj1JyJHbPAGLNlgZq h+LNRpbBpQwV7lBgi+JQ1gEHV0TravIXlahxfU+AQzc3aJ2yq4A2o3lkVxmUIPLPZZb9 qt4A4Px1YbBoKQDgl/7M8500mb2JbzvVoY3QFPXTE5gvDUfvVT8ral6eJYldZPrfK73l T/9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=8oo5Jk2SD7JU2vkSTDYam8cg3/23eaYoPmN3cO5/LUE=; b=B+OO5NH6Lf5k+tiC8cqWW40jAE0XgaugpDKPWqjFVndDcuQwlJD5Mm0dEchoIqft8v pzLKq/ui/Ts/F1PHagGL0qNDiXgenD6xVHZqSn5NCeypZ6BXYc0VsI/Gvn0QBLblm9dx hUrA++47LlSanWPlNvtuJD8iy/P6bzIoI95LNruRNY9jrcPPGtn4R6Grd985QUz7T5iU BRAHmtOyEYqg0CfSqJn1XTv7TyfMebcYOr4YejTspgT1hKEyp+rnmBDDsgJwj927rXT0 NxOvb5diaeUItCw0IOBTX2RXfmMdBK6pdEl5rMqVg0VTwAzHUvNynijEmqu7KMgkZ+4P oxeQ== X-Gm-Message-State: AOAM533BLlWZn8fuaT3qT6NNPSUlCLssxzeU1PROg3AgSUQLtgNm2p9i EHxsx4oyl9L82Ekjdt404acAY8tbv/c++A== X-Google-Smtp-Source: ABdhPJwW/QWOUvGwGGnf8kzdrmdbZeKgWa5iGCYvawqvagCU0R84qSnmuk29cBVjuyU7R5xRmgIvjQ== X-Received: by 2002:a5d:6ac4:: with SMTP id u4mr12884986wrw.166.1628284746063; Fri, 06 Aug 2021 14:19:06 -0700 (PDT) Received: from ?IPv6:2003:ea:8f10:c200:cc6d:4891:c067:bf7b? (p200300ea8f10c200cc6d4891c067bf7b.dip0.t-ipconnect.de. [2003:ea:8f10:c200:cc6d:4891:c067:bf7b]) by smtp.googlemail.com with ESMTPSA id r2sm10853656wrx.27.2021.08.06.14.19.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Aug 2021 14:19:05 -0700 (PDT) Subject: [PATCH v2 2/9] i2c: i801: make p2sb_spinlock a mutex From: Heiner Kallweit To: Jean Delvare Cc: "linux-i2c@vger.kernel.org" References: Message-ID: <90aee333-6490-db08-01ae-c0de1e18368a@gmail.com> Date: Fri, 6 Aug 2021 23:13:29 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org p2sb_spinlock is used in i801_add_tco_spt() only, and in process context only. Therefore a mutex is sufficient, and we can make the definition local to i801_add_tco_spt(). Reviewed-by: Jean Delvare Reviewed-by: Mika Westerberg Signed-off-by: Heiner Kallweit --- drivers/i2c/busses/i2c-i801.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index ef6dbb531..12e0c2ac3 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -110,6 +110,7 @@ #include #include #include +#include #if IS_ENABLED(CONFIG_I2C_MUX_GPIO) && defined CONFIG_DMI #include @@ -1492,12 +1493,11 @@ static const struct itco_wdt_platform_data spt_tco_platform_data = { .version = 4, }; -static DEFINE_SPINLOCK(p2sb_spinlock); - static struct platform_device * i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev, struct resource *tco_res) { + static DEFINE_MUTEX(p2sb_mutex); struct resource *res; unsigned int devfn; u64 base64_addr; @@ -1510,7 +1510,7 @@ i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev, * enumerated by the PCI subsystem, so we need to unhide/hide it * to lookup the P2SB BAR. */ - spin_lock(&p2sb_spinlock); + mutex_lock(&p2sb_mutex); devfn = PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 1); @@ -1528,7 +1528,7 @@ i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev, /* Hide the P2SB device, if it was hidden before */ if (hidden) pci_bus_write_config_byte(pci_dev->bus, devfn, 0xe1, hidden); - spin_unlock(&p2sb_spinlock); + mutex_unlock(&p2sb_mutex); res = &tco_res[1]; if (pci_dev->device == PCI_DEVICE_ID_INTEL_DNV_SMBUS) From patchwork Fri Aug 6 21:15:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 493012 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62986C4338F for ; Fri, 6 Aug 2021 21:19:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3E7AD61186 for ; Fri, 6 Aug 2021 21:19:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237662AbhHFVTb (ORCPT ); Fri, 6 Aug 2021 17:19:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237975AbhHFVTb (ORCPT ); Fri, 6 Aug 2021 17:19:31 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E118BC0613CF for ; Fri, 6 Aug 2021 14:19:13 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id f9-20020a05600c1549b029025b0f5d8c6cso9847659wmg.4 for ; Fri, 06 Aug 2021 14:19:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=HvM3lPG2xI8313rRdu83d9EPpxbMXrPiuZRB9e1Nt8U=; b=UDWCLeuIOjALS6BJG9A3LVfVYE2SA2T7aBTFbT52QEUp2F2CEKKkkOUAAjOem5B2OM 0qP3rrVqJqGAvaEOs20Af+pq040+YMRva7w0yDMN/TZhjwAj50rvPwWd6/LjvV0WFW+D Xn/JhZWEh0zuzZ7ygraVeOM8DVjLJGwbGjJyA4aqtNeFUmeHr5AgRWlpU/VrsvEoe4B4 9gTMU8uw4qV2KQUNgJiahhMO4zSejdRq9BAH3SYSQwj1I/KZKl+lhf2f9RpzdAV+4DYv PjxaLvVnkIY4D2Lfq8L1eY/0G0aSjU2wH33GXH3MWAaCXsYm/Dvbq9yeNX5EQj+WigD7 1WLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=HvM3lPG2xI8313rRdu83d9EPpxbMXrPiuZRB9e1Nt8U=; b=f+/Im6E3CKbq7OuxasPd8nVzaHwo1ALtKvZy7c0iz2+I/oYwDpJG8+WTq1WArETptM lwk1YtnUk17ENt+yIQcDXyaEXQSzCvTftVTiEoin4xYEQcXEmrOjQdFQuLi1RCZ9NX/j qFuWcqNg/TEtS+kCb5J4HD+e1TGY+415UPMqX/79ZXtd3rAyM6vRknFyEiwItqOh4qak BdkEU0DhSSQGPV/RI1CYBReX40wquiWOrZDLUWlG7gJq/hx15CieyCB8G6gZXiFUJrFU BGr7m3u+w6wKTRO2N8pnP0ZHf/ihzkhjl2AvX2hCcsAx34t1ibDFHX8C0pvSFiZHvTbW YRfA== X-Gm-Message-State: AOAM530fsYwFnvYjBydRji9XfYzLLtuS9yG9BKr7oA6ENNt0LQfmTAmU 3P2GC2QuvZBjCBpNto1OuXhswWYrUk97aQ== X-Google-Smtp-Source: ABdhPJyEYAXD/uxVOZH8GTXl4cTDLw2y+HmfA7wI/RKkHndsNN82KI49o3f/gDS9m5BIwSvD19MUZQ== X-Received: by 2002:a7b:c254:: with SMTP id b20mr22462388wmj.189.1628284752370; Fri, 06 Aug 2021 14:19:12 -0700 (PDT) Received: from ?IPv6:2003:ea:8f10:c200:cc6d:4891:c067:bf7b? (p200300ea8f10c200cc6d4891c067bf7b.dip0.t-ipconnect.de. [2003:ea:8f10:c200:cc6d:4891:c067:bf7b]) by smtp.googlemail.com with ESMTPSA id b20sm10609529wmj.48.2021.08.06.14.19.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Aug 2021 14:19:12 -0700 (PDT) Subject: [PATCH v2 4/9] i2c: i801: Improve is_dell_system_with_lis3lv02d From: Heiner Kallweit To: Jean Delvare Cc: "linux-i2c@vger.kernel.org" References: Message-ID: Date: Fri, 6 Aug 2021 23:15:15 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Replace the ugly cast of the return_value pointer with proper usage. In addition use dmi_match() instead of open-coding it. Signed-off-by: Heiner Kallweit Reviewed-by: Jean Delvare --- v2: - avoid assigning potentially dangling pointer to *return_value --- drivers/i2c/busses/i2c-i801.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 89ae78ef1..f56060fcf 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -1192,7 +1192,7 @@ static acpi_status check_acpi_smo88xx_device(acpi_handle obj_handle, kfree(info); - *((bool *)return_value) = true; + *return_value = NULL; return AE_CTRL_TERMINATE; smo88xx_not_found: @@ -1202,11 +1202,9 @@ static acpi_status check_acpi_smo88xx_device(acpi_handle obj_handle, static bool is_dell_system_with_lis3lv02d(void) { - bool found; - const char *vendor; + void *err = ERR_PTR(-ENOENT); - vendor = dmi_get_system_info(DMI_SYS_VENDOR); - if (!vendor || strcmp(vendor, "Dell Inc.")) + if (!dmi_match(DMI_SYS_VENDOR, "Dell Inc.")) return false; /* @@ -1217,11 +1215,9 @@ static bool is_dell_system_with_lis3lv02d(void) * accelerometer but unfortunately ACPI does not provide any other * information (like I2C address). */ - found = false; - acpi_get_devices(NULL, check_acpi_smo88xx_device, NULL, - (void **)&found); + acpi_get_devices(NULL, check_acpi_smo88xx_device, NULL, &err); - return found; + return !IS_ERR(err); } /* From patchwork Fri Aug 6 21:16:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 493011 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E366EC4338F for ; Fri, 6 Aug 2021 21:19:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C768561186 for ; Fri, 6 Aug 2021 21:19:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237975AbhHFVTh (ORCPT ); Fri, 6 Aug 2021 17:19:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238155AbhHFVTg (ORCPT ); Fri, 6 Aug 2021 17:19:36 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B8B7C0613CF for ; Fri, 6 Aug 2021 14:19:20 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id b11so12695676wrx.6 for ; Fri, 06 Aug 2021 14:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=AQvMtFq8Po6vh52QjvN0sEfHzpusUaBiZ8gx3Z9m+QI=; b=uBy6XGm0S3KgJpQ0tv+Po7W0GcBYp59FysOH/a/2RciBK4HObvq25KHUrWZYe3t7Ci OF7KISbzxmXU3yxtxh2SUe/b8OGdfSDKraxQi+H61/uQouaPJjY0JpNRx/LUJjyKRUC1 +zC+5rtVkjye43nA7dr2ZyKBs6jrX87DUSMppNYKx+5V4FOult2aWx3i1qcfEqhTOx3F Clc2tzhrOjYung8SEVCVt0s6At5CaQuE65JSXFO69qIgYIhRyYQcIYfHxJ0/Xs44n8X0 USEtIIh29mmXKCkci/s9G1YchXD/nEv2AGEPkORFx53roRKFOdNldk1kxvUEpaJyjcaw igZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=AQvMtFq8Po6vh52QjvN0sEfHzpusUaBiZ8gx3Z9m+QI=; b=Pkc+mEJWTcy/kvMZyV/6hVTTYSauxMdWawJf3nCS4Hh6fTVoK0i4Tcwam9+knCrJ9H xfbgV2xrtTbJb5Jkwugjf8+VvSLcCZobKNblINpjrliTekQNZSsRkXCckiPqg0eYYI9n oPopmEpihSto4hQxue702yBJ4QKg913dwM+TL+9w1QdUxrUJGl62A7F3IoZnyt+PvpU2 tLT3hKjNZtdGropwuxxZkuL4YpwZQ8jURAM+t38tx3i0PvHJ47ISaGsTJT5cfdaj21VU HQlDWRC88DsRccKu7IS7zHiYxd5smg9qds1LnDZzqFaYCNYhumK4NrGpmgDseRvo0d/s O8nw== X-Gm-Message-State: AOAM5338ej6aqRYtUsVFWuMlrwozUEb9++33nIOeH1vJHraw8vMZvaE3 EvNhfgEZ0hQF1qWnVzMsArj4aqdj0MYSmg== X-Google-Smtp-Source: ABdhPJx6WnhNaBO2R8vBPw2+3XprPd963gT4IFrNbj23PruGwhdPwzupToOA2zsF2B22m0FChodTQA== X-Received: by 2002:adf:e0c4:: with SMTP id m4mr12719217wri.312.1628284758834; Fri, 06 Aug 2021 14:19:18 -0700 (PDT) Received: from ?IPv6:2003:ea:8f10:c200:cc6d:4891:c067:bf7b? (p200300ea8f10c200cc6d4891c067bf7b.dip0.t-ipconnect.de. [2003:ea:8f10:c200:cc6d:4891:c067:bf7b]) by smtp.googlemail.com with ESMTPSA id m9sm10462487wrz.75.2021.08.06.14.19.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Aug 2021 14:19:18 -0700 (PDT) Subject: [PATCH v2 6/9] i2c: i801: Improve i801_acpi_probe/remove functions From: Heiner Kallweit To: Jean Delvare Cc: "linux-i2c@vger.kernel.org" References: Message-ID: Date: Fri, 6 Aug 2021 23:16:33 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org By using ACPI_HANDLE() the handler argument can be retrieved directly. Both address space handler functions check the handler argument and return an error if it's NULL. This allows to further simplify the code. Reviewed-by: Jean Delvare Tested-by: Jean Delvare Reviewed-by: Mika Westerberg Signed-off-by: Heiner Kallweit --- drivers/i2c/busses/i2c-i801.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 7fa06b85f..bd1db0f0a 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -1635,31 +1635,22 @@ i801_acpi_io_handler(u32 function, acpi_physical_address address, u32 bits, static int i801_acpi_probe(struct i801_priv *priv) { - struct acpi_device *adev; + acpi_handle ah = ACPI_HANDLE(&priv->pci_dev->dev); acpi_status status; - adev = ACPI_COMPANION(&priv->pci_dev->dev); - if (adev) { - status = acpi_install_address_space_handler(adev->handle, - ACPI_ADR_SPACE_SYSTEM_IO, i801_acpi_io_handler, - NULL, priv); - if (ACPI_SUCCESS(status)) - return 0; - } + status = acpi_install_address_space_handler(ah, ACPI_ADR_SPACE_SYSTEM_IO, + i801_acpi_io_handler, NULL, priv); + if (ACPI_SUCCESS(status)) + return 0; return acpi_check_resource_conflict(&priv->pci_dev->resource[SMBBAR]); } static void i801_acpi_remove(struct i801_priv *priv) { - struct acpi_device *adev; - - adev = ACPI_COMPANION(&priv->pci_dev->dev); - if (!adev) - return; + acpi_handle ah = ACPI_HANDLE(&priv->pci_dev->dev); - acpi_remove_address_space_handler(adev->handle, - ACPI_ADR_SPACE_SYSTEM_IO, i801_acpi_io_handler); + acpi_remove_address_space_handler(ah, ACPI_ADR_SPACE_SYSTEM_IO, i801_acpi_io_handler); } #else static inline int i801_acpi_probe(struct i801_priv *priv) { return 0; } From patchwork Fri Aug 6 21:18:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 493010 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB82FC4338F for ; Fri, 6 Aug 2021 21:19:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C14B76108D for ; Fri, 6 Aug 2021 21:19:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238155AbhHFVTo (ORCPT ); Fri, 6 Aug 2021 17:19:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238016AbhHFVTn (ORCPT ); Fri, 6 Aug 2021 17:19:43 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D914C0613CF for ; Fri, 6 Aug 2021 14:19:26 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id n12so2616028wrr.2 for ; Fri, 06 Aug 2021 14:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=k+H9Qy6AVSQfmzCVSq6PZRXdQZcZaCG04yQUbjpoH7w=; b=mB5209/k84mATchksY3tGTM+p+bS08KRMFOqWTH45WT0pZ5xjZs+1xZukxmJmVgkrT SX2Wmnmk9jvR+eZhwrIVOwheugbG2uiibbasekQqFk9YSPh63JIEFYUxTYIJZ9wfoXlC Hwz2RHbstCDZdcp7TALwolHceKprMkB/51J88ob1R651fVKXfUia0YZvtZ3/TAbR6yQA QoOc6y+7zoTkugrBXu0pst/92bjOEvhsKuteiUkr36O4ku1J2WY40WTq0dGr7DsK5qCZ L7cRFsTiT6u3pHGJMHnSCcZr0C8xSYC+7AbNjzREhVmelrC9qA5SvVNn4On+H6WefphV Zxdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=k+H9Qy6AVSQfmzCVSq6PZRXdQZcZaCG04yQUbjpoH7w=; b=PxVLqv22XJjRMcrVyFp0VaMGvYLyNuWvfB3L8YwP09PsjoxOCDofa3xaQJmxB5o2T7 Mmdun5ur0G/8OcGwibdUSFmWx8DBynovlC4ieug2WTY6gApMwVAsE4sa3m44XzL8OBKF PkNw0LJhNkNmDSyGHbuARH7HqZujq20Hhkq8kO6T2l8LccOg/OhzfV+owNuZuK8e97ja VfyieAYBfMa7cGIUlgvzC9fb12ae3U3G6K3tF1bNecFci8A2n4sIpIyWWgIJEFcaTvC9 Mq7e2dzmGblhloz4mHjYImkqNT9sjtEZbeE2dHQIF+Owqlkl5C7qw8wj6siSVqcLy9rJ aBDg== X-Gm-Message-State: AOAM530Fdn/r/B8OCTQ2bJJ4tG5OmAQwOGuluCQD4/hH8otwqZ979AGP FPSUWHT2layNLOoXYmwb6aua3YIuMiAT5g== X-Google-Smtp-Source: ABdhPJxdr7JtohA893+zdSrUeFlWuloq0gfLYjHScddaeZrLY7USZE94LYQG53vHH816hYVU1oBlQQ== X-Received: by 2002:adf:d087:: with SMTP id y7mr12535051wrh.323.1628284765118; Fri, 06 Aug 2021 14:19:25 -0700 (PDT) Received: from ?IPv6:2003:ea:8f10:c200:cc6d:4891:c067:bf7b? (p200300ea8f10c200cc6d4891c067bf7b.dip0.t-ipconnect.de. [2003:ea:8f10:c200:cc6d:4891:c067:bf7b]) by smtp.googlemail.com with ESMTPSA id q5sm10997601wrx.33.2021.08.06.14.19.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Aug 2021 14:19:24 -0700 (PDT) Subject: [PATCH v2 8/9] i2c: i801: Improve register_dell_lis3lv02d_i2c_device From: Heiner Kallweit To: Jean Delvare Cc: "linux-i2c@vger.kernel.org" References: Message-ID: <3ce2ea87-809e-5999-e920-07ddd5fcc035@gmail.com> Date: Fri, 6 Aug 2021 23:18:05 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org - Use an initializer for struct i2c_board_info info - Use dmi_match() - Simplify loop logic Signed-off-by: Heiner Kallweit --- v2: - move definition of struct i2c_board_info info to inner loop - add missing curly braces to outer for loop --- drivers/i2c/busses/i2c-i801.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 6e9aca81b..88745e3bc 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -1247,28 +1247,22 @@ static const struct { static void register_dell_lis3lv02d_i2c_device(struct i801_priv *priv) { - struct i2c_board_info info; - const char *dmi_product_name; int i; - dmi_product_name = dmi_get_system_info(DMI_PRODUCT_NAME); for (i = 0; i < ARRAY_SIZE(dell_lis3lv02d_devices); ++i) { - if (strcmp(dmi_product_name, - dell_lis3lv02d_devices[i].dmi_product_name) == 0) - break; - } - - if (i == ARRAY_SIZE(dell_lis3lv02d_devices)) { - dev_warn(&priv->pci_dev->dev, - "Accelerometer lis3lv02d is present on SMBus but its" - " address is unknown, skipping registration\n"); - return; + if (dmi_match(DMI_PRODUCT_NAME, dell_lis3lv02d_devices[i].dmi_product_name)) { + struct i2c_board_info info = { + .type = "lis3lv02d", + .addr = dell_lis3lv02d_devices[i].i2c_addr, + }; + + i2c_new_client_device(&priv->adapter, &info); + return; + } } - memset(&info, 0, sizeof(struct i2c_board_info)); - info.addr = dell_lis3lv02d_devices[i].i2c_addr; - strlcpy(info.type, "lis3lv02d", I2C_NAME_SIZE); - i2c_new_client_device(&priv->adapter, &info); + pci_warn(priv->pci_dev, + "Accelerometer lis3lv02d is present on SMBus but its address is unknown, skipping registration\n"); } /* Register optional slaves */