~ubuntu-branches/ubuntu/lucid/linux-rt/lucid

« back to all changes in this revision

Viewing changes to drivers/isdn/capi/capiutil.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2009-08-05 23:00:52 UTC
  • Revision ID: james.westby@ubuntu.com-20090805230052-7xedvqcyk9dnnxb2
Tags: 2.6.31-1.1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
490
490
        }
491
491
}
492
492
 
493
 
/*-------------------------------------------------------*/
 
493
/**
 
494
 * capi_cmsg2message() - assemble CAPI 2.0 message from _cmsg structure
 
495
 * @cmsg:       _cmsg structure
 
496
 * @msg:        buffer for assembled message
 
497
 *
 
498
 * Return value: 0 for success
 
499
 */
 
500
 
494
501
unsigned capi_cmsg2message(_cmsg * cmsg, u8 * msg)
495
502
{
496
503
        cmsg->m = msg;
553
560
        }
554
561
}
555
562
 
556
 
/*-------------------------------------------------------*/
 
563
/**
 
564
 * capi_message2cmsg() - disassemble CAPI 2.0 message into _cmsg structure
 
565
 * @cmsg:       _cmsg structure
 
566
 * @msg:        buffer for assembled message
 
567
 *
 
568
 * Return value: 0 for success
 
569
 */
 
570
 
557
571
unsigned capi_message2cmsg(_cmsg * cmsg, u8 * msg)
558
572
{
559
573
        memset(cmsg, 0, sizeof(_cmsg));
573
587
        return 0;
574
588
}
575
589
 
576
 
/*-------------------------------------------------------*/
 
590
/**
 
591
 * capi_cmsg_header() - initialize header part of _cmsg structure
 
592
 * @cmsg:       _cmsg structure
 
593
 * @_ApplId:    ApplID field value
 
594
 * @_Command:   Command field value
 
595
 * @_Subcommand:        Subcommand field value
 
596
 * @_Messagenumber:     Message Number field value
 
597
 * @_Controller:        Controller/PLCI/NCCI field value
 
598
 *
 
599
 * Return value: 0 for success
 
600
 */
 
601
 
577
602
unsigned capi_cmsg_header(_cmsg * cmsg, u16 _ApplId,
578
603
                          u8 _Command, u8 _Subcommand,
579
604
                          u16 _Messagenumber, u32 _Controller)
641
666
        [0x4e] = "MANUFACTURER_RESP"
642
667
};
643
668
 
 
669
/**
 
670
 * capi_cmd2str() - convert CAPI 2.0 command/subcommand number to name
 
671
 * @cmd:        command number
 
672
 * @subcmd:     subcommand number
 
673
 *
 
674
 * Return value: static string, NULL if command/subcommand unknown
 
675
 */
 
676
 
644
677
char *capi_cmd2str(u8 cmd, u8 subcmd)
645
678
{
646
679
        return mnames[command_2_index(cmd, subcmd)];
879
912
        return cdb;
880
913
}
881
914
 
 
915
/**
 
916
 * cdebbuf_free() - free CAPI debug buffer
 
917
 * @cdb:        buffer to free
 
918
 */
 
919
 
882
920
void cdebbuf_free(_cdebbuf *cdb)
883
921
{
884
922
        if (likely(cdb == g_debbuf)) {
891
929
}
892
930
 
893
931
 
 
932
/**
 
933
 * capi_message2str() - format CAPI 2.0 message for printing
 
934
 * @msg:        CAPI 2.0 message
 
935
 *
 
936
 * Allocates a CAPI debug buffer and fills it with a printable representation
 
937
 * of the CAPI 2.0 message in @msg.
 
938
 * Return value: allocated debug buffer, NULL on error
 
939
 * The returned buffer should be freed by a call to cdebbuf_free() after use.
 
940
 */
 
941
 
894
942
_cdebbuf *capi_message2str(u8 * msg)
895
943
{
896
944
        _cdebbuf *cdb;
926
974
        return cdb;
927
975
}
928
976
 
 
977
/**
 
978
 * capi_cmsg2str() - format _cmsg structure for printing
 
979
 * @cmsg:       _cmsg structure
 
980
 *
 
981
 * Allocates a CAPI debug buffer and fills it with a printable representation
 
982
 * of the CAPI 2.0 message stored in @cmsg by a previous call to
 
983
 * capi_cmsg2message() or capi_message2cmsg().
 
984
 * Return value: allocated debug buffer, NULL on error
 
985
 * The returned buffer should be freed by a call to cdebbuf_free() after use.
 
986
 */
 
987
 
929
988
_cdebbuf *capi_cmsg2str(_cmsg * cmsg)
930
989
{
931
990
        _cdebbuf *cdb;
932
991
 
 
992
        if (!cmsg->m)
 
993
                return NULL;    /* no message */
933
994
        cdb = cdebbuf_alloc();
934
995
        if (!cdb)
935
996
                return NULL;