Message ID | 20240617210844.337476-4-bvanassche@acm.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | UFS patches for kernel 6.11 | expand |
> Make ufshcd_mcq_decide_queue_depth() easier to read by inlining > ufshcd_mcq_vops_get_hba_mac(). This changes its functionality by making it non-mandatory. Maybe relate to that in the commit log. Also, it would make sense to squash it to the next patch, so your line of reasoning is clear. Thanks, Avri > > Signed-off-by: Bart Van Assche <bvanassche@acm.org> > --- > drivers/ufs/core/ufs-mcq.c | 18 +++++++++++------- > drivers/ufs/core/ufshcd-priv.h | 8 -------- > 2 files changed, 11 insertions(+), 15 deletions(-) > > diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c index > 4bcae410c268..0482c7a1e419 100644 > --- a/drivers/ufs/core/ufs-mcq.c > +++ b/drivers/ufs/core/ufs-mcq.c > @@ -144,14 +144,14 @@ EXPORT_SYMBOL_GPL(ufshcd_mcq_queue_cfg_addr); > */ > int ufshcd_mcq_decide_queue_depth(struct ufs_hba *hba) { > - int mac; > + int mac = -EOPNOTSUPP; > > - /* Mandatory to implement get_hba_mac() */ > - mac = ufshcd_mcq_vops_get_hba_mac(hba); > - if (mac < 0) { > - dev_err(hba->dev, "Failed to get mac, err=%d\n", mac); > - return mac; > - } > + if (!hba->vops || !hba->vops->get_hba_mac) > + goto err; > + > + mac = hba->vops->get_hba_mac(hba); > + if (mac < 0) > + goto err; > > WARN_ON_ONCE(!hba->dev_info.bqueuedepth); > /* > @@ -160,6 +160,10 @@ int ufshcd_mcq_decide_queue_depth(struct ufs_hba > *hba) > * shared queuing architecture is enabled. > */ > return min_t(int, mac, hba->dev_info.bqueuedepth); > + > +err: > + dev_err(hba->dev, "Failed to get mac, err=%d\n", mac); > + return mac; > } > > static int ufshcd_mcq_config_nr_queues(struct ufs_hba *hba) diff --git > a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h index > f42d99ce5bf1..a1add22205db 100644 > --- a/drivers/ufs/core/ufshcd-priv.h > +++ b/drivers/ufs/core/ufshcd-priv.h > @@ -255,14 +255,6 @@ static inline int > ufshcd_vops_mcq_config_resource(struct ufs_hba *hba) > return -EOPNOTSUPP; > } > > -static inline int ufshcd_mcq_vops_get_hba_mac(struct ufs_hba *hba) -{ > - if (hba->vops && hba->vops->get_hba_mac) > - return hba->vops->get_hba_mac(hba); > - > - return -EOPNOTSUPP; > -} > - > static inline int ufshcd_mcq_vops_op_runtime_config(struct ufs_hba *hba) { > if (hba->vops && hba->vops->op_runtime_config)
On 6/17/24 11:23 PM, Avri Altman wrote: > >> Make ufshcd_mcq_decide_queue_depth() easier to read by inlining >> ufshcd_mcq_vops_get_hba_mac(). > > This changes its functionality by making it non-mandatory. > Maybe relate to that in the commit log. I do not agree. Even with this patch applied, .get_hba_mac() is still mandatory. > Also, it would make sense to squash it to the next patch, so your line of reasoning is clear. I prefer to keep the inlining (no functional change) separate from the patch that introduces a behavior change. Thanks, Bart.
diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c index 4bcae410c268..0482c7a1e419 100644 --- a/drivers/ufs/core/ufs-mcq.c +++ b/drivers/ufs/core/ufs-mcq.c @@ -144,14 +144,14 @@ EXPORT_SYMBOL_GPL(ufshcd_mcq_queue_cfg_addr); */ int ufshcd_mcq_decide_queue_depth(struct ufs_hba *hba) { - int mac; + int mac = -EOPNOTSUPP; - /* Mandatory to implement get_hba_mac() */ - mac = ufshcd_mcq_vops_get_hba_mac(hba); - if (mac < 0) { - dev_err(hba->dev, "Failed to get mac, err=%d\n", mac); - return mac; - } + if (!hba->vops || !hba->vops->get_hba_mac) + goto err; + + mac = hba->vops->get_hba_mac(hba); + if (mac < 0) + goto err; WARN_ON_ONCE(!hba->dev_info.bqueuedepth); /* @@ -160,6 +160,10 @@ int ufshcd_mcq_decide_queue_depth(struct ufs_hba *hba) * shared queuing architecture is enabled. */ return min_t(int, mac, hba->dev_info.bqueuedepth); + +err: + dev_err(hba->dev, "Failed to get mac, err=%d\n", mac); + return mac; } static int ufshcd_mcq_config_nr_queues(struct ufs_hba *hba) diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h index f42d99ce5bf1..a1add22205db 100644 --- a/drivers/ufs/core/ufshcd-priv.h +++ b/drivers/ufs/core/ufshcd-priv.h @@ -255,14 +255,6 @@ static inline int ufshcd_vops_mcq_config_resource(struct ufs_hba *hba) return -EOPNOTSUPP; } -static inline int ufshcd_mcq_vops_get_hba_mac(struct ufs_hba *hba) -{ - if (hba->vops && hba->vops->get_hba_mac) - return hba->vops->get_hba_mac(hba); - - return -EOPNOTSUPP; -} - static inline int ufshcd_mcq_vops_op_runtime_config(struct ufs_hba *hba) { if (hba->vops && hba->vops->op_runtime_config)
Make ufshcd_mcq_decide_queue_depth() easier to read by inlining ufshcd_mcq_vops_get_hba_mac(). Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- drivers/ufs/core/ufs-mcq.c | 18 +++++++++++------- drivers/ufs/core/ufshcd-priv.h | 8 -------- 2 files changed, 11 insertions(+), 15 deletions(-)