Skip to content

Commit

Permalink
driver core: make struct bus_type.uevent() take a const *
Browse files Browse the repository at this point in the history
The uevent() callback in struct bus_type should not be modifying the
device that is passed into it, so mark it as a const * and propagate the
function signature changes out into all relevant subsystems that use
this callback.

Acked-by: Rafael J. Wysocki <[email protected]>
Acked-by: Hans de Goede <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
gregkh authored and junxiaoc committed Jul 18, 2023
1 parent f1d7912 commit a3cf4c4
Show file tree
Hide file tree
Showing 81 changed files with 160 additions and 160 deletions.
4 changes: 2 additions & 2 deletions arch/mips/sgi-ip22/ip22-gio.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ static struct attribute *gio_dev_attrs[] = {
};
ATTRIBUTE_GROUPS(gio_dev);

static int gio_device_uevent(struct device *dev, struct kobj_uevent_env *env)
static int gio_device_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
struct gio_device *gio_dev = to_gio_device(dev);
const struct gio_device *gio_dev = to_gio_device(dev);

add_uevent_var(env, "MODALIAS=gio:%x", gio_dev->id.id);
return 0;
Expand Down
4 changes: 2 additions & 2 deletions arch/parisc/kernel/drivers.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ static int parisc_generic_match(struct device *dev, struct device_driver *drv)
return match_device(to_parisc_driver(drv), to_parisc_device(dev));
}

static ssize_t make_modalias(struct device *dev, char *buf)
static ssize_t make_modalias(const struct device *dev, char *buf)
{
const struct parisc_device *padev = to_parisc_device(dev);
const struct parisc_device_id *id = &padev->id;
Expand All @@ -562,7 +562,7 @@ static ssize_t make_modalias(struct device *dev, char *buf)
(u32)id->sversion);
}

static int parisc_uevent(struct device *dev, struct kobj_uevent_env *env)
static int parisc_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
const struct parisc_device *padev;
char modalias[40];
Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/platforms/pseries/vio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1609,10 +1609,10 @@ static int vio_bus_match(struct device *dev, struct device_driver *drv)
return (ids != NULL) && (vio_match_device(ids, vio_dev) != NULL);
}

static int vio_hotplug(struct device *dev, struct kobj_uevent_env *env)
static int vio_hotplug(const struct device *dev, struct kobj_uevent_env *env)
{
const struct vio_dev *vio_dev = to_vio_dev(dev);
struct device_node *dn;
const struct device_node *dn;
const char *cp;

dn = dev->of_node;
Expand Down
2 changes: 1 addition & 1 deletion arch/sparc/kernel/vio.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static const struct vio_device_id *vio_match_device(
return NULL;
}

static int vio_hotplug(struct device *dev, struct kobj_uevent_env *env)
static int vio_hotplug(const struct device *dev, struct kobj_uevent_env *env)
{
const struct vio_dev *vio_dev = to_vio_dev(dev);

Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ static int acpi_bus_match(struct device *dev, struct device_driver *drv)
&& !acpi_match_device_ids(acpi_dev, acpi_drv->ids);
}

static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env)
static int acpi_device_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
return __acpi_device_uevent_modalias(to_acpi_device(dev), env);
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/amba/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ static int amba_match(struct device *dev, struct device_driver *drv)
return amba_lookup(pcdrv->id_table, pcdev) != NULL;
}

static int amba_uevent(struct device *dev, struct kobj_uevent_env *env)
static int amba_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
struct amba_device *pcdev = to_amba_device(dev);
const struct amba_device *pcdev = to_amba_device(dev);
int retval = 0;

retval = add_uevent_var(env, "AMBA_ID=%08x", pcdev->periphid);
Expand Down
2 changes: 1 addition & 1 deletion drivers/base/auxiliary.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static int auxiliary_match(struct device *dev, struct device_driver *drv)
return !!auxiliary_match_id(auxdrv->id_table, auxdev);
}

static int auxiliary_uevent(struct device *dev, struct kobj_uevent_env *env)
static int auxiliary_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
const char *name, *p;

Expand Down
2 changes: 1 addition & 1 deletion drivers/base/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ static ssize_t print_cpu_modalias(struct device *dev,
return len;
}

static int cpu_uevent(struct device *dev, struct kobj_uevent_env *env)
static int cpu_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
char *buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
if (buf) {
Expand Down
4 changes: 2 additions & 2 deletions drivers/base/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -1353,9 +1353,9 @@ static int platform_match(struct device *dev, struct device_driver *drv)
return (strcmp(pdev->name, drv->name) == 0);
}

