Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2835080rdh; Mon, 30 Oct 2023 09:00:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGRPwHWNXtL/VHAH0wzUB0tbzupLq29XUQS4jPXO0cYn0EtrAzUa7Ax1UZtiWLAmmFRcXLT X-Received: by 2002:a17:902:f9c3:b0:1cc:474d:bdf9 with SMTP id kz3-20020a170902f9c300b001cc474dbdf9mr2284066plb.36.1698681649825; Mon, 30 Oct 2023 09:00:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698681649; cv=none; d=google.com; s=arc-20160816; b=Pz3K51V89140Fb5ARL6urKaKkXBuMPKKNI94eaxthcONYuSmdJ9uXspiNDBmc6v8dI qHRRRehbEW4PeIX4Y1e/WQgbVllO6GMO1hcxsyEr+milMz78oTc9xE99vtRiAcIRDlMY O57UClOUszt6r31XGQkTx9NGxSeM8lPUivm87oDPepjByYxbIyarFrXNGE2n5hSBSrut dO24RBSK5JR70y3APobNi861HJITMIRPuP4Q9R9gPHums+58oDdREyfODDrRvnIHBJgR WfGb5u/tGyUXXSMCJtI9+fgWgsDRfYfCluWxyejbGIrQeoOoes3Ci91Puq+WZ7Hoh+hz LJmg== 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=AFG0y1+Kt4uBNbCJA7x9jafadrAHzG0guHlprUsry1A=; fh=cPelUX1quKhMc9zEfBBYitXPF+RxsYLYh6A6gF7DEU8=; b=CPgD3P+WaLFoFJCxiHllGevtdB3CclpxK3Gqh1uNULE3Mmq07wjCEanDuBfv3OZAfz pRMjh/NDzyzGTGPi/5/CJTYkMcBMcX7Ht/mGcldg20SlcKu8OiOfr0bklSc/0p7E2WUF tnsARXJfoUInooLCoKg1wP/ky8zROYZ0q92euCSljeyR2K3ikNENzFeJH5mL0bBmKOlT 9SJe0i+uuQUj7BBrXGFH9Z+cODgRu1c44zAVJnHNVZtsglbgoa45L0A9w5bWtGKw+IAX lDviOxakwvGNf4GkshoV/AfYSASOKITnQq6I7ZYgRDzsSaTRFZRLFO4OZNatoVcZc/rR 0cEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RHW2qKjI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id kz12-20020a170902f9cc00b001cc32a5e086si3453651plb.104.2023.10.30.09.00.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 09:00:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RHW2qKjI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id D1BC180AE56E; Mon, 30 Oct 2023 09:00:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233770AbjJ3QA1 (ORCPT + 99 others); Mon, 30 Oct 2023 12:00:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233781AbjJ3QAY (ORCPT ); Mon, 30 Oct 2023 12:00:24 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D576E8; Mon, 30 Oct 2023 09:00:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698681622; x=1730217622; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=R95PXWqdcCQqpxhYQ7a+K0L2FvJAJWH3UWqlEom9KTY=; b=RHW2qKjILCtfZpI0Zmmy3urwmK+hfxLvgbYmIBvgN9QVHEDCZtgGTcGL VxPmB7zGht4GV7X24KhJw2hPlAY0k5h2l0BhXmaj9PGQ1lRYluvvDw5ss McuN1axJKSAgzt6ZVrl4sRuW09AZchjAnKKN2RY6ltucUcEDGYitIuRwQ uKaiB94Kcax0NGsEpjqJclP5ojm0PwHOeH2HfDCuTvx2XcAacOg51p6eQ my+QU3KH/8oe02j/dDQBZ8o7f7B8AYCBx4KvuV7IS3d8ZJ435d2SN6pxm +AsgUC+I8mAphlT+MwxiRbCSMgP2mhxDkFmmHGeb2IuZf0u9DGpwx4H6n w==; X-IronPort-AV: E=McAfee;i="6600,9927,10879"; a="9630399" X-IronPort-AV: E=Sophos;i="6.03,263,1694761200"; d="scan'208";a="9630399" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2023 09:00:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10879"; a="850955302" X-IronPort-AV: E=Sophos;i="6.03,263,1694761200"; d="scan'208";a="850955302" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2023 09:00:19 -0700 Date: Mon, 30 Oct 2023 18:00:16 +0200 From: Raag Jadav To: Andy Shevchenko Cc: "Rafael J. Wysocki" , Mika Westerberg , len.brown@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: X-Spam-Status: No, score=-1.3 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 pete.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 (pete.vger.email [0.0.0.0]); Mon, 30 Oct 2023 09:00:47 -0700 (PDT) On Mon, Oct 30, 2023 at 12:12:27PM +0200, Andy Shevchenko wrote: > On Sat, Oct 28, 2023 at 11:58:12AM +0300, Raag Jadav wrote: > > On Fri, Oct 27, 2023 at 07:40:38PM +0200, Rafael J. Wysocki wrote: > > ... > > > We'd probably end up with an oops trying to strcmp into a random address > > without knowing its type, so I think Mika's would be a better approach. > > > > #define acpi_dev_uid_match(adev, uid2) \ > > ({ \ > > const char *uid1 = acpi_device_uid(adev); \ > > u64 __uid1; \ > > \ > > _Generic(uid2, \ > > int: uid1 && !kstrtou64(uid1, 0, &__uid1) && (typeof(uid2))__uid1 == uid2, \ > > const char *: uid1 && uid2 && !strcmp(uid1, (const char *)uid2), \ > > default: false); \ > > \ > > }) > > > > This one I atleast got to compile, but I'm not very well versed with _Generic, > > so this could definitely use some comments. > > If you go this way, make _Generic() use simple in the macro with a help of two > additional functions (per type). Also you need to take care about uid2 type to > be _any_ unsigned integer. Or if you want to complicate things, then you need > to distinguish signed and unsigned cases. My initial thought was to have separate functions per type, but then I realized it would become an unnecessary inconvenience to maintain one per type. Having it inline with _Generic would make it relatively easier, but I'll leave it to the maintainers to decide. > P.S. > All to me it seems way too overengineered w/o any potential prospective user. I found a couple of acpi_dev_uid_to_integer() usages which could be simplified with this implementation, but let's see how everyone feels about this. Thanks for the comments, Raag