From nobody Mon Dec 15 21:47:12 2025 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E17DC20C033 for ; Tue, 14 Jan 2025 20:36:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736886992; cv=none; b=Sg2xyJATd5sa/LAKlxjixzMNxxDP1OTjHP+z+qhOwk6ObIbT4WEPCU1q6j6OPoKg0uYvtPVvas1aWi06aOEHFTbCElb8XCB3t/1lCKZo/gvstsxC9sVLKRyBwfeAAlD+kutRxuJcXn0s0ze5tbxK8fi12faC3MYbFIc09Crn/Xs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736886992; c=relaxed/simple; bh=+FdAt+z1xAYLIMV6nT+KP7RkmVpp5RJIbbDyhP2bsNM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=I1wFhuPJdjZAgTKaaBeYsz0zwQF1uN9CCizrMTktI4Hoi2+jFdI6mOUl3tw2LwA3QN5t2Kfz2PZfaINGLwc3IoroLQO9n7jYLRJmMLd7IZR/F6WjtnRt4ZPPXCC0tUTBklbdm99WO7R45NN3QQmpiWJ+XBwfKK87icLDLSWu+Mk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=biR0JEF4; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="biR0JEF4" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-43616bf3358so7514555e9.3 for ; Tue, 14 Jan 2025 12:36:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736886987; x=1737491787; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/U9E38Yq0RbsKRmPfymuMsLZemc21T6r6c/BM5thOn8=; b=biR0JEF4SaeFMLZ2BnnjyaRQc6JrTyT318nblzig563Zt6PENMxni9SeDgrPhRw5pv dEY3mWybZYDSR20G6d5womVbXXF7bYbCqyOYaOMJ8P5XiPvHJsMRFZeMTgafLiY7VXmu HQXoq6IT8q+pV63qxjg0nbJ81nrKToExO67k0OmWTfWdZS18iTLx69+5xf+IZd71WDHZ U3M5kaexEbXTVv6asnDYxWTKRD0RFDilSD5dM0zjIkRuPGfdRblFSk3Oc7zn012UKYcU 5EFAXE1HHRGs7y+8+wpxH8rCTQcIeIN/sg0K4NEHti22HzMDoTCQOL44byU2TjIcnQja maZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736886987; x=1737491787; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/U9E38Yq0RbsKRmPfymuMsLZemc21T6r6c/BM5thOn8=; b=ZzSkn2XMdMoglJ4gPq8jgt5+aXDHNmRzXWU+eQy76oydZqay8VT6KNtmS0wpYMb5j+ mBYwqP3vZUaEICDZx615aU1YulacDKS+hcTSbLYEF/GJ/kV6BNR8rIDHDBSajaa9jmod aQToHYs+p9yk0bExYz6rV0TCEYkeqPKa6eB/oh9IZKL3l1u2ftrOrwEpZdl7IctdLhhC ZguPctxvnHrFuU7Dk5JyHP56j7bYWZKjebDRxvwW/WC6pulWRlIY1WqOpBVNdveX01Ub zoXBuRzmu4rUih5Uz7fxHt3LktVJF6+jP8YDLBknPqfxgyZZkar/9hALBPXk1LsQZ9q6 BmGA== X-Forwarded-Encrypted: i=1; AJvYcCWNPFJFId8Mcs7jJWW7kVy7fbNbizaD6rXB1EOeiGU4R0irL/emv+MVRbc0eGhcnJYfRxuQrYNXxZvhvIk=@vger.kernel.org X-Gm-Message-State: AOJu0YyPaHunNJRckDYJPab0rFeQtrHkiPuNMXhBO8Y9y/90TG9eHf8T 0i8WuylsDMU2gZhV1KUjNR1V8Dt7/MPuN1/RT/Be+XpRmPeQmITjtb3GK7YYY1s= X-Gm-Gg: ASbGncsTOkcbLj86vpm/SWOQuZCJuHq7g3Majy71/PxLVObtVGgCA+j4m4Y0sLP/1Lf E61Tf9hZ1d5/FZrX4K++3vOumlNQ06XrE/3KVzD27NOWGlDuxD7ofsXtBzAItwQy0ctYQevyNeb 0zQ6G7GrGqqGts3qxM9zs8p7+ZyUId7Q4Tylm8UWHe/BPXipPptLKYxPZ2IEeeGX5/X76+BkFvK ka8KBWbEnef+TPxcTR/ktYJI0dW1dJE17Sb83y2w1vNN8zy/EXOxW4ybva8pLGR/uR2qmQ= X-Google-Smtp-Source: AGHT+IHg3w8EMpYt7LtaYqc3wAUCEGmoqRwXRltHnQR4piUaIUNbFN6feV+vosMmYhZXMPXP0I845g== X-Received: by 2002:a05:600c:4455:b0:434:f9c1:a5b1 with SMTP id 5b1f17b1804b1-436e269968amr98702715e9.3.1736886987112; Tue, 14 Jan 2025 12:36:27 -0800 (PST) Received: from krzk-bin.. ([178.197.223.165]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38bddbf50a2sm5346578f8f.43.2025.01.14.12.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 12:36:26 -0800 (PST) From: Krzysztof Kozlowski To: Alexandre Belloni , Nicolas Ferre , Claudiu Beznea , Joshua Kinard , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Krzysztof Kozlowski Subject: [PATCH] rtc: Use str_enable_disable-like helpers Date: Tue, 14 Jan 2025 21:36:23 +0100 Message-ID: <20250114203623.1013555-1-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace ternary (condition ? "enable" : "disable") syntax with helpers from string_choices.h because: 1. Simple function call with one argument is easier to read. Ternary operator has three arguments and with wrapping might lead to quite long code. 2. Is slightly shorter thus also easier to read. 3. It brings uniformity in the text - same string. 4. Allows deduping by the linker, which results in a smaller binary file. Signed-off-by: Krzysztof Kozlowski --- drivers/rtc/proc.c | 9 +++++---- drivers/rtc/rtc-at91sam9.c | 3 ++- drivers/rtc/rtc-cmos.c | 9 +++++---- drivers/rtc/rtc-ds1286.c | 7 ++++--- drivers/rtc/rtc-ds1685.c | 9 +++++---- drivers/rtc/rtc-efi.c | 5 +++-- drivers/rtc/rtc-max8997.c | 5 +++-- drivers/rtc/rtc-mc13xxx.c | 3 ++- drivers/rtc/rtc-mcp795.c | 3 ++- drivers/rtc/rtc-pic32.c | 3 ++- drivers/rtc/rtc-pxa.c | 5 +++-- drivers/rtc/rtc-sh.c | 5 +++-- 12 files changed, 39 insertions(+), 27 deletions(-) diff --git a/drivers/rtc/proc.c b/drivers/rtc/proc.c index cbcdbb19d848..19576ce89f6c 100644 --- a/drivers/rtc/proc.c +++ b/drivers/rtc/proc.c @@ -12,6 +12,7 @@ #include #include #include +#include =20 #include "rtc-core.h" =20 @@ -57,13 +58,13 @@ static int rtc_proc_show(struct seq_file *seq, void *of= fset) seq_printf(seq, "alrm_time\t: %ptRt\n", &alrm.time); seq_printf(seq, "alrm_date\t: %ptRd\n", &alrm.time); seq_printf(seq, "alarm_IRQ\t: %s\n", - alrm.enabled ? "yes" : "no"); + str_yes_no(alrm.enabled)); seq_printf(seq, "alrm_pending\t: %s\n", - alrm.pending ? "yes" : "no"); + str_yes_no(alrm.pending)); seq_printf(seq, "update IRQ enabled\t: %s\n", - (rtc->uie_rtctimer.enabled) ? "yes" : "no"); + str_yes_no(rtc->uie_rtctimer.enabled)); seq_printf(seq, "periodic IRQ enabled\t: %s\n", - (rtc->pie_enabled) ? "yes" : "no"); + str_yes_no(rtc->pie_enabled)); seq_printf(seq, "periodic IRQ frequency\t: %d\n", rtc->irq_freq); seq_printf(seq, "max user IRQ frequency\t: %d\n", diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c index 15b21da2788f..030ae2241a4a 100644 --- a/drivers/rtc/rtc-at91sam9.c +++ b/drivers/rtc/rtc-at91sam9.c @@ -20,6 +20,7 @@ #include #include #include +#include #include =20 /* @@ -252,7 +253,7 @@ static int at91_rtc_proc(struct device *dev, struct seq= _file *seq) u32 mr =3D rtt_readl(rtc, MR); =20 seq_printf(seq, "update_IRQ\t: %s\n", - (mr & AT91_RTT_RTTINCIEN) ? "yes" : "no"); + str_yes_no(mr & AT91_RTT_RTTINCIEN)); return 0; } =20 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index 78f2ce12c75a..1f556cdd778f 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -604,12 +605,12 @@ static int cmos_procfs(struct device *dev, struct seq= _file *seq) "DST_enable\t: %s\n" "periodic_freq\t: %d\n" "batt_status\t: %s\n", - (rtc_control & RTC_PIE) ? "yes" : "no", - (rtc_control & RTC_UIE) ? "yes" : "no", - use_hpet_alarm() ? "yes" : "no", + str_yes_no(rtc_control & RTC_PIE), + str_yes_no(rtc_control & RTC_UIE), + str_yes_no(use_hpet_alarm()), // (rtc_control & RTC_SQWE) ? "yes" : "no", (rtc_control & RTC_DM_BINARY) ? "no" : "yes", - (rtc_control & RTC_DST_EN) ? "yes" : "no", + str_yes_no(rtc_control & RTC_DST_EN), cmos->rtc->irq_freq, (valid & RTC_VRT) ? "okay" : "dead"); =20 diff --git a/drivers/rtc/rtc-ds1286.c b/drivers/rtc/rtc-ds1286.c index 7acf849d4902..32fff586d3ec 100644 --- a/drivers/rtc/rtc-ds1286.c +++ b/drivers/rtc/rtc-ds1286.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include =20 @@ -133,12 +134,12 @@ static int ds1286_proc(struct device *dev, struct seq= _file *seq) "interrupt_mode\t: %s\n" "INTB_mode\t: %s_active\n" "interrupt_pins\t: %s\n", - (cmd & RTC_TDF) ? "yes" : "no", - (cmd & RTC_WAF) ? "yes" : "no", + str_yes_no(cmd & RTC_TDF), + str_yes_no(cmd & RTC_WAF), (cmd & RTC_TDM) ? "disabled" : "enabled", (cmd & RTC_WAM) ? "disabled" : "enabled", (cmd & RTC_PU_LVL) ? "pulse" : "level", - (cmd & RTC_IBH_LO) ? "low" : "high", + str_low_high(cmd & RTC_IBH_LO), (cmd & RTC_IPSW) ? "unswapped" : "swapped"); return 0; } diff --git a/drivers/rtc/rtc-ds1685.c b/drivers/rtc/rtc-ds1685.c index 38e25f63597a..25ee2d96bf76 100644 --- a/drivers/rtc/rtc-ds1685.c +++ b/drivers/rtc/rtc-ds1685.c @@ -21,6 +21,7 @@ #include #include #include +#include #include =20 #include @@ -802,14 +803,14 @@ ds1685_rtc_proc(struct device *dev, struct seq_file *= seq) "SQW Freq\t: %s\n" "Serial #\t: %8phC\n", model, - ((ctrla & RTC_CTRL_A_DV1) ? "enabled" : "disabled"), + str_enabled_disabled(ctrla & RTC_CTRL_A_DV1), ((ctrlb & RTC_CTRL_B_2412) ? "24-hour" : "12-hour"), - ((ctrlb & RTC_CTRL_B_DSE) ? "enabled" : "disabled"), + str_enabled_disabled(ctrlb & RTC_CTRL_B_DSE), ((ctrlb & RTC_CTRL_B_DM) ? "binary" : "BCD"), ((ctrld & RTC_CTRL_D_VRT) ? "ok" : "exhausted or n/a"), ((ctrl4a & RTC_CTRL_4A_VRT2) ? "ok" : "exhausted or n/a"), - ((ctrlb & RTC_CTRL_B_UIE) ? "yes" : "no"), - ((ctrlb & RTC_CTRL_B_PIE) ? "yes" : "no"), + str_yes_no(ctrlb & RTC_CTRL_B_UIE), + str_yes_no(ctrlb & RTC_CTRL_B_PIE), (!(ctrl4b & RTC_CTRL_4B_E32K) ? ds1685_rtc_pirq_rate[(ctrla & RTC_CTRL_A_RS_MASK)] : "none"), (!((ctrl4b & RTC_CTRL_4B_E32K)) ? diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c index fa8bf82df948..fd4bc2d715da 100644 --- a/drivers/rtc/rtc-efi.c +++ b/drivers/rtc/rtc-efi.c @@ -16,6 +16,7 @@ #include #include #include +#include #include =20 #define EFI_ISDST (EFI_TIME_ADJUST_DAYLIGHT|EFI_TIME_IN_DAYLIGHT) @@ -224,8 +225,8 @@ static int efi_procfs(struct device *dev, struct seq_fi= le *seq) alm.hour, alm.minute, alm.second, alm.nanosecond, alm.year, alm.month, alm.day, alm.daylight, - enabled =3D=3D 1 ? "yes" : "no", - pending =3D=3D 1 ? "yes" : "no"); + str_yes_no(enabled =3D=3D 1), + str_yes_no(pending =3D=3D 1)); =20 if (alm.timezone =3D=3D EFI_UNSPECIFIED_TIMEZONE) seq_puts(seq, "Timezone\t: unspecified\n"); diff --git a/drivers/rtc/rtc-max8997.c b/drivers/rtc/rtc-max8997.c index 20e50d9fdf88..0b094b8f9bb9 100644 --- a/drivers/rtc/rtc-max8997.c +++ b/drivers/rtc/rtc-max8997.c @@ -9,6 +9,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt =20 #include +#include #include #include #include @@ -379,7 +380,7 @@ static void max8997_rtc_enable_wtsr(struct max8997_rtc_= info *info, bool enable) mask =3D WTSR_EN_MASK | WTSRT_MASK; =20 dev_info(info->dev, "%s: %s WTSR\n", __func__, - enable ? "enable" : "disable"); + str_enable_disable(enable)); =20 ret =3D max8997_update_reg(info->rtc, MAX8997_RTC_WTSR_SMPL, val, mask); if (ret < 0) { @@ -407,7 +408,7 @@ static void max8997_rtc_enable_smpl(struct max8997_rtc_= info *info, bool enable) mask =3D SMPL_EN_MASK | SMPLT_MASK; =20 dev_info(info->dev, "%s: %s SMPL\n", __func__, - enable ? "enable" : "disable"); + str_enable_disable(enable)); =20 ret =3D max8997_update_reg(info->rtc, MAX8997_RTC_WTSR_SMPL, val, mask); if (ret < 0) { diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c index e7b87130e624..fd874baa08ab 100644 --- a/drivers/rtc/rtc-mc13xxx.c +++ b/drivers/rtc/rtc-mc13xxx.c @@ -12,6 +12,7 @@ #include #include #include +#include #include =20 #define DRIVER_NAME "mc13xxx-rtc" @@ -214,7 +215,7 @@ static int mc13xxx_rtc_set_alarm(struct device *dev, st= ruct rtc_wkalrm *alarm) =20 s1970 =3D rtc_tm_to_time64(&alarm->time); =20 - dev_dbg(dev, "%s: %s %lld\n", __func__, alarm->enabled ? "on" : "off", + dev_dbg(dev, "%s: %s %lld\n", __func__, str_on_off(alarm->enabled), (long long)s1970); =20 ret =3D mc13xxx_rtc_irq_enable_unlocked(dev, alarm->enabled, diff --git a/drivers/rtc/rtc-mcp795.c b/drivers/rtc/rtc-mcp795.c index e12f0f806ec4..4a55d7e91d08 100644 --- a/drivers/rtc/rtc-mcp795.c +++ b/drivers/rtc/rtc-mcp795.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -161,7 +162,7 @@ static int mcp795_update_alarm(struct device *dev, bool= enable) { int ret; =20 - dev_dbg(dev, "%s alarm\n", enable ? "Enable" : "Disable"); + dev_dbg(dev, "%s alarm\n", str_enable_disable(enable)); =20 if (enable) { /* clear ALM0IF (Alarm 0 Interrupt Flag) bit */ diff --git a/drivers/rtc/rtc-pic32.c b/drivers/rtc/rtc-pic32.c index bed3c27e665f..256e7e5e7fd6 100644 --- a/drivers/rtc/rtc-pic32.c +++ b/drivers/rtc/rtc-pic32.c @@ -14,6 +14,7 @@ #include #include #include +#include #include =20 #include @@ -247,7 +248,7 @@ static int pic32_rtc_proc(struct device *dev, struct se= q_file *seq) =20 repeat =3D readw(base + PIC32_RTCALRM); repeat &=3D PIC32_RTCALRM_ARPT; - seq_printf(seq, "periodic_IRQ\t: %s\n", repeat ? "yes" : "no"); + seq_printf(seq, "periodic_IRQ\t: %s\n", str_yes_no(repeat)); =20 clk_disable(pdata->clk); return 0; diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c index 34d8545c8e15..ff8f0387d023 100644 --- a/drivers/rtc/rtc-pxa.c +++ b/drivers/rtc/rtc-pxa.c @@ -13,6 +13,7 @@ #include #include #include +#include #include =20 #include "rtc-sa1100.h" @@ -282,9 +283,9 @@ static int pxa_rtc_proc(struct device *dev, struct seq_= file *seq) =20 seq_printf(seq, "trim/divider\t: 0x%08x\n", rtc_readl(pxa_rtc, RTTR)); seq_printf(seq, "update_IRQ\t: %s\n", - (rtc_readl(pxa_rtc, RTSR) & RTSR_HZE) ? "yes" : "no"); + str_yes_no(rtc_readl(pxa_rtc, RTSR) & RTSR_HZE)); seq_printf(seq, "periodic_IRQ\t: %s\n", - (rtc_readl(pxa_rtc, RTSR) & RTSR_PIALE) ? "yes" : "no"); + str_yes_no(rtc_readl(pxa_rtc, RTSR) & RTSR_PIALE)); seq_printf(seq, "periodic_freq\t: %u\n", rtc_readl(pxa_rtc, PIAR)); =20 return 0; diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c index a5df521876ba..8073421217fa 100644 --- a/drivers/rtc/rtc-sh.c +++ b/drivers/rtc/rtc-sh.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -237,11 +238,11 @@ static int sh_rtc_proc(struct device *dev, struct seq= _file *seq) unsigned int tmp; =20 tmp =3D readb(rtc->regbase + RCR1); - seq_printf(seq, "carry_IRQ\t: %s\n", (tmp & RCR1_CIE) ? "yes" : "no"); + seq_printf(seq, "carry_IRQ\t: %s\n", str_yes_no(tmp & RCR1_CIE)); =20 tmp =3D readb(rtc->regbase + RCR2); seq_printf(seq, "periodic_IRQ\t: %s\n", - (tmp & RCR2_PESMASK) ? "yes" : "no"); + str_yes_no(tmp & RCR2_PESMASK)); =20 return 0; } --=20 2.43.0