Main Page | Class List | Directories | File List | Class Members | File Members

ipmi_sdr.h File Reference

#include <OpenIPMI/ipmi_types.h>
#include <stdint.h>

Go to the source code of this file.

Classes

struct  ipmi_sdr_s

Defines

#define MAX_SDR_DATA   255

Typedefs

typedef ipmi_sdr_s ipmi_sdr_t
typedef ipmi_sdr_info_s ipmi_sdr_info_t
typedef void(* ipmi_sdr_destroyed_t )(ipmi_sdr_info_t *sdrs, void *cb_data)
typedef void(* ipmi_sdrs_fetched_t )(ipmi_sdr_info_t *sdrs, int err, int changed, unsigned int count, void *cb_data)
typedef void(* ipmi_sdr_save_cb )(ipmi_sdr_info_t *sdrs, int err, void *cb_data)

Functions

int ipmi_sdr_info_alloc (ipmi_domain_t *domain, ipmi_mc_t *mc, unsigned int lun, int sensor, ipmi_sdr_info_t **new_sdrs)
void ipmi_sdr_clean_out_sdrs (ipmi_sdr_info_t *sdrs)
int ipmi_sdr_info_destroy (ipmi_sdr_info_t *sdrs, ipmi_sdr_destroyed_t handler, void *cb_data)
int ipmi_sdr_fetch (ipmi_sdr_info_t *sdrs, ipmi_sdrs_fetched_t handler, void *cb_data)
int ipmi_get_sdr_count (ipmi_sdr_info_t *sdr, unsigned int *count)
int ipmi_get_sdr_by_recid (ipmi_sdr_info_t *sdr, int recid, ipmi_sdr_t *return_sdr)
int ipmi_get_sdr_by_type (ipmi_sdr_info_t *sdr, int type, ipmi_sdr_t *return_sdr)
int ipmi_get_sdr_by_index (ipmi_sdr_info_t *sdr, int index, ipmi_sdr_t *return_sdr)
int ipmi_set_sdr_by_index (ipmi_sdr_info_t *sdrs, int index, ipmi_sdr_t *sdr)
int ipmi_get_all_sdrs (ipmi_sdr_info_t *sdr, int *array_size, ipmi_sdr_t *array)
int ipmi_sdr_get_major_version (ipmi_sdr_info_t *sdr, int *val)
int ipmi_sdr_get_minor_version (ipmi_sdr_info_t *sdr, int *val)
int ipmi_sdr_get_overflow (ipmi_sdr_info_t *sdr, int *val)
int ipmi_sdr_get_update_mode (ipmi_sdr_info_t *sdr, int *val)
int ipmi_sdr_get_supports_delete_sdr (ipmi_sdr_info_t *sdr, int *val)
int ipmi_sdr_get_supports_partial_add_sdr (ipmi_sdr_info_t *sdr, int *val)
int ipmi_sdr_get_supports_reserve_sdr (ipmi_sdr_info_t *sdr, int *val)
int ipmi_sdr_get_supports_get_sdr_repository_allocation (ipmi_sdr_info_t *sdr, int *val)
int ipmi_sdr_get_dynamic_population (ipmi_sdr_info_t *sdr, int *val)
int ipmi_sdr_get_lun_has_sensors (ipmi_sdr_info_t *sdr, unsigned int lun, int *val)
int ipmi_sdr_add (ipmi_sdr_info_t *sdrs, ipmi_sdr_t *sdr)
int ipmi_sdr_save (ipmi_sdr_info_t *sdrs, ipmi_sdr_save_cb done, void *cb_data)


Define Documentation

#define MAX_SDR_DATA   255
 

Definition at line 43 of file ipmi_sdr.h.


Typedef Documentation

typedef void(* ipmi_sdr_destroyed_t)(ipmi_sdr_info_t *sdrs, void *cb_data)
 

Definition at line 77 of file ipmi_sdr.h.

typedef struct ipmi_sdr_info_s ipmi_sdr_info_t
 

Definition at line 57 of file ipmi_sdr.h.

typedef void(* ipmi_sdr_save_cb)(ipmi_sdr_info_t *sdrs, int err, void *cb_data)
 

