mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	struct bus_type should never be modified in a sysfs callback as there is nothing in the structure to modify, and frankly, the structure is almost never used in a sysfs callback, so mark it as constant to allow struct bus_type to be moved to read-only memory. Cc: "David S. Miller" <davem@davemloft.net> Cc: "James E.J. Bottomley" <jejb@linux.ibm.com> Cc: "K. Y. Srinivasan" <kys@microsoft.com> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Alexandre Bounine <alex.bou9@gmail.com> Cc: Alison Schofield <alison.schofield@intel.com> Cc: Ben Widawsky <bwidawsk@kernel.org> Cc: Dexuan Cui <decui@microsoft.com> Cc: Eric Dumazet <edumazet@google.com> Cc: Haiyang Zhang <haiyangz@microsoft.com> Cc: Hannes Reinecke <hare@suse.de> Cc: Harald Freudenberger <freude@linux.ibm.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Hu Haowen <src.res@email.cn> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Jens Axboe <axboe@kernel.dk> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com> Cc: Matt Porter <mporter@kernel.crashing.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Paolo Abeni <pabeni@redhat.com> Cc: Stuart Yoder <stuyoder@gmail.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Vishal Verma <vishal.l.verma@intel.com> Cc: Yanteng Si <siyanteng@loongson.cn> Acked-by: Ilya Dryomov <idryomov@gmail.com> # rbd Acked-by: Ira Weiny <ira.weiny@intel.com> # cxl Reviewed-by: Alex Shi <alexs@kernel.org> Acked-by: Iwona Winiarska <iwona.winiarska@intel.com> Acked-by: Dan Williams <dan.j.williams@intel.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> # pci Acked-by: Wei Liu <wei.liu@kernel.org> Acked-by: Martin K. Petersen <martin.petersen@oracle.com> # scsi Link: https://lore.kernel.org/r/20230313182918.1312597-23-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
		
			
				
	
	
		
			82 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			82 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
// SPDX-License-Identifier: GPL-2.0-only
 | 
						|
// Copyright (c) 2021 Intel Corporation
 | 
						|
 | 
						|
#include <linux/device.h>
 | 
						|
#include <linux/kernel.h>
 | 
						|
#include <linux/peci.h>
 | 
						|
 | 
						|
#include "internal.h"
 | 
						|
 | 
						|
static int rescan_controller(struct device *dev, void *data)
 | 
						|
{
 | 
						|
	if (dev->type != &peci_controller_type)
 | 
						|
		return 0;
 | 
						|
 | 
						|
	return peci_controller_scan_devices(to_peci_controller(dev));
 | 
						|
}
 | 
						|
 | 
						|
static ssize_t rescan_store(const struct bus_type *bus, const char *buf, size_t count)
 | 
						|
{
 | 
						|
	bool res;
 | 
						|
	int ret;
 | 
						|
 | 
						|
	ret = kstrtobool(buf, &res);
 | 
						|
	if (ret)
 | 
						|
		return ret;
 | 
						|
 | 
						|
	if (!res)
 | 
						|
		return count;
 | 
						|
 | 
						|
	ret = bus_for_each_dev(&peci_bus_type, NULL, NULL, rescan_controller);
 | 
						|
	if (ret)
 | 
						|
		return ret;
 | 
						|
 | 
						|
	return count;
 | 
						|
}
 | 
						|
static BUS_ATTR_WO(rescan);
 | 
						|
 | 
						|
static struct attribute *peci_bus_attrs[] = {
 | 
						|
	&bus_attr_rescan.attr,
 | 
						|
	NULL
 | 
						|
};
 | 
						|
 | 
						|
static const struct attribute_group peci_bus_group = {
 | 
						|
	.attrs = peci_bus_attrs,
 | 
						|
};
 | 
						|
 | 
						|
const struct attribute_group *peci_bus_groups[] = {
 | 
						|
	&peci_bus_group,
 | 
						|
	NULL
 | 
						|
};
 | 
						|
 | 
						|
static ssize_t remove_store(struct device *dev, struct device_attribute *attr,
 | 
						|
			    const char *buf, size_t count)
 | 
						|
{
 | 
						|
	struct peci_device *device = to_peci_device(dev);
 | 
						|
	bool res;
 | 
						|
	int ret;
 | 
						|
 | 
						|
	ret = kstrtobool(buf, &res);
 | 
						|
	if (ret)
 | 
						|
		return ret;
 | 
						|
 | 
						|
	if (res && device_remove_file_self(dev, attr))
 | 
						|
		peci_device_destroy(device);
 | 
						|
 | 
						|
	return count;
 | 
						|
}
 | 
						|
static DEVICE_ATTR_IGNORE_LOCKDEP(remove, 0200, NULL, remove_store);
 | 
						|
 | 
						|
static struct attribute *peci_device_attrs[] = {
 | 
						|
	&dev_attr_remove.attr,
 | 
						|
	NULL
 | 
						|
};
 | 
						|
 | 
						|
static const struct attribute_group peci_device_group = {
 | 
						|
	.attrs = peci_device_attrs,
 | 
						|
};
 | 
						|
 | 
						|
const struct attribute_group *peci_device_groups[] = {
 | 
						|
	&peci_device_group,
 | 
						|
	NULL
 | 
						|
};
 |