void mptsas_fix_config_reply_endianness(MPIMsgConfigReply *reply) { cpu_to_le16s(&reply->ExtPageLength); cpu_to_le32s(&reply->MsgContext); cpu_to_le16s(&reply->IOCStatus); cpu_to_le32s(&reply->IOCLogInfo); }
void mptsas_fix_scsi_io_reply_endianness(MPIMsgSCSIIOReply *reply) { cpu_to_le32s(&reply->MsgContext); cpu_to_le16s(&reply->IOCStatus); cpu_to_le32s(&reply->IOCLogInfo); cpu_to_le32s(&reply->TransferCount); cpu_to_le32s(&reply->SenseCount); cpu_to_le32s(&reply->ResponseInfo); cpu_to_le16s(&reply->TaskTag); }
void mptsas_fix_scsi_task_mgmt_reply_endianness(MPIMsgSCSITaskMgmtReply *reply) { cpu_to_le32s(&reply->MsgContext); cpu_to_le16s(&reply->IOCStatus); cpu_to_le32s(&reply->IOCLogInfo); cpu_to_le32s(&reply->TerminationCount); }
void mptsas_fix_event_notification_reply_endianness(MPIMsgEventNotifyReply *reply) { int length = reply->EventDataLength; int i; cpu_to_le16s(&reply->EventDataLength); cpu_to_le32s(&reply->MsgContext); cpu_to_le16s(&reply->IOCStatus); cpu_to_le32s(&reply->IOCLogInfo); cpu_to_le32s(&reply->Event); cpu_to_le32s(&reply->EventContext); /* Really depends on the event kind. This will do for now. */ for (i = 0; i < length; i++) { cpu_to_le32s(&reply->Data[i]); } }
static int aqc111_write16_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 *data) { u16 tmp = *data; cpu_to_le16s(&tmp); return aqc111_write_cmd(dev, cmd, value, index, sizeof(tmp), &tmp); }
void mptsas_fix_ioc_facts_reply_endianness(MPIMsgIOCFactsReply *reply) { cpu_to_le16s(&reply->MsgVersion); cpu_to_le16s(&reply->HeaderVersion); cpu_to_le32s(&reply->MsgContext); cpu_to_le16s(&reply->IOCExceptions); cpu_to_le16s(&reply->IOCStatus); cpu_to_le32s(&reply->IOCLogInfo); cpu_to_le16s(&reply->ReplyQueueDepth); cpu_to_le16s(&reply->RequestFrameSize); cpu_to_le16s(&reply->ProductID); cpu_to_le32s(&reply->CurrentHostMfaHighAddr); cpu_to_le16s(&reply->GlobalCredits); cpu_to_le32s(&reply->CurrentSenseBufferHighAddr); cpu_to_le16s(&reply->CurReplyFrameSize); cpu_to_le32s(&reply->FWImageSize); cpu_to_le32s(&reply->IOCCapabilities); cpu_to_le16s(&reply->HighPriorityQueueDepth); mptsas_fix_sgentry_endianness_reply(&reply->HostPageBufferSGE); cpu_to_le32s(&reply->ReplyFifoHostSignalingAddr); }
void mptsas_fix_port_facts_reply_endianness(MPIMsgPortFactsReply *reply) { cpu_to_le32s(&reply->MsgContext); cpu_to_le16s(&reply->IOCStatus); cpu_to_le32s(&reply->IOCLogInfo); cpu_to_le16s(&reply->MaxDevices); cpu_to_le16s(&reply->PortSCSIID); cpu_to_le16s(&reply->ProtocolFlags); cpu_to_le16s(&reply->MaxPostedCmdBuffers); cpu_to_le16s(&reply->MaxPersistentIDs); cpu_to_le16s(&reply->MaxLanBuckets); }
static void ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size, void *data) { if (2 == size) { u16 buf; buf = *((u16 *)data); cpu_to_le16s(&buf); usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, value, index, &buf, size); } else { usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, value, index, data, size); } }
static int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size, void *data) { int ret; if (2 == size) { u16 buf; buf = *((u16 *)data); cpu_to_le16s(&buf); ret = __ax88179_write_cmd(dev, cmd, value, index, size, &buf, 0); } else { ret = __ax88179_write_cmd(dev, cmd, value, index, size, data, 0); } return ret; }
static int e1000_set_eeprom(struct net_device *netdev, struct ethtool_eeprom *eeprom, u8 *bytes) { struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; u16 *eeprom_buff; void *ptr; int max_len; int first_word; int last_word; int ret_val = 0; u16 i; if (eeprom->len == 0) return -EOPNOTSUPP; if (eeprom->magic != (adapter->pdev->vendor | (adapter->pdev->device << 16))) return -EFAULT; if (adapter->flags & FLAG_READ_ONLY_NVM) return -EINVAL; max_len = hw->nvm.word_size * 2; first_word = eeprom->offset >> 1; last_word = (eeprom->offset + eeprom->len - 1) >> 1; eeprom_buff = kmalloc(max_len, GFP_KERNEL); if (!eeprom_buff) return -ENOMEM; ptr = (void *)eeprom_buff; if (eeprom->offset & 1) { /* need read/modify/write of first changed EEPROM word */ /* only the second byte of the word is being modified */ ret_val = e1000_read_nvm(hw, first_word, 1, &eeprom_buff[0]); ptr++; } if (((eeprom->offset + eeprom->len) & 1) && (!ret_val)) /* need read/modify/write of last changed EEPROM word */ /* only the first byte of the word is being modified */ ret_val = e1000_read_nvm(hw, last_word, 1, &eeprom_buff[last_word - first_word]); if (ret_val) goto out; /* Device's eeprom is always little-endian, word addressable */ for (i = 0; i < last_word - first_word + 1; i++) le16_to_cpus(&eeprom_buff[i]); memcpy(ptr, bytes, eeprom->len); for (i = 0; i < last_word - first_word + 1; i++) cpu_to_le16s(&eeprom_buff[i]); ret_val = e1000_write_nvm(hw, first_word, last_word - first_word + 1, eeprom_buff); if (ret_val) goto out; /* * Update the checksum over the first part of the EEPROM if needed * and flush shadow RAM for applicable controllers */ if ((first_word <= NVM_CHECKSUM_REG) || (hw->mac.type == e1000_82583) || (hw->mac.type == e1000_82574) || (hw->mac.type == e1000_82573)) ret_val = e1000e_update_nvm_checksum(hw); out: kfree(eeprom_buff); return ret_val; }
void mptsas_fix_port_enable_reply_endianness(MPIMsgPortEnableReply *reply) { cpu_to_le32s(&reply->MsgContext); cpu_to_le16s(&reply->IOCStatus); cpu_to_le32s(&reply->IOCLogInfo); }
void mptsas_fix_ioc_init_reply_endianness(MPIMsgIOCInitReply *reply) { cpu_to_le32s(&reply->MsgContext); cpu_to_le16s(&reply->IOCStatus); cpu_to_le32s(&reply->IOCLogInfo); }
static void ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index, u16 size, void *data) { struct usb_ctrlrequest *req; int status; struct urb *urb; void *buf = NULL; u16 buf_le; if (2 == size) { buf_le = *((u16 *)data); cpu_to_le16s(&buf_le); } urb = usb_alloc_urb(0, GFP_ATOMIC); if (urb == NULL) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) netdev_err(dev->net, "Error allocating URB in write_cmd_async!"); #else deverr(dev, "Error allocating URB in write_cmd_async!"); #endif return; } if (data) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) if (2 == size) buf = kmemdup(&buf_le, size, GFP_ATOMIC); else buf = kmemdup(data, size, GFP_ATOMIC); #else buf = kmalloc(size, GFP_ATOMIC); #endif if (!buf) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) netdev_err(dev->net, "Error allocating buffer in %s!\n", __func__); #else deverr(dev, "Error allocating buffer in %s!\n", __func__); #endif return; } else { #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) if (2 == size) memcpy(buf, &buf_le, size); else memcpy(buf, data, size); #endif } } req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC); if (req == NULL) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) netdev_err(dev->net, "Failed to allocate memory for control request"); #else deverr(dev, "Failed to allocate memory for control request"); #endif usb_free_urb(urb); return; } req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE; req->bRequest = cmd; req->wValue = cpu_to_le16(value); req->wIndex = cpu_to_le16(index); req->wLength = cpu_to_le16(size); usb_fill_control_urb(urb, dev->udev, usb_sndctrlpipe(dev->udev, 0), (void *)req, buf, size, ax88179_async_cmd_callback, req); status = usb_submit_urb(urb, GFP_ATOMIC); if (status < 0) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) netdev_err(dev->net, "Error submitting the control message: status=%d", status); #else deverr(dev, "Error submitting the control message: status=%d", status); #endif kfree(req); usb_free_urb(urb); } }