[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZT+BiykmKepdAA8K@smile.fi.intel.com>
Date: Mon, 30 Oct 2023 12:12:27 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Raag Jadav <raag.jadav@...el.com>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
len.brown@...el.com, linux-acpi@...r.kernel.org,
linux-kernel@...r.kernel.org,
mallikarjunappa.sangannavar@...el.com, bala.senthil@...el.com
Subject: Re: [PATCH v2] ACPI: LPSS: use acpi_dev_uid_match() for matching _UID
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.
P.S.
All to me it seems way too overengineered w/o any potential prospective user.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists