Skip to content

Commit

Permalink
From patchwork series 436916
Browse files Browse the repository at this point in the history
  • Loading branch information
Fox Snowpatch committed Dec 16, 2024
1 parent 2dd0957 commit 8d20ea1
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 31 deletions.
27 changes: 19 additions & 8 deletions drivers/misc/c2port/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ static ssize_t __c2port_read_flash_data(struct c2port_device *dev,
}

static ssize_t c2port_read_flash_data(struct file *filp, struct kobject *kobj,
struct bin_attribute *attr,
const struct bin_attribute *attr,
char *buffer, loff_t offset, size_t count)
{
struct c2port_device *c2dev = dev_get_drvdata(kobj_to_dev(kobj));
Expand Down Expand Up @@ -829,7 +829,7 @@ static ssize_t __c2port_write_flash_data(struct c2port_device *dev,
}

static ssize_t c2port_write_flash_data(struct file *filp, struct kobject *kobj,
struct bin_attribute *attr,
const struct bin_attribute *attr,
char *buffer, loff_t offset, size_t count)
{
struct c2port_device *c2dev = dev_get_drvdata(kobj_to_dev(kobj));
Expand All @@ -849,8 +849,8 @@ static ssize_t c2port_write_flash_data(struct file *filp, struct kobject *kobj,
return ret;
}
/* size is computed at run-time */
static BIN_ATTR(flash_data, 0644, c2port_read_flash_data,
c2port_write_flash_data, 0);
static const BIN_ATTR(flash_data, 0644, c2port_read_flash_data,
c2port_write_flash_data, 0);

/*
* Class attributes
Expand All @@ -869,14 +869,27 @@ static struct attribute *c2port_attrs[] = {
NULL,
};

static struct bin_attribute *c2port_bin_attrs[] = {
static const struct bin_attribute *const c2port_bin_attrs[] = {
&bin_attr_flash_data,
NULL,
};

static size_t c2port_bin_attr_size(struct kobject *kobj,
const struct bin_attribute *attr,
int i)
{
struct c2port_device *c2dev = dev_get_drvdata(kobj_to_dev(kobj));

if (attr == &bin_attr_flash_data)
return c2dev->ops->blocks_num * c2dev->ops->block_size;

return attr->size;
}

static const struct attribute_group c2port_group = {
.attrs = c2port_attrs,
.bin_attrs = c2port_bin_attrs,
.bin_attrs_new = c2port_bin_attrs,
.bin_size = c2port_bin_attr_size,
};

static const struct attribute_group *c2port_groups[] = {
Expand Down Expand Up @@ -913,8 +926,6 @@ struct c2port_device *c2port_device_register(char *name,
goto error_idr_alloc;
c2dev->id = ret;

bin_attr_flash_data.size = ops->blocks_num * ops->block_size;

c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
"c2port%d", c2dev->id);
if (IS_ERR(c2dev->dev)) {
Expand Down
8 changes: 4 additions & 4 deletions drivers/misc/cxl/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ static ssize_t api_version_compatible_show(struct device *device,
}

static ssize_t afu_eb_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr, char *buf,
const struct bin_attribute *bin_attr, char *buf,
loff_t off, size_t count)
{
struct cxl_afu *afu = to_cxl_afu(kobj_to_dev(kobj));
Expand Down Expand Up @@ -538,7 +538,7 @@ static ssize_t class_show(struct kobject *kobj,
}

static ssize_t afu_read_config(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr, char *buf,
const struct bin_attribute *bin_attr, char *buf,
loff_t off, size_t count)
{
struct afu_config_record *cr = to_cr(kobj);
Expand Down Expand Up @@ -620,7 +620,7 @@ static struct afu_config_record *cxl_sysfs_afu_new_cr(struct cxl_afu *afu, int c
cr->config_attr.attr.name = "config";
cr->config_attr.attr.mode = S_IRUSR;
cr->config_attr.size = afu->crs_len;
cr->config_attr.read = afu_read_config;
cr->config_attr.read_new = afu_read_config;

rc = kobject_init_and_add(&cr->kobj, &afu_config_record_type,
&afu->dev.kobj, "cr%i", cr->cr);
Expand Down Expand Up @@ -693,7 +693,7 @@ int cxl_sysfs_afu_add(struct cxl_afu *afu)
afu->attr_eb.attr.name = "afu_err_buff";
afu->attr_eb.attr.mode = S_IRUGO;
afu->attr_eb.size = afu->eb_len;
afu->attr_eb.read = afu_eb_read;
afu->attr_eb.read_new = afu_eb_read;

rc = device_create_bin_file(&afu->dev, &afu->attr_eb);
if (rc) {
Expand Down
8 changes: 4 additions & 4 deletions drivers/misc/ds1682.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static const struct attribute_group ds1682_group = {
* User data attribute
*/
static ssize_t ds1682_eeprom_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *attr,
const struct bin_attribute *attr,
char *buf, loff_t off, size_t count)
{
struct i2c_client *client = kobj_to_i2c_client(kobj);
Expand All @@ -172,7 +172,7 @@ static ssize_t ds1682_eeprom_read(struct file *filp, struct kobject *kobj,
}

static ssize_t ds1682_eeprom_write(struct file *filp, struct kobject *kobj,
struct bin_attribute *attr,
const struct bin_attribute *attr,
char *buf, loff_t off, size_t count)
{
struct i2c_client *client = kobj_to_i2c_client(kobj);
Expand All @@ -194,8 +194,8 @@ static const struct bin_attribute ds1682_eeprom_attr = {
.mode = S_IRUGO | S_IWUSR,
},
.size = DS1682_EEPROM_SIZE,
.read = ds1682_eeprom_read,
.write = ds1682_eeprom_write,
.read_new = ds1682_eeprom_read,
.write_new = ds1682_eeprom_write,
};

static int ds1682_nvmem_read(void *priv, unsigned int offset, void *val,
Expand Down
6 changes: 3 additions & 3 deletions drivers/misc/eeprom/idt_89hpesx.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ static int idt_csr_read(struct idt_89hpesx_dev *pdev, u16 csraddr, u32 *data)
* @count: Number of bytes to write
*/
static ssize_t eeprom_write(struct file *filp, struct kobject *kobj,
struct bin_attribute *attr,
const struct bin_attribute *attr,
char *buf, loff_t off, size_t count)
{
struct idt_89hpesx_dev *pdev;
Expand All @@ -871,7 +871,7 @@ static ssize_t eeprom_write(struct file *filp, struct kobject *kobj,
* @count: Number of bytes to write
*/
static ssize_t eeprom_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *attr,
const struct bin_attribute *attr,
char *buf, loff_t off, size_t count)
{
struct idt_89hpesx_dev *pdev;
Expand Down Expand Up @@ -1017,7 +1017,7 @@ static ssize_t idt_dbgfs_csr_read(struct file *filep, char __user *ubuf,
* NOTE Size will be changed in compliance with OF node. EEPROM attribute will
* be read-only as well if the corresponding flag is specified in OF node.
*/
static BIN_ATTR_RW(eeprom, EEPROM_DEF_SIZE);
static const BIN_ATTR_RW(eeprom, EEPROM_DEF_SIZE);

/*
* csr_dbgfs_ops - CSR debugfs-node read/write operations
Expand Down
4 changes: 2 additions & 2 deletions drivers/misc/eeprom/max6875.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static void max6875_update_slice(struct i2c_client *client, int slice)
}

static ssize_t max6875_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr,
const struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count)
{
struct i2c_client *client = kobj_to_i2c_client(kobj);
Expand All @@ -127,7 +127,7 @@ static const struct bin_attribute user_eeprom_attr = {
.mode = S_IRUGO,
},
.size = USER_EEPROM_SIZE,
.read = max6875_read,
.read_new = max6875_read,
};

static int max6875_probe(struct i2c_client *client)
Expand Down
4 changes: 2 additions & 2 deletions drivers/misc/ocxl/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static struct device_attribute afu_attrs[] = {
};

static ssize_t global_mmio_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr, char *buf,
const struct bin_attribute *bin_attr, char *buf,
loff_t off, size_t count)
{
struct ocxl_afu *afu = to_afu(kobj_to_dev(kobj));
Expand Down Expand Up @@ -155,7 +155,7 @@ int ocxl_sysfs_register_afu(struct ocxl_file_info *info)
info->attr_global_mmio.attr.name = "global_mmio_area";
info->attr_global_mmio.attr.mode = 0600;
info->attr_global_mmio.size = info->afu->config.global_mmio_size;
info->attr_global_mmio.read = global_mmio_read;
info->attr_global_mmio.read_new = global_mmio_read;
info->attr_global_mmio.mmap = global_mmio_mmap;
rc = device_create_bin_file(&info->dev, &info->attr_global_mmio);
if (rc) {
Expand Down
8 changes: 4 additions & 4 deletions drivers/misc/pch_phub.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ static int pch_phub_write_gbe_mac_addr(struct pch_phub_reg *chip, u8 *data)
}

static ssize_t pch_phub_bin_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *attr, char *buf,
const struct bin_attribute *attr, char *buf,
loff_t off, size_t count)
{
unsigned int rom_signature;
Expand Down Expand Up @@ -553,7 +553,7 @@ static ssize_t pch_phub_bin_read(struct file *filp, struct kobject *kobj,
}

static ssize_t pch_phub_bin_write(struct file *filp, struct kobject *kobj,
struct bin_attribute *attr,
const struct bin_attribute *attr,
char *buf, loff_t off, size_t count)
{
int err;
Expand Down Expand Up @@ -655,8 +655,8 @@ static const struct bin_attribute pch_bin_attr = {
.mode = S_IRUGO | S_IWUSR,
},
.size = PCH_PHUB_OROM_SIZE + 1,
.read = pch_phub_bin_read,
.write = pch_phub_bin_write,
.read_new = pch_phub_bin_read,
.write_new = pch_phub_bin_write,
};

static int pch_phub_probe(struct pci_dev *pdev,
Expand Down
8 changes: 4 additions & 4 deletions drivers/misc/sram.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#define SRAM_GRANULARITY 32

static ssize_t sram_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *attr,
const struct bin_attribute *attr,
char *buf, loff_t pos, size_t count)
{
struct sram_partition *part;
Expand All @@ -38,7 +38,7 @@ static ssize_t sram_read(struct file *filp, struct kobject *kobj,
}

static ssize_t sram_write(struct file *filp, struct kobject *kobj,
struct bin_attribute *attr,
const struct bin_attribute *attr,
char *buf, loff_t pos, size_t count)
{
struct sram_partition *part;
Expand Down Expand Up @@ -83,8 +83,8 @@ static int sram_add_export(struct sram_dev *sram, struct sram_reserve *block,
return -ENOMEM;

part->battr.attr.mode = S_IRUSR | S_IWUSR;
part->battr.read = sram_read;
part->battr.write = sram_write;
part->battr.read_new = sram_read;
part->battr.write_new = sram_write;
part->battr.size = block->size;

return device_create_bin_file(sram->dev, &part->battr);
Expand Down

0 comments on commit 8d20ea1

Please sign in to comment.