diff mbox series

[3/7] blk-iocost: Just open code the q_name()

Message ID 3bdc9526ac839a6952db8cd50cf0e75280614b1d.1606186717.git.baolin.wang@linux.alibaba.com (mailing list archive)
State New, archived
Headers show
Series Some cleanups and improvements for blk-iocost | expand

Commit Message

Baolin Wang Nov. 24, 2020, 3:33 a.m. UTC
The simple q_name() function is only called from ioc_name(),
just open code it to make code more readable.

Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
 block/blk-iocost.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

Comments

Tejun Heo Nov. 25, 2020, 11:33 a.m. UTC | #1
On Tue, Nov 24, 2020 at 11:33:32AM +0800, Baolin Wang wrote:
> The simple q_name() function is only called from ioc_name(),
> just open code it to make code more readable.
> 
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>

I'm not sure this is an improvement. Either way seems fine to me. So, why
change?

Thanks.
Baolin Wang Nov. 25, 2020, 1:35 p.m. UTC | #2
> On Tue, Nov 24, 2020 at 11:33:32AM +0800, Baolin Wang wrote:
>> The simple q_name() function is only called from ioc_name(),
>> just open code it to make code more readable.
>>
>> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> 
> I'm not sure this is an improvement. Either way seems fine to me. So, why
> change?

Yes, this may be not called an 'improvement'. Just from my taste of 
reading code, there is no need to factor out a separate function only 
including 4 lines code and called by only one place. Anyway I can drop
this patch if you think this is unnecessary. Thanks.
diff mbox series

Patch

diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 103ccbd..089f3fe 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -665,17 +665,14 @@  static struct ioc *q_to_ioc(struct request_queue *q)
 	return rqos_to_ioc(rq_qos_id(q, RQ_QOS_COST));
 }
 
-static const char *q_name(struct request_queue *q)
+static const char __maybe_unused *ioc_name(struct ioc *ioc)
 {
+	struct request_queue *q = ioc->rqos.q;
+
 	if (blk_queue_registered(q))
 		return kobject_name(q->kobj.parent);
-	else
-		return "<unknown>";
-}
 
-static const char __maybe_unused *ioc_name(struct ioc *ioc)
-{
-	return q_name(ioc->rqos.q);
+	return "<unknown>";
 }
 
 static struct ioc_gq *pd_to_iocg(struct blkg_policy_data *pd)