162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci******************************************************************************* 362306a36Sopenharmony_ci** O.S : Linux 462306a36Sopenharmony_ci** FILE NAME : arcmsr_attr.c 562306a36Sopenharmony_ci** BY : Nick Cheng 662306a36Sopenharmony_ci** Description: attributes exported to sysfs and device host 762306a36Sopenharmony_ci******************************************************************************* 862306a36Sopenharmony_ci** Copyright (C) 2002 - 2005, Areca Technology Corporation All rights reserved 962306a36Sopenharmony_ci** 1062306a36Sopenharmony_ci** Web site: www.areca.com.tw 1162306a36Sopenharmony_ci** E-mail: support@areca.com.tw 1262306a36Sopenharmony_ci** 1362306a36Sopenharmony_ci** This program is free software; you can redistribute it and/or modify 1462306a36Sopenharmony_ci** it under the terms of the GNU General Public License version 2 as 1562306a36Sopenharmony_ci** published by the Free Software Foundation. 1662306a36Sopenharmony_ci** This program is distributed in the hope that it will be useful, 1762306a36Sopenharmony_ci** but WITHOUT ANY WARRANTY; without even the implied warranty of 1862306a36Sopenharmony_ci** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1962306a36Sopenharmony_ci** GNU General Public License for more details. 2062306a36Sopenharmony_ci******************************************************************************* 2162306a36Sopenharmony_ci** Redistribution and use in source and binary forms, with or without 2262306a36Sopenharmony_ci** modification, are permitted provided that the following conditions 2362306a36Sopenharmony_ci** are met: 2462306a36Sopenharmony_ci** 1. Redistributions of source code must retain the above copyright 2562306a36Sopenharmony_ci** notice, this list of conditions and the following disclaimer. 2662306a36Sopenharmony_ci** 2. Redistributions in binary form must reproduce the above copyright 2762306a36Sopenharmony_ci** notice, this list of conditions and the following disclaimer in the 2862306a36Sopenharmony_ci** documentation and/or other materials provided with the distribution. 2962306a36Sopenharmony_ci** 3. The name of the author may not be used to endorse or promote products 3062306a36Sopenharmony_ci** derived from this software without specific prior written permission. 3162306a36Sopenharmony_ci** 3262306a36Sopenharmony_ci** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 3362306a36Sopenharmony_ci** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 3462306a36Sopenharmony_ci** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 3562306a36Sopenharmony_ci** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 3662306a36Sopenharmony_ci** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING,BUT 3762306a36Sopenharmony_ci** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3862306a36Sopenharmony_ci** DATA, OR PROFITS; OR BUSINESS INTERRUPTION)HOWEVER CAUSED AND ON ANY 3962306a36Sopenharmony_ci** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 4062306a36Sopenharmony_ci** (INCLUDING NEGLIGENCE OR OTHERWISE)ARISING IN ANY WAY OUT OF THE USE OF 4162306a36Sopenharmony_ci** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 4262306a36Sopenharmony_ci******************************************************************************* 4362306a36Sopenharmony_ci** For history of changes, see Documentation/scsi/ChangeLog.arcmsr 4462306a36Sopenharmony_ci** Firmware Specification, see Documentation/scsi/arcmsr_spec.rst 4562306a36Sopenharmony_ci******************************************************************************* 4662306a36Sopenharmony_ci*/ 4762306a36Sopenharmony_ci#include <linux/module.h> 4862306a36Sopenharmony_ci#include <linux/kernel.h> 4962306a36Sopenharmony_ci#include <linux/init.h> 5062306a36Sopenharmony_ci#include <linux/errno.h> 5162306a36Sopenharmony_ci#include <linux/delay.h> 5262306a36Sopenharmony_ci#include <linux/pci.h> 5362306a36Sopenharmony_ci#include <linux/circ_buf.h> 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci#include <scsi/scsi_cmnd.h> 5662306a36Sopenharmony_ci#include <scsi/scsi_device.h> 5762306a36Sopenharmony_ci#include <scsi/scsi_host.h> 5862306a36Sopenharmony_ci#include <scsi/scsi_transport.h> 5962306a36Sopenharmony_ci#include "arcmsr.h" 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_cistatic ssize_t arcmsr_sysfs_iop_message_read(struct file *filp, 6262306a36Sopenharmony_ci struct kobject *kobj, 6362306a36Sopenharmony_ci struct bin_attribute *bin, 6462306a36Sopenharmony_ci char *buf, loff_t off, 6562306a36Sopenharmony_ci size_t count) 6662306a36Sopenharmony_ci{ 6762306a36Sopenharmony_ci struct device *dev = container_of(kobj,struct device,kobj); 6862306a36Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 6962306a36Sopenharmony_ci struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 7062306a36Sopenharmony_ci uint8_t *ptmpQbuffer; 7162306a36Sopenharmony_ci int32_t allxfer_len = 0; 7262306a36Sopenharmony_ci unsigned long flags; 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci if (!capable(CAP_SYS_ADMIN)) 7562306a36Sopenharmony_ci return -EACCES; 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci /* do message unit read. */ 7862306a36Sopenharmony_ci ptmpQbuffer = (uint8_t *)buf; 7962306a36Sopenharmony_ci spin_lock_irqsave(&acb->rqbuffer_lock, flags); 8062306a36Sopenharmony_ci if (acb->rqbuf_getIndex != acb->rqbuf_putIndex) { 8162306a36Sopenharmony_ci unsigned int tail = acb->rqbuf_getIndex; 8262306a36Sopenharmony_ci unsigned int head = acb->rqbuf_putIndex; 8362306a36Sopenharmony_ci unsigned int cnt_to_end = CIRC_CNT_TO_END(head, tail, ARCMSR_MAX_QBUFFER); 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci allxfer_len = CIRC_CNT(head, tail, ARCMSR_MAX_QBUFFER); 8662306a36Sopenharmony_ci if (allxfer_len > ARCMSR_API_DATA_BUFLEN) 8762306a36Sopenharmony_ci allxfer_len = ARCMSR_API_DATA_BUFLEN; 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci if (allxfer_len <= cnt_to_end) 9062306a36Sopenharmony_ci memcpy(ptmpQbuffer, acb->rqbuffer + tail, allxfer_len); 9162306a36Sopenharmony_ci else { 9262306a36Sopenharmony_ci memcpy(ptmpQbuffer, acb->rqbuffer + tail, cnt_to_end); 9362306a36Sopenharmony_ci memcpy(ptmpQbuffer + cnt_to_end, acb->rqbuffer, allxfer_len - cnt_to_end); 9462306a36Sopenharmony_ci } 9562306a36Sopenharmony_ci acb->rqbuf_getIndex = (acb->rqbuf_getIndex + allxfer_len) % ARCMSR_MAX_QBUFFER; 9662306a36Sopenharmony_ci } 9762306a36Sopenharmony_ci if (acb->acb_flags & ACB_F_IOPDATA_OVERFLOW) { 9862306a36Sopenharmony_ci struct QBUFFER __iomem *prbuffer; 9962306a36Sopenharmony_ci acb->acb_flags &= ~ACB_F_IOPDATA_OVERFLOW; 10062306a36Sopenharmony_ci prbuffer = arcmsr_get_iop_rqbuffer(acb); 10162306a36Sopenharmony_ci if (arcmsr_Read_iop_rqbuffer_data(acb, prbuffer) == 0) 10262306a36Sopenharmony_ci acb->acb_flags |= ACB_F_IOPDATA_OVERFLOW; 10362306a36Sopenharmony_ci } 10462306a36Sopenharmony_ci spin_unlock_irqrestore(&acb->rqbuffer_lock, flags); 10562306a36Sopenharmony_ci return allxfer_len; 10662306a36Sopenharmony_ci} 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_cistatic ssize_t arcmsr_sysfs_iop_message_write(struct file *filp, 10962306a36Sopenharmony_ci struct kobject *kobj, 11062306a36Sopenharmony_ci struct bin_attribute *bin, 11162306a36Sopenharmony_ci char *buf, loff_t off, 11262306a36Sopenharmony_ci size_t count) 11362306a36Sopenharmony_ci{ 11462306a36Sopenharmony_ci struct device *dev = container_of(kobj,struct device,kobj); 11562306a36Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 11662306a36Sopenharmony_ci struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 11762306a36Sopenharmony_ci int32_t user_len, cnt2end; 11862306a36Sopenharmony_ci uint8_t *pQbuffer, *ptmpuserbuffer; 11962306a36Sopenharmony_ci unsigned long flags; 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci if (!capable(CAP_SYS_ADMIN)) 12262306a36Sopenharmony_ci return -EACCES; 12362306a36Sopenharmony_ci if (count > ARCMSR_API_DATA_BUFLEN) 12462306a36Sopenharmony_ci return -EINVAL; 12562306a36Sopenharmony_ci /* do message unit write. */ 12662306a36Sopenharmony_ci ptmpuserbuffer = (uint8_t *)buf; 12762306a36Sopenharmony_ci user_len = (int32_t)count; 12862306a36Sopenharmony_ci spin_lock_irqsave(&acb->wqbuffer_lock, flags); 12962306a36Sopenharmony_ci if (acb->wqbuf_putIndex != acb->wqbuf_getIndex) { 13062306a36Sopenharmony_ci arcmsr_write_ioctldata2iop(acb); 13162306a36Sopenharmony_ci spin_unlock_irqrestore(&acb->wqbuffer_lock, flags); 13262306a36Sopenharmony_ci return 0; /*need retry*/ 13362306a36Sopenharmony_ci } else { 13462306a36Sopenharmony_ci pQbuffer = &acb->wqbuffer[acb->wqbuf_putIndex]; 13562306a36Sopenharmony_ci cnt2end = ARCMSR_MAX_QBUFFER - acb->wqbuf_putIndex; 13662306a36Sopenharmony_ci if (user_len > cnt2end) { 13762306a36Sopenharmony_ci memcpy(pQbuffer, ptmpuserbuffer, cnt2end); 13862306a36Sopenharmony_ci ptmpuserbuffer += cnt2end; 13962306a36Sopenharmony_ci user_len -= cnt2end; 14062306a36Sopenharmony_ci acb->wqbuf_putIndex = 0; 14162306a36Sopenharmony_ci pQbuffer = acb->wqbuffer; 14262306a36Sopenharmony_ci } 14362306a36Sopenharmony_ci memcpy(pQbuffer, ptmpuserbuffer, user_len); 14462306a36Sopenharmony_ci acb->wqbuf_putIndex += user_len; 14562306a36Sopenharmony_ci acb->wqbuf_putIndex %= ARCMSR_MAX_QBUFFER; 14662306a36Sopenharmony_ci if (acb->acb_flags & ACB_F_MESSAGE_WQBUFFER_CLEARED) { 14762306a36Sopenharmony_ci acb->acb_flags &= 14862306a36Sopenharmony_ci ~ACB_F_MESSAGE_WQBUFFER_CLEARED; 14962306a36Sopenharmony_ci arcmsr_write_ioctldata2iop(acb); 15062306a36Sopenharmony_ci } 15162306a36Sopenharmony_ci spin_unlock_irqrestore(&acb->wqbuffer_lock, flags); 15262306a36Sopenharmony_ci return count; 15362306a36Sopenharmony_ci } 15462306a36Sopenharmony_ci} 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_cistatic ssize_t arcmsr_sysfs_iop_message_clear(struct file *filp, 15762306a36Sopenharmony_ci struct kobject *kobj, 15862306a36Sopenharmony_ci struct bin_attribute *bin, 15962306a36Sopenharmony_ci char *buf, loff_t off, 16062306a36Sopenharmony_ci size_t count) 16162306a36Sopenharmony_ci{ 16262306a36Sopenharmony_ci struct device *dev = container_of(kobj,struct device,kobj); 16362306a36Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 16462306a36Sopenharmony_ci struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; 16562306a36Sopenharmony_ci uint8_t *pQbuffer; 16662306a36Sopenharmony_ci unsigned long flags; 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_ci if (!capable(CAP_SYS_ADMIN)) 16962306a36Sopenharmony_ci return -EACCES; 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ci arcmsr_clear_iop2drv_rqueue_buffer(acb); 17262306a36Sopenharmony_ci acb->acb_flags |= 17362306a36Sopenharmony_ci (ACB_F_MESSAGE_WQBUFFER_CLEARED 17462306a36Sopenharmony_ci | ACB_F_MESSAGE_RQBUFFER_CLEARED 17562306a36Sopenharmony_ci | ACB_F_MESSAGE_WQBUFFER_READED); 17662306a36Sopenharmony_ci spin_lock_irqsave(&acb->rqbuffer_lock, flags); 17762306a36Sopenharmony_ci acb->rqbuf_getIndex = 0; 17862306a36Sopenharmony_ci acb->rqbuf_putIndex = 0; 17962306a36Sopenharmony_ci spin_unlock_irqrestore(&acb->rqbuffer_lock, flags); 18062306a36Sopenharmony_ci spin_lock_irqsave(&acb->wqbuffer_lock, flags); 18162306a36Sopenharmony_ci acb->wqbuf_getIndex = 0; 18262306a36Sopenharmony_ci acb->wqbuf_putIndex = 0; 18362306a36Sopenharmony_ci spin_unlock_irqrestore(&acb->wqbuffer_lock, flags); 18462306a36Sopenharmony_ci pQbuffer = acb->rqbuffer; 18562306a36Sopenharmony_ci memset(pQbuffer, 0, sizeof (struct QBUFFER)); 18662306a36Sopenharmony_ci pQbuffer = acb->wqbuffer; 18762306a36Sopenharmony_ci memset(pQbuffer, 0, sizeof (struct QBUFFER)); 18862306a36Sopenharmony_ci return 1; 18962306a36Sopenharmony_ci} 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_cistatic const struct bin_attribute arcmsr_sysfs_message_read_attr = { 19262306a36Sopenharmony_ci .attr = { 19362306a36Sopenharmony_ci .name = "mu_read", 19462306a36Sopenharmony_ci .mode = S_IRUSR , 19562306a36Sopenharmony_ci }, 19662306a36Sopenharmony_ci .size = ARCMSR_API_DATA_BUFLEN, 19762306a36Sopenharmony_ci .read = arcmsr_sysfs_iop_message_read, 19862306a36Sopenharmony_ci}; 19962306a36Sopenharmony_ci 20062306a36Sopenharmony_cistatic const struct bin_attribute arcmsr_sysfs_message_write_attr = { 20162306a36Sopenharmony_ci .attr = { 20262306a36Sopenharmony_ci .name = "mu_write", 20362306a36Sopenharmony_ci .mode = S_IWUSR, 20462306a36Sopenharmony_ci }, 20562306a36Sopenharmony_ci .size = ARCMSR_API_DATA_BUFLEN, 20662306a36Sopenharmony_ci .write = arcmsr_sysfs_iop_message_write, 20762306a36Sopenharmony_ci}; 20862306a36Sopenharmony_ci 20962306a36Sopenharmony_cistatic const struct bin_attribute arcmsr_sysfs_message_clear_attr = { 21062306a36Sopenharmony_ci .attr = { 21162306a36Sopenharmony_ci .name = "mu_clear", 21262306a36Sopenharmony_ci .mode = S_IWUSR, 21362306a36Sopenharmony_ci }, 21462306a36Sopenharmony_ci .size = 1, 21562306a36Sopenharmony_ci .write = arcmsr_sysfs_iop_message_clear, 21662306a36Sopenharmony_ci}; 21762306a36Sopenharmony_ci 21862306a36Sopenharmony_ciint arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *acb) 21962306a36Sopenharmony_ci{ 22062306a36Sopenharmony_ci struct Scsi_Host *host = acb->host; 22162306a36Sopenharmony_ci int error; 22262306a36Sopenharmony_ci 22362306a36Sopenharmony_ci error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr); 22462306a36Sopenharmony_ci if (error) { 22562306a36Sopenharmony_ci printk(KERN_ERR "arcmsr: alloc sysfs mu_read failed\n"); 22662306a36Sopenharmony_ci goto error_bin_file_message_read; 22762306a36Sopenharmony_ci } 22862306a36Sopenharmony_ci error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr); 22962306a36Sopenharmony_ci if (error) { 23062306a36Sopenharmony_ci printk(KERN_ERR "arcmsr: alloc sysfs mu_write failed\n"); 23162306a36Sopenharmony_ci goto error_bin_file_message_write; 23262306a36Sopenharmony_ci } 23362306a36Sopenharmony_ci error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_clear_attr); 23462306a36Sopenharmony_ci if (error) { 23562306a36Sopenharmony_ci printk(KERN_ERR "arcmsr: alloc sysfs mu_clear failed\n"); 23662306a36Sopenharmony_ci goto error_bin_file_message_clear; 23762306a36Sopenharmony_ci } 23862306a36Sopenharmony_ci return 0; 23962306a36Sopenharmony_cierror_bin_file_message_clear: 24062306a36Sopenharmony_ci sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr); 24162306a36Sopenharmony_cierror_bin_file_message_write: 24262306a36Sopenharmony_ci sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr); 24362306a36Sopenharmony_cierror_bin_file_message_read: 24462306a36Sopenharmony_ci return error; 24562306a36Sopenharmony_ci} 24662306a36Sopenharmony_ci 24762306a36Sopenharmony_civoid arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb) 24862306a36Sopenharmony_ci{ 24962306a36Sopenharmony_ci struct Scsi_Host *host = acb->host; 25062306a36Sopenharmony_ci 25162306a36Sopenharmony_ci sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_clear_attr); 25262306a36Sopenharmony_ci sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr); 25362306a36Sopenharmony_ci sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr); 25462306a36Sopenharmony_ci} 25562306a36Sopenharmony_ci 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_cistatic ssize_t 25862306a36Sopenharmony_ciarcmsr_attr_host_driver_version(struct device *dev, 25962306a36Sopenharmony_ci struct device_attribute *attr, char *buf) 26062306a36Sopenharmony_ci{ 26162306a36Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 26262306a36Sopenharmony_ci "%s\n", 26362306a36Sopenharmony_ci ARCMSR_DRIVER_VERSION); 26462306a36Sopenharmony_ci} 26562306a36Sopenharmony_ci 26662306a36Sopenharmony_cistatic ssize_t 26762306a36Sopenharmony_ciarcmsr_attr_host_driver_posted_cmd(struct device *dev, 26862306a36Sopenharmony_ci struct device_attribute *attr, char *buf) 26962306a36Sopenharmony_ci{ 27062306a36Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 27162306a36Sopenharmony_ci struct AdapterControlBlock *acb = 27262306a36Sopenharmony_ci (struct AdapterControlBlock *) host->hostdata; 27362306a36Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 27462306a36Sopenharmony_ci "%4d\n", 27562306a36Sopenharmony_ci atomic_read(&acb->ccboutstandingcount)); 27662306a36Sopenharmony_ci} 27762306a36Sopenharmony_ci 27862306a36Sopenharmony_cistatic ssize_t 27962306a36Sopenharmony_ciarcmsr_attr_host_driver_reset(struct device *dev, 28062306a36Sopenharmony_ci struct device_attribute *attr, char *buf) 28162306a36Sopenharmony_ci{ 28262306a36Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 28362306a36Sopenharmony_ci struct AdapterControlBlock *acb = 28462306a36Sopenharmony_ci (struct AdapterControlBlock *) host->hostdata; 28562306a36Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 28662306a36Sopenharmony_ci "%4d\n", 28762306a36Sopenharmony_ci acb->num_resets); 28862306a36Sopenharmony_ci} 28962306a36Sopenharmony_ci 29062306a36Sopenharmony_cistatic ssize_t 29162306a36Sopenharmony_ciarcmsr_attr_host_driver_abort(struct device *dev, 29262306a36Sopenharmony_ci struct device_attribute *attr, char *buf) 29362306a36Sopenharmony_ci{ 29462306a36Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 29562306a36Sopenharmony_ci struct AdapterControlBlock *acb = 29662306a36Sopenharmony_ci (struct AdapterControlBlock *) host->hostdata; 29762306a36Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 29862306a36Sopenharmony_ci "%4d\n", 29962306a36Sopenharmony_ci acb->num_aborts); 30062306a36Sopenharmony_ci} 30162306a36Sopenharmony_ci 30262306a36Sopenharmony_cistatic ssize_t 30362306a36Sopenharmony_ciarcmsr_attr_host_fw_model(struct device *dev, struct device_attribute *attr, 30462306a36Sopenharmony_ci char *buf) 30562306a36Sopenharmony_ci{ 30662306a36Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 30762306a36Sopenharmony_ci struct AdapterControlBlock *acb = 30862306a36Sopenharmony_ci (struct AdapterControlBlock *) host->hostdata; 30962306a36Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 31062306a36Sopenharmony_ci "%s\n", 31162306a36Sopenharmony_ci acb->firm_model); 31262306a36Sopenharmony_ci} 31362306a36Sopenharmony_ci 31462306a36Sopenharmony_cistatic ssize_t 31562306a36Sopenharmony_ciarcmsr_attr_host_fw_version(struct device *dev, 31662306a36Sopenharmony_ci struct device_attribute *attr, char *buf) 31762306a36Sopenharmony_ci{ 31862306a36Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 31962306a36Sopenharmony_ci struct AdapterControlBlock *acb = 32062306a36Sopenharmony_ci (struct AdapterControlBlock *) host->hostdata; 32162306a36Sopenharmony_ci 32262306a36Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 32362306a36Sopenharmony_ci "%s\n", 32462306a36Sopenharmony_ci acb->firm_version); 32562306a36Sopenharmony_ci} 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_cistatic ssize_t 32862306a36Sopenharmony_ciarcmsr_attr_host_fw_request_len(struct device *dev, 32962306a36Sopenharmony_ci struct device_attribute *attr, char *buf) 33062306a36Sopenharmony_ci{ 33162306a36Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 33262306a36Sopenharmony_ci struct AdapterControlBlock *acb = 33362306a36Sopenharmony_ci (struct AdapterControlBlock *) host->hostdata; 33462306a36Sopenharmony_ci 33562306a36Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 33662306a36Sopenharmony_ci "%4d\n", 33762306a36Sopenharmony_ci acb->firm_request_len); 33862306a36Sopenharmony_ci} 33962306a36Sopenharmony_ci 34062306a36Sopenharmony_cistatic ssize_t 34162306a36Sopenharmony_ciarcmsr_attr_host_fw_numbers_queue(struct device *dev, 34262306a36Sopenharmony_ci struct device_attribute *attr, char *buf) 34362306a36Sopenharmony_ci{ 34462306a36Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 34562306a36Sopenharmony_ci struct AdapterControlBlock *acb = 34662306a36Sopenharmony_ci (struct AdapterControlBlock *) host->hostdata; 34762306a36Sopenharmony_ci 34862306a36Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 34962306a36Sopenharmony_ci "%4d\n", 35062306a36Sopenharmony_ci acb->firm_numbers_queue); 35162306a36Sopenharmony_ci} 35262306a36Sopenharmony_ci 35362306a36Sopenharmony_cistatic ssize_t 35462306a36Sopenharmony_ciarcmsr_attr_host_fw_sdram_size(struct device *dev, 35562306a36Sopenharmony_ci struct device_attribute *attr, char *buf) 35662306a36Sopenharmony_ci{ 35762306a36Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 35862306a36Sopenharmony_ci struct AdapterControlBlock *acb = 35962306a36Sopenharmony_ci (struct AdapterControlBlock *) host->hostdata; 36062306a36Sopenharmony_ci 36162306a36Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 36262306a36Sopenharmony_ci "%4d\n", 36362306a36Sopenharmony_ci acb->firm_sdram_size); 36462306a36Sopenharmony_ci} 36562306a36Sopenharmony_ci 36662306a36Sopenharmony_cistatic ssize_t 36762306a36Sopenharmony_ciarcmsr_attr_host_fw_hd_channels(struct device *dev, 36862306a36Sopenharmony_ci struct device_attribute *attr, char *buf) 36962306a36Sopenharmony_ci{ 37062306a36Sopenharmony_ci struct Scsi_Host *host = class_to_shost(dev); 37162306a36Sopenharmony_ci struct AdapterControlBlock *acb = 37262306a36Sopenharmony_ci (struct AdapterControlBlock *) host->hostdata; 37362306a36Sopenharmony_ci 37462306a36Sopenharmony_ci return snprintf(buf, PAGE_SIZE, 37562306a36Sopenharmony_ci "%4d\n", 37662306a36Sopenharmony_ci acb->firm_hd_channels); 37762306a36Sopenharmony_ci} 37862306a36Sopenharmony_ci 37962306a36Sopenharmony_cistatic DEVICE_ATTR(host_driver_version, S_IRUGO, arcmsr_attr_host_driver_version, NULL); 38062306a36Sopenharmony_cistatic DEVICE_ATTR(host_driver_posted_cmd, S_IRUGO, arcmsr_attr_host_driver_posted_cmd, NULL); 38162306a36Sopenharmony_cistatic DEVICE_ATTR(host_driver_reset, S_IRUGO, arcmsr_attr_host_driver_reset, NULL); 38262306a36Sopenharmony_cistatic DEVICE_ATTR(host_driver_abort, S_IRUGO, arcmsr_attr_host_driver_abort, NULL); 38362306a36Sopenharmony_cistatic DEVICE_ATTR(host_fw_model, S_IRUGO, arcmsr_attr_host_fw_model, NULL); 38462306a36Sopenharmony_cistatic DEVICE_ATTR(host_fw_version, S_IRUGO, arcmsr_attr_host_fw_version, NULL); 38562306a36Sopenharmony_cistatic DEVICE_ATTR(host_fw_request_len, S_IRUGO, arcmsr_attr_host_fw_request_len, NULL); 38662306a36Sopenharmony_cistatic DEVICE_ATTR(host_fw_numbers_queue, S_IRUGO, arcmsr_attr_host_fw_numbers_queue, NULL); 38762306a36Sopenharmony_cistatic DEVICE_ATTR(host_fw_sdram_size, S_IRUGO, arcmsr_attr_host_fw_sdram_size, NULL); 38862306a36Sopenharmony_cistatic DEVICE_ATTR(host_fw_hd_channels, S_IRUGO, arcmsr_attr_host_fw_hd_channels, NULL); 38962306a36Sopenharmony_ci 39062306a36Sopenharmony_cistatic struct attribute *arcmsr_host_attrs[] = { 39162306a36Sopenharmony_ci &dev_attr_host_driver_version.attr, 39262306a36Sopenharmony_ci &dev_attr_host_driver_posted_cmd.attr, 39362306a36Sopenharmony_ci &dev_attr_host_driver_reset.attr, 39462306a36Sopenharmony_ci &dev_attr_host_driver_abort.attr, 39562306a36Sopenharmony_ci &dev_attr_host_fw_model.attr, 39662306a36Sopenharmony_ci &dev_attr_host_fw_version.attr, 39762306a36Sopenharmony_ci &dev_attr_host_fw_request_len.attr, 39862306a36Sopenharmony_ci &dev_attr_host_fw_numbers_queue.attr, 39962306a36Sopenharmony_ci &dev_attr_host_fw_sdram_size.attr, 40062306a36Sopenharmony_ci &dev_attr_host_fw_hd_channels.attr, 40162306a36Sopenharmony_ci NULL, 40262306a36Sopenharmony_ci}; 40362306a36Sopenharmony_ci 40462306a36Sopenharmony_cistatic const struct attribute_group arcmsr_host_attr_group = { 40562306a36Sopenharmony_ci .attrs = arcmsr_host_attrs, 40662306a36Sopenharmony_ci}; 40762306a36Sopenharmony_ci 40862306a36Sopenharmony_ciconst struct attribute_group *arcmsr_host_groups[] = { 40962306a36Sopenharmony_ci &arcmsr_host_attr_group, 41062306a36Sopenharmony_ci NULL 41162306a36Sopenharmony_ci}; 412