static int platform_uevent(struct device *dev, struct kobj_uevent_env *env)
static int platform_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
struct platform_device *pdev = to_platform_device(dev);
const struct platform_device *pdev = to_platform_device(dev);
int rc;

/* Some devices have extra OF data and an OF-style MODALIAS */
Expand Down
6 changes: 3 additions & 3 deletions drivers/bcma/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static DEFINE_MUTEX(bcma_buses_mutex);
static int bcma_bus_match(struct device *dev, struct device_driver *drv);
static int bcma_device_probe(struct device *dev);
static void bcma_device_remove(struct device *dev);
static int bcma_device_uevent(struct device *dev, struct kobj_uevent_env *env);
static int bcma_device_uevent(const struct device *dev, struct kobj_uevent_env *env);

static ssize_t manuf_show(struct device *dev, struct device_attribute *attr, char *buf)
{
Expand Down Expand Up @@ -625,9 +625,9 @@ static void bcma_device_remove(struct device *dev)
put_device(dev);
}

static int bcma_device_uevent(struct device *dev, struct kobj_uevent_env *env)
static int bcma_device_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
struct bcma_device *core = container_of(dev, struct bcma_device, dev);
const struct bcma_device *core = container_of_const(dev, struct bcma_device, dev);

return add_uevent_var(env,
"MODALIAS=bcma:m%04Xid%04Xrev%02Xcl%02X",
Expand Down
4 changes: 2 additions & 2 deletions drivers/bus/fsl-mc/fsl-mc-bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ static int fsl_mc_bus_match(struct device *dev, struct device_driver *drv)
/*
* fsl_mc_bus_uevent - callback invoked when a device is added
*/
static int fsl_mc_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
static int fsl_mc_bus_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
const struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);

if (add_uevent_var(env, "MODALIAS=fsl-mc:v%08Xd%s",
mc_dev->obj_desc.vendor,
Expand Down
4 changes: 2 additions & 2 deletions drivers/bus/mhi/ep/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1543,9 +1543,9 @@ void mhi_ep_driver_unregister(struct mhi_ep_driver *mhi_drv)
}
EXPORT_SYMBOL_GPL(mhi_ep_driver_unregister);

static int mhi_ep_uevent(struct device *dev, struct kobj_uevent_env *env)
static int mhi_ep_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
struct mhi_ep_device *mhi_dev = to_mhi_ep_device(dev);
const struct mhi_ep_device *mhi_dev = to_mhi_ep_device(dev);

return add_uevent_var(env, "MODALIAS=" MHI_EP_DEVICE_MODALIAS_FMT,
mhi_dev->name);
Expand Down
4 changes: 2 additions & 2 deletions drivers/bus/mhi/host/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1407,9 +1407,9 @@ void mhi_driver_unregister(struct mhi_driver *mhi_drv)
}
EXPORT_SYMBOL_GPL(mhi_driver_unregister);

static int mhi_uevent(struct device *dev, struct kobj_uevent_env *env)
static int mhi_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
struct mhi_device *mhi_dev = to_mhi_device(dev);
const struct mhi_device *mhi_dev = to_mhi_device(dev);

return add_uevent_var(env, "MODALIAS=" MHI_DEVICE_MODALIAS_FMT,
mhi_dev->name);
Expand Down
4 changes: 2 additions & 2 deletions drivers/bus/mips_cdmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ static int mips_cdmm_match(struct device *dev, struct device_driver *drv)
return mips_cdmm_lookup(cdrv->id_table, cdev) != NULL;
}

static int mips_cdmm_uevent(struct device *dev, struct kobj_uevent_env *env)
static int mips_cdmm_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
struct mips_cdmm_device *cdev = to_mips_cdmm_device(dev);
const struct mips_cdmm_device *cdev = to_mips_cdmm_device(dev);
int retval = 0;

retval = add_uevent_var(env, "CDMM_CPU=%u", cdev->cpu);
Expand Down
2 changes: 1 addition & 1 deletion drivers/bus/sunxi-rsb.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static void sunxi_rsb_device_remove(struct device *dev)
drv->remove(to_sunxi_rsb_device(dev));
}

