Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1295966rdh; Fri, 27 Oct 2023 09:53:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHIzhs+7pHUwW+eYGlEWa+uasZSIEY70oOCaeoCUXcOCOeiPYGdv0euwmKGHXjj871co+Vv X-Received: by 2002:a05:6358:9144:b0:168:de6a:d653 with SMTP id r4-20020a056358914400b00168de6ad653mr4275903rwr.21.1698425590008; Fri, 27 Oct 2023 09:53:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698425589; cv=none; d=google.com; s=arc-20160816; b=W2E4JRMpNTkXBwI2Q08T5BvtC1qltmL7BYR1ao95squWRkHFCFGLwx53KkHJ99n4ox IN30KVEQgzYWL3nDJjtX38a89LflCnIKKvtlM6hAE0AFXSw7uuW1jDeOI/wLj4dtEanG o7VNUKipBY72oGlwsbESNUk/VSQ15hd4bnaRQ5i32GlB2EQpumctBUe2QY31xuZg7gap jyL7bws/iFsuuTe/Qf3XihTE97uFeRnS3nQ2GqLuUvlYMVNN8UUjQFDt8m+wC1J7Fe+S exGdGDAXjNja1xXJP3LindvD8R6LyGnvEcktjSXHiRMpVZ05DkkcmKFQ8zvtCEPlY88D DDtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=C4n4HaISg1eh5BIaLP1O5tZmDSWzNkjUhT6IpDC1fc8=; fh=tBy8eVSD4moMZnPuIRuzNXje623dsKDm39LwkhrNNsE=; b=Bovq1sYBH6iUn2ZWbpHHuQ+hBslU1Q1j7JwZXqywejTEDJAQDemaMmlb9sHcMrvbP8 gj/rFOlcO2Y5SeSgGZnVNgl4R3bgbfUIrAPpGK5CQ+6niGe0hmtN/0FhNvok96uPdabF eWdS4FeHhPdbOLfHl7lhBUf+eSNROiXCf6zVzrMy9QEDd0KOg8QwSkOav7laMKU5JoD3 yM80U/CyiVM+gBSDI0fo+zcDwsTOh5nqviX+DXcPfQj8Ymbf/150r2pqxwuIgUg3GMei AefBZz+IDv5oumvSn7CNHyT/AxIzPNciZFD2Xg1xZLTvtPHGYo5598S0Yp7Y7N/wp3bs ZTHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PbwtnDCq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id x132-20020a0dd58a000000b005af081d5beesi3195137ywd.256.2023.10.27.09.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 09:53:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PbwtnDCq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 9D4AD8093783; Fri, 27 Oct 2023 09:51:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231974AbjJ0Qv2 (ORCPT + 99 others); Fri, 27 Oct 2023 12:51:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjJ0Qv0 (ORCPT ); Fri, 27 Oct 2023 12:51:26 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22847E1; Fri, 27 Oct 2023 09:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698425484; x=1729961484; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=CIzSUICgUbCBinCWTNlvODDWm9cp8C+3Sy6BfA5aCfE=; b=PbwtnDCq3Zg6/z6A6EaK57pmxvmkcavverQWMIpHZoOSs8U+iUgOZ+6o 6nDb71iz0A+IKcy+QSPtXr8TzH+IDHrVDecbWr5I6hpZVhWdlRMZiqxrr TuYpVZEbDOksi+NmOm8Ug/F51igJdeBLh//YuAzskH97X73K5+9z/gsw9 mNvfaSYuPf3o0ZoK2S46EFVRyeM0P85HtVRzRUdbavZz0ohD8jyQbl3uj X5DORlVGGKL8lztXCe+grwVf3ZThtI9koUaY50WPWYNJftD1sFdMdMr9w U/cRdZw9ngoSNhRMVfFNeqLiVgQpxcPW1oQ2IX9PIH43GPudFUT0YmNPV A==; X-IronPort-AV: E=McAfee;i="6600,9927,10876"; a="378180553" X-IronPort-AV: E=Sophos;i="6.03,256,1694761200"; d="scan'208";a="378180553" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2023 09:51:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10876"; a="1006793183" X-IronPort-AV: E=Sophos;i="6.03,256,1694761200"; d="scan'208";a="1006793183" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2023 09:51:21 -0700 Date: Fri, 27 Oct 2023 19:51:18 +0300 From: Raag Jadav To: Mika Westerberg Cc: rafael@kernel.org, len.brown@intel.com, andriy.shevchenko@linux.intel.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, mallikarjunappa.sangannavar@intel.com, bala.senthil@intel.com Subject: Re: [PATCH v2] ACPI: LPSS: use acpi_dev_uid_match() for matching _UID Message-ID: References: <20231026083335.12551-1-raag.jadav@intel.com> <20231027081855.GK3208943@black.fi.intel.com> <20231027142856.GL3208943@black.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231027142856.GL3208943@black.fi.intel.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 27 Oct 2023 09:51:35 -0700 (PDT) On Fri, Oct 27, 2023 at 05:28:56PM +0300, Mika Westerberg wrote: > On Fri, Oct 27, 2023 at 05:17:12PM +0300, Raag Jadav wrote: > > Or perhaps something like, > > > > bool acpi_dev_uid_match(struct acpi_device *adev, const void *uid2, enum uid_type type) > > { > > u64 uid1_d, uid2_d; > > > > if (type == UID_TYPE_STR) { > > char *uid2_s = (char *)uid2; > > if (!(uid2_s && !kstrtou64(uid2_s, 0, &uid2_d))) > > return false; > > } else if (type == UID_TYPE_INT) { > > u64 *uid2_p; > > uid2_p = (u64 *)uid2; > > uid2_d = *uid2_p; > > } else { > > return false; > > } > > > > if (!acpi_dev_uid_to_integer(adev, &uid1_d) && uid1_d == uid2_d) > > return true; > > else > > return false; > > } > > > > Although this looks unnecessarily hideous. > > Indeed, but using the _Generic() you should be able to have > a single acpi_dev_uid_match() to work for either type so: > > acpi_dev_uid_match(adev, "1") > > and > > acpi_dev_uid_match(adev, 1) > > would both work with type checkings etc. > > Not sure if this is worth the trouble though. Well, in that case we can probably try both and hope for the best ;) bool acpi_dev_uid_match(struct acpi_device *adev, const char *uid2) { const char *uid1 = acpi_device_uid(adev); u64 uid1_d; return uid1 && uid2 && (!strcmp(uid1, uid2) || (!kstrtou64(uid1, 0, &uid1_d) && uid1_d == (u64)uid2)); } But I'm guessing the compiler wouldn't be very happy about this. Raag