Skip to content

Commit c496016

Browse files
Nitin Rawatmartinkpetersen
authored andcommitted
scsi: ufs: core: Add ufshcd_dme_rmw() to modify DME attributes
Introduce ufshcd_dme_rmw() API to read, modify, and write DME attributes in UFS host controllers using a mask and value. Signed-off-by: Nitin Rawat <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 7a9d519 commit c496016

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4253,6 +4253,30 @@ int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel,
42534253
}
42544254
EXPORT_SYMBOL_GPL(ufshcd_dme_get_attr);
42554255

4256+
/**
4257+
* ufshcd_dme_rmw - get modify set a DME attribute
4258+
* @hba: per adapter instance
4259+
* @mask: indicates which bits to clear from the value that has been read
4260+
* @val: actual value to write
4261+
* @attr: dme attribute
4262+
*/
4263+
int ufshcd_dme_rmw(struct ufs_hba *hba, u32 mask,
4264+
u32 val, u32 attr)
4265+
{
4266+
u32 cfg = 0;
4267+
int err;
4268+
4269+
err = ufshcd_dme_get(hba, UIC_ARG_MIB(attr), &cfg);
4270+
if (err)
4271+
return err;
4272+
4273+
cfg &= ~mask;
4274+
cfg |= (val & mask);
4275+
4276+
return ufshcd_dme_set(hba, UIC_ARG_MIB(attr), cfg);
4277+
}
4278+
EXPORT_SYMBOL_GPL(ufshcd_dme_rmw);
4279+
42564280
/**
42574281
* ufshcd_uic_pwr_ctrl - executes UIC commands (which affects the link power
42584282
* state) and waits for it to take effect.

include/ufs/ufshcd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,7 @@ void ufshcd_resume_complete(struct device *dev);
14801480
bool ufshcd_is_hba_active(struct ufs_hba *hba);
14811481
void ufshcd_pm_qos_init(struct ufs_hba *hba);
14821482
void ufshcd_pm_qos_exit(struct ufs_hba *hba);
1483+
int ufshcd_dme_rmw(struct ufs_hba *hba, u32 mask, u32 val, u32 attr);
14831484

14841485
/* Wrapper functions for safely calling variant operations */
14851486
static inline int ufshcd_vops_init(struct ufs_hba *hba)

0 commit comments

Comments
 (0)