Definition at line 150 of file ipmi_sdr.h.

typedef struct ipmi_sdr_s ipmi_sdr_t
 

typedef void(* ipmi_sdrs_fetched_t)(ipmi_sdr_info_t *sdrs, int err, int changed, unsigned int count, void *cb_data)
 

Definition at line 85 of file ipmi_sdr.h.


Function Documentation

int ipmi_get_all_sdrs ipmi_sdr_info_t sdr,
int *  array_size,
ipmi_sdr_t array
 

Definition at line 2030 of file sdr.c.

References ipmi_sdr_info_s::destroyed, i, ipmi_sdr_info_s::num_sdrs, sdr_lock(), sdr_unlock(), and ipmi_sdr_info_s::sdrs.

02033 {
02034     int i;
02035     int rv = 0;
02036 
02037     sdr_lock(sdrs);
02038     if (sdrs->destroyed) {
02039         sdr_unlock(sdrs);
02040         return EINVAL;
02041     }
02042 
02043     if (*array_size < sdrs->num_sdrs) {
02044         rv = E2BIG;
02045     } else {
02046         for (i=0; i<sdrs->num_sdrs; i++) {
02047             *array = sdrs->sdrs[i];
02048             array++;
02049         }
02050         *array_size = sdrs->num_sdrs;
02051     }
02052 
02053     sdr_unlock(sdrs);
02054     return rv;
02055 }

int ipmi_get_sdr_by_index ipmi_sdr_info_t sdr,
int  index,
ipmi_sdr_t return_sdr
 

Definition at line 1987 of file sdr.c.

References ipmi_sdr_info_s::destroyed, ipmi_sdr_info_s::num_sdrs, sdr_lock(), sdr_unlock(), and ipmi_sdr_info_s::sdrs.

Referenced by amc_sdrs_fixup(), get_sensors_from_sdrs(), ipmi_entity_scan_sdrs(), misc_sdrs_fixup(), and sdrs_fetched().

01990 {
01991     int rv = 0;
01992 
01993     sdr_lock(sdrs);
01994     if (sdrs->destroyed) {
01995         sdr_unlock(sdrs);
01996         return EINVAL;
01997     }
01998 
01999     if (index >= sdrs->num_sdrs)
02000         rv = ENOENT;
02001     else
02002         *return_sdr = sdrs->sdrs[index];
02003 
02004     sdr_unlock(sdrs);
02005     return rv;
02006 }

int ipmi_get_sdr_by_recid ipmi_sdr_info_t sdr,
int  recid,
ipmi_sdr_t return_sdr
 

Definition at line 1935 of file sdr.c.

References ipmi_sdr_info_s::destroyed, i, ipmi_sdr_s::record_id, sdr_lock(), sdr_unlock(), and ipmi_sdr_info_s::sdrs.

01938 {
01939     int i;
01940     int rv = ENOENT;
01941 
01942     sdr_lock(sdrs);
01943     if (sdrs->destroyed) {
01944         sdr_unlock(sdrs);
01945         return EINVAL;
01946     }
01947 
01948     for (i=0; i<sdrs->num_sdrs; i++) {
01949         if (sdrs->sdrs[i].record_id == recid) {
01950             rv = 0;
01951             *return_sdr = sdrs->sdrs[i];
01952             break;
01953         }
01954     }
01955 
01956     sdr_unlock(sdrs);
01957     return rv;
01958 }

int ipmi_get_sdr_by_type ipmi_sdr_info_t sdr,
int  type,
ipmi_sdr_t return_sdr
 

Definition at line 1961 of file sdr.c.

References ipmi_sdr_info_s::destroyed, i, sdr_lock(), sdr_unlock(), ipmi_sdr_info_s::sdrs, and ipmi_sdr_s::type.

Referenced by get_channels().

01964 {
01965     int i;
01966     int rv = ENOENT;
01967 
01968     sdr_lock(sdrs);
01969     if (sdrs->destroyed) {
01970         sdr_unlock(sdrs);
01971         return EINVAL;
01972     }
01973 
01974     for (i=0; i<sdrs->num_sdrs; i++) {
01975         if (sdrs->sdrs[i].type == type) {
01976             rv = 0;
01977             *return_sdr = sdrs->sdrs[i];
01978             break;
01979         }
01980     }
01981 
01982     sdr_unlock(sdrs);
01983     return rv;
01984 }

int ipmi_get_sdr_count ipmi_sdr_info_t sdr,
unsigned int *  count
 

Definition at line 1919 of file sdr.c.

References ipmi_sdr_info_s::destroyed, ipmi_sdr_info_s::num_sdrs, sdr_lock(), and sdr_unlock().

Referenced by amc_sdrs_fixup(), get_sensors_from_sdrs(), ipmi_entity_scan_sdrs(), and misc_sdrs_fixup().

01921 {
01922     sdr_lock(sdrs);
01923     if (sdrs->destroyed) {
01924         sdr_unlock(sdrs);
01925         return EINVAL;
01926     }
01927 
01928     *count = sdrs->num_sdrs;
01929 
01930     sdr_unlock(sdrs);
01931     return 0;
01932 }

int ipmi_sdr_add ipmi_sdr_info_t sdrs,
ipmi_sdr_t sdr
 

Definition at line 2212 of file sdr.c.

References ipmi_mem_alloc(), ipmi_mem_free(), ipmi_sdr_info_s::num_sdrs, pos, ipmi_sdr_info_s::sdr_array_size, sdr_lock(), sdr_unlock(), and ipmi_sdr_info_s::sdrs.

Referenced by frudlr_output(), gdlr_output(), mcdlr_output(), and misc_sdrs_fixup().

02214 {
02215     int rv = 0;
02216     int pos;
02217 
02218     sdr_lock(sdrs);
02219     if (sdrs->num_sdrs >= sdrs->sdr_array_size) {
02220         ipmi_sdr_t *new_array;
02221         /* Allocate 9 extra bytes for the db info. */
02222         new_array = ipmi_mem_alloc((sizeof(ipmi_sdr_t)
02223                                     * (sdrs->sdr_array_size + 10)) + 9);
02224         if (!new_array) {
02225             rv = ENOMEM;
02226             goto out_unlock;
02227         }
02228         memcpy(new_array, sdrs->sdrs, sizeof(ipmi_sdr_t)*sdrs->sdr_array_size);
02229         ipmi_mem_free(sdrs->sdrs);
02230         sdrs->sdrs = new_array;
02231         sdrs->sdr_array_size += 10;
02232     }
02233 
02234     pos = sdrs->num_sdrs;
02235     (sdrs->num_sdrs)++;
02236 
02237     memcpy(&((sdrs->sdrs)[pos]), sdr, sizeof(*sdr));
02238 
02239  out_unlock:
02240     sdr_unlock(sdrs);
02241     return rv;
02242 }

void ipmi_sdr_clean_out_sdrs ipmi_sdr_info_t sdrs  ) 
 

Definition at line 523 of file sdr.c.

References ipmi_sdr_info_s::dynamic_population, ipmi_sdr_info_s::fetched, ipmi_mem_free(), and ipmi_sdr_info_s::sdrs.

Referenced by mc_cleanup().

00524 {
00525     if (sdrs->sdrs)
00526         ipmi_mem_free(sdrs->sdrs);
00527     sdrs->sdrs = NULL;
00528     sdrs->dynamic_population = 1;
00529     sdrs->fetched = 0;
00530 }

int ipmi_sdr_fetch ipmi_sdr_info_t sdrs,
ipmi_sdrs_fetched_t  handler,
void *  cb_data
 

Definition at line 1893 of file sdr.c.

References sdr_fetch_info_s::cb_data, DEBUG_INFO, ipmi_sdr_info_s::dynamic_population, sdr_fetch_info_s::handler, ipmi_mc_pointer_cb(), ipmi_sdr_info_s::mc, sdr_fetch_info_s::rv, sdr_fetch_cb(), and sdr_fetch_info_s::sdrs.

Referenced by check_main_sdrs(), got_guid(), ipmi_mc_reread_sensors(), mc_sdrs(), and start_sdr_dump().

01896 {
01897     int              rv;
01898     sdr_fetch_info_t info;
01899 
01900     if (! sdrs->dynamic_population)
01901         return ENOSYS;
01902 
01903     DEBUG_INFO(sdrs);
01904     info.sdrs = sdrs;
01905     info.handler = handler;
01906     info.cb_data = cb_data;
01907     info.rv = 0;
01908 
01909     /* Convert the mc id to an mc. */
01910     rv = ipmi_mc_pointer_cb(sdrs->mc, sdr_fetch_cb, &info);
01911     if (rv) {
01912         DEBUG_INFO(sdrs);
01913         return rv;
01914     }
01915     return info.rv;
01916 }

int ipmi_sdr_get_dynamic_population ipmi_sdr_info_t sdr,
int *  val
 

Definition at line 2179 of file sdr.c.

References ipmi_sdr_info_s::dynamic_population, sdr_lock(), sdr_unlock(), and ipmi_sdr_info_s::sensor.

02180 {
02181     sdr_lock(sdrs);
02182     if (!sdrs->sensor) {
02183         sdr_unlock(sdrs);
02184         return EINVAL;
02185     }
02186 
02187     *val = sdrs->dynamic_population;
02188 
02189     sdr_unlock(sdrs);
02190     return 0;
02191 }

int ipmi_sdr_get_lun_has_sensors ipmi_sdr_info_t sdr,
unsigned int  lun,
int *  val
 

Definition at line 2194 of file sdr.c.

References ipmi_sdr_info_s::lun_has_sensors, sdr_lock(), sdr_unlock(), and ipmi_sdr_info_s::sensor.

02195 {
02196     if (lun >= 4)
02197         return EINVAL;
02198 
02199     sdr_lock(sdrs);
02200     if (!sdrs->sensor) {
02201         sdr_unlock(sdrs);
02202         return EINVAL;
02203     }
02204 
02205     *val = sdrs->lun_has_sensors[lun];
02206 
02207     sdr_unlock(sdrs);
02208     return 0;
02209 }

int ipmi_sdr_get_major_version ipmi_sdr_info_t sdr,
int *  val
 

Definition at line 2058 of file sdr.c.

References ipmi_sdr_info_s::major_version, sdr_lock(), sdr_unlock(), and ipmi_sdr_info_s::sensor.

02059 {
02060     sdr_lock(sdrs);
02061     if (sdrs->sensor) {
02062         sdr_unlock(sdrs);
02063         return EINVAL;
02064     }
02065 
02066     *val = sdrs->major_version;
02067 
02068     sdr_unlock(sdrs);
02069     return 0;
02070 }

int ipmi_sdr_get_minor_version ipmi_sdr_info_t sdr,
int *  val
 

Definition at line 2073 of file sdr.c.

References ipmi_sdr_info_s::minor_version, sdr_lock(), sdr_unlock(), and ipmi_sdr_info_s::sensor.

02074 {
02075     sdr_lock(sdrs);
02076     if (sdrs->sensor) {
02077         sdr_unlock(sdrs);
02078         return EINVAL;
02079     }
02080 
02081     *val = sdrs->minor_version;
02082 
02083     sdr_unlock(sdrs);
02084     return 0;
02085 }

int ipmi_sdr_get_overflow ipmi_sdr_info_t sdr,
int *  val
 

Definition at line 2088 of file sdr.c.

References ipmi_sdr_info_s::overflow, sdr_lock(), sdr_unlock(), and ipmi_sdr_info_s::sensor.

02089 {
02090     sdr_lock(sdrs);
02091     if (sdrs->sensor) {
02092         sdr_unlock(sdrs);
02093         return EINVAL;
02094     }
02095 
02096     *val = sdrs->overflow;
02097 
02098     sdr_unlock(sdrs);
02099     return 0;
02100 }

int ipmi_sdr_get_supports_delete_sdr ipmi_sdr_info_t sdr,
int *  val
 

Definition at line 2118 of file sdr.c.

References sdr_lock(), sdr_unlock(), ipmi_sdr_info_s::sensor, and ipmi_sdr_info_s::supports_delete_sdr.

02119 {
02120     sdr_lock(sdrs);
02121     if (sdrs->sensor) {
02122         sdr_unlock(sdrs);
02123         return EINVAL;
02124     }
02125 
02126     *val = sdrs->supports_delete_sdr;
02127 
02128     sdr_unlock(sdrs);
02129     return 0;
02130 }

int ipmi_sdr_get_supports_get_sdr_repository_allocation ipmi_sdr_info_t sdr,
int *  val
 

Definition at line 2163 of file sdr.c.

References sdr_lock(), sdr_unlock(), ipmi_sdr_info_s::sensor, and ipmi_sdr_info_s::supports_get_sdr_repository_allocation.

02165 {
02166     sdr_lock(sdrs);
02167     if (sdrs->sensor) {
02168         sdr_unlock(sdrs);
02169         return EINVAL;
02170     }
02171 
02172     *val = sdrs->supports_get_sdr_repository_allocation;
02173 
02174     sdr_unlock(sdrs);
02175     return 0;
02176 }

int ipmi_sdr_get_supports_partial_add_sdr ipmi_sdr_info_t sdr,
int *  val
 

Definition at line 2133 of file sdr.c.

References sdr_lock(), sdr_unlock(), ipmi_sdr_info_s::sensor, and ipmi_sdr_info_s::supports_partial_add_sdr.

02134 {
02135     sdr_lock(sdrs);
02136     if (sdrs->sensor) {
02137         sdr_unlock(sdrs);
02138         return EINVAL;
02139     }
02140 
02141     *val = sdrs->supports_partial_add_sdr;
02142 
02143     sdr_unlock(sdrs);
02144     return 0;
02145 }

int ipmi_sdr_get_supports_reserve_sdr ipmi_sdr_info_t sdr,
int *  val
 

Definition at line 2148 of file sdr.c.

References sdr_lock(), sdr_unlock(), ipmi_sdr_info_s::sensor, and ipmi_sdr_info_s::supports_reserve_sdr.

02149 {
02150     sdr_lock(sdrs);
02151     if (sdrs->sensor) {
02152         sdr_unlock(sdrs);
02153         return EINVAL;
02154     }
02155 
02156     *val = sdrs->supports_reserve_sdr;
02157 
02158     sdr_unlock(sdrs);
02159     return 0;
02160 }

int ipmi_sdr_get_update_mode ipmi_sdr_info_t sdr,
int *  val
 

Definition at line 2103 of file sdr.c.

References sdr_lock(), sdr_unlock(), ipmi_sdr_info_s::sensor, and ipmi_sdr_info_s::update_mode.

02104 {
02105     sdr_lock(sdrs);
02106     if (sdrs->sensor) {
02107         sdr_unlock(sdrs);
02108         return EINVAL;
02109     }
02110 
02111     *val = sdrs->update_mode;
02112 
02113     sdr_unlock(sdrs);
02114     return 0;
02115 }

int ipmi_sdr_info_alloc ipmi_domain_t domain,
ipmi_mc_t mc,
unsigned int  lun,
int  sensor,
ipmi_sdr_info_t **  new_sdrs
 

Definition at line 373 of file sdr.c.

References alloc_ilist(), os_handler_s::alloc_timer, CHECK_MC_LOCK, free_fetch(), free_ilist(), i, IDLE, ilist_add_tail(), ilist_iter(), ipmi_create_lock(), ipmi_destroy_lock(), ipmi_domain_get_os_hnd(), ipmi_mc_convert_to_id(), ipmi_mc_get_name(), ipmi_mem_alloc(), ipmi_mem_free(), MAX_SDR_FETCH_BYTES, MAX_SDR_FETCH_OUTSTANDING, ipmi_mc_s::name, opq_alloc(), and os_hnd.

Referenced by _ipmi_create_mc(), ipmi_mc_set_main_sdrs_as_device(), mc_sdrs(), setup_domain(), and start_sdr_dump().

00378 {
00379     ipmi_sdr_info_t *sdrs = NULL;
00380     int             rv;
00381     fetch_info_t    *info;
00382     int             i;
00383     os_handler_t    *os_hnd = ipmi_domain_get_os_hnd(domain);
00384 
00385     CHECK_MC_LOCK(mc);
00386 
00387     if (lun >= 4)
00388         return EINVAL;
00389 
00390     sdrs = ipmi_mem_alloc(sizeof(*sdrs));
00391     if (!sdrs) {
00392         rv = ENOMEM;
00393         goto out;
00394     }
00395     memset(sdrs, 0, sizeof(*sdrs));
00396 
00397     i = ipmi_mc_get_name(mc, sdrs->name, sizeof(sdrs->name));
00398     snprintf(sdrs->name+i, sizeof(sdrs->name)-i, "(%c,%d) ",
00399              sensor ? 's' : 'm', lun);
00400 
00401     sdrs->mc = ipmi_mc_convert_to_id(mc);
00402     sdrs->os_hnd = os_hnd;
00403     sdrs->destroyed = 0;
00404     sdrs->sdr_lock = NULL;
00405     sdrs->fetched = 0;
00406     sdrs->fetch_state = IDLE;
00407     sdrs->sdrs = NULL;
00408     sdrs->num_sdrs = 0;
00409     sdrs->sdr_array_size = 0;
00410     sdrs->destroy_handler = NULL;
00411     sdrs->lun = lun;
00412     sdrs->sensor = sensor;
00413     sdrs->sdr_wait_q = NULL;
00414     sdrs->fetch_size = MAX_SDR_FETCH_BYTES;
00415 
00416     /* Assume we have a dynamic population until told otherwise. */
00417     sdrs->dynamic_population = 1;
00418 
00419     rv = ipmi_create_lock(domain, &sdrs->sdr_lock);
00420     if (rv)
00421         goto out_done;
00422 
00423     rv = os_hnd->alloc_timer(os_hnd, &(sdrs->restart_timer));
00424     if (rv)
00425         goto out_done;
00426 
00427     sdrs->free_fetch = alloc_ilist();
00428     if (!sdrs->free_fetch) {
00429         rv = ENOMEM;
00430         goto out_done;
00431     }
00432 
00433     sdrs->outstanding_fetch = alloc_ilist();
00434     if (!sdrs->outstanding_fetch) {
00435         rv = ENOMEM;
00436         goto out_done;
00437     }
00438 
00439     for (i=0; i<MAX_SDR_FETCH_OUTSTANDING; i++) {
00440         info = ipmi_mem_alloc(sizeof(*info));
00441         if (!info) {
00442             rv = ENOMEM;
00443             goto out_done;
00444         }
00445         info->sdrs = sdrs;
00446         ilist_add_tail(sdrs->free_fetch, info, &info->link);
00447     }
00448 
00449     sdrs->process_fetch = alloc_ilist();
00450     if (!sdrs->process_fetch) {
00451         rv = ENOMEM;
00452         goto out_done;
00453     }
00454 
00455     sdrs->sdr_wait_q = opq_alloc(os_hnd);
00456     if (! sdrs->sdr_wait_q) {
00457         rv = ENOMEM;
00458         goto out_done;
00459     }
00460 
00461  out_done:
00462     if (rv) {
00463         if (sdrs) {
00464             if (sdrs->free_fetch) {
00465                 ilist_iter(sdrs->free_fetch, free_fetch, NULL);
00466                 free_ilist(sdrs->free_fetch);
00467             }
00468             if (sdrs->outstanding_fetch)
00469                 free_ilist(sdrs->outstanding_fetch);
00470             if (sdrs->process_fetch)
00471                 free_ilist(sdrs->process_fetch);
00472             if (sdrs->sdr_lock)
00473                 ipmi_destroy_lock(sdrs->sdr_lock);
00474             ipmi_mem_free(sdrs);
00475         }
00476     } else {
00477         *new_sdrs = sdrs;
00478     }
00479  out:
00480     return rv;
00481 }

int ipmi_sdr_info_destroy ipmi_sdr_info_t sdrs,
ipmi_sdr_destroyed_t  handler,
void *  cb_data
 

Definition at line 533 of file sdr.c.

