mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-01 10:42:11 +00:00
65a09ba269
Modules registering driver with scsi_driver_register() might forget to set
.owner field. The field is used by some of other kernel parts for
reference counting (try_module_get()), so it is expected that drivers will
set it.
Solve the problem by moving this task away from the drivers to the core
scsi code, just like we did for platform_driver in commit 9447057eaf
("platform_device: use a macro instead of platform_driver_register").
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240328-b4-module-owner-scsi-v1-1-c86cb4f6e91c@linaro.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
42 lines
1.1 KiB
C
42 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _SCSI_SCSI_DRIVER_H
|
|
#define _SCSI_SCSI_DRIVER_H
|
|
|
|
#include <linux/blk_types.h>
|
|
#include <linux/device.h>
|
|
#include <scsi/scsi_cmnd.h>
|
|
|
|
struct module;
|
|
struct request;
|
|
|
|
struct scsi_driver {
|
|
struct device_driver gendrv;
|
|
|
|
void (*rescan)(struct device *);
|
|
blk_status_t (*init_command)(struct scsi_cmnd *);
|
|
void (*uninit_command)(struct scsi_cmnd *);
|
|
int (*done)(struct scsi_cmnd *);
|
|
int (*eh_action)(struct scsi_cmnd *, int);
|
|
void (*eh_reset)(struct scsi_cmnd *);
|
|
};
|
|
#define to_scsi_driver(drv) \
|
|
container_of((drv), struct scsi_driver, gendrv)
|
|
|
|
#define scsi_register_driver(drv) \
|
|
__scsi_register_driver(drv, THIS_MODULE)
|
|
int __scsi_register_driver(struct device_driver *, struct module *);
|
|
#define scsi_unregister_driver(drv) \
|
|
driver_unregister(drv);
|
|
|
|
extern int scsi_register_interface(struct class_interface *);
|
|
#define scsi_unregister_interface(intf) \
|
|
class_interface_unregister(intf)
|
|
|
|
/* make sure not to use it with passthrough commands */
|
|
static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
|
|
{
|
|
return to_scsi_driver(cmd->device->sdev_gendev.driver);
|
|
}
|
|
|
|
#endif /* _SCSI_SCSI_DRIVER_H */
|