From patchwork Wed Sep 7 16:46:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12969261 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4DC86C38145 for ; Wed, 7 Sep 2022 16:47:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7CcJ4tE7d84ZIC9o3xxNyKu92X9iqxy0QlEtGvDu6X4=; b=YjpMbZKsUEh/My K1/O7nP+962v6uf/5l4M8QLcgygbSV0e2rRC9GEck6slwVBuwBNWqxqHiB0ppYLyGkE5nsogrqhqv ipWoE15gYiO6/asYOn9VPSHZpM7l/6oCOMhJQ8SxNx9WlK9oEvrcr99EutbtaA/5l3cra218+vA+o BEMcNLexloff9FhFOSS8+dskPPRVtMnhG8f8qZGQZI/P9cD90a5s45qx83ajpuwTY6N8AZ6onwcDl EBTpmBzL+LCDZtQisup0DM2wbGajdsNirhZuU67bdQT5RNy7shvQ+lQXnt5dfIdIPgIORTCrluaVK 3doBXx5icCGTiLH08NcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVyCA-007tE8-BM; Wed, 07 Sep 2022 16:46:34 +0000 Received: from mga17.intel.com ([192.55.52.151]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVyBl-007sz4-DC for linux-arm-kernel@lists.infradead.org; Wed, 07 Sep 2022 16:46:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662569169; x=1694105169; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IreFFSbzDFZGfkcBSxeZQScWewSs28Fo3w9m3W8uX74=; b=eGet0BC/UfJPXB57zjBfnBzWKe8IEgxG5iqz9fPzt+1O1kgtqBKrn7He 9tf92JUKaAJok0lC0a0Nn8zo4S4jBczJxqNfCixp6PSyWLHEuL9oGzjvH AjZ2Tbovrb6AFAko3YyJTVRzkRrrI90dAKGC22WN2/vzRox+VeNnelv5H 1d9gD1o95FsEA6WFc0WlXuo9grPFtNnf2lQ/xAmTpvUXgvxIVv1ZLiruC lfAS6JfJk0OFLcNh6v/R5rtZjid5apQklyPuezruTYwNdVnB7eHO67CUl 0yTHJcZbyBah9wQX8A6sqVpYBYd8Em2eOvVhBc7k6Mq4g9ekzvHlYxHEz Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10463"; a="277324200" X-IronPort-AV: E=Sophos;i="5.93,297,1654585200"; d="scan'208";a="277324200" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2022 09:46:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,297,1654585200"; d="scan'208";a="591788324" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 07 Sep 2022 09:45:56 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 01F1945C; Wed, 7 Sep 2022 19:46:11 +0300 (EEST) From: Andy Shevchenko To: "Rafael J. Wysocki" , Andy Shevchenko , Wolfram Sang , Hans de Goede , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org, devel@acpica.org Cc: "Rafael J. Wysocki" , Len Brown , Ard Biesheuvel , Elie Morisse , Nehal Shah , Shyam Sundar S K , Khalil Blaiech , Andy Gross , Bjorn Andersson , Konrad Dybcio , Will Deacon , Mark Rutland , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Mark Brown , Robert Moore , Wolfram Sang Subject: [PATCH v1 4/8] i2c: amd-mp2-plat: Refactor _UID handling to use acpi_dev_uid_to_integer() Date: Wed, 7 Sep 2022 19:46:02 +0300 Message-Id: <20220907164606.65742-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220907164606.65742-1-andriy.shevchenko@linux.intel.com> References: <20220907164606.65742-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220907_094609_500855_1207FD0E X-CRM114-Status: GOOD ( 16.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org ACPI utils provide acpi_dev_uid_to_integer() helper to extract _UID as an integer. Use it instead of custom approach. Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/i2c-amd-mp2-plat.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/i2c/busses/i2c-amd-mp2-plat.c b/drivers/i2c/busses/i2c-amd-mp2-plat.c index 84b7e6cbc67b..423fe0c8a471 100644 --- a/drivers/i2c/busses/i2c-amd-mp2-plat.c +++ b/drivers/i2c/busses/i2c-amd-mp2-plat.c @@ -244,14 +244,18 @@ static const struct i2c_adapter_quirks amd_i2c_dev_quirks = { static int i2c_amd_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; int ret; struct amd_i2c_dev *i2c_dev; - struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); struct amd_mp2_dev *mp2_dev; - const char *uid; + u64 uid; - if (!adev) - return -ENODEV; + ret = acpi_dev_uid_to_integer(ACPI_COMPANION(dev), &uid); + if (ret) + return dev_err_probe(dev, ret, "missing UID/bus id!\n"); + if (uid >= 2) + return dev_err_probe(dev, -EINVAL, "incorrect UID/bus id \"%llu\"!\n", uid); + dev_dbg(dev, "bus id is %llu\n", uid); /* The ACPI namespace doesn't contain information about which MP2 PCI * device an AMDI0011 ACPI device is related to, so assume that there's @@ -266,6 +270,7 @@ static int i2c_amd_probe(struct platform_device *pdev) if (!i2c_dev) return -ENOMEM; + i2c_dev->common.bus_id = uid; i2c_dev->common.mp2_dev = mp2_dev; i2c_dev->pdev = pdev; platform_set_drvdata(pdev, i2c_dev); @@ -276,20 +281,6 @@ static int i2c_amd_probe(struct platform_device *pdev) i2c_dev->common.resume = &i2c_amd_resume; #endif - uid = adev->pnp.unique_id; - if (!uid) { - dev_err(&pdev->dev, "missing UID/bus id!\n"); - return -EINVAL; - } else if (strcmp(uid, "0") == 0) { - i2c_dev->common.bus_id = 0; - } else if (strcmp(uid, "1") == 0) { - i2c_dev->common.bus_id = 1; - } else { - dev_err(&pdev->dev, "incorrect UID/bus id \"%s\"!\n", uid); - return -EINVAL; - } - dev_dbg(&pdev->dev, "bus id is %u\n", i2c_dev->common.bus_id); - /* Register the adapter */ amd_mp2_pm_runtime_get(mp2_dev);