static int sunxi_rsb_device_modalias(struct device *dev, struct kobj_uevent_env *env)
static int sunxi_rsb_device_modalias(const struct device *dev, struct kobj_uevent_env *env)
{
return of_device_uevent_modalias(dev, env);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/cxl/core/memdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static const struct device_type cxl_memdev_type = {
.groups = cxl_memdev_attribute_groups,
};

bool is_cxl_memdev(struct device *dev)
bool is_cxl_memdev(const struct device *dev)
{
return dev->type == &cxl_memdev_type;
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/cxl/core/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static ssize_t devtype_show(struct device *dev, struct device_attribute *attr,
}
static DEVICE_ATTR_RO(devtype);

static int cxl_device_id(struct device *dev)
static int cxl_device_id(const struct device *dev)
{
if (dev->type == &cxl_nvdimm_bridge_type)
return CXL_DEVICE_NVDIMM_BRIDGE;
Expand Down Expand Up @@ -523,13 +523,13 @@ static const struct device_type cxl_port_type = {
.groups = cxl_port_attribute_groups,
};

bool is_cxl_port(struct device *dev)
bool is_cxl_port(const struct device *dev)
{
return dev->type == &cxl_port_type;
}
EXPORT_SYMBOL_NS_GPL(is_cxl_port, CXL);

struct cxl_port *to_cxl_port(struct device *dev)
struct cxl_port *to_cxl_port(const struct device *dev)
{
if (dev_WARN_ONCE(dev, dev->type != &cxl_port_type,
"not a cxl_port device\n"))
Expand Down Expand Up @@ -1767,7 +1767,7 @@ void cxl_driver_unregister(struct cxl_driver *cxl_drv)
}
EXPORT_SYMBOL_NS_GPL(cxl_driver_unregister, CXL);

static int cxl_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
static int cxl_bus_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
return add_uevent_var(env, "MODALIAS=" CXL_MODALIAS_FMT,
cxl_device_id(dev));
Expand Down
4 changes: 2 additions & 2 deletions drivers/cxl/cxl.h
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,8 @@ static inline bool is_cxl_root(struct cxl_port *port)
return port->uport == port->dev.parent;
}

bool is_cxl_port(struct device *dev);
struct cxl_port *to_cxl_port(struct device *dev);
bool is_cxl_port(const struct device *dev);
struct cxl_port *to_cxl_port(const struct device *dev);
struct pci_bus;
int devm_cxl_register_pci_bus(struct device *host, struct device *uport,
struct pci_bus *bus);
Expand Down
2 changes: 1 addition & 1 deletion drivers/cxl/cxlmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ cxled_to_memdev(struct cxl_endpoint_decoder *cxled)
return to_cxl_memdev(port->uport);
}

bool is_cxl_memdev(struct device *dev);
bool is_cxl_memdev(const struct device *dev);
static inline bool is_cxl_endpoint(struct cxl_port *port)
{
return is_cxl_memdev(port->uport);
Expand Down
2 changes: 1 addition & 1 deletion drivers/dax/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct dax_id {
char dev_name[DAX_NAME_LEN];
};

static int dax_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
static int dax_bus_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
/*
* We only ever expect to handle device-dax instances, i.e. the
Expand Down
4 changes: 2 additions & 2 deletions drivers/eisa/eisa-bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ static int eisa_bus_match(struct device *dev, struct device_driver *drv)
return 0;
}

static int eisa_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
static int eisa_bus_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
struct eisa_device *edev = to_eisa_device(dev);
const struct eisa_device *edev = to_eisa_device(dev);

add_uevent_var(env, "MODALIAS=" EISA_DEVICE_MODALIAS_FMT, edev->id.sig);
return 0;
Expand Down
4 changes: 2 additions & 2 deletions drivers/firmware/arm_ffa/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ static void ffa_device_remove(struct device *dev)
ffa_drv->remove(to_ffa_dev(dev));
}

static int ffa_device_uevent(struct device *dev, struct kobj_uevent_env *env)
static int ffa_device_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
struct ffa_device *ffa_dev = to_ffa_dev(dev);
const struct ffa_device *ffa_dev = to_ffa_dev(dev);

return add_uevent_var(env, "MODALIAS=arm_ffa:%04x:%pUb",
ffa_dev->vm_id, &ffa_dev->uuid);
Expand Down
4 changes: 2 additions & 2 deletions drivers/fpga/dfl.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ static void dfl_bus_remove(struct device *dev)
ddrv->remove(ddev);
}

static int dfl_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
static int dfl_bus_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
struct dfl_device *ddev = to_dfl_dev(dev);
const struct dfl_device *ddev = to_dfl_dev(dev);

return add_uevent_var(env, "MODALIAS=dfl:t%04Xf%04X",
ddev->type, ddev->feature_id);
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/drm_mipi_dsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ static int mipi_dsi_device_match(struct device *dev, struct device_driver *drv)
return 0;
}

static int mipi_dsi_uevent(struct device *dev, struct kobj_uevent_env *env)
static int mipi_dsi_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
const struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
int err;

err = of_device_uevent_modalias(dev, env);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/host1x/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv)
return strcmp(dev_name(dev), drv->name) == 0;
}

static int host1x_device_uevent(struct device *dev,
static int host1x_device_uevent(const struct device *dev,
struct kobj_uevent_env *env)
{
struct device_node *np = dev->parent->of_node;
Expand Down
14 changes: 7 additions & 7 deletions drivers/greybus/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ static int greybus_match_device(struct device *dev, struct device_driver *drv)
return 0;
}

static int greybus_uevent(struct device *dev, struct kobj_uevent_env *env)
static int greybus_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
struct gb_host_device *hd;
struct gb_module *module = NULL;
struct gb_interface *intf = NULL;
struct gb_control *control = NULL;
struct gb_bundle *bundle = NULL;
struct gb_svc *svc = NULL;
const struct gb_host_device *hd;
const struct gb_module *module = NULL;
const struct gb_interface *intf = NULL;
const struct gb_control *control = NULL;
const struct gb_bundle *bundle = NULL;
const struct gb_svc *svc = NULL;

if (is_gb_host_device(dev)) {
hd = to_gb_host_device(dev);
Expand Down
4 changes: 2 additions & 2 deletions drivers/hid/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2685,9 +2685,9 @@ static const struct attribute_group hid_dev_group = {
};
__ATTRIBUTE_GROUPS(hid_dev);

static int hid_uevent(struct device *dev, struct kobj_uevent_env *env)
static int hid_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
struct hid_device *hdev = to_hid_device(dev);
const struct hid_device *hdev = to_hid_device(dev);

if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X",
hdev->bus, hdev->vendor, hdev->product))
Expand Down
2 changes: 1 addition & 1 deletion drivers/hid/intel-ish-hid/ishtp/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ static struct attribute *ishtp_cl_dev_attrs[] = {
};
ATTRIBUTE_GROUPS(ishtp_cl_dev);

static int ishtp_cl_uevent(struct device *dev, struct kobj_uevent_env *env)
static int ishtp_cl_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
if (add_uevent_var(env, "MODALIAS=" ISHTP_MODULE_PREFIX "%s", dev_name(dev)))
return -ENOMEM;
Expand Down
2 changes: 1 addition & 1 deletion drivers/hsi/hsi_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static struct attribute *hsi_bus_dev_attrs[] = {
};
ATTRIBUTE_GROUPS(hsi_bus_dev);

static int hsi_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
static int hsi_bus_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
add_uevent_var(env, "MODALIAS=hsi:%s", dev_name(dev));

Expand Down
4 changes: 2 additions & 2 deletions drivers/hv/vmbus_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,9 +690,9 @@ __ATTRIBUTE_GROUPS(vmbus_bus);
* representation of the device guid (each byte of the guid will be
* represented with two hex characters.
*/
static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
static int vmbus_uevent(const struct device *device, struct kobj_uevent_env *env)
{
struct hv_device *dev = device_to_hv_device(device);
const struct hv_device *dev = device_to_hv_device(device);
const char *format = "MODALIAS=vmbus:%*phN";

return add_uevent_var(env, format, UUID_SIZE, &dev->dev_type);
Expand Down
4 changes: 2 additions & 2 deletions drivers/input/serio/serio.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,9 +895,9 @@ static int serio_bus_match(struct device *dev, struct device_driver *drv)
return err; \
} while (0)

static int serio_uevent(struct device *dev, struct kobj_uevent_env *env)
static int serio_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
struct serio *serio;
const struct serio *serio;

if (!dev)
return -ENODEV;
Expand Down
4 changes: 2 additions & 2 deletions drivers/ipack/ipack.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ static void ipack_bus_remove(struct device *device)
drv->ops->remove(dev);
}

static int ipack_uevent(struct device *dev, struct kobj_uevent_env *env)
static int ipack_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
struct ipack_device *idev;
const struct ipack_device *idev;

if (!dev)
return -ENODEV;
Expand Down
Loading

0 comments on commit a3cf4c4

Please sign in to comment.