Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5930787rwb; Wed, 7 Sep 2022 10:00:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR6mQEwr/NcyJIM8cDu8OMPoiuvhjyVh1I7rkTgNPYLecOqiiJ3pg6BdqgjcXaL9DbMscECm X-Received: by 2002:a05:6402:d0b:b0:443:df38:9df with SMTP id eb11-20020a0564020d0b00b00443df3809dfmr3768337edb.9.1662570047510; Wed, 07 Sep 2022 10:00:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662570047; cv=none; d=google.com; s=arc-20160816; b=v8oIYmDK+LIvel69X/dxXGld26MPe9jTB5hZHTuf7og0BYKavqogsrCqz3THppoNa/ Jn2/cgKuwGv58yZX4+22Hk/eOMfRWozwcMuhJmCBR4aSs6PBolQOny6AvwyoGXHzvUAS vpo3Jv4V0gMJSAySaMDFPrRqtSpAXX6HnzF/B6ISvvZwB7a0AAF8TeSTHpCfs+dMYv4r uNawfzSioHSHAf7YwrURWhUEVkvND1zdtZctzJneYgsf5RVUQCXoB0kX2+nkXe7VK8lo QI0Zq3DW84dLyaWP2k17iJLPp6LLh/6NdG5/roNUBhLIxwnbolmIoeWU+XadKBUoT0J3 FexQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DOf9MNHB/Ng44ROqxHncCFxO2nGG+QzjaSmISsaChrE=; b=jWT4TPdLSwo1dosVxgD0745pubo0t24YC4EOoqHyawkvQciYrTv7ej7RYlwsEqeci+ 7fQPiBMDahrFkyScKUOQBmrPGm1LdIwoDhQI1l2VtI/PrbkUoov86ZjzbkiLJkcIJFn1 gjryLrG35WenCSYcfRfTlJoeFj9/eJo131dJTxg4QiFXgNhOHk74+kRQh7o7jVehP4KS q3ErwoBtf1jqKAoUj/EctxtSqWwd8QxoqpH1y1bn0vOwtikEOiDYGc4hy7I4FDMJ4bz0 1Eg91pc13w1+YTer57IAw1tb2HckEHSYGtdR/ZVlc+kEc236QzlInilZBKO32RubVQth Vyfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FEkvAg9J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q24-20020aa7d458000000b0044791991d0fsi10675890edr.439.2022.09.07.10.00.18; Wed, 07 Sep 2022 10:00:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FEkvAg9J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230098AbiIGQq6 (ORCPT + 99 others); Wed, 7 Sep 2022 12:46:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229793AbiIGQqn (ORCPT ); Wed, 7 Sep 2022 12:46:43 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1697980F6A; Wed, 7 Sep 2022 09:46:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662569199; x=1694105199; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IreFFSbzDFZGfkcBSxeZQScWewSs28Fo3w9m3W8uX74=; b=FEkvAg9J6us49GwYghpJNCfjtVCLQayZ5aUB0B6VphGPMUcf7xwWboM/ pTK6wzwca3u/bmkafo8U4QStvSGen08W92LE6Gab8690RVCPSZtc//WsT d2ohiMh/M/hlhlNJ/MhMjZ/drMnmhNaBuJ24zny5ZX6LGyRb0t4UhwlTK nLDEBeCucTz8HB1U0hDTNoca5p4f/0cHl7pQS3uI7FrHqPifjefUu6Stw kXxaam/F2D+Ot0TJ5jVhWT5bsu5x7odKgWg1gEUYkZ4Zn+h3jlGYoYrVI 7J98H2LDxdDI5aGfyO4qj7kvh/XmSdIOm2TRvPj5CC3pwmS1Oxm/pI6So g==; X-IronPort-AV: E=McAfee;i="6500,9779,10463"; a="296932669" X-IronPort-AV: E=Sophos;i="5.93,297,1654585200"; d="scan'208";a="296932669" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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); -- 2.35.1