@@ -69,17 +69,18 @@ int I2CEEBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size)
69
69
{
70
70
_i2c->start ();
71
71
72
- auto const pagedDeviceAddress = get_paged_device_address (page);
73
-
74
- if (!_i2c->write (pagedDeviceAddress)) {
72
+ if (1 != _i2c->write (pagedDeviceAddress))
73
+ {
75
74
return BD_ERROR_DEVICE_ERROR;
76
75
}
77
76
78
- if (!_address_is_eight_bit && !_i2c->write ((char )(pagedStart >> 8u ))) {
77
+ if (!_address_is_eight_bit && 1 != _i2c->write ((char ) (pagedStart >> 8u )))
78
+ {
79
79
return BD_ERROR_DEVICE_ERROR;
80
80
}
81
81
82
- if (!_i2c->write ((char )(pagedStart & 0xffu ))) {
82
+ if (1 != _i2c->write ((char ) (pagedStart & 0xffu )))
83
+ {
83
84
return BD_ERROR_DEVICE_ERROR;
84
85
}
85
86
@@ -113,28 +114,34 @@ int I2CEEBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size
113
114
const uint8_t &pagedDeviceAddress) -> int
114
115
{
115
116
// While we have some more data to write.
116
- while (size > 0 ) {
117
+ while (size > 0 )
118
+ {
117
119
uint32_t off = addr % _block;
118
120
uint32_t chunk = (off + size < _block) ? size : (_block - off);
119
121
120
122
_i2c->start ();
121
123
122
- auto const pagedDeviceAddress = get_paged_device_address (page);
123
-
124
- if (!_i2c->write (pagedDeviceAddress)) {
124
+ if (1 != _i2c->write (pagedDeviceAddress))
125
+ {
125
126
return BD_ERROR_DEVICE_ERROR;
126
127
}
127
128
128
- if (!_address_is_eight_bit && !_i2c->write ((char )(pagedStart >> 8u ))) {
129
+ if (!_address_is_eight_bit && 1 != _i2c->write ((char ) (pagedStart >> 8u )))
130
+ {
129
131
return BD_ERROR_DEVICE_ERROR;
130
132
}
131
133
132
- if (!_i2c->write ((char )(addr & 0xffu ))) {
134
+ if (1 != _i2c->write ((char ) (addr & 0xffu )))
135
+ {
133
136
return BD_ERROR_DEVICE_ERROR;
134
137
}
135
138
136
- for (unsigned i = 0 ; i < chunk; i++) {
137
- _i2c->write (charBuffer[i]);
139
+ for (unsigned i = 0 ; i < chunk; i++)
140
+ {
141
+ if (1 != _i2c->write (charBuffer[i]))
142
+ {
143
+ return BD_ERROR_DEVICE_ERROR;
144
+ }
138
145
}
139
146
140
147
_i2c->stop ();
0 commit comments