Message ID | 20240816215605.36240-18-bvanassche@acm.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Simplify multiple create*_workqueue() invocations | expand |
On Fri, Aug 16, 2024 at 02:55:40PM -0700, Bart Van Assche wrote: > Let alloc*_workqueue() format the workqueue name instead of calling > snprintf() explicitly. > > Signed-off-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> - Mani > --- > drivers/ufs/core/ufshcd.c | 23 +++++++---------------- > 1 file changed, 7 insertions(+), 16 deletions(-) > > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c > index 22d5e27485c5..ee68e911741c 100644 > --- a/drivers/ufs/core/ufshcd.c > +++ b/drivers/ufs/core/ufshcd.c > @@ -1785,8 +1785,6 @@ static void ufshcd_remove_clk_scaling_sysfs(struct ufs_hba *hba) > > static void ufshcd_init_clk_scaling(struct ufs_hba *hba) > { > - char wq_name[sizeof("ufs_clkscaling_00")]; > - > if (!ufshcd_is_clkscaling_supported(hba)) > return; > > @@ -1798,10 +1796,8 @@ static void ufshcd_init_clk_scaling(struct ufs_hba *hba) > INIT_WORK(&hba->clk_scaling.resume_work, > ufshcd_clk_scaling_resume_work); > > - snprintf(wq_name, sizeof(wq_name), "ufs_clkscaling_%d", > - hba->host->host_no); > - hba->clk_scaling.workq = > - alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, wq_name); > + hba->clk_scaling.workq = alloc_ordered_workqueue( > + "ufs_clkscaling_%d", WQ_MEM_RECLAIM, hba->host->host_no); > > hba->clk_scaling.is_initialized = true; > } > @@ -2125,8 +2121,6 @@ static void ufshcd_remove_clk_gating_sysfs(struct ufs_hba *hba) > > static void ufshcd_init_clk_gating(struct ufs_hba *hba) > { > - char wq_name[sizeof("ufs_clk_gating_00")]; > - > if (!ufshcd_is_clkgating_allowed(hba)) > return; > > @@ -2136,10 +2130,9 @@ static void ufshcd_init_clk_gating(struct ufs_hba *hba) > INIT_DELAYED_WORK(&hba->clk_gating.gate_work, ufshcd_gate_work); > INIT_WORK(&hba->clk_gating.ungate_work, ufshcd_ungate_work); > > - snprintf(wq_name, ARRAY_SIZE(wq_name), "ufs_clk_gating_%d", > - hba->host->host_no); > - hba->clk_gating.clk_gating_workq = alloc_ordered_workqueue(wq_name, > - WQ_MEM_RECLAIM | WQ_HIGHPRI); > + hba->clk_gating.clk_gating_workq = alloc_ordered_workqueue( > + "ufs_clk_gating_%d", WQ_MEM_RECLAIM | WQ_HIGHPRI, > + hba->host->host_no); > > ufshcd_init_clk_gating_sysfs(hba); > > @@ -10392,7 +10385,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) > int err; > struct Scsi_Host *host = hba->host; > struct device *dev = hba->dev; > - char eh_wq_name[sizeof("ufs_eh_wq_00")]; > > /* > * dev_set_drvdata() must be called before any callbacks are registered > @@ -10459,9 +10451,8 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) > hba->max_pwr_info.is_valid = false; > > /* Initialize work queues */ > - snprintf(eh_wq_name, sizeof(eh_wq_name), "ufs_eh_wq_%d", > - hba->host->host_no); > - hba->eh_wq = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, eh_wq_name); > + hba->eh_wq = alloc_ordered_workqueue("ufs_eh_wq_%d", WQ_MEM_RECLAIM, > + hba->host->host_no); > if (!hba->eh_wq) { > dev_err(hba->dev, "%s: failed to create eh workqueue\n", > __func__);
On Fri, 2024-08-16 at 14:55 -0700, Bart Van Assche wrote: > > External email : Please do not click links or open attachments until > you have verified the sender or the content. > Let alloc*_workqueue() format the workqueue name instead of calling > snprintf() explicitly. > > Signed-off-by: Bart Van Assche <bvanassche@acm.org> > --- > Reviewed-by: Peter Wang <peter.wang@mediatek.com>
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 22d5e27485c5..ee68e911741c 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -1785,8 +1785,6 @@ static void ufshcd_remove_clk_scaling_sysfs(struct ufs_hba *hba) static void ufshcd_init_clk_scaling(struct ufs_hba *hba) { - char wq_name[sizeof("ufs_clkscaling_00")]; - if (!ufshcd_is_clkscaling_supported(hba)) return; @@ -1798,10 +1796,8 @@ static void ufshcd_init_clk_scaling(struct ufs_hba *hba) INIT_WORK(&hba->clk_scaling.resume_work, ufshcd_clk_scaling_resume_work); - snprintf(wq_name, sizeof(wq_name), "ufs_clkscaling_%d", - hba->host->host_no); - hba->clk_scaling.workq = - alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, wq_name); + hba->clk_scaling.workq = alloc_ordered_workqueue( + "ufs_clkscaling_%d", WQ_MEM_RECLAIM, hba->host->host_no); hba->clk_scaling.is_initialized = true; } @@ -2125,8 +2121,6 @@ static void ufshcd_remove_clk_gating_sysfs(struct ufs_hba *hba) static void ufshcd_init_clk_gating(struct ufs_hba *hba) { - char wq_name[sizeof("ufs_clk_gating_00")]; - if (!ufshcd_is_clkgating_allowed(hba)) return; @@ -2136,10 +2130,9 @@ static void ufshcd_init_clk_gating(struct ufs_hba *hba) INIT_DELAYED_WORK(&hba->clk_gating.gate_work, ufshcd_gate_work); INIT_WORK(&hba->clk_gating.ungate_work, ufshcd_ungate_work); - snprintf(wq_name, ARRAY_SIZE(wq_name), "ufs_clk_gating_%d", - hba->host->host_no); - hba->clk_gating.clk_gating_workq = alloc_ordered_workqueue(wq_name, - WQ_MEM_RECLAIM | WQ_HIGHPRI); + hba->clk_gating.clk_gating_workq = alloc_ordered_workqueue( + "ufs_clk_gating_%d", WQ_MEM_RECLAIM | WQ_HIGHPRI, + hba->host->host_no); ufshcd_init_clk_gating_sysfs(hba); @@ -10392,7 +10385,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) int err; struct Scsi_Host *host = hba->host; struct device *dev = hba->dev; - char eh_wq_name[sizeof("ufs_eh_wq_00")]; /* * dev_set_drvdata() must be called before any callbacks are registered @@ -10459,9 +10451,8 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) hba->max_pwr_info.is_valid = false; /* Initialize work queues */ - snprintf(eh_wq_name, sizeof(eh_wq_name), "ufs_eh_wq_%d", - hba->host->host_no); - hba->eh_wq = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, eh_wq_name); + hba->eh_wq = alloc_ordered_workqueue("ufs_eh_wq_%d", WQ_MEM_RECLAIM, + hba->host->host_no); if (!hba->eh_wq) { dev_err(hba->dev, "%s: failed to create eh workqueue\n", __func__);
Let alloc*_workqueue() format the workqueue name instead of calling snprintf() explicitly. Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- drivers/ufs/core/ufshcd.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)