Skip to content

Commit 428eced

Browse files
hanan619cfriedt
authored andcommitted
drivers: flash: flash_rpi_pico: fix indentation and remove unused variables
Cleaned up the flash_rpi_pico driver to improve code readability and compliance with Zephyr coding standards. Fixed inconsistent indentation across the file and removed variables that were declared but not used. A few improvements are credited to Manu3l0us. Signed-off-by: Hanan Arshad <[email protected]>
1 parent 5d36e85 commit 428eced

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

drivers/flash/flash_rpi_pico.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ LOG_MODULE_REGISTER(flash_rpi_pico, CONFIG_FLASH_LOG_LEVEL);
2020

2121
#define DT_DRV_COMPAT raspberrypi_pico_flash_controller
2222

23-
#define PAGE_SIZE 256
23+
#define PAGE_SIZE 256
2424
#define SECTOR_SIZE DT_PROP(DT_CHOSEN(zephyr_flash), erase_block_size)
2525
#define ERASE_VALUE 0xff
26-
#define FLASH_SIZE KB(CONFIG_FLASH_SIZE)
26+
#define FLASH_SIZE KB(CONFIG_FLASH_SIZE)
2727

2828
static const struct flash_parameters flash_rpi_parameters = {
2929
.write_block_size = 1,
@@ -39,6 +39,8 @@ static bool is_valid_range(off_t offset, uint32_t size)
3939

4040
static int flash_rpi_read(const struct device *dev, off_t offset, void *data, size_t size)
4141
{
42+
ARG_UNUSED(dev);
43+
4244
if (size == 0) {
4345
return 0;
4446
}
@@ -59,13 +61,15 @@ static int flash_rpi_write(const struct device *dev, off_t offset, const void *d
5961
size_t bytes_to_write;
6062
uint8_t *data_pointer = (uint8_t *)data;
6163

64+
ARG_UNUSED(dev);
65+
6266
if (size == 0) {
6367
return 0;
6468
}
6569

6670
if (!is_valid_range(offset, size)) {
67-
LOG_ERR("Write range exceeds the flash boundaries. Offset=%#lx, Size=%u",
68-
offset, size);
71+
LOG_ERR("Write range exceeds the flash boundaries. Offset=%#lx, Size=%u", offset,
72+
size);
6973
return -EINVAL;
7074
}
7175

@@ -108,14 +112,14 @@ static int flash_rpi_erase(const struct device *dev, off_t offset, size_t size)
108112
}
109113

110114
if (!is_valid_range(offset, size)) {
111-
LOG_ERR("Erase range exceeds the flash boundaries. Offset=%#lx, Size=%u",
112-
offset, size);
115+
LOG_ERR("Erase range exceeds the flash boundaries. Offset=%#lx, Size=%u", offset,
116+
size);
113117
return -EINVAL;
114118
}
115119

116120
if ((offset % SECTOR_SIZE) || (size % SECTOR_SIZE)) {
117121
LOG_ERR("Erase range is not a multiple of the sector size. Offset=%#lx, Size=%u",
118-
offset, size);
122+
offset, size);
119123
return -EINVAL;
120124
}
121125

@@ -143,7 +147,7 @@ static const struct flash_pages_layout flash_rpi_pages_layout = {
143147
};
144148

145149
void flash_rpi_page_layout(const struct device *dev, const struct flash_pages_layout **layout,
146-
size_t *layout_size)
150+
size_t *layout_size)
147151
{
148152
*layout = &flash_rpi_pages_layout;
149153
*layout_size = 1;
@@ -161,5 +165,5 @@ static DEVICE_API(flash, flash_rpi_driver_api) = {
161165
#endif /* CONFIG_FLASH_PAGE_LAYOUT */
162166
};
163167

164-
DEVICE_DT_INST_DEFINE(0, NULL, NULL, NULL, NULL, POST_KERNEL,
165-
CONFIG_FLASH_INIT_PRIORITY, &flash_rpi_driver_api);
168+
DEVICE_DT_INST_DEFINE(0, NULL, NULL, NULL, NULL, POST_KERNEL, CONFIG_FLASH_INIT_PRIORITY,
169+
&flash_rpi_driver_api);

0 commit comments

Comments
 (0)