References ipmi_sdr_info_s::db_fetching, DEBUG_INFO, ipmi_sdr_info_s::destroy_cb_data, ipmi_sdr_info_s::destroy_handler, ipmi_sdr_info_s::destroyed, ipmi_sdr_info_s::fetch_state, IDLE, internal_destroy_sdr_info(), ipmi_sdr_info_s::os_hnd, ipmi_sdr_info_s::restart_timer, restart_timer_cb(), ipmi_sdr_info_s::restart_timer_running, sdr_lock(), sdr_unlock(), and os_handler_s::stop_timer.

Referenced by check_mc_destroy(), cleanup_domain(), ipmi_mc_set_main_sdrs_as_device(), mc_sdrs(), sdrs_fetched(), and start_sdr_dump().

00536 {
00537     /* We don't need the read lock, because the sdrs are stand-alone
00538        after they are created (except for fetching SDRs, of course). */
00539     sdr_lock(sdrs);
00540     DEBUG_INFO(sdrs);
00541     if (sdrs->destroyed) {
00542         sdr_unlock(sdrs);
00543         return EINVAL;
00544     }
00545     sdrs->destroyed = 1;
00546     sdrs->destroy_handler = handler;
00547     sdrs->destroy_cb_data = cb_data;
00548     if ((sdrs->fetch_state != IDLE) || sdrs->db_fetching) {
00549         /* It's currently in fetch state, so let it be destroyed in
00550            the handler, since we can't cancel the handler or
00551            operation. */
00552         DEBUG_INFO(sdrs);
00553         if (sdrs->restart_timer_running) {
00554             /* Stop the timer.  If we fail, the timer handler is
00555                running (error is returned from the stop), just let it
00556                handle the stop.  Otherwise, we handle the stop. */
00557             int rv;
00558 
00559             rv = sdrs->os_hnd->stop_timer(sdrs->os_hnd, sdrs->restart_timer);
00560             if (!rv) {
00561                 DEBUG_INFO(sdrs);
00562                 sdr_unlock(sdrs);
00563                 restart_timer_cb(sdrs, sdrs->restart_timer);
00564                 goto out1;
00565             }
00566         }
00567         sdr_unlock(sdrs);
00568     out1:
00569         return 0;
00570     }
00571 
00572     /* This unlocks the lock. */
00573     internal_destroy_sdr_info(sdrs);
00574     return 0;
00575 }

int ipmi_sdr_save ipmi_sdr_info_t sdrs,
ipmi_sdr_save_cb  done,
void *  cb_data
 

Definition at line 2752 of file sdr.c.

References sdr_save_info_s::cb_data, sdr_save_info_s::done, ipmi_mc_pointer_cb(), ipmi_sdr_info_s::mc, sdr_save_info_s::rv, sdr_save_cb(), and sdr_save_info_s::sdrs.

02755 {
02756     int             rv;
02757     sdr_save_info_t info;
02758 
02759     info.sdrs = sdrs;
02760     info.done = done;
02761     info.cb_data = cb_data;
02762     info.rv = 0;
02763 
02764     /* Convert the mc id to an mc. */
02765     rv = ipmi_mc_pointer_cb(sdrs->mc, sdr_save_cb, &info);
02766     if (rv)
02767         return rv;
02768     return info.rv;
02769 }

int ipmi_set_sdr_by_index ipmi_sdr_info_t sdrs,
int  index,
ipmi_sdr_t sdr
 

Definition at line 2009 of file sdr.c.

References ipmi_sdr_info_s::destroyed, ipmi_sdr_info_s::num_sdrs, sdr_lock(), sdr_unlock(), and ipmi_sdr_info_s::sdrs.

Referenced by amc_sdrs_fixup(), and misc_sdrs_fixup().

02012 {
02013     int rv = 0;
02014 
02015     sdr_lock(sdrs);
02016     if (sdrs->destroyed) {
02017         sdr_unlock(sdrs);
02018         return EINVAL;
02019     }
02020 
02021     if (index >= sdrs->num_sdrs)
02022         rv = ENOENT;
02023     else
02024         sdrs->sdrs[index] = *sdr;
02025 
02026     sdr_unlock(sdrs);
02027     return rv;
02028 }


© sourcejam.com 2005-2008