Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bsp/allwinner] feat: porting to RT_USING_DEVICE_OPS #9142

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
511 changes: 243 additions & 268 deletions bsp/allwinner/d1s/.config

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions bsp/allwinner/d1s/applications/mnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#define SD_CHECK_PIN GET_PIN(GPIO_PORT_G, GPIO_PIN_3)

int sd_check_thread_entry(void *p)
void sd_check_thread_entry(void *p)
{
rt_uint8_t old_sd_check = 0;

Expand All @@ -38,7 +38,7 @@ int sd_check_thread_entry(void *p)
else
{
rt_kprintf("Mount \"sd0p0\" on \"/\" fail\n");
return -1;
return ;
}

/* 挂载sd1分区 */
Expand Down Expand Up @@ -105,7 +105,7 @@ int sd_check_thread_entry(void *p)
rt_thread_delay(RT_TICK_PER_SECOND);
}
}
return 0;
return ;
}

int mnt_init(void)
Expand All @@ -116,7 +116,7 @@ int mnt_init(void)

rt_pin_mode(SD_CHECK_PIN, PIN_MODE_INPUT_PULLUP);

thread = rt_thread_create("sd", sd_check_thread_entry, NULL, 4096, 21, 10);
thread = rt_thread_create("sd", sd_check_thread_entry, NULL, RT_SYSTEM_WORKQUEUE_STACKSIZE, 21, 10);
if (thread == NULL)
{
return -1;
Expand Down
16 changes: 16 additions & 0 deletions bsp/allwinner/d1s/ports/partition/partition.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@ static rt_ssize_t partition_write(rt_device_t dev,
return 0;
}

#ifdef RT_USING_DEVICE_OPS
const static struct rt_device_ops _partition_ops =
{
.init = partition_init,
.open = partition_open,
.close = partition_close,
.read = partition_read,
.write = partition_write,
.control = partition_control,
};
#endif /* RT_USING_DEVICE_OPS */

int rt_partition_init(const char* flash_device, const struct rt_partition* parts, rt_size_t num)
{
struct rt_device *device;
Expand Down Expand Up @@ -148,12 +160,16 @@ int rt_partition_init(const char* flash_device, const struct rt_partition* parts

/* register device */
part_dev->parent.type = RT_Device_Class_Block;
#ifndef RT_USING_DEVICE_OPS
part_dev->parent.init = partition_init;
part_dev->parent.open = partition_open;
part_dev->parent.close = partition_close;
part_dev->parent.read = partition_read;
part_dev->parent.write = partition_write;
part_dev->parent.control = partition_control;
#else
part_dev->parent.ops = &_partition_ops;
#endif /* RT_USING_DEVICE_OPS */
/* no private */
part_dev->parent.user_data = RT_NULL;

Expand Down
Loading
Loading