Changeset c4d35fb in rtems


Ignore:
Timestamp:
Mar 3, 2018, 12:30:01 PM (22 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
70502b48
Parents:
30c3898
git-author:
Sebastian Huber <sebastian.huber@…> (03/03/18 12:30:01)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/18/18 08:44:18)
Message:

libchip: Use rtems_blkdev_create()

Update #3358.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bsps/shared/dev/i2c/spi-sd-card.c

    r30c3898 rc4d35fb  
    66
    77/*
    8  * Copyright (c) 2008
    9  * Embedded Brains GmbH
    10  * Obere Lagerstr. 30
    11  * D-82178 Puchheim
    12  * Germany
    13  * rtems@embedded-brains.de
     8 * Copyright (c) 2008, 2018 embedded brains GmbH
     9 *
     10 *  embedded brains GmbH
     11 *  Dornierstr. 4
     12 *  82178 Puchheim
     13 *  Germany
     14 *  <rtems@embedded-brains.de>
    1415 *
    1516 * The license and distribution terms for this file may be
     
    2627#include <rtems/libi2c.h>
    2728#include <rtems/libio.h>
    28 #include <rtems/diskdevs.h>
    2929#include <rtems/blkdev.h>
    3030
     
    12391239static int sd_card_disk_ioctl( rtems_disk_device *dd, uint32_t req, void *arg)
    12401240{
    1241         RTEMS_DEBUG_PRINT( "sd_card_disk_ioctl minor = %u, req = 0x%08x, arg = %p\n",
    1242                         (unsigned)rtems_filesystem_dev_minor_t(dd->dev), (unsigned)req, arg);
     1241        RTEMS_DEBUG_PRINT( "sd_card_disk_ioctl req = 0x%08x, arg = %p\n", (unsigned)req, arg);
    12431242        if (req == RTEMS_BLKIO_REQUEST) {
    1244                 rtems_device_minor_number minor = rtems_disk_get_minor_number( dd);
    1245                 sd_card_driver_entry *e = &sd_card_driver_table [minor];
     1243                sd_card_driver_entry *e = rtems_disk_get_driver_data( dd);
    12461244                rtems_blkdev_request *r = (rtems_blkdev_request *) arg;
    12471245                int (*f)( sd_card_driver_entry *, rtems_blkdev_request *);
     
    12731271}
    12741272
    1275 static rtems_status_code sd_card_disk_init( rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
    1276 {
    1277         rtems_status_code sc = RTEMS_SUCCESSFUL;
    1278 
    1279         /* Initialize disk IO */
    1280         sc = rtems_disk_io_initialize();
    1281         RTEMS_CHECK_SC( sc, "Initialize RTEMS disk IO");
    1282 
    1283         for (minor = 0; minor < sd_card_driver_table_size; ++minor) {
    1284                 sd_card_driver_entry *e = &sd_card_driver_table [minor];
    1285                 dev_t dev = rtems_filesystem_make_dev_t( major, minor);
     1273rtems_status_code sd_card_register( void)
     1274{
     1275        size_t i;
     1276
     1277        for (i = 0; i < sd_card_driver_table_size; ++i) {
     1278                sd_card_driver_entry *e = &sd_card_driver_table [i];
    12861279                uint32_t retries = e->retries;
     1280                rtems_status_code sc;
    12871281
    12881282                /* Initialize SD Card */
     
    12931287
    12941288                /* Create disk device */
    1295                 sc = rtems_disk_create_phys( dev, e->block_size, e->block_number, sd_card_disk_ioctl, NULL, e->device_name);
     1289                sc = rtems_blkdev_create( e->device_name, e->block_size, e->block_number, sd_card_disk_ioctl, NULL);
    12961290                RTEMS_CHECK_SC( sc, "Create disk device");
    12971291        }
     
    12991293        return RTEMS_SUCCESSFUL;
    13001294}
    1301 
    1302 /** @} */
    1303 
    1304 static const rtems_driver_address_table sd_card_disk_ops = {
    1305         .initialization_entry = sd_card_disk_init,
    1306         .open_entry = rtems_blkdev_generic_open,
    1307         .close_entry = rtems_blkdev_generic_close,
    1308         .read_entry = rtems_blkdev_generic_read,
    1309         .write_entry = rtems_blkdev_generic_write,
    1310         .control_entry = rtems_blkdev_generic_ioctl
    1311 };
    1312 
    1313 rtems_status_code sd_card_register( void)
    1314 {
    1315         rtems_status_code sc = RTEMS_SUCCESSFUL;
    1316         rtems_device_major_number major = 0;
    1317 
    1318         sc = rtems_io_register_driver( 0, &sd_card_disk_ops, &major);
    1319         RTEMS_CHECK_SC( sc, "Register disk SD Card driver");
    1320 
    1321         return RTEMS_SUCCESSFUL;
    1322 }
Note: See TracChangeset for help on using the changeset viewer.