cdrom: don't attempt to fiddle with cdo->capability
[ Upstream commit 8f94004e2a51a3ea195cf3447eb5d5906f36d8b3 ]
We can't modify cdo->capability as it is defined as a const.
Change the modification hack to just WARN_ON_ONCE() if we hit
any of the invalid combinations.
This fixes a regression for pcd, which doesn't work after the
constify patch.
Fixes: 853fe1bf75
("cdrom: Make device operations read-only")
Tested-by: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
0c5c34c1aa
commit
2cd0b70c55
1 changed files with 13 additions and 14 deletions
|
@ -411,10 +411,10 @@ static int cdrom_get_disc_info(struct cdrom_device_info *cdi,
|
|||
* hack to have the capability flags defined const, while we can still
|
||||
* change it here without gcc complaining at every line.
|
||||
*/
|
||||
#define ENSURE(call, bits) \
|
||||
do { \
|
||||
if (cdo->call == NULL) \
|
||||
*change_capability &= ~(bits); \
|
||||
#define ENSURE(cdo, call, bits) \
|
||||
do { \
|
||||
if (cdo->call == NULL) \
|
||||
WARN_ON_ONCE((cdo)->capability & (bits)); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
|
@ -590,7 +590,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
|
|||
{
|
||||
static char banner_printed;
|
||||
const struct cdrom_device_ops *cdo = cdi->ops;
|
||||
int *change_capability = (int *)&cdo->capability; /* hack */
|
||||
|
||||
cd_dbg(CD_OPEN, "entering register_cdrom\n");
|
||||
|
||||
|
@ -602,16 +601,16 @@ int register_cdrom(struct cdrom_device_info *cdi)
|
|||
cdrom_sysctl_register();
|
||||
}
|
||||
|
||||
ENSURE(drive_status, CDC_DRIVE_STATUS);
|
||||
ENSURE(cdo, drive_status, CDC_DRIVE_STATUS);
|
||||
if (cdo->check_events == NULL && cdo->media_changed == NULL)
|
||||
*change_capability = ~(CDC_MEDIA_CHANGED | CDC_SELECT_DISC);
|
||||
ENSURE(tray_move, CDC_CLOSE_TRAY | CDC_OPEN_TRAY);
|
||||
ENSURE(lock_door, CDC_LOCK);
|
||||
ENSURE(select_speed, CDC_SELECT_SPEED);
|
||||
ENSURE(get_last_session, CDC_MULTI_SESSION);
|
||||
ENSURE(get_mcn, CDC_MCN);
|
||||
ENSURE(reset, CDC_RESET);
|
||||
ENSURE(generic_packet, CDC_GENERIC_PACKET);
|
||||
WARN_ON_ONCE(cdo->capability & (CDC_MEDIA_CHANGED | CDC_SELECT_DISC));
|
||||
ENSURE(cdo, tray_move, CDC_CLOSE_TRAY | CDC_OPEN_TRAY);
|
||||
ENSURE(cdo, lock_door, CDC_LOCK);
|
||||
ENSURE(cdo, select_speed, CDC_SELECT_SPEED);
|
||||
ENSURE(cdo, get_last_session, CDC_MULTI_SESSION);
|
||||
ENSURE(cdo, get_mcn, CDC_MCN);
|
||||
ENSURE(cdo, reset, CDC_RESET);
|
||||
ENSURE(cdo, generic_packet, CDC_GENERIC_PACKET);
|
||||
cdi->mc_flags = 0;
|
||||
cdi->options = CDO_USE_FFLAGS;
|
||||
|
||||
|
|
Loading…
Reference in a new issue