Skip to content

Commit cf28f48

Browse files
committed
🎨 Apply const (MarlinFirmware#25643)
1 parent 69e8f2e commit cf28f48

13 files changed

+153
-155
lines changed

Marlin/src/MarlinCore.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
777777
* - Update the Průša MMU2
778778
* - Handle Joystick jogging
779779
*/
780-
void idle(bool no_stepper_sleep/*=false*/) {
780+
void idle(const bool no_stepper_sleep/*=false*/) {
781781
#ifdef MAX7219_DEBUG_PROFILE
782782
CodeProfiler idle_profiler;
783783
#endif

Marlin/src/MarlinCore.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
void stop();
3131

3232
// Pass true to keep steppers from timing out
33-
void idle(bool no_stepper_sleep=false);
33+
void idle(const bool no_stepper_sleep=false);
3434
inline void idle_no_sleep() { idle(true); }
3535

3636
#if ENABLED(G38_PROBE_TARGET)

Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ uint32_t SPIFlashStorage::m_startAddress;
148148

149149
#endif // HAS_SPI_FLASH_COMPRESSION
150150

151-
void SPIFlashStorage::beginWrite(uint32_t startAddress) {
151+
void SPIFlashStorage::beginWrite(const uint32_t startAddress) {
152152
m_pageDataUsed = 0;
153153
m_currentPage = 0;
154154
m_startAddress = startAddress;
@@ -171,7 +171,7 @@ void SPIFlashStorage::endWrite() {
171171
#endif
172172
}
173173

174-
void SPIFlashStorage::savePage(uint8_t *buffer) {
174+
void SPIFlashStorage::savePage(uint8_t * const buffer) {
175175
W25QXX.SPI_FLASH_BufferWrite(buffer, m_startAddress + (SPI_FLASH_PageSize * m_currentPage), SPI_FLASH_PageSize);
176176
// Test env
177177
// char fname[256];
@@ -181,7 +181,7 @@ void SPIFlashStorage::savePage(uint8_t *buffer) {
181181
// fclose(fp);
182182
}
183183

184-
void SPIFlashStorage::loadPage(uint8_t *buffer) {
184+
void SPIFlashStorage::loadPage(uint8_t * const buffer) {
185185
W25QXX.SPI_FLASH_BufferRead(buffer, m_startAddress + (SPI_FLASH_PageSize * m_currentPage), SPI_FLASH_PageSize);
186186
// Test env
187187
// char fname[256];
@@ -260,20 +260,20 @@ void SPIFlashStorage::readPage() {
260260
#endif
261261
}
262262

263-
uint16_t SPIFlashStorage::inData(uint8_t *data, uint16_t size) {
263+
uint16_t SPIFlashStorage::inData(const uint8_t * const data, uint16_t size) {
264264
// Don't write more than we can
265265
NOMORE(size, pageDataFree());
266266
memcpy(m_pageData + m_pageDataUsed, data, size);
267267
m_pageDataUsed += size;
268268
return size;
269269
}
270270

271-
void SPIFlashStorage::writeData(uint8_t *data, uint16_t size) {
271+
void SPIFlashStorage::writeData(const uint8_t *data, uint16_t size) {
272272
// Flush a page if needed
273273
if (pageDataFree() == 0) flushPage();
274274

275275
while (size > 0) {
276-
uint16_t written = inData(data, size);
276+
const uint16_t written = inData(data, size);
277277
size -= written;
278278
// Need to write more? Flush page and continue!
279279
if (size > 0) {
@@ -283,7 +283,7 @@ void SPIFlashStorage::writeData(uint8_t *data, uint16_t size) {
283283
}
284284
}
285285

286-
void SPIFlashStorage::beginRead(uint32_t startAddress) {
286+
void SPIFlashStorage::beginRead(const uint32_t startAddress) {
287287
m_startAddress = startAddress;
288288
m_currentPage = 0;
289289
// Nothing in memory now
@@ -293,7 +293,7 @@ void SPIFlashStorage::beginRead(uint32_t startAddress) {
293293
#endif
294294
}
295295

296-
uint16_t SPIFlashStorage::outData(uint8_t *data, uint16_t size) {
296+
uint16_t SPIFlashStorage::outData(uint8_t * const data, uint16_t size) {
297297
// Don't read more than we have
298298
NOMORE(size, pageDataFree());
299299
memcpy(data, m_pageData + m_pageDataUsed, size);
@@ -306,7 +306,7 @@ void SPIFlashStorage::readData(uint8_t *data, uint16_t size) {
306306
if (pageDataFree() == 0) readPage();
307307

308308
while (size > 0) {
309-
uint16_t read = outData(data, size);
309+
const uint16_t read = outData(data, size);
310310
size -= read;
311311
// Need to write more? Flush page and continue!
312312
if (size > 0) {

Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,23 @@
7575
class SPIFlashStorage {
7676
public:
7777
// Write operation
78-
static void beginWrite(uint32_t startAddress);
78+
static void beginWrite(const uint32_t startAddress);
7979
static void endWrite();
80-
static void writeData(uint8_t *data, uint16_t size);
80+
static void writeData(const uint8_t *data, uint16_t size);
8181

8282
// Read operation
83-
static void beginRead(uint32_t startAddress);
83+
static void beginRead(const uint32_t startAddress);
8484
static void readData(uint8_t *data, uint16_t size);
8585

8686
static uint32_t getCurrentPage() { return m_currentPage; }
8787

8888
private:
8989
static void flushPage();
90-
static void savePage(uint8_t *buffer);
91-
static void loadPage(uint8_t *buffer);
90+
static void savePage(uint8_t * const buffer);
91+
static void loadPage(uint8_t * const buffer);
9292
static void readPage();
93-
static uint16_t inData(uint8_t *data, uint16_t size);
94-
static uint16_t outData(uint8_t *data, uint16_t size);
93+
static uint16_t inData(const uint8_t * const data, uint16_t size);
94+
static uint16_t outData(uint8_t * const data, uint16_t size);
9595

9696
static uint8_t m_pageData[SPI_FLASH_PageSize];
9797
static uint32_t m_currentPage;

Marlin/src/sd/Sd2Card.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ bool DiskIODriver_SPI_SD::init(const uint8_t sckRateID, const pin_t chipSelectPi
345345
* \param[out] dst Pointer to the location that will receive the data.
346346
* \return true for success, false for failure.
347347
*/
348-
bool DiskIODriver_SPI_SD::readBlock(uint32_t blockNumber, uint8_t *dst) {
348+
bool DiskIODriver_SPI_SD::readBlock(uint32_t blockNumber, uint8_t * const dst) {
349349
#if IS_TEENSY_35_36 || IS_TEENSY_40_41
350350
return 0 == SDHC_CardReadBlock(dst, blockNumber);
351351
#endif
@@ -385,7 +385,7 @@ bool DiskIODriver_SPI_SD::readBlock(uint32_t blockNumber, uint8_t *dst) {
385385
*
386386
* \return true for success, false for failure.
387387
*/
388-
bool DiskIODriver_SPI_SD::readData(uint8_t *dst) {
388+
bool DiskIODriver_SPI_SD::readData(uint8_t * const dst) {
389389
chipSelect();
390390
return readData(dst, 512);
391391
}
@@ -455,7 +455,7 @@ bool DiskIODriver_SPI_SD::readData(uint8_t *dst) {
455455

456456
#endif // SD_CHECK_AND_RETRY
457457

458-
bool DiskIODriver_SPI_SD::readData(uint8_t *dst, const uint16_t count) {
458+
bool DiskIODriver_SPI_SD::readData(uint8_t * const dst, const uint16_t count) {
459459
bool success = false;
460460

461461
const millis_t read_timeout = millis() + SD_READ_TIMEOUT;
@@ -487,8 +487,8 @@ bool DiskIODriver_SPI_SD::readData(uint8_t *dst, const uint16_t count) {
487487
}
488488

489489
/** read CID or CSR register */
490-
bool DiskIODriver_SPI_SD::readRegister(const uint8_t cmd, void *buf) {
491-
uint8_t *dst = reinterpret_cast<uint8_t*>(buf);
490+
bool DiskIODriver_SPI_SD::readRegister(const uint8_t cmd, void * const buf) {
491+
uint8_t * const dst = reinterpret_cast<uint8_t*>(buf);
492492
if (cardCommand(cmd, 0)) {
493493
error(SD_CARD_ERROR_READ_REG);
494494
chipDeselect();
@@ -567,7 +567,7 @@ void DiskIODriver_SPI_SD::error(const uint8_t code) { errorCode_ = code; }
567567
* \param[in] src Pointer to the location of the data to be written.
568568
* \return true for success, false for failure.
569569
*/
570-
bool DiskIODriver_SPI_SD::writeBlock(uint32_t blockNumber, const uint8_t *src) {
570+
bool DiskIODriver_SPI_SD::writeBlock(uint32_t blockNumber, const uint8_t * const src) {
571571
if (ENABLED(SDCARD_READONLY)) return false;
572572

573573
#if IS_TEENSY_35_36 || IS_TEENSY_40_41
@@ -598,7 +598,7 @@ bool DiskIODriver_SPI_SD::writeBlock(uint32_t blockNumber, const uint8_t *src) {
598598
* \param[in] src Pointer to the location of the data to be written.
599599
* \return true for success, false for failure.
600600
*/
601-
bool DiskIODriver_SPI_SD::writeData(const uint8_t *src) {
601+
bool DiskIODriver_SPI_SD::writeData(const uint8_t * const src) {
602602
if (ENABLED(SDCARD_READONLY)) return false;
603603

604604
bool success = true;
@@ -613,7 +613,7 @@ bool DiskIODriver_SPI_SD::writeData(const uint8_t *src) {
613613
}
614614

615615
// Send one block of data for write block or write multiple blocks
616-
bool DiskIODriver_SPI_SD::writeData(const uint8_t token, const uint8_t *src) {
616+
bool DiskIODriver_SPI_SD::writeData(const uint8_t token, const uint8_t * const src) {
617617
if (ENABLED(SDCARD_READONLY)) return false;
618618

619619
const uint16_t crc = TERN(SD_CHECK_AND_RETRY, CRC_CCITT(src, 512), 0xFFFF);

Marlin/src/sd/Sd2Card.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class DiskIODriver_SPI_SD : public DiskIODriver {
143143
*
144144
* \return true for success or false for failure.
145145
*/
146-
bool readCID(cid_t *cid) { return readRegister(CMD10, cid); }
146+
bool readCID(cid_t * const cid) { return readRegister(CMD10, cid); }
147147

148148
/**
149149
* Read a card's CSD register. The CSD contains Card-Specific Data that
@@ -153,18 +153,18 @@ class DiskIODriver_SPI_SD : public DiskIODriver {
153153
*
154154
* \return true for success or false for failure.
155155
*/
156-
inline bool readCSD(csd_t *csd) override { return readRegister(CMD9, csd); }
156+
inline bool readCSD(csd_t * const csd) override { return readRegister(CMD9, csd); }
157157

158-
bool readData(uint8_t *dst) override;
158+
bool readData(uint8_t * const dst) override;
159159
bool readStart(uint32_t blockNumber) override;
160160
bool readStop() override;
161161

162-
bool writeData(const uint8_t *src) override;
163-
bool writeStart(const uint32_t blockNumber, const uint32_t eraseCount) override;
162+
bool writeData(const uint8_t * const src) override;
163+
bool writeStart(uint32_t blockNumber, const uint32_t eraseCount) override;
164164
bool writeStop() override;
165165

166-
bool readBlock(uint32_t block, uint8_t *dst) override;
167-
bool writeBlock(uint32_t blockNumber, const uint8_t *src) override;
166+
bool readBlock(uint32_t blockNumber, uint8_t * const dst) override;
167+
bool writeBlock(uint32_t blockNumber, const uint8_t * const src) override;
168168

169169
uint32_t cardSize() override;
170170

@@ -187,11 +187,11 @@ class DiskIODriver_SPI_SD : public DiskIODriver {
187187
}
188188
uint8_t cardCommand(const uint8_t cmd, const uint32_t arg);
189189

190-
bool readData(uint8_t *dst, const uint16_t count);
191-
bool readRegister(const uint8_t cmd, void *buf);
190+
bool readData(uint8_t * const dst, const uint16_t count);
191+
bool readRegister(const uint8_t cmd, void * const buf);
192192
void chipDeselect();
193193
void chipSelect();
194194
inline void type(const uint8_t value) { type_ = value; }
195195
bool waitNotBusy(const millis_t timeout_ms);
196-
bool writeData(const uint8_t token, const uint8_t *src);
196+
bool writeData(const uint8_t token, const uint8_t * const src);
197197
};

0 commit comments

Comments
 (0)