[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f07c4980-9adc-96a2-4b72-c5db850e44c2@linux.intel.com>
Date: Tue, 28 May 2024 12:03:34 +0300 (EEST)
From: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To: "Luke D. Jones" <luke@...nes.dev>
cc: Hans de Goede <hdegoede@...hat.com>, corentin.chary@...il.com,
platform-driver-x86@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 4/9] platform/x86: asus-wmi: reduce code duplication with
macros
On Tue, 28 May 2024, Luke D. Jones wrote:
> Over time many default patterns have emerged while adding functionality.
> This patch consolidates those patterns in to a few macros to remove a lot
> of copy/paste, and make it easier to add more of the same style of
> features in the future.
>
> Signed-off-by: Luke D. Jones <luke@...nes.dev>
> ---
> +#define WMI_SIMPLE_SHOW(_fname, _fmt, _wmi) \
> +static ssize_t _fname##_show(struct device *dev, \
> + struct device_attribute *attr, char *buf) \
> +{ \
> + struct asus_wmi *asus = dev_get_drvdata(dev); \
> + u32 result; \
> + asus_wmi_get_devstate(asus, _wmi, &result); \
> + if (result < 0) \
> + return result; \
> + return sysfs_emit(buf, _fmt, result & ~ASUS_WMI_DSTS_PRESENCE_BIT); \
> +}
One more thing. To improve readability further, add also normal newlines
into macros like this (obviously with the continuation backslashes far
right as already mentioned).
--
i.
Powered by blists - more mailing lists