Message ID | 20220331223424.1054715-10-bvanassche@acm.org |
---|---|
State | Superseded |
Headers | show |
Series | UFS patches for kernel v5.19 | expand |
> > Declare the quirks array and also its 'model' member const to make it explicit > that these are not modified. > > Signed-off-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Avri Altman <avri.altman@wdc.com>
On 04/04/2022 23:14, Bart Van Assche wrote: > On 4/1/22 12:56, Avri Altman wrote: >>> Declare the quirks array and also its 'model' member const to make it explicit >>> that these are not modified. >> >> Sometimes it's useful to be able to add a quirk as part of e.g. a debug session in the OEM premises. >> And not always we are able to recompile the kernel. >> Since we have a debugfs now, how about adding this capability, instead of blocking it? > > Hmm ... does declaring data const prevent from modifying that data from > inside a kernel debugger? Don't kernel debuggers allow to cast away > constness? We strive to make all initdata const for several safety reasons, so such debugging/hacking session without recompiling the kernel is not a good reason to abandon that goal. Such data is already const (or constified in progress) in most of the kernel places, so why UFS is special? Other subsystems are not... Best regards, Krzysztof
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c index 217348dde6a6..9a4474210627 100644 --- a/drivers/scsi/ufs/ufs-mediatek.c +++ b/drivers/scsi/ufs/ufs-mediatek.c @@ -44,7 +44,7 @@ #define ufs_mtk_device_reset_ctrl(high, res) \ ufs_mtk_smc(UFS_MTK_SIP_DEVICE_RESET, high, res) -static struct ufs_dev_quirk ufs_mtk_dev_fixups[] = { +static const struct ufs_dev_quirk ufs_mtk_dev_fixups[] = { { .wmanufacturerid = UFS_VENDOR_MICRON, .model = UFS_ANY_MODEL, .quirk = UFS_DEVICE_QUIRK_DELAY_AFTER_LPM }, diff --git a/drivers/scsi/ufs/ufs_quirks.h b/drivers/scsi/ufs/ufs_quirks.h index e38dec5f0351..bcb4f004bed5 100644 --- a/drivers/scsi/ufs/ufs_quirks.h +++ b/drivers/scsi/ufs/ufs_quirks.h @@ -25,7 +25,7 @@ */ struct ufs_dev_quirk { u16 wmanufacturerid; - u8 *model; + const u8 *model; unsigned int quirk; }; diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 97b9b2b77593..931ce620fc34 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -204,7 +204,7 @@ ufs_get_desired_pm_lvl_for_dev_link_state(enum ufs_dev_pwr_mode dev_state, return UFS_PM_LVL_0; } -static struct ufs_dev_quirk ufs_fixups[] = { +static const struct ufs_dev_quirk ufs_fixups[] = { /* UFS cards deviations table */ { .wmanufacturerid = UFS_VENDOR_MICRON, .model = UFS_ANY_MODEL, @@ -7624,9 +7624,10 @@ static void ufshcd_temp_notif_probe(struct ufs_hba *hba, u8 *desc_buf) } } -void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_quirk *fixups) +void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, + const struct ufs_dev_quirk *fixups) { - struct ufs_dev_quirk *f; + const struct ufs_dev_quirk *f; struct ufs_dev_info *dev_info = &hba->dev_info; if (!fixups) diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 3d18581afc2b..107d19e98d52 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -1180,7 +1180,8 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode, void ufshcd_auto_hibern8_enable(struct ufs_hba *hba); void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit); -void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_quirk *fixups); +void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, + const struct ufs_dev_quirk *fixups); #define SD_ASCII_STD true #define SD_RAW false int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
Declare the quirks array and also its 'model' member const to make it explicit that these are not modified. Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- drivers/scsi/ufs/ufs-mediatek.c | 2 +- drivers/scsi/ufs/ufs_quirks.h | 2 +- drivers/scsi/ufs/ufshcd.c | 7 ++++--- drivers/scsi/ufs/ufshcd.h | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-)