Some style updates: - structure; - comments; - C99 identifiers --- src/cd-scsi-dev-params.h | 15 +++----- src/cd-scsi.c | 26 +++++-------- src/cd-scsi.h | 15 +++----- src/cd-usb-bulk-msd.c | 13 +++---- src/cd-usb-bulk-msd.h | 79 ++++++++++++++++++++-------------------- src/scsi-constants.h | 4 +- 6 files changed, 68 insertions(+), 84 deletions(-) diff --git a/src/cd-scsi-dev-params.h b/src/cd-scsi-dev-params.h index cddce0a0..b480bcdc 100644 --- a/src/cd-scsi-dev-params.h +++ b/src/cd-scsi-dev-params.h @@ -21,32 +21,29 @@ License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#ifndef _CD_SCSI_DEV_PARAMS_H_ -#define _CD_SCSI_DEV_PARAMS_H_ +#ifndef SPICE_GTK_CD_SCSI_DEV_PARAMS_H_ +#define SPICE_GTK_CD_SCSI_DEV_PARAMS_H_ #include <gio/gio.h> -typedef struct _CdScsiDeviceParameters -{ +typedef struct CdScsiDeviceParameters { const char *vendor; const char *product; const char *version; const char *serial; } CdScsiDeviceParameters; -typedef struct _CdScsiDeviceInfo -{ +typedef struct CdScsiDeviceInfo { CdScsiDeviceParameters parameters; uint32_t started : 1; uint32_t locked : 1; uint32_t loaded : 1; } CdScsiDeviceInfo; -typedef struct _CdScsiMediaParameters -{ +typedef struct CdScsiMediaParameters { GFileInputStream *stream; uint64_t size; uint32_t block_size; } CdScsiMediaParameters; -#endif /* _CD_SCSI_DEV_PARAMS_H_ */ +#endif /* SPICE_GTK_CD_SCSI_DEV_PARAMS_H_ */ diff --git a/src/cd-scsi.c b/src/cd-scsi.c index e8251249..b35dad57 100644 --- a/src/cd-scsi.c +++ b/src/cd-scsi.c @@ -34,18 +34,16 @@ #define MAX_LUNS 32 -struct _CdScsiTarget; /* forward declaration */ -typedef struct _CdScsiTarget CdScsiTarget; +typedef struct CdScsiTarget CdScsiTarget; -typedef enum _CdScsiPowerCondition { +typedef enum CdScsiPowerCondition { CD_SCSI_POWER_STOPPED, CD_SCSI_POWER_ACTIVE, CD_SCSI_POWER_IDLE, CD_SCSI_POWER_STANDBY } CdScsiPowerCondition; -typedef struct _ScsiShortSense -{ +typedef struct ScsiShortSense { uint8_t key; uint8_t asc; uint8_t ascq; @@ -64,8 +62,7 @@ typedef struct _ScsiShortSense #define CD_POWER_EVENT_CHANGE_SUCCESS 0x1 #define CD_POWER_EVENT_CHANGE_FALED 0x2 -typedef struct _CdScsiLU -{ +typedef struct CdScsiLU { CdScsiTarget *tgt; uint32_t lun; @@ -96,14 +93,12 @@ typedef struct _CdScsiLU uint8_t fixed_sense[FIXED_SENSE_LEN]; } CdScsiLU; -typedef enum _CdScsiTargetState -{ +typedef enum CdScsiTargetState { CD_SCSI_TGT_STATE_RUNNING, CD_SCSI_TGT_STATE_RESET, } CdScsiTargetState; -struct _CdScsiTarget -{ +struct CdScsiTarget { void *user_data; CdScsiTargetState state; @@ -698,11 +693,10 @@ int cd_scsi_dev_reset(void *scsi_target, uint32_t lun) } dev = &st->units[lun]; - /* - if we reset the 'prevent' flag we can't create - the unit that is locked from the beginning, so - we keep this flag as persistent over resets - */ + /* if we reset the 'prevent' flag we can't create + * the unit that is locked from the beginning, so + * we keep this flag as persistent over resets + */ /* dev->prevent_media_removal = FALSE; */ dev->power_cond = CD_SCSI_POWER_ACTIVE; dev->power_event = CD_POWER_EVENT_CHANGE_SUCCESS; diff --git a/src/cd-scsi.h b/src/cd-scsi.h index b1d0ce23..93c975a2 100644 --- a/src/cd-scsi.h +++ b/src/cd-scsi.h @@ -21,8 +21,8 @@ License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#ifndef __CD_SCSI_H__ -#define __CD_SCSI_H__ +#ifndef SPICE_GTK_CD_SCSI_H__ +#define SPICE_GTK_CD_SCSI_H__ #include "cd-scsi-dev-params.h" #include "cd-usb-bulk-msd.h" @@ -40,8 +40,7 @@ #define htobe32(x) htonl(x) #endif -typedef enum _ScsiXferDir -{ +typedef enum ScsiXferDir { SCSI_XFER_NONE = 0, /* TEST_UNIT_READY, ... */ SCSI_XFER_FROM_DEV, /* READ, INQUIRY, MODE_SENSE, ... */ SCSI_XFER_TO_DEV, /* WRITE, MODE_SELECT, ... */ @@ -50,8 +49,7 @@ typedef enum _ScsiXferDir #define SCSI_CDB_BUF_SIZE 16 #define SCSI_SENSE_BUF_SIZE 64 -typedef enum _CdScsiReqState -{ +typedef enum CdScsiReqState { SCSI_REQ_IDLE = 0, SCSI_REQ_RUNNING, SCSI_REQ_COMPLETE, @@ -59,8 +57,7 @@ typedef enum _CdScsiReqState SCSI_REQ_DISPOSED, } CdScsiReqState; -typedef struct _CdScsiRequest -{ +typedef struct CdScsiRequest { /* request */ uint8_t cdb[SCSI_CDB_BUF_SIZE]; uint32_t cdb_len; @@ -119,4 +116,4 @@ void cd_scsi_dev_changed(void *target_user_data, uint32_t lun); void cd_scsi_dev_reset_complete(void *target_user_data, uint32_t lun); void cd_scsi_target_reset_complete(void *target_user_data); -#endif /* __CD_SCSI_H__ */ +#endif /* SPICE_GTK_CD_SCSI_H__ */ diff --git a/src/cd-usb-bulk-msd.c b/src/cd-usb-bulk-msd.c index be0fee36..c1a3a8c3 100644 --- a/src/cd-usb-bulk-msd.c +++ b/src/cd-usb-bulk-msd.c @@ -33,7 +33,7 @@ #define SPICE_ERROR(fmt, ...) \ do { SPICE_DEBUG("usb-msd error: " fmt , ## __VA_ARGS__); } while (0) -typedef enum _UsbCdState { +typedef enum UsbCdState { USB_CD_STATE_INIT, /* Not ready */ USB_CD_STATE_CBW, /* Waiting for Command Block */ USB_CD_STATE_DATAOUT, /* Transfer data to device */ @@ -61,14 +61,13 @@ struct __attribute__((__packed__)) UsbCdCSW { uint8_t status; }; -typedef enum _UsbMsdStatus { +typedef enum UsbMsdStatus { USB_MSD_STATUS_GOOD = 0, USB_MSD_STATUS_FAILED = 1, USB_MSD_STATUS_PHASE_ERR = 2, } UsbMsdStatus; -typedef struct _UsbCdBulkMsdRequest -{ +typedef struct UsbCdBulkMsdRequest { CdScsiRequest scsi_req; uint32_t lun; @@ -82,8 +81,7 @@ typedef struct _UsbCdBulkMsdRequest struct UsbCdCSW csw; /* usb status header */ } UsbCdBulkMsdRequest; -typedef struct _UsbCdBulkMsdDevice -{ +typedef struct UsbCdBulkMsdDevice { UsbCdState state; void *scsi_target; /* scsi handle */ void *usb_user_data; /* used in callbacks to usb */ @@ -94,8 +92,7 @@ typedef struct _UsbCdBulkMsdDevice static inline const char *usb_cd_state_str(UsbCdState state) { - switch(state) - { + switch (state) { case USB_CD_STATE_INIT: return "INIT"; case USB_CD_STATE_CBW: diff --git a/src/cd-usb-bulk-msd.h b/src/cd-usb-bulk-msd.h index 1098a879..976b422a 100644 --- a/src/cd-usb-bulk-msd.h +++ b/src/cd-usb-bulk-msd.h @@ -19,8 +19,8 @@ License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#ifndef __CD_USB_BULK_MSD_H__ -#define __CD_USB_BULK_MSD_H__ +#ifndef SPICE_GTK_CD_USB_BULK_MSD_H__ +#define SPICE_GTK_CD_USB_BULK_MSD_H__ G_BEGIN_DECLS @@ -28,8 +28,7 @@ G_BEGIN_DECLS #include "cd-scsi-dev-params.h" -typedef enum _CdUsbBulkStatus -{ +typedef enum CdUsbBulkStatus { BULK_STATUS_GOOD = 0, BULK_STATUS_ERROR, BULK_STATUS_CANCELED, @@ -39,22 +38,22 @@ typedef enum _CdUsbBulkStatus /* USB backend callbacks */ /* called on completed read data bulk transfer - user_data - user_data in unit parameters structure - status - bulk status code -*/ + * user_data - user_data in unit parameters structure + * status - bulk status code + */ void cd_usb_bulk_msd_read_complete(void *user_data, uint8_t *data, uint32_t length, CdUsbBulkStatus status); /* called when state of device's unit changed to signal GUI component - user_data - user_data in unit parameters structure -*/ + * user_data - user_data in unit parameters structure + */ void cd_usb_bulk_msd_lun_changed(void *user_data, uint32_t lun); /* called on completed device reset - user_data - user_data in unit parameters structure - status - error code -*/ + * user_data - user_data in unit parameters structure + * status - error code + */ void cd_usb_bulk_msd_reset_complete(void *user_data, int status); @@ -67,68 +66,68 @@ void *cd_usb_bulk_msd_alloc(void *user_data, uint32_t max_lun); void cd_usb_bulk_msd_free(void *device); /* configure a new Logical Unit to be represented by the device - returns: error code -*/ + * returns: error code + */ int cd_usb_bulk_msd_realize(void *device, uint32_t lun, const CdScsiDeviceParameters *dev_params); /* lock the device, prevent unloading - returns: error code -*/ + * returns: error code + */ int cd_usb_bulk_msd_lock(void *device, uint32_t lun, gboolean lock); /* load new media, if already loaded, simulate media change - returns: error code -*/ + * returns: error code + */ int cd_usb_bulk_msd_load(void *device, uint32_t lun, const CdScsiMediaParameters *media_params); /* query unit parameters and status - returns: error code -*/ + * returns: error code + */ int cd_usb_bulk_msd_get_info(void *device, uint32_t lun, CdScsiDeviceInfo *lun_info); /* unload the media - returns: error code -*/ + * returns: error code + */ int cd_usb_bulk_msd_unload(void *device, uint32_t lun); /* detach a Logical Unit - returns: error code -*/ + * returns: error code + */ int cd_usb_bulk_msd_unrealize(void *device, uint32_t lun); /* reset the device instance; cancel all IO ops, reset state - returns: error code -*/ + * returns: error code + */ int cd_usb_bulk_msd_reset(void *device); /* perform a write data bulk transfer - data_len - length of available data to write - returns: error code -*/ + * data_len - length of available data to write + * returns: error code + */ int cd_usb_bulk_msd_write(void *device, uint8_t *buf, uint32_t data_len); /* perform a read data bulk transfer - max_len - length of available buffer to fill - If data available immediately, should call cd_usb_bulk_msd_read_complete() - and return success - If fatal error detected immediately, should call cd_usb_bulk_msd_read_complete() - with error code and return success - - returns: 0 - success, -1 - error -*/ + * max_len - length of available buffer to fill + * If data available immediately, should call cd_usb_bulk_msd_read_complete() + * and return success + * If fatal error detected immediately, should call cd_usb_bulk_msd_read_complete() + * with error code and return success + * + * returns: 0 - success, -1 - error + */ int cd_usb_bulk_msd_read(void *device, uint32_t max_len); /* cancels pending read data bulk transfer - returns: error code -*/ + * returns: error code + */ int cd_usb_bulk_msd_cancel_read(void *device); G_END_DECLS -#endif /* __CD_USB_BULK_MSD_H__ */ +#endif /* SPICE_GTK_CD_USB_BULK_MSD_H__ */ diff --git a/src/scsi-constants.h b/src/scsi-constants.h index 31da7509..cf8a8825 100644 --- a/src/scsi-constants.h +++ b/src/scsi-constants.h @@ -17,8 +17,8 @@ License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#ifndef __SCSI_CONSTANTS_H__ -#define __SCSI_CONSTANTS_H__ +#ifndef SPICE_GTK_SCSI_CONSTANTS_H__ +#define SPICE_GTK_SCSI_CONSTANTS_H__ /* * SCSI opcodes -- 2.20.1 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel