Skip to content

Commit 4d0c346

Browse files
committed
Fix Code style and reorder class members to get besser packing
1 parent 3741440 commit 4d0c346

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ int I2CEEBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size)
6262
// Check the address and size fit onto the chip.
6363
MBED_ASSERT(is_valid_read(addr, size));
6464

65-
auto *pBuffer = reinterpret_cast<char *>(buffer);
65+
auto *pBuffer = static_cast<char *>(buffer);
6666

6767
while (size > 0) {
6868
uint32_t off = addr % _block;
@@ -107,7 +107,7 @@ int I2CEEBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size
107107
// Check the addr and size fit onto the chip.
108108
MBED_ASSERT(is_valid_program(addr, size));
109109

110-
auto const *pBuffer = reinterpret_cast<char const *>(buffer);
110+
const auto *pBuffer = static_cast<const char *>(buffer);
111111

112112
// While we have some more data to write.
113113
while (size > 0) {
@@ -197,13 +197,14 @@ const char *I2CEEBlockDevice::get_type() const
197197
return "I2CEE";
198198
}
199199

200-
uint8_t I2CEEBlockDevice::get_paged_device_address(const bd_addr_t &address)
200+
uint8_t I2CEEBlockDevice::get_paged_device_address(bd_addr_t address)
201201
{
202-
if (!this->_address_is_eight_bit) {
203-
return this->_i2c_addr;
202+
if (!_address_is_eight_bit) {
203+
return _i2c_addr;
204204
} else {
205205
// Use the three least significant bits of the 2nd byte as the page
206206
// The page will be bits 2-4 of the user defined addresses.
207-
return this->_i2c_addr | ((address & 0x0700u) >> 7u);
207+
return _i2c_addr | ((address & 0x0700u) >> 7u);
208208
}
209-
}
209+
}
210+

components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,22 +174,21 @@ class I2CEEBlockDevice : public BlockDevice {
174174
mbed::I2C *_i2c;
175175
uint32_t _i2c_buffer[sizeof(mbed::I2C) / sizeof(uint32_t)];
176176
uint8_t _i2c_addr;
177+
bool _address_is_eight_bit;
177178
uint32_t _size;
178179
uint32_t _block;
179180

180-
bool _address_is_eight_bit;
181-
182181
int _sync();
183182

184183
/**
185184
* Gets the device's I2C address with respect to the requested page.
186-
* When eight bit mode is disabled, this function is a noop.
187-
* When eight bit mode is enabled, it sets the bits required
185+
* When eight-bit mode is disabled, this function is a noop.
186+
* When eight-bit mode is enabled, it sets the bits required
188187
* in the devices address. Other bits remain unchanged.
189188
* @param address An address in the requested page.
190189
* @return The device's I2C address for that page
191190
*/
192-
uint8_t get_paged_device_address(const bd_addr_t &address);
191+
uint8_t get_paged_device_address(bd_addr_t address);
193192
};
194193

195194

0 commit comments

Comments
 (0)