* [PATCH v2 1/4] scsi: qedi: use DEVICE_ATTR_RO macro
2021-06-16 3:44 [PATCH v2 0/4] scsi: use DEVICE_ATTR_*() macros to simplify code Zhen Lei
@ 2021-06-16 3:44 ` Zhen Lei
2021-06-22 6:40 ` Manish Rangankar
2021-06-16 3:44 ` [PATCH v2 2/4] scsi: qedf: " Zhen Lei
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Zhen Lei @ 2021-06-16 3:44 UTC (permalink / raw)
To: Nilesh Javali, Manish Rangankar, Saurav Kashyap, Javed Hasan,
Kashyap Desai, Sumit Saxena, Shivasharan S,
GR-QLogic-Storage-Upstream, megaraidlinux . pdl,
James E . J . Bottomley, Martin K . Petersen, linux-scsi
Cc: Zhen Lei
Use DEVICE_ATTR_RO macro helper instead of plain DEVICE_ATTR, which makes
the code a bit shorter and easier to read.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
drivers/scsi/qedi/qedi_sysfs.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/scsi/qedi/qedi_sysfs.c b/drivers/scsi/qedi/qedi_sysfs.c
index 04ee68e6499c912..be174d30eb7c275 100644
--- a/drivers/scsi/qedi/qedi_sysfs.c
+++ b/drivers/scsi/qedi/qedi_sysfs.c
@@ -16,9 +16,9 @@ static inline struct qedi_ctx *qedi_dev_to_hba(struct device *dev)
return iscsi_host_priv(shost);
}
-static ssize_t qedi_show_port_state(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t port_state_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
{
struct qedi_ctx *qedi = qedi_dev_to_hba(dev);
@@ -28,8 +28,8 @@ static ssize_t qedi_show_port_state(struct device *dev,
return sprintf(buf, "Linkdown\n");
}
-static ssize_t qedi_show_speed(struct device *dev,
- struct device_attribute *attr, char *buf)
+static ssize_t speed_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
{
struct qedi_ctx *qedi = qedi_dev_to_hba(dev);
struct qed_link_output if_link;
@@ -39,8 +39,8 @@ static ssize_t qedi_show_speed(struct device *dev,
return sprintf(buf, "%d Gbit\n", if_link.speed / 1000);
}
-static DEVICE_ATTR(port_state, 0444, qedi_show_port_state, NULL);
-static DEVICE_ATTR(speed, 0444, qedi_show_speed, NULL);
+static DEVICE_ATTR_RO(port_state);
+static DEVICE_ATTR_RO(speed);
struct device_attribute *qedi_shost_attrs[] = {
&dev_attr_port_state,
--
2.26.0.106.g9fadedd
^ permalink raw reply related [flat|nested] 7+ messages in thread
* RE: [PATCH v2 1/4] scsi: qedi: use DEVICE_ATTR_RO macro
2021-06-16 3:44 ` [PATCH v2 1/4] scsi: qedi: use DEVICE_ATTR_RO macro Zhen Lei
@ 2021-06-22 6:40 ` Manish Rangankar
0 siblings, 0 replies; 7+ messages in thread
From: Manish Rangankar @ 2021-06-22 6:40 UTC (permalink / raw)
To: Zhen Lei, Nilesh Javali, Saurav Kashyap, Javed Hasan,
Kashyap Desai, Sumit Saxena, Shivasharan S,
GR-QLogic-Storage-Upstream, megaraidlinux . pdl,
James E . J . Bottomley, Martin K . Petersen, linux-scsi
> -----Original Message-----
> From: Zhen Lei <thunder.leizhen@huawei.com>
> Sent: Wednesday, June 16, 2021 9:14 AM
> To: Nilesh Javali <njavali@marvell.com>; Manish Rangankar
> <mrangankar@marvell.com>; Saurav Kashyap <skashyap@marvell.com>; Javed
> Hasan <jhasan@marvell.com>; Kashyap Desai
> <kashyap.desai@broadcom.com>; Sumit Saxena
> <sumit.saxena@broadcom.com>; Shivasharan S
> <shivasharan.srikanteshwara@broadcom.com>; GR-QLogic-Storage-Upstream
> <GR-QLogic-Storage-Upstream@marvell.com>; megaraidlinux . pdl
> <megaraidlinux.pdl@broadcom.com>; James E . J . Bottomley
> <jejb@linux.ibm.com>; Martin K . Petersen <martin.petersen@oracle.com>;
> linux-scsi <linux-scsi@vger.kernel.org>
> Cc: Zhen Lei <thunder.leizhen@huawei.com>
> Subject: [PATCH v2 1/4] scsi: qedi: use DEVICE_ATTR_RO macro
>
> Use DEVICE_ATTR_RO macro helper instead of plain DEVICE_ATTR, which
> makes the code a bit shorter and easier to read.
>
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> ---
> drivers/scsi/qedi/qedi_sysfs.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/scsi/qedi/qedi_sysfs.c b/drivers/scsi/qedi/qedi_sysfs.c index
> 04ee68e6499c912..be174d30eb7c275 100644
> --- a/drivers/scsi/qedi/qedi_sysfs.c
> +++ b/drivers/scsi/qedi/qedi_sysfs.c
> @@ -16,9 +16,9 @@ static inline struct qedi_ctx *qedi_dev_to_hba(struct
> device *dev)
> return iscsi_host_priv(shost);
> }
>
> -static ssize_t qedi_show_port_state(struct device *dev,
> - struct device_attribute *attr,
> - char *buf)
> +static ssize_t port_state_show(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> {
> struct qedi_ctx *qedi = qedi_dev_to_hba(dev);
>
> @@ -28,8 +28,8 @@ static ssize_t qedi_show_port_state(struct device *dev,
> return sprintf(buf, "Linkdown\n");
> }
>
> -static ssize_t qedi_show_speed(struct device *dev,
> - struct device_attribute *attr, char *buf)
> +static ssize_t speed_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> {
> struct qedi_ctx *qedi = qedi_dev_to_hba(dev);
> struct qed_link_output if_link;
> @@ -39,8 +39,8 @@ static ssize_t qedi_show_speed(struct device *dev,
> return sprintf(buf, "%d Gbit\n", if_link.speed / 1000); }
>
> -static DEVICE_ATTR(port_state, 0444, qedi_show_port_state, NULL); -static
> DEVICE_ATTR(speed, 0444, qedi_show_speed, NULL);
> +static DEVICE_ATTR_RO(port_state);
> +static DEVICE_ATTR_RO(speed);
>
> struct device_attribute *qedi_shost_attrs[] = {
> &dev_attr_port_state,
> --
Thanks,
Acked-by: Manish Rangankar <mrangankar@marvell.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/4] scsi: qedf: use DEVICE_ATTR_RO macro
2021-06-16 3:44 [PATCH v2 0/4] scsi: use DEVICE_ATTR_*() macros to simplify code Zhen Lei
2021-06-16 3:44 ` [PATCH v2 1/4] scsi: qedi: use DEVICE_ATTR_RO macro Zhen Lei
@ 2021-06-16 3:44 ` Zhen Lei
2021-06-16 3:44 ` [PATCH v2 3/4] scsi: megaraid_mbox: use DEVICE_ATTR_ADMIN_RO macro Zhen Lei
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Zhen Lei @ 2021-06-16 3:44 UTC (permalink / raw)
To: Nilesh Javali, Manish Rangankar, Saurav Kashyap, Javed Hasan,
Kashyap Desai, Sumit Saxena, Shivasharan S,
GR-QLogic-Storage-Upstream, megaraidlinux . pdl,
James E . J . Bottomley, Martin K . Petersen, linux-scsi
Cc: Zhen Lei
Use DEVICE_ATTR_RO macro helper instead of plain DEVICE_ATTR, which makes
the code a bit shorter and easier to read.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
drivers/scsi/qedf/qedf_attr.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/scsi/qedf/qedf_attr.c b/drivers/scsi/qedf/qedf_attr.c
index d995f72a67595bd..461c0c9180c444e 100644
--- a/drivers/scsi/qedf/qedf_attr.c
+++ b/drivers/scsi/qedf/qedf_attr.c
@@ -24,9 +24,8 @@ static struct qedf_ctx *qedf_get_base_qedf(struct qedf_ctx *qedf)
return lport_priv(base_lport);
}
-static ssize_t
-qedf_fcoe_mac_show(struct device *dev,
- struct device_attribute *attr, char *buf)
+static ssize_t fcoe_mac_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
{
struct fc_lport *lport = shost_priv(class_to_shost(dev));
u32 port_id;
@@ -42,9 +41,8 @@ qedf_fcoe_mac_show(struct device *dev,
return scnprintf(buf, PAGE_SIZE, "%pM\n", fcoe_mac);
}
-static ssize_t
-qedf_fka_period_show(struct device *dev,
- struct device_attribute *attr, char *buf)
+static ssize_t fka_period_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
{
struct fc_lport *lport = shost_priv(class_to_shost(dev));
struct qedf_ctx *qedf = lport_priv(lport);
@@ -59,8 +57,8 @@ qedf_fka_period_show(struct device *dev,
return scnprintf(buf, PAGE_SIZE, "%d\n", fka_period);
}
-static DEVICE_ATTR(fcoe_mac, S_IRUGO, qedf_fcoe_mac_show, NULL);
-static DEVICE_ATTR(fka_period, S_IRUGO, qedf_fka_period_show, NULL);
+static DEVICE_ATTR_RO(fcoe_mac);
+static DEVICE_ATTR_RO(fka_period);
struct device_attribute *qedf_host_attrs[] = {
&dev_attr_fcoe_mac,
--
2.26.0.106.g9fadedd
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/4] scsi: megaraid_mbox: use DEVICE_ATTR_ADMIN_RO macro
2021-06-16 3:44 [PATCH v2 0/4] scsi: use DEVICE_ATTR_*() macros to simplify code Zhen Lei
2021-06-16 3:44 ` [PATCH v2 1/4] scsi: qedi: use DEVICE_ATTR_RO macro Zhen Lei
2021-06-16 3:44 ` [PATCH v2 2/4] scsi: qedf: " Zhen Lei
@ 2021-06-16 3:44 ` Zhen Lei
2021-06-16 3:44 ` [PATCH v2 4/4] scsi: mvsas: use DEVICE_ATTR_RO/RW macro Zhen Lei
2021-06-23 2:42 ` [PATCH v2 0/4] scsi: use DEVICE_ATTR_*() macros to simplify code Martin K. Petersen
4 siblings, 0 replies; 7+ messages in thread
From: Zhen Lei @ 2021-06-16 3:44 UTC (permalink / raw)
To: Nilesh Javali, Manish Rangankar, Saurav Kashyap, Javed Hasan,
Kashyap Desai, Sumit Saxena, Shivasharan S,
GR-QLogic-Storage-Upstream, megaraidlinux . pdl,
James E . J . Bottomley, Martin K . Petersen, linux-scsi
Cc: Zhen Lei
Use DEVICE_ATTR_ADMIN_RO macro helper instead of plain DEVICE_ATTR, which
makes the code a bit shorter and easier to read.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
drivers/scsi/megaraid/megaraid_mbox.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index d3fac99db786256..d20c2e4ee7934c9 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -121,8 +121,8 @@ static irqreturn_t megaraid_isr(int, void *);
static void megaraid_mbox_dpc(unsigned long);
-static ssize_t megaraid_sysfs_show_app_hndl(struct device *, struct device_attribute *attr, char *);
-static ssize_t megaraid_sysfs_show_ldnum(struct device *, struct device_attribute *attr, char *);
+static ssize_t megaraid_mbox_app_hndl_show(struct device *, struct device_attribute *attr, char *);
+static ssize_t megaraid_mbox_ld_show(struct device *, struct device_attribute *attr, char *);
static int megaraid_cmm_register(adapter_t *);
static int megaraid_cmm_unregister(adapter_t *);
@@ -302,8 +302,7 @@ static struct pci_driver megaraid_pci_driver = {
// definitions for the device attributes for exporting logical drive number
// for a scsi address (Host, Channel, Id, Lun)
-static DEVICE_ATTR(megaraid_mbox_app_hndl, S_IRUSR, megaraid_sysfs_show_app_hndl,
- NULL);
+static DEVICE_ATTR_ADMIN_RO(megaraid_mbox_app_hndl);
// Host template initializer for megaraid mbox sysfs device attributes
static struct device_attribute *megaraid_shost_attrs[] = {
@@ -312,7 +311,7 @@ static struct device_attribute *megaraid_shost_attrs[] = {
};
-static DEVICE_ATTR(megaraid_mbox_ld, S_IRUSR, megaraid_sysfs_show_ldnum, NULL);
+static DEVICE_ATTR_ADMIN_RO(megaraid_mbox_ld);
// Host template initializer for megaraid mbox sysfs device attributes
static struct device_attribute *megaraid_sdev_attrs[] = {
@@ -3961,7 +3960,7 @@ megaraid_sysfs_get_ldmap(adapter_t *adapter)
/**
- * megaraid_sysfs_show_app_hndl - display application handle for this adapter
+ * megaraid_mbox_app_hndl_show - display application handle for this adapter
* @dev : class device object representation for the host
* @attr : device attribute (unused)
* @buf : buffer to send data to
@@ -3971,8 +3970,7 @@ megaraid_sysfs_get_ldmap(adapter_t *adapter)
* handle, since we do not interface with applications directly.
*/
static ssize_t
-megaraid_sysfs_show_app_hndl(struct device *dev, struct device_attribute *attr,
- char *buf)
+megaraid_mbox_app_hndl_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct Scsi_Host *shost = class_to_shost(dev);
adapter_t *adapter = (adapter_t *)SCSIHOST2ADAP(shost);
@@ -3985,7 +3983,7 @@ megaraid_sysfs_show_app_hndl(struct device *dev, struct device_attribute *attr,
/**
- * megaraid_sysfs_show_ldnum - display the logical drive number for this device
+ * megaraid_mbox_ld_show - display the logical drive number for this device
* @dev : device object representation for the scsi device
* @attr : device attribute to show
* @buf : buffer to send data to
@@ -4000,7 +3998,7 @@ megaraid_sysfs_show_app_hndl(struct device *dev, struct device_attribute *attr,
* <int> <int> <int> <int>
*/
static ssize_t
-megaraid_sysfs_show_ldnum(struct device *dev, struct device_attribute *attr, char *buf)
+megaraid_mbox_ld_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct scsi_device *sdev = to_scsi_device(dev);
adapter_t *adapter = (adapter_t *)SCSIHOST2ADAP(sdev->host);
--
2.26.0.106.g9fadedd
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 4/4] scsi: mvsas: use DEVICE_ATTR_RO/RW macro
2021-06-16 3:44 [PATCH v2 0/4] scsi: use DEVICE_ATTR_*() macros to simplify code Zhen Lei
` (2 preceding siblings ...)
2021-06-16 3:44 ` [PATCH v2 3/4] scsi: megaraid_mbox: use DEVICE_ATTR_ADMIN_RO macro Zhen Lei
@ 2021-06-16 3:44 ` Zhen Lei
2021-06-23 2:42 ` [PATCH v2 0/4] scsi: use DEVICE_ATTR_*() macros to simplify code Martin K. Petersen
4 siblings, 0 replies; 7+ messages in thread
From: Zhen Lei @ 2021-06-16 3:44 UTC (permalink / raw)
To: Nilesh Javali, Manish Rangankar, Saurav Kashyap, Javed Hasan,
Kashyap Desai, Sumit Saxena, Shivasharan S,
GR-QLogic-Storage-Upstream, megaraidlinux . pdl,
James E . J . Bottomley, Martin K . Petersen, linux-scsi
Cc: Zhen Lei
Use DEVICE_ATTR_RO/RW macro helper instead of plain DEVICE_ATTR, which makes
the code a bit shorter and easier to read.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
drivers/scsi/mvsas/mv_init.c | 26 +++++++++-----------------
1 file changed, 9 insertions(+), 17 deletions(-)
diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
index 6aa2697c4a15d24..53137f7d0e993da 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -692,22 +692,17 @@ static struct pci_driver mvs_pci_driver = {
.remove = mvs_pci_remove,
};
-static ssize_t
-mvs_show_driver_version(struct device *cdev,
- struct device_attribute *attr, char *buffer)
+static ssize_t driver_version_show(struct device *cdev,
+ struct device_attribute *attr, char *buffer)
{
return snprintf(buffer, PAGE_SIZE, "%s\n", DRV_VERSION);
}
-static DEVICE_ATTR(driver_version,
- S_IRUGO,
- mvs_show_driver_version,
- NULL);
+static DEVICE_ATTR_RO(driver_version);
-static ssize_t
-mvs_store_interrupt_coalescing(struct device *cdev,
- struct device_attribute *attr,
- const char *buffer, size_t size)
+static ssize_t interrupt_coalescing_store(struct device *cdev,
+ struct device_attribute *attr,
+ const char *buffer, size_t size)
{
unsigned int val = 0;
struct mvs_info *mvi = NULL;
@@ -745,16 +740,13 @@ mvs_store_interrupt_coalescing(struct device *cdev,
return strlen(buffer);
}
-static ssize_t mvs_show_interrupt_coalescing(struct device *cdev,
- struct device_attribute *attr, char *buffer)
+static ssize_t interrupt_coalescing_show(struct device *cdev,
+ struct device_attribute *attr, char *buffer)
{
return snprintf(buffer, PAGE_SIZE, "%d\n", interrupt_coalescing);
}
-static DEVICE_ATTR(interrupt_coalescing,
- S_IRUGO|S_IWUSR,
- mvs_show_interrupt_coalescing,
- mvs_store_interrupt_coalescing);
+static DEVICE_ATTR_RW(interrupt_coalescing);
static int __init mvs_init(void)
{
--
2.26.0.106.g9fadedd
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/4] scsi: use DEVICE_ATTR_*() macros to simplify code
2021-06-16 3:44 [PATCH v2 0/4] scsi: use DEVICE_ATTR_*() macros to simplify code Zhen Lei
` (3 preceding siblings ...)
2021-06-16 3:44 ` [PATCH v2 4/4] scsi: mvsas: use DEVICE_ATTR_RO/RW macro Zhen Lei
@ 2021-06-23 2:42 ` Martin K. Petersen
4 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2021-06-23 2:42 UTC (permalink / raw)
To: Zhen Lei
Cc: Nilesh Javali, Manish Rangankar, Saurav Kashyap, Javed Hasan,
Kashyap Desai, Sumit Saxena, Shivasharan S,
GR-QLogic-Storage-Upstream, megaraidlinux . pdl,
James E . J . Bottomley, Martin K . Petersen, linux-scsi
Zhen,
> Zhen Lei (4):
> scsi: qedi: use DEVICE_ATTR_RO macro
> scsi: qedf: use DEVICE_ATTR_RO macro
> scsi: megaraid_mbox: use DEVICE_ATTR_ADMIN_RO macro
> scsi: mvsas: use DEVICE_ATTR_RO/RW macro
Applied to 5.14/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 7+ messages in thread