Changeset b7fd2a0 in mainline for uspace/drv/block/ahci/ahci.c


Ignore:
Timestamp:
2018-01-13T03:10:29Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a53ed3a
Parents:
36f0738
Message:

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/block/ahci/ahci.c

    r36f0738 rb7fd2a0  
    109109        }
    110110
    111 static int get_sata_device_name(ddf_fun_t *, size_t, char *);
    112 static int get_num_blocks(ddf_fun_t *, uint64_t *);
    113 static int get_block_size(ddf_fun_t *, size_t *);
    114 static int read_blocks(ddf_fun_t *, uint64_t, size_t, void *);
    115 static int write_blocks(ddf_fun_t *, uint64_t, size_t, void *);
    116 
    117 static int ahci_identify_device(sata_dev_t *);
    118 static int ahci_set_highest_ultra_dma_mode(sata_dev_t *);
    119 static int ahci_rb_fpdma(sata_dev_t *, uintptr_t, uint64_t);
    120 static int ahci_wb_fpdma(sata_dev_t *, uintptr_t, uint64_t);
     111static errno_t get_sata_device_name(ddf_fun_t *, size_t, char *);
     112static errno_t get_num_blocks(ddf_fun_t *, uint64_t *);
     113static errno_t get_block_size(ddf_fun_t *, size_t *);
     114static errno_t read_blocks(ddf_fun_t *, uint64_t, size_t, void *);
     115static errno_t write_blocks(ddf_fun_t *, uint64_t, size_t, void *);
     116
     117static errno_t ahci_identify_device(sata_dev_t *);
     118static errno_t ahci_set_highest_ultra_dma_mode(sata_dev_t *);
     119static errno_t ahci_rb_fpdma(sata_dev_t *, uintptr_t, uint64_t);
     120static errno_t ahci_wb_fpdma(sata_dev_t *, uintptr_t, uint64_t);
    121121
    122122static void ahci_sata_devices_create(ahci_dev_t *, ddf_dev_t *);
     
    124124static void ahci_ahci_hw_start(ahci_dev_t *);
    125125
    126 static int ahci_dev_add(ddf_dev_t *);
     126static errno_t ahci_dev_add(ddf_dev_t *);
    127127
    128128static void ahci_get_model_name(uint16_t *, char *);
     
    177177 *
    178178 */
    179 static int get_sata_device_name(ddf_fun_t *fun,
     179static errno_t get_sata_device_name(ddf_fun_t *fun,
    180180    size_t sata_dev_name_length, char *sata_dev_name)
    181181{
     
    193193 *
    194194 */
    195 static int get_num_blocks(ddf_fun_t *fun, uint64_t *num_blocks)
     195static errno_t get_num_blocks(ddf_fun_t *fun, uint64_t *num_blocks)
    196196{
    197197        sata_dev_t *sata = fun_sata_dev(fun);
     
    208208 *
    209209 */
    210 static int get_block_size(ddf_fun_t *fun, size_t *block_size)
     210static errno_t get_block_size(ddf_fun_t *fun, size_t *block_size)
    211211{
    212212        sata_dev_t *sata = fun_sata_dev(fun);
     
    225225 *
    226226 */
    227 static int read_blocks(ddf_fun_t *fun, uint64_t blocknum,
     227static errno_t read_blocks(ddf_fun_t *fun, uint64_t blocknum,
    228228    size_t count, void *buf)
    229229{
     
    232232        uintptr_t phys;
    233233        void *ibuf = AS_AREA_ANY;
    234         int rc = dmamem_map_anonymous(sata->block_size, DMAMEM_4GiB,
     234        errno_t rc = dmamem_map_anonymous(sata->block_size, DMAMEM_4GiB,
    235235            AS_AREA_READ | AS_AREA_WRITE, 0, &phys, &ibuf);
    236236        if (rc != EOK) {
     
    268268 *
    269269 */
    270 static int write_blocks(ddf_fun_t *fun, uint64_t blocknum,
     270static errno_t write_blocks(ddf_fun_t *fun, uint64_t blocknum,
    271271    size_t count, void *buf)
    272272{
     
    275275        uintptr_t phys;
    276276        void *ibuf = AS_AREA_ANY;
    277         int rc = dmamem_map_anonymous(sata->block_size, DMAMEM_4GiB,
     277        errno_t rc = dmamem_map_anonymous(sata->block_size, DMAMEM_4GiB,
    278278            AS_AREA_READ | AS_AREA_WRITE, 0, &phys, &ibuf);
    279279        if (rc != EOK) {
     
    424424 *
    425425 */
    426 static int ahci_identify_device(sata_dev_t *sata)
     426static errno_t ahci_identify_device(sata_dev_t *sata)
    427427{
    428428        if (sata->is_invalid_device) {
     
    434434        uintptr_t phys;
    435435        sata_identify_data_t *idata = AS_AREA_ANY;
    436         int rc = dmamem_map_anonymous(SATA_IDENTIFY_DEVICE_BUFFER_LENGTH,
     436        errno_t rc = dmamem_map_anonymous(SATA_IDENTIFY_DEVICE_BUFFER_LENGTH,
    437437            DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, &phys,
    438438            (void *) &idata);
     
    605605 *
    606606 */
    607 static int ahci_set_highest_ultra_dma_mode(sata_dev_t *sata)
     607static errno_t ahci_set_highest_ultra_dma_mode(sata_dev_t *sata)
    608608{
    609609        if (sata->is_invalid_device) {
     
    628628        uintptr_t phys;
    629629        sata_identify_data_t *idata = AS_AREA_ANY;
    630         int rc = dmamem_map_anonymous(SATA_SET_FEATURE_BUFFER_LENGTH,
     630        errno_t rc = dmamem_map_anonymous(SATA_SET_FEATURE_BUFFER_LENGTH,
    631631            DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, &phys,
    632632            (void *) &idata);
     
    734734 *
    735735 */
    736 static int ahci_rb_fpdma(sata_dev_t *sata, uintptr_t phys, uint64_t blocknum)
     736static errno_t ahci_rb_fpdma(sata_dev_t *sata, uintptr_t phys, uint64_t blocknum)
    737737{
    738738        if (sata->is_invalid_device) {
     
    822822 *
    823823 */
    824 static int ahci_wb_fpdma(sata_dev_t *sata, uintptr_t phys, uint64_t blocknum)
     824static errno_t ahci_wb_fpdma(sata_dev_t *sata, uintptr_t phys, uint64_t blocknum)
    825825{
    826826        if (sata->is_invalid_device) {
     
    949949       
    950950        /* Allocate and init retfis structure. */
    951         int rc = dmamem_map_anonymous(size, DMAMEM_4GiB,
     951        errno_t rc = dmamem_map_anonymous(size, DMAMEM_4GiB,
    952952            AS_AREA_READ | AS_AREA_WRITE, 0, &phys, &virt_fb);
    953953        if (rc != EOK)
     
    10381038 *
    10391039 */
    1040 static int ahci_sata_create(ahci_dev_t *ahci, ddf_dev_t *dev,
     1040static errno_t ahci_sata_create(ahci_dev_t *ahci, ddf_dev_t *dev,
    10411041    volatile ahci_port_t *port, unsigned int port_num)
    10421042{
    10431043        ddf_fun_t *fun = NULL;
    1044         int rc;
     1044        errno_t rc;
    10451045       
    10461046        sata_dev_t *sata = ahci_sata_allocate(ahci, port);
     
    11851185       
    11861186        int irq_cap;
    1187         int rc = register_interrupt_handler(dev,
     1187        errno_t rc = register_interrupt_handler(dev,
    11881188            hw_res_parsed.irqs.irqs[0], ahci_interrupt, &ct, &irq_cap);
    11891189        if (rc != EOK) {
     
    12551255 *
    12561256 */
    1257 static int ahci_dev_add(ddf_dev_t *dev)
     1257static errno_t ahci_dev_add(ddf_dev_t *dev)     
    12581258{
    12591259        ahci_dev_t *ahci = ahci_ahci_create(dev);
Note: See TracChangeset for help on using the changeset viewer.