From patchwork Fri Dec 9 14:27:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 9468389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0619460231 for ; Fri, 9 Dec 2016 14:30:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC7722861B for ; Fri, 9 Dec 2016 14:30:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E15E128621; Fri, 9 Dec 2016 14:30:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F21B2861B for ; Fri, 9 Dec 2016 14:30:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753945AbcLIO2X (ORCPT ); Fri, 9 Dec 2016 09:28:23 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:33024 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751829AbcLIO2U (ORCPT ); Fri, 9 Dec 2016 09:28:20 -0500 Received: by mail-pg0-f66.google.com with SMTP id 3so2492493pgd.0; Fri, 09 Dec 2016 06:28:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2p4yGFxph5nKkYOXY5Tk9AxTNFuCgsEfSMX3oaQYzc0=; b=mV0HAmH0hKJu55nadncSqdmGHOlGlISOB+ffMJA11O2WoTh77R48iys7FYJQxULrHe M7KMUzMEXoe9qIJ6tgBI+4iJ3Opp6Fqoxg0Z6m5jtJ7Ekm41xZFlFl4tf5dVjESJGj62 sDiCtj3GxqmfrLCHkpmvYrKlEph2CEZPn6niGc40PXZnSd2NcgtIJr+SqUWF/FICHKbs Nl0Lqi0Y8AO+dwu6nAuYRpcUMRPLQT9m2fCCT0udc+41ZqIKTwlIWmU83GreICU9f4NU SUI2n+6HduDAsVsaNAFFFMCISrOTyrepLyOJ0hiUxRMdfTlvH3CmmgazrKgKuXvI8Pdi L7BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2p4yGFxph5nKkYOXY5Tk9AxTNFuCgsEfSMX3oaQYzc0=; b=gaF2TfyzGPWReAcBph1wq3YGt7w7htIHpej/671vm/CjtIBEpyNaM3vMOj3Wrnna24 WzuKi8xXz3Xx/g2AO2jJyBTIujYXeiYqvw4bggtym2w4P1RsmUFE8GmmYoXbd4kP9ZR+ VP5ah3dC9Net0Pr5oF/GxPdy46QE5qEgmR08WT0AO7iskfTcuLBQ0rVh77QfAEGyeoUe LLZuQaN3RAafZ/ME/kHjrXBIgGSdoUrERes8NVgREW8FnjNdxjeKOKO5TGToJs6iOXdF eITcb/gcg1/oG5o9lCyAlW+VyC3qSbIn+34S7+8ogEuQ5lya96RMZQgizzbW3ks4xhm6 4Tkg== X-Gm-Message-State: AKaTC02yLqsEtNNVOmHOA+c5MY6S/fOWfWDSI4eXvdsix/BCb/mR0uYFhCQH0PB5gBjhRw== X-Received: by 10.98.61.152 with SMTP id x24mr83102695pfj.88.1481293699758; Fri, 09 Dec 2016 06:28:19 -0800 (PST) Received: from localhost (li411-102.members.linode.com. [106.187.91.102]) by smtp.gmail.com with ESMTPSA id 71sm58260868pft.25.2016.12.09.06.28.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 09 Dec 2016 06:28:19 -0800 (PST) From: Geliang Tang To: "James E.J. Bottomley" , "Martin K. Petersen" Cc: Geliang Tang , qla2xxx-upstream@qlogic.com, QLogic-Storage-Upstream@qlogic.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] qla2xxx/qla4xxx: use kobj_to_dev Date: Fri, 9 Dec 2016 22:27:59 +0800 Message-Id: X-Mailer: git-send-email 2.9.3 In-Reply-To: <9bb02ed75e099a2bba8fb53069b955cfe60ce622.1480487321.git.geliangtang@gmail.com> References: <9bb02ed75e099a2bba8fb53069b955cfe60ce622.1480487321.git.geliangtang@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use kobj_to_dev() instead of open-coding it. Signed-off-by: Geliang Tang --- drivers/scsi/qla2xxx/qla_attr.c | 42 ++++++++++++++--------------------------- drivers/scsi/qla4xxx/ql4_attr.c | 6 ++---- 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index fe7469c..820b416 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c @@ -21,8 +21,7 @@ qla2x00_sysfs_read_fw_dump(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { - struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, - struct device, kobj))); + struct scsi_qla_host *vha = shost_priv(dev_to_shost(kobj_to_dev(kobj))); struct qla_hw_data *ha = vha->hw; int rval = 0; @@ -54,8 +53,7 @@ qla2x00_sysfs_write_fw_dump(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { - struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, - struct device, kobj))); + struct scsi_qla_host *vha = shost_priv(dev_to_shost(kobj_to_dev(kobj))); struct qla_hw_data *ha = vha->hw; int reading; @@ -151,8 +149,7 @@ qla2x00_sysfs_read_nvram(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { - struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, - struct device, kobj))); + struct scsi_qla_host *vha = shost_priv(dev_to_shost(kobj_to_dev(kobj))); struct qla_hw_data *ha = vha->hw; if (!capable(CAP_SYS_ADMIN)) @@ -170,8 +167,7 @@ qla2x00_sysfs_write_nvram(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { - struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, - struct device, kobj))); + struct scsi_qla_host *vha = shost_priv(dev_to_shost(kobj_to_dev(kobj))); struct qla_hw_data *ha = vha->hw; uint16_t cnt; @@ -238,8 +234,7 @@ qla2x00_sysfs_read_optrom(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { - struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, - struct device, kobj))); + struct scsi_qla_host *vha = shost_priv(dev_to_shost(kobj_to_dev(kobj))); struct qla_hw_data *ha = vha->hw; ssize_t rval = 0; @@ -259,8 +254,7 @@ qla2x00_sysfs_write_optrom(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { - struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, - struct device, kobj))); + struct scsi_qla_host *vha = shost_priv(dev_to_shost(kobj_to_dev(kobj))); struct qla_hw_data *ha = vha->hw; if (ha->optrom_state != QLA_SWRITING) @@ -292,8 +286,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { - struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, - struct device, kobj))); + struct scsi_qla_host *vha = shost_priv(dev_to_shost(kobj_to_dev(kobj))); struct qla_hw_data *ha = vha->hw; uint32_t start = 0; uint32_t size = ha->optrom_size; @@ -473,8 +466,7 @@ qla2x00_sysfs_read_vpd(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { - struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, - struct device, kobj))); + struct scsi_qla_host *vha = shost_priv(dev_to_shost(kobj_to_dev(kobj))); struct qla_hw_data *ha = vha->hw; uint32_t faddr; @@ -502,8 +494,7 @@ qla2x00_sysfs_write_vpd(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { - struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, - struct device, kobj))); + struct scsi_qla_host *vha = shost_priv(dev_to_shost(kobj_to_dev(kobj))); struct qla_hw_data *ha = vha->hw; uint8_t *tmp_data; @@ -555,8 +546,7 @@ qla2x00_sysfs_read_sfp(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { - struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, - struct device, kobj))); + struct scsi_qla_host *vha = shost_priv(dev_to_shost(kobj_to_dev(kobj))); struct qla_hw_data *ha = vha->hw; uint16_t iter, addr, offset; int rval; @@ -616,8 +606,7 @@ qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { - struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, - struct device, kobj))); + struct scsi_qla_host *vha = shost_priv(dev_to_shost(kobj_to_dev(kobj))); struct qla_hw_data *ha = vha->hw; struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); int type; @@ -750,8 +739,7 @@ qla2x00_issue_logo(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { - struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, - struct device, kobj))); + struct scsi_qla_host *vha = shost_priv(dev_to_shost(kobj_to_dev(kobj))); int type; int rval = 0; port_id_t did; @@ -785,8 +773,7 @@ qla2x00_sysfs_read_xgmac_stats(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { - struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, - struct device, kobj))); + struct scsi_qla_host *vha = shost_priv(dev_to_shost(kobj_to_dev(kobj))); struct qla_hw_data *ha = vha->hw; int rval; uint16_t actual_size; @@ -837,8 +824,7 @@ qla2x00_sysfs_read_dcbx_tlv(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { - struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, - struct device, kobj))); + struct scsi_qla_host *vha = shost_priv(dev_to_shost(kobj_to_dev(kobj))); struct qla_hw_data *ha = vha->hw; int rval; diff --git a/drivers/scsi/qla4xxx/ql4_attr.c b/drivers/scsi/qla4xxx/ql4_attr.c index 463239c..53fb004 100644 --- a/drivers/scsi/qla4xxx/ql4_attr.c +++ b/drivers/scsi/qla4xxx/ql4_attr.c @@ -14,8 +14,7 @@ qla4_8xxx_sysfs_read_fw_dump(struct file *filep, struct kobject *kobj, struct bin_attribute *ba, char *buf, loff_t off, size_t count) { - struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, - struct device, kobj))); + struct scsi_qla_host *ha = to_qla_host(dev_to_shost(kobj_to_dev(kobj))); if (is_qla40XX(ha)) return -EINVAL; @@ -32,8 +31,7 @@ qla4_8xxx_sysfs_write_fw_dump(struct file *filep, struct kobject *kobj, struct bin_attribute *ba, char *buf, loff_t off, size_t count) { - struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, - struct device, kobj))); + struct scsi_qla_host *ha = to_qla_host(dev_to_shost(kobj_to_dev(kobj))); uint32_t dev_state; long reading; int ret = 0;