From 647c6135c3bc20cbe583996669c9350d5232a66b Mon Sep 17 00:00:00 2001 From: zvecr Date: Thu, 23 Mar 2023 00:25:36 +0000 Subject: [PATCH 1/2] Tidy up duplication of MIN/MAX fallback implementations --- quantum/audio/audio.c | 1 + quantum/audio/audio.h | 5 ----- quantum/color.c | 4 +--- quantum/midi/midi.c | 5 +---- quantum/rgblight/rgblight.c | 8 +------- quantum/velocikey.c | 8 +------- 6 files changed, 5 insertions(+), 26 deletions(-) diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index ca78a483ad8f..d7db3a23f54b 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c @@ -18,6 +18,7 @@ #include "eeconfig.h" #include "timer.h" #include "wait.h" +#include "util.h" /* audio system: * diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index fe23cf3ed1a8..11fc797241ef 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h @@ -43,11 +43,6 @@ typedef union { }; } audio_config_t; -// AVR/LUFA has a MIN, arm/chibios does not -#ifndef MIN -# define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif - /* * a 'musical note' is represented by pitch and duration; a 'musical tone' adds intensity and timbre * https://en.wikipedia.org/wiki/Musical_tone diff --git a/quantum/color.c b/quantum/color.c index c80078dbf215..767155c9db9b 100644 --- a/quantum/color.c +++ b/quantum/color.c @@ -17,6 +17,7 @@ #include "color.h" #include "led_tables.h" #include "progmem.h" +#include "util.h" RGB hsv_to_rgb_impl(HSV hsv, bool use_cie) { RGB rgb; @@ -109,9 +110,6 @@ RGB hsv_to_rgb_nocie(HSV hsv) { } #ifdef RGBW -# ifndef MIN -# define MIN(a, b) ((a) < (b) ? (a) : (b)) -# endif void convert_rgb_to_rgbw(LED_TYPE *led) { // Determine lowest value in all three colors, put that into // the white channel and then shift all colors by that amount diff --git a/quantum/midi/midi.c b/quantum/midi/midi.c index 1ba3e73a4020..1c481f2f0b38 100644 --- a/quantum/midi/midi.c +++ b/quantum/midi/midi.c @@ -18,10 +18,7 @@ #include "midi.h" #include //for memcpy - -#ifndef MIN -# define MIN(x, y) (((x) < (y)) ? (x) : (y)) -#endif +#include "util.h" #ifndef NULL # define NULL 0 diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c index 19d80e0097dc..dc75c1a842df 100644 --- a/quantum/rgblight/rgblight.c +++ b/quantum/rgblight/rgblight.c @@ -21,6 +21,7 @@ #include "rgblight.h" #include "color.h" #include "debug.h" +#include "util.h" #include "led_tables.h" #include #ifdef EEPROM_ENABLE @@ -30,13 +31,6 @@ # include "velocikey.h" #endif -#ifndef MIN -# define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef MAX -# define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif - #ifdef RGBLIGHT_SPLIT /* for split keyboard */ # define RGBLIGHT_SPLIT_SET_CHANGE_MODE rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_MODE diff --git a/quantum/velocikey.c b/quantum/velocikey.c index 58e14215bb36..03e91911f6c6 100644 --- a/quantum/velocikey.c +++ b/quantum/velocikey.c @@ -2,13 +2,7 @@ #include "timer.h" #include "eeconfig.h" #include "eeprom.h" - -#ifndef MIN -# define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef MAX -# define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif +#include "util.h" #define TYPING_SPEED_MAX_VALUE 200 uint8_t typing_speed = 0; From aee12e27e3b050110d6b7be391756888ecf5f378 Mon Sep 17 00:00:00 2001 From: zvecr Date: Thu, 23 Mar 2023 00:27:46 +0000 Subject: [PATCH 2/2] More --- platforms/arm_atsam/eeprom_samd.c | 5 +---- platforms/avr/drivers/i2c_master.c | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/platforms/arm_atsam/eeprom_samd.c b/platforms/arm_atsam/eeprom_samd.c index 1c1e031e5da3..9c42041f2da4 100644 --- a/platforms/arm_atsam/eeprom_samd.c +++ b/platforms/arm_atsam/eeprom_samd.c @@ -15,15 +15,12 @@ */ #include "eeprom.h" #include "debug.h" +#include "util.h" #include "samd51j18a.h" #include "core_cm4.h" #include "component/nvmctrl.h" #include "eeprom_samd.h" -#ifndef MAX -# define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) -#endif - #ifndef BUSY_RETRIES # define BUSY_RETRIES 10000 #endif diff --git a/platforms/avr/drivers/i2c_master.c b/platforms/avr/drivers/i2c_master.c index 524494c99d79..58939f3e00e5 100644 --- a/platforms/avr/drivers/i2c_master.c +++ b/platforms/avr/drivers/i2c_master.c @@ -23,6 +23,7 @@ #include "i2c_master.h" #include "timer.h" #include "wait.h" +#include "util.h" #ifndef F_SCL # define F_SCL 400000UL // SCL frequency @@ -37,8 +38,6 @@ #define TWBR_val (((F_CPU / F_SCL) - 16) / 2) -#define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) - void i2c_init(void) { TWSR = 0; /* no prescaler */ TWBR = (uint8_t)TWBR_val;