From f567035a6187f1a5e7f86d4da4dbbca46cb68082 Mon Sep 17 00:00:00 2001 From: Kun Yi Date: Wed, 17 Oct 2018 15:27:09 -0700 Subject: dt-bindings: hwmon: Add adm127x documentation adm127x are hot-swap controllers that allow a circuit board to be removed from or inserted into a live backplane. This patch adds the device tree bindings documentation. Signed-off-by: Kun Yi Reviewed-by: Rob Herring Signed-off-by: Guenter Roeck --- .../devicetree/bindings/hwmon/adm1275.txt | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/adm1275.txt diff --git a/Documentation/devicetree/bindings/hwmon/adm1275.txt b/Documentation/devicetree/bindings/hwmon/adm1275.txt new file mode 100644 index 000000000000..1ecd03f3da4d --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/adm1275.txt @@ -0,0 +1,25 @@ +adm1275 properties + +Required properties: +- compatible: Must be one of the supported compatible strings: + - "adi,adm1075" for adm1075 + - "adi,adm1272" for adm1272 + - "adi,adm1275" for adm1275 + - "adi,adm1276" for adm1276 + - "adi,adm1278" for adm1278 + - "adi,adm1293" for adm1293 + - "adi,adm1294" for adm1294 +- reg: I2C address + +Optional properties: + +- shunt-resistor-micro-ohms + Shunt resistor value in micro-Ohm + +Example: + +adm1272@10 { + compatible = "adi,adm1272"; + reg = <0x10>; + shunt-resistor-micro-ohms = <500>; +}; -- cgit v1.2.3 From 6e5c06ad94115e58e4f274bdaed2618b1e39ac38 Mon Sep 17 00:00:00 2001 From: Kun Yi Date: Wed, 17 Oct 2018 15:26:39 -0700 Subject: hwmon: (adm1275) Allow setting shunt reg value The ADM series of hotswap controllers support extending the current measurement range by using a sensing resistor value other than the typical 1 mOhm. For example, using a 0.5 mOhm sensing resistor doubles the maximal current can be measured. Current driver assumes a shunt resistor value of 1 mOhm in calculation, meaning for other resistor values, hwmon will report scaled current/power measurements. This patch parses device tree parameter "shunt-resistor-micro-ohms", if there is one. Signed-off-by: Kun Yi Signed-off-by: Guenter Roeck --- Documentation/hwmon/adm1275 | 3 +++ drivers/hwmon/pmbus/adm1275.c | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Documentation/hwmon/adm1275 b/Documentation/hwmon/adm1275 index 39033538eb03..5e277b0d91ce 100644 --- a/Documentation/hwmon/adm1275 +++ b/Documentation/hwmon/adm1275 @@ -58,6 +58,9 @@ The ADM1075, unlike many other PMBus devices, does not support internal voltage or current scaling. Reported voltages, currents, and power are raw measurements, and will typically have to be scaled. +The shunt value in micro-ohms can be set via device tree at compile-time. Please +refer to the Documentation/devicetree/bindings/hwmon/adm1275.txt for bindings +if the device tree is used. Platform data support --------------------- diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c index 13600fa79e7f..f569372c9204 100644 --- a/drivers/hwmon/pmbus/adm1275.c +++ b/drivers/hwmon/pmbus/adm1275.c @@ -373,6 +373,7 @@ static int adm1275_probe(struct i2c_client *client, const struct coefficients *coefficients; int vindex = -1, voindex = -1, cindex = -1, pindex = -1; int tindex = -1; + u32 shunt; if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA @@ -421,6 +422,13 @@ static int adm1275_probe(struct i2c_client *client, if (!data) return -ENOMEM; + if (of_property_read_u32(client->dev.of_node, + "shunt-resistor-micro-ohms", &shunt)) + shunt = 1000; /* 1 mOhm if not set via DT */ + + if (shunt == 0) + return -EINVAL; + data->id = mid->driver_data; info = &data->info; @@ -654,12 +662,15 @@ static int adm1275_probe(struct i2c_client *client, info->R[PSC_VOLTAGE_OUT] = coefficients[voindex].R; } if (cindex >= 0) { - info->m[PSC_CURRENT_OUT] = coefficients[cindex].m; + /* Scale current with sense resistor value */ + info->m[PSC_CURRENT_OUT] = + coefficients[cindex].m * shunt / 1000; info->b[PSC_CURRENT_OUT] = coefficients[cindex].b; info->R[PSC_CURRENT_OUT] = coefficients[cindex].R; } if (pindex >= 0) { - info->m[PSC_POWER] = coefficients[pindex].m; + info->m[PSC_POWER] = + coefficients[pindex].m * shunt / 1000; info->b[PSC_POWER] = coefficients[pindex].b; info->R[PSC_POWER] = coefficients[pindex].R; } -- cgit v1.2.3 From 3b443def46cc730c0ba590c5692d085b80a8659c Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Sat, 27 Oct 2018 00:30:59 +0200 Subject: hwmon: (core) remove redundant cast struct attribute::name which this local variable name is eventually assigned to is "const char*", and so is the template parameter. We might as well preserve the constness all the way through. Signed-off-by: Rasmus Villemoes Signed-off-by: Guenter Roeck --- drivers/hwmon/hwmon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index 84f61cec6319..36ed50d4b276 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -267,7 +267,7 @@ static struct attribute *hwmon_genattr(struct device *dev, struct device_attribute *dattr; struct attribute *a; umode_t mode; - char *name; + const char *name; bool is_string = is_string_attr(type, attr); /* The attribute is invisible if there is no template string */ @@ -289,7 +289,7 @@ static struct attribute *hwmon_genattr(struct device *dev, return ERR_PTR(-ENOMEM); if (type == hwmon_chip) { - name = (char *)template; + name = template; } else { scnprintf(hattr->name, sizeof(hattr->name), template, index + hwmon_attr_base(type)); -- cgit v1.2.3 From f1af93216c3460873e0ff46f17951eac4c066d79 Mon Sep 17 00:00:00 2001 From: Chris Packham Date: Wed, 31 Oct 2018 09:25:27 +1300 Subject: hwmon: (adt7475) document mapping of sysfs entries to inputs As per the usual standard with hwmon drivers the mapping to sysfs entries follows the register map of the device e.g. in0_input corresponds to the register 0x20, in1_input corresponds to 0x21 etc. Hardware designers tend to work with input pins instead of registers which is where things start to get confusing. A hardware designer might say "the 1.5V rail is connected to the VCCP pin" leaving the software designer none the wiser as to which of the sysfs entries should be associated with the label "1.5V". Try to bridge the gap by documenting the mapping of sysfs entries to the corresponding pins. This should allow someone to create a configuration file or other mapping without needing to dive into the code and ADT datasheets. Signed-off-by: Chris Packham Signed-off-by: Guenter Roeck --- Documentation/hwmon/adt7475 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/hwmon/adt7475 b/Documentation/hwmon/adt7475 index 09d73a10644c..01b46b290532 100644 --- a/Documentation/hwmon/adt7475 +++ b/Documentation/hwmon/adt7475 @@ -79,6 +79,18 @@ ADT7490: * 2 GPIO pins (not implemented) * system acoustics optimizations (not implemented) +Sysfs Mapping +------------- + + ADT7490 ADT7476 ADT7475 ADT7473 + ------- ------- ------- ------- +in0 2.5VIN (22) 2.5VIN (22) - - +in1 VCCP (23) VCCP (23) VCCP (14) VCCP (14) +in2 VCC (4) VCC (4) VCC (4) VCC (3) +in3 5VIN (20) 5VIN (20) +in4 12VIN (21) 12VIN (21) +in5 VTT (8) + Special Features ---------------- -- cgit v1.2.3 From 6021c48f3acd68301eacd99ff5dd4744f7b2f288 Mon Sep 17 00:00:00 2001 From: Eddie James Date: Thu, 8 Nov 2018 15:05:20 -0600 Subject: dt-bindings: fsi: Add P9 OCC device documentation Document the bindings for the FSI-attached POWER9 On-Chip Controller. Signed-off-by: Eddie James Signed-off-by: Guenter Roeck --- Documentation/devicetree/bindings/fsi/ibm,p9-occ.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Documentation/devicetree/bindings/fsi/ibm,p9-occ.txt diff --git a/Documentation/devicetree/bindings/fsi/ibm,p9-occ.txt b/Documentation/devicetree/bindings/fsi/ibm,p9-occ.txt new file mode 100644 index 000000000000..99ca9862a586 --- /dev/null +++ b/Documentation/devicetree/bindings/fsi/ibm,p9-occ.txt @@ -0,0 +1,16 @@ +Device-tree bindings for FSI-attached POWER9 On-Chip Controller (OCC) +--------------------------------------------------------------------- + +This is the binding for the P9 On-Chip Controller accessed over FSI from a +service processor. See fsi.txt for details on bindings for FSI slave and CFAM +nodes. The OCC is not an FSI slave device itself, rather it is accessed +through the SBE fifo. + +Required properties: + - compatible = "ibm,p9-occ" + +Examples: + + occ { + compatible = "ibm,p9-occ"; + }; -- cgit v1.2.3 From 7ed98dddb764eebf2783881a17dc4980181a6e1a Mon Sep 17 00:00:00 2001 From: Eddie James Date: Thu, 8 Nov 2018 15:05:21 -0600 Subject: fsi: Add On-Chip Controller (OCC) driver The OCC is a device embedded on a POWER processor that collects and aggregates sensor data from the processor and system. The OCC can provide the raw sensor data as well as perform thermal and power management on the system. This driver provides an atomic communications channel between a service processor (e.g. a BMC) and the OCC. The driver is dependent on the FSI SBEFIFO driver to get hardware access through the SBE to the OCC SRAM. Commands are issued to the SBE to send or fetch data to the SRAM. Signed-off-by: Eddie James Signed-off-by: Andrew Jeffery Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Joel Stanley Signed-off-by: Guenter Roeck --- drivers/fsi/Kconfig | 10 + drivers/fsi/Makefile | 1 + drivers/fsi/fsi-occ.c | 599 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/fsi-occ.h | 25 ++ 4 files changed, 635 insertions(+) create mode 100644 drivers/fsi/fsi-occ.c create mode 100644 include/linux/fsi-occ.h diff --git a/drivers/fsi/Kconfig b/drivers/fsi/Kconfig index 99c99a5d57fe..5cc20f3c3fd6 100644 --- a/drivers/fsi/Kconfig +++ b/drivers/fsi/Kconfig @@ -65,4 +65,14 @@ config FSI_SBEFIFO a pipe-like FSI device for communicating with the self boot engine (SBE) on POWER processors. +config FSI_OCC + tristate "OCC SBEFIFO client device driver" + depends on FSI_SBEFIFO + ---help--- + This option enables an SBEFIFO based On-Chip Controller (OCC) device + driver. The OCC is a device embedded on a POWER processor that collects + and aggregates sensor data from the processor and system. The OCC can + provide the raw sensor data as well as perform thermal and power + management on the system. + endif diff --git a/drivers/fsi/Makefile b/drivers/fsi/Makefile index a50d6ce22fb3..62687ec86d2e 100644 --- a/drivers/fsi/Makefile +++ b/drivers/fsi/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_FSI_MASTER_GPIO) += fsi-master-gpio.o obj-$(CONFIG_FSI_MASTER_AST_CF) += fsi-master-ast-cf.o obj-$(CONFIG_FSI_SCOM) += fsi-scom.o obj-$(CONFIG_FSI_SBEFIFO) += fsi-sbefifo.o +obj-$(CONFIG_FSI_OCC) += fsi-occ.o diff --git a/drivers/fsi/fsi-occ.c b/drivers/fsi/fsi-occ.c new file mode 100644 index 000000000000..a2301cea1cbb --- /dev/null +++ b/drivers/fsi/fsi-occ.c @@ -0,0 +1,599 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define OCC_SRAM_BYTES 4096 +#define OCC_CMD_DATA_BYTES 4090 +#define OCC_RESP_DATA_BYTES 4089 + +#define OCC_SRAM_CMD_ADDR 0xFFFBE000 +#define OCC_SRAM_RSP_ADDR 0xFFFBF000 + +/* + * Assume we don't have much FFDC, if we do we'll overflow and + * fail the command. This needs to be big enough for simple + * commands as well. + */ +#define OCC_SBE_STATUS_WORDS 32 + +#define OCC_TIMEOUT_MS 1000 +#define OCC_CMD_IN_PRG_WAIT_MS 50 + +struct occ { + struct device *dev; + struct device *sbefifo; + char name[32]; + int idx; + struct miscdevice mdev; + struct mutex occ_lock; +}; + +#define to_occ(x) container_of((x), struct occ, mdev) + +struct occ_response { + u8 seq_no; + u8 cmd_type; + u8 return_status; + __be16 data_length; + u8 data[OCC_RESP_DATA_BYTES + 2]; /* two bytes checksum */ +} __packed; + +struct occ_client { + struct occ *occ; + struct mutex lock; + size_t data_size; + size_t read_offset; + u8 *buffer; +}; + +#define to_client(x) container_of((x), struct occ_client, xfr) + +static DEFINE_IDA(occ_ida); + +static int occ_open(struct inode *inode, struct file *file) +{ + struct occ_client *client = kzalloc(sizeof(*client), GFP_KERNEL); + struct miscdevice *mdev = file->private_data; + struct occ *occ = to_occ(mdev); + + if (!client) + return -ENOMEM; + + client->buffer = (u8 *)__get_free_page(GFP_KERNEL); + if (!client->buffer) { + kfree(client); + return -ENOMEM; + } + + client->occ = occ; + mutex_init(&client->lock); + file->private_data = client; + + /* We allocate a 1-page buffer, make sure it all fits */ + BUILD_BUG_ON((OCC_CMD_DATA_BYTES + 3) > PAGE_SIZE); + BUILD_BUG_ON((OCC_RESP_DATA_BYTES + 7) > PAGE_SIZE); + + return 0; +} + +static ssize_t occ_read(struct file *file, char __user *buf, size_t len, + loff_t *offset) +{ + struct occ_client *client = file->private_data; + ssize_t rc = 0; + + if (!client) + return -ENODEV; + + if (len > OCC_SRAM_BYTES) + return -EINVAL; + + mutex_lock(&client->lock); + + /* This should not be possible ... */ + if (WARN_ON_ONCE(client->read_offset > client->data_size)) { + rc = -EIO; + goto done; + } + + /* Grab how much data we have to read */ + rc = min(len, client->data_size - client->read_offset); + if (copy_to_user(buf, client->buffer + client->read_offset, rc)) + rc = -EFAULT; + else + client->read_offset += rc; + + done: + mutex_unlock(&client->lock); + + return rc; +} + +static ssize_t occ_write(struct file *file, const char __user *buf, + size_t len, loff_t *offset) +{ + struct occ_client *client = file->private_data; + size_t rlen, data_length; + u16 checksum = 0; + ssize_t rc, i; + u8 *cmd; + + if (!client) + return -ENODEV; + + if (len > (OCC_CMD_DATA_BYTES + 3) || len < 3) + return -EINVAL; + + mutex_lock(&client->lock); + + /* Construct the command */ + cmd = client->buffer; + + /* Sequence number (we could increment and compare with response) */ + cmd[0] = 1; + + /* + * Copy the user command (assume user data follows the occ command + * format) + * byte 0: command type + * bytes 1-2: data length (msb first) + * bytes 3-n: data + */ + if (copy_from_user(&cmd[1], buf, len)) { + rc = -EFAULT; + goto done; + } + + /* Extract data length */ + data_length = (cmd[2] << 8) + cmd[3]; + if (data_length > OCC_CMD_DATA_BYTES) { + rc = -EINVAL; + goto done; + } + + /* Calculate checksum */ + for (i = 0; i < data_length + 4; ++i) + checksum += cmd[i]; + + cmd[data_length + 4] = checksum >> 8; + cmd[data_length + 5] = checksum & 0xFF; + + /* Submit command */ + rlen = PAGE_SIZE; + rc = fsi_occ_submit(client->occ->dev, cmd, data_length + 6, cmd, + &rlen); + if (rc) + goto done; + + /* Set read tracking data */ + client->data_size = rlen; + client->read_offset = 0; + + /* Done */ + rc = len; + + done: + mutex_unlock(&client->lock); + + return rc; +} + +static int occ_release(struct inode *inode, struct file *file) +{ + struct occ_client *client = file->private_data; + + free_page((unsigned long)client->buffer); + kfree(client); + + return 0; +} + +static const struct file_operations occ_fops = { + .owner = THIS_MODULE, + .open = occ_open, + .read = occ_read, + .write = occ_write, + .release = occ_release, +}; + +static int occ_verify_checksum(struct occ_response *resp, u16 data_length) +{ + /* Fetch the two bytes after the data for the checksum. */ + u16 checksum_resp = get_unaligned_be16(&resp->data[data_length]); + u16 checksum; + u16 i; + + checksum = resp->seq_no; + checksum += resp->cmd_type; + checksum += resp->return_status; + checksum += (data_length >> 8) + (data_length & 0xFF); + + for (i = 0; i < data_length; ++i) + checksum += resp->data[i]; + + if (checksum != checksum_resp) + return -EBADMSG; + + return 0; +} + +static int occ_getsram(struct occ *occ, u32 address, void *data, ssize_t len) +{ + u32 data_len = ((len + 7) / 8) * 8; /* must be multiples of 8 B */ + size_t resp_len, resp_data_len; + __be32 *resp, cmd[5]; + int rc; + + /* + * Magic sequence to do SBE getsram command. SBE will fetch data from + * specified SRAM address. + */ + cmd[0] = cpu_to_be32(0x5); + cmd[1] = cpu_to_be32(SBEFIFO_CMD_GET_OCC_SRAM); + cmd[2] = cpu_to_be32(1); + cmd[3] = cpu_to_be32(address); + cmd[4] = cpu_to_be32(data_len); + + resp_len = (data_len >> 2) + OCC_SBE_STATUS_WORDS; + resp = kzalloc(resp_len << 2, GFP_KERNEL); + if (!resp) + return -ENOMEM; + + rc = sbefifo_submit(occ->sbefifo, cmd, 5, resp, &resp_len); + if (rc) + goto free; + + rc = sbefifo_parse_status(occ->sbefifo, SBEFIFO_CMD_GET_OCC_SRAM, + resp, resp_len, &resp_len); + if (rc) + goto free; + + resp_data_len = be32_to_cpu(resp[resp_len - 1]); + if (resp_data_len != data_len) { + dev_err(occ->dev, "SRAM read expected %d bytes got %zd\n", + data_len, resp_data_len); + rc = -EBADMSG; + } else { + memcpy(data, resp, len); + } + +free: + /* Convert positive SBEI status */ + if (rc > 0) { + dev_err(occ->dev, "SRAM read returned failure status: %08x\n", + rc); + rc = -EBADMSG; + } + + kfree(resp); + return rc; +} + +static int occ_putsram(struct occ *occ, u32 address, const void *data, + ssize_t len) +{ + size_t cmd_len, buf_len, resp_len, resp_data_len; + u32 data_len = ((len + 7) / 8) * 8; /* must be multiples of 8 B */ + __be32 *buf; + int rc; + + /* + * We use the same buffer for command and response, make + * sure it's big enough + */ + resp_len = OCC_SBE_STATUS_WORDS; + cmd_len = (data_len >> 2) + 5; + buf_len = max(cmd_len, resp_len); + buf = kzalloc(buf_len << 2, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + /* + * Magic sequence to do SBE putsram command. SBE will transfer + * data to specified SRAM address. + */ + buf[0] = cpu_to_be32(cmd_len); + buf[1] = cpu_to_be32(SBEFIFO_CMD_PUT_OCC_SRAM); + buf[2] = cpu_to_be32(1); + buf[3] = cpu_to_be32(address); + buf[4] = cpu_to_be32(data_len); + + memcpy(&buf[5], data, len); + + rc = sbefifo_submit(occ->sbefifo, buf, cmd_len, buf, &resp_len); + if (rc) + goto free; + + rc = sbefifo_parse_status(occ->sbefifo, SBEFIFO_CMD_PUT_OCC_SRAM, + buf, resp_len, &resp_len); + if (rc) + goto free; + + if (resp_len != 1) { + dev_err(occ->dev, "SRAM write response length invalid: %zd\n", + resp_len); + rc = -EBADMSG; + } else { + resp_data_len = be32_to_cpu(buf[0]); + if (resp_data_len != data_len) { + dev_err(occ->dev, + "SRAM write expected %d bytes got %zd\n", + data_len, resp_data_len); + rc = -EBADMSG; + } + } + +free: + /* Convert positive SBEI status */ + if (rc > 0) { + dev_err(occ->dev, "SRAM write returned failure status: %08x\n", + rc); + rc = -EBADMSG; + } + + kfree(buf); + return rc; +} + +static int occ_trigger_attn(struct occ *occ) +{ + __be32 buf[OCC_SBE_STATUS_WORDS]; + size_t resp_len, resp_data_len; + int rc; + + BUILD_BUG_ON(OCC_SBE_STATUS_WORDS < 7); + resp_len = OCC_SBE_STATUS_WORDS; + + buf[0] = cpu_to_be32(0x5 + 0x2); /* Chip-op length in words */ + buf[1] = cpu_to_be32(SBEFIFO_CMD_PUT_OCC_SRAM); + buf[2] = cpu_to_be32(0x3); /* Mode: Circular */ + buf[3] = cpu_to_be32(0x0); /* Address: ignore in mode 3 */ + buf[4] = cpu_to_be32(0x8); /* Data length in bytes */ + buf[5] = cpu_to_be32(0x20010000); /* Trigger OCC attention */ + buf[6] = 0; + + rc = sbefifo_submit(occ->sbefifo, buf, 7, buf, &resp_len); + if (rc) + goto error; + + rc = sbefifo_parse_status(occ->sbefifo, SBEFIFO_CMD_PUT_OCC_SRAM, + buf, resp_len, &resp_len); + if (rc) + goto error; + + if (resp_len != 1) { + dev_err(occ->dev, "SRAM attn response length invalid: %zd\n", + resp_len); + rc = -EBADMSG; + } else { + resp_data_len = be32_to_cpu(buf[0]); + if (resp_data_len != 8) { + dev_err(occ->dev, + "SRAM attn expected 8 bytes got %zd\n", + resp_data_len); + rc = -EBADMSG; + } + } + + error: + /* Convert positive SBEI status */ + if (rc > 0) { + dev_err(occ->dev, "SRAM attn returned failure status: %08x\n", + rc); + rc = -EBADMSG; + } + + return rc; +} + +int fsi_occ_submit(struct device *dev, const void *request, size_t req_len, + void *response, size_t *resp_len) +{ + const unsigned long timeout = msecs_to_jiffies(OCC_TIMEOUT_MS); + const unsigned long wait_time = + msecs_to_jiffies(OCC_CMD_IN_PRG_WAIT_MS); + struct occ *occ = dev_get_drvdata(dev); + struct occ_response *resp = response; + u16 resp_data_length; + unsigned long start; + int rc; + + if (!occ) + return -ENODEV; + + if (*resp_len < 7) { + dev_dbg(dev, "Bad resplen %zd\n", *resp_len); + return -EINVAL; + } + + mutex_lock(&occ->occ_lock); + + rc = occ_putsram(occ, OCC_SRAM_CMD_ADDR, request, req_len); + if (rc) + goto done; + + rc = occ_trigger_attn(occ); + if (rc) + goto done; + + /* Read occ response header */ + start = jiffies; + do { + rc = occ_getsram(occ, OCC_SRAM_RSP_ADDR, resp, 8); + if (rc) + goto done; + + if (resp->return_status == OCC_RESP_CMD_IN_PRG) { + rc = -ETIMEDOUT; + + if (time_after(jiffies, start + timeout)) + break; + + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(wait_time); + } + } while (rc); + + /* Extract size of response data */ + resp_data_length = get_unaligned_be16(&resp->data_length); + + /* Message size is data length + 5 bytes header + 2 bytes checksum */ + if ((resp_data_length + 7) > *resp_len) { + rc = -EMSGSIZE; + goto done; + } + + dev_dbg(dev, "resp_status=%02x resp_data_len=%d\n", + resp->return_status, resp_data_length); + + /* Grab the rest */ + if (resp_data_length > 1) { + /* already got 3 bytes resp, also need 2 bytes checksum */ + rc = occ_getsram(occ, OCC_SRAM_RSP_ADDR + 8, + &resp->data[3], resp_data_length - 1); + if (rc) + goto done; + } + + *resp_len = resp_data_length + 7; + rc = occ_verify_checksum(resp, resp_data_length); + + done: + mutex_unlock(&occ->occ_lock); + + return rc; +} +EXPORT_SYMBOL_GPL(fsi_occ_submit); + +static int occ_unregister_child(struct device *dev, void *data) +{ + struct platform_device *hwmon_dev = to_platform_device(dev); + + platform_device_unregister(hwmon_dev); + + return 0; +} + +static int occ_probe(struct platform_device *pdev) +{ + int rc; + u32 reg; + struct occ *occ; + struct platform_device *hwmon_dev; + struct device *dev = &pdev->dev; + struct platform_device_info hwmon_dev_info = { + .parent = dev, + .name = "occ-hwmon", + }; + + occ = devm_kzalloc(dev, sizeof(*occ), GFP_KERNEL); + if (!occ) + return -ENOMEM; + + occ->dev = dev; + occ->sbefifo = dev->parent; + mutex_init(&occ->occ_lock); + + if (dev->of_node) { + rc = of_property_read_u32(dev->of_node, "reg", ®); + if (!rc) { + /* make sure we don't have a duplicate from dts */ + occ->idx = ida_simple_get(&occ_ida, reg, reg + 1, + GFP_KERNEL); + if (occ->idx < 0) + occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX, + GFP_KERNEL); + } else { + occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX, + GFP_KERNEL); + } + } else { + occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX, GFP_KERNEL); + } + + platform_set_drvdata(pdev, occ); + + snprintf(occ->name, sizeof(occ->name), "occ%d", occ->idx); + occ->mdev.fops = &occ_fops; + occ->mdev.minor = MISC_DYNAMIC_MINOR; + occ->mdev.name = occ->name; + occ->mdev.parent = dev; + + rc = misc_register(&occ->mdev); + if (rc) { + dev_err(dev, "failed to register miscdevice: %d\n", rc); + ida_simple_remove(&occ_ida, occ->idx); + return rc; + } + + hwmon_dev_info.id = occ->idx; + hwmon_dev = platform_device_register_full(&hwmon_dev_info); + if (!hwmon_dev) + dev_warn(dev, "failed to create hwmon device\n"); + + return 0; +} + +static int occ_remove(struct platform_device *pdev) +{ + struct occ *occ = platform_get_drvdata(pdev); + + misc_deregister(&occ->mdev); + + device_for_each_child(&pdev->dev, NULL, occ_unregister_child); + + ida_simple_remove(&occ_ida, occ->idx); + + return 0; +} + +static const struct of_device_id occ_match[] = { + { .compatible = "ibm,p9-occ" }, + { }, +}; + +static struct platform_driver occ_driver = { + .driver = { + .name = "occ", + .of_match_table = occ_match, + }, + .probe = occ_probe, + .remove = occ_remove, +}; + +static int occ_init(void) +{ + return platform_driver_register(&occ_driver); +} + +static void occ_exit(void) +{ + platform_driver_unregister(&occ_driver); + + ida_destroy(&occ_ida); +} + +module_init(occ_init); +module_exit(occ_exit); + +MODULE_AUTHOR("Eddie James "); +MODULE_DESCRIPTION("BMC P9 OCC driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/fsi-occ.h b/include/linux/fsi-occ.h new file mode 100644 index 000000000000..d4cdc2aa6e33 --- /dev/null +++ b/include/linux/fsi-occ.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0 + +#ifndef LINUX_FSI_OCC_H +#define LINUX_FSI_OCC_H + +struct device; + +#define OCC_RESP_CMD_IN_PRG 0xFF +#define OCC_RESP_SUCCESS 0 +#define OCC_RESP_CMD_INVAL 0x11 +#define OCC_RESP_CMD_LEN_INVAL 0x12 +#define OCC_RESP_DATA_INVAL 0x13 +#define OCC_RESP_CHKSUM_ERR 0x14 +#define OCC_RESP_INT_ERR 0x15 +#define OCC_RESP_BAD_STATE 0x16 +#define OCC_RESP_CRIT_EXCEPT 0xE0 +#define OCC_RESP_CRIT_INIT 0xE1 +#define OCC_RESP_CRIT_WATCHDOG 0xE2 +#define OCC_RESP_CRIT_OCB 0xE3 +#define OCC_RESP_CRIT_HW 0xE4 + +int fsi_occ_submit(struct device *dev, const void *request, size_t req_len, + void *response, size_t *resp_len); + +#endif /* LINUX_FSI_OCC_H */ -- cgit v1.2.3 From cd261c9832a4349a1432afd8747ac15cd1c4d3b0 Mon Sep 17 00:00:00 2001 From: Eddie James Date: Thu, 8 Nov 2018 15:05:22 -0600 Subject: Documentation: hwmon: Add OCC documentation Document the hwmon interface for the OCC. Signed-off-by: Eddie James Signed-off-by: Guenter Roeck --- Documentation/hwmon/occ | 112 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 Documentation/hwmon/occ diff --git a/Documentation/hwmon/occ b/Documentation/hwmon/occ new file mode 100644 index 000000000000..e787596e03fe --- /dev/null +++ b/Documentation/hwmon/occ @@ -0,0 +1,112 @@ +Kernel driver occ-hwmon +======================= + +Supported chips: + * POWER8 + * POWER9 + +Author: Eddie James + +Description +----------- + +This driver supports hardware monitoring for the On-Chip Controller (OCC) +embedded on POWER processors. The OCC is a device that collects and aggregates +sensor data from the processor and the system. The OCC can provide the raw +sensor data as well as perform thermal and power management on the system. + +The P8 version of this driver is a client driver of I2C. It may be probed +manually if an "ibm,p8-occ-hwmon" compatible device is found under the +appropriate I2C bus node in the device-tree. + +The P9 version of this driver is a client driver of the FSI-based OCC driver. +It will be probed automatically by the FSI-based OCC driver. + +Sysfs entries +------------- + +The following attributes are supported. All attributes are read-only unless +specified. + +The OCC sensor ID is an integer that represents the unique identifier of the +sensor with respect to the OCC. For example, a temperature sensor for the third +DIMM slot in the system may have a sensor ID of 7. This mapping is unavailable +to the device driver, which must therefore export the sensor ID as-is. + +Some entries are only present with certain OCC sensor versions or only on +certain OCCs in the system. The version number is not exported to the user +but can be inferred. + +temp[1-n]_label OCC sensor ID. +[with temperature sensor version 1] + temp[1-n]_input Measured temperature of the component in millidegrees + Celsius. +[with temperature sensor version >= 2] + temp[1-n]_type The FRU (Field Replaceable Unit) type + (represented by an integer) for the component + that this sensor measures. + temp[1-n]_fault Temperature sensor fault boolean; 1 to indicate + that a fault is present or 0 to indicate that + no fault is present. + [with type == 3 (FRU type is VRM)] + temp[1-n]_alarm VRM temperature alarm boolean; 1 to indicate + alarm, 0 to indicate no alarm + [else] + temp[1-n]_input Measured temperature of the component in + millidegrees Celsius. + +freq[1-n]_label OCC sensor ID. +freq[1-n]_input Measured frequency of the component in MHz. + +power[1-n]_input Latest measured power reading of the component in + microwatts. +power[1-n]_average Average power of the component in microwatts. +power[1-n]_average_interval The amount of time over which the power average + was taken in microseconds. +[with power sensor version < 2] + power[1-n]_label OCC sensor ID. +[with power sensor version >= 2] + power[1-n]_label OCC sensor ID + function ID + channel in the form + of a string, delimited by underscores, i.e. "0_15_1". + Both the function ID and channel are integers that + further identify the power sensor. +[with power sensor version 0xa0] + power[1-n]_label OCC sensor ID + sensor type in the form of a string, + delimited by an underscore, i.e. "0_system". Sensor + type will be one of "system", "proc", "vdd" or "vdn". + For this sensor version, OCC sensor ID will be the same + for all power sensors. +[present only on "master" OCC; represents the whole system power; only one of + this type of power sensor will be present] + power[1-n]_label "system" + power[1-n]_input Latest system output power in microwatts. + power[1-n]_cap Current system power cap in microwatts. + power[1-n]_cap_not_redundant System power cap in microwatts when + there is not redundant power. + power[1-n]_cap_max Maximum power cap that the OCC can enforce in + microwatts. + power[1-n]_cap_min Minimum power cap that the OCC can enforce in + microwatts. + power[1-n]_cap_user The power cap set by the user, in microwatts. + This attribute will return 0 if no user power + cap has been set. This attribute is read-write, + but writing any precision below watts will be + ignored, i.e. requesting a power cap of + 500900000 microwatts will result in a power cap + request of 500 watts. + [with caps sensor version > 1] + power[1-n]_cap_user_source Indicates how the user power cap was + set. This is an integer that maps to + system or firmware components that can + set the user power cap. + +The following "extn" sensors are exported as a way for the OCC to provide data +that doesn't fit anywhere else. The meaning of these sensors is entirely +dependent on their data, and cannot be statically defined. + +extn[1-n]_label ASCII ID or OCC sensor ID. +extn[1-n]_flags This is one byte hexadecimal value. Bit 7 indicates the + type of the label attribute; 1 for sensor ID, 0 for + ASCII ID. Other bits are reserved. +extn[1-n]_input 6 bytes of hexadecimal data, with a meaning defined by + the sensor ID. -- cgit v1.2.3 From c0c9872a8ba291fc39fdb62652c24418670ccc46 Mon Sep 17 00:00:00 2001 From: Eddie James Date: Thu, 8 Nov 2018 15:05:23 -0600 Subject: dt-bindings: i2c: Add P8 OCC hwmon device documentation Document the bindings for I2C-based OCC hwmon device. Signed-off-by: Eddie James Acked-by: Rob Herring Signed-off-by: Guenter Roeck --- .../devicetree/bindings/i2c/ibm,p8-occ-hwmon.txt | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/ibm,p8-occ-hwmon.txt diff --git a/Documentation/devicetree/bindings/i2c/ibm,p8-occ-hwmon.txt b/Documentation/devicetree/bindings/i2c/ibm,p8-occ-hwmon.txt new file mode 100644 index 000000000000..5dc5d2e2573d --- /dev/null +++ b/Documentation/devicetree/bindings/i2c/ibm,p8-occ-hwmon.txt @@ -0,0 +1,25 @@ +Device-tree bindings for I2C-based On-Chip Controller hwmon device +------------------------------------------------------------------ + +Required properties: + - compatible = "ibm,p8-occ-hwmon"; + - reg = ; : I2C bus address + +Examples: + + i2c-bus@100 { + #address-cells = <1>; + #size-cells = <0>; + clock-frequency = <100000>; + < more properties > + + occ-hwmon@1 { + compatible = "ibm,p8-occ-hwmon"; + reg = <0x50>; + }; + + occ-hwmon@2 { + compatible = "ibm,p8-occ-hwmon"; + reg = <0x51>; + }; + }; -- cgit v1.2.3 From 5b5513b8800291226a8fa63fd22a14cc235b313e Mon Sep 17 00:00:00 2001 From: Eddie James Date: Thu, 8 Nov 2018 15:05:24 -0600 Subject: hwmon: Add On-Chip Controller (OCC) hwmon driver The OCC is a device embedded on a POWER processor that collects and aggregates sensor data from the processor and system. The OCC can provide the raw sensor data as well as perform thermal and power management on the system. This driver provides a hwmon interface to the OCC from a service processor (e.g. a BMC). The driver supports both POWER8 and POWER9 OCCs. Communications with the POWER8 OCC are established over standard I2C bus. The driver communicates with the POWER9 OCC through the FSI-based OCC driver, which handles the lower-level communication details. This patch lays out the structure of the OCC hwmon driver. There are two platform drivers, one each for P8 and P9 OCCs. These are probed through the I2C tree and the FSI-based OCC driver, respectively. The patch also defines the first common structures and methods between the two OCC versions. Signed-off-by: Eddie James [groeck: Fix up SPDX license identifier] Signed-off-by: Guenter Roeck --- drivers/hwmon/Kconfig | 2 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/occ/Kconfig | 31 +++++++++++++++++++++ drivers/hwmon/occ/Makefile | 5 ++++ drivers/hwmon/occ/common.c | 40 +++++++++++++++++++++++++++ drivers/hwmon/occ/common.h | 34 +++++++++++++++++++++++ drivers/hwmon/occ/p8_i2c.c | 61 +++++++++++++++++++++++++++++++++++++++++ drivers/hwmon/occ/p9_sbe.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 242 insertions(+) create mode 100644 drivers/hwmon/occ/Kconfig create mode 100644 drivers/hwmon/occ/Makefile create mode 100644 drivers/hwmon/occ/common.c create mode 100644 drivers/hwmon/occ/common.h create mode 100644 drivers/hwmon/occ/p8_i2c.c create mode 100644 drivers/hwmon/occ/p9_sbe.c diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 81da17a42dc9..e3bef55451ae 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1293,6 +1293,8 @@ config SENSORS_NSA320 This driver can also be built as a module. If so, the module will be called nsa320-hwmon. +source "drivers/hwmon/occ/Kconfig" + config SENSORS_PCF8591 tristate "Philips PCF8591 ADC/DAC" depends on I2C diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 93f7f41ea4ad..f5c7b442e69e 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -178,6 +178,7 @@ obj-$(CONFIG_SENSORS_WM831X) += wm831x-hwmon.o obj-$(CONFIG_SENSORS_WM8350) += wm8350-hwmon.o obj-$(CONFIG_SENSORS_XGENE) += xgene-hwmon.o +obj-$(CONFIG_SENSORS_OCC) += occ/ obj-$(CONFIG_PMBUS) += pmbus/ ccflags-$(CONFIG_HWMON_DEBUG_CHIP) := -DDEBUG diff --git a/drivers/hwmon/occ/Kconfig b/drivers/hwmon/occ/Kconfig new file mode 100644 index 000000000000..66686628fb53 --- /dev/null +++ b/drivers/hwmon/occ/Kconfig @@ -0,0 +1,31 @@ +# +# On-Chip Controller configuration +# + +config SENSORS_OCC_P8_I2C + tristate "POWER8 OCC through I2C" + depends on I2C + select SENSORS_OCC + help + This option enables support for monitoring sensors provided by the + On-Chip Controller (OCC) on a POWER8 processor. Communications with + the OCC are established through I2C bus. + + This driver can also be built as a module. If so, the module will be + called occ-p8-hwmon. + +config SENSORS_OCC_P9_SBE + tristate "POWER9 OCC through SBE" + depends on FSI_OCC + select SENSORS_OCC + help + This option enables support for monitoring sensors provided by the + On-Chip Controller (OCC) on a POWER9 processor. Communications with + the OCC are established through SBE fifo on an FSI bus. + + This driver can also be built as a module. If so, the module will be + called occ-p9-hwmon. + +config SENSORS_OCC + bool "POWER On-Chip Controller" + depends on SENSORS_OCC_P8_I2C || SENSORS_OCC_P9_SBE diff --git a/drivers/hwmon/occ/Makefile b/drivers/hwmon/occ/Makefile new file mode 100644 index 000000000000..57c0e911005b --- /dev/null +++ b/drivers/hwmon/occ/Makefile @@ -0,0 +1,5 @@ +occ-p8-hwmon-objs := common.o p8_i2c.o +occ-p9-hwmon-objs := common.o p9_sbe.o + +obj-$(CONFIG_SENSORS_OCC_P8_I2C) += occ-p8-hwmon.o +obj-$(CONFIG_SENSORS_OCC_P9_SBE) += occ-p9-hwmon.o diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c new file mode 100644 index 000000000000..81acd4b5020d --- /dev/null +++ b/drivers/hwmon/occ/common.c @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include + +#include "common.h" + +static int occ_poll(struct occ *occ) +{ + u16 checksum = occ->poll_cmd_data + 1; + u8 cmd[8]; + + /* big endian */ + cmd[0] = 0; /* sequence number */ + cmd[1] = 0; /* cmd type */ + cmd[2] = 0; /* data length msb */ + cmd[3] = 1; /* data length lsb */ + cmd[4] = occ->poll_cmd_data; /* data */ + cmd[5] = checksum >> 8; /* checksum msb */ + cmd[6] = checksum & 0xFF; /* checksum lsb */ + cmd[7] = 0; + + return occ->send_cmd(occ, cmd); +} + +int occ_setup(struct occ *occ, const char *name) +{ + int rc; + + rc = occ_poll(occ); + if (rc == -ESHUTDOWN) { + dev_info(occ->bus_dev, "host is not ready\n"); + return rc; + } else if (rc < 0) { + dev_err(occ->bus_dev, "failed to get OCC poll response: %d\n", + rc); + return rc; + } + + return 0; +} diff --git a/drivers/hwmon/occ/common.h b/drivers/hwmon/occ/common.h new file mode 100644 index 000000000000..0602196d6704 --- /dev/null +++ b/drivers/hwmon/occ/common.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef OCC_COMMON_H +#define OCC_COMMON_H + +struct device; + +#define OCC_RESP_DATA_BYTES 4089 + +/* + * Same response format for all OCC versions. + * Allocate the largest possible response. + */ +struct occ_response { + u8 seq_no; + u8 cmd_type; + u8 return_status; + __be16 data_length; + u8 data[OCC_RESP_DATA_BYTES]; + __be16 checksum; +} __packed; + +struct occ { + struct device *bus_dev; + + struct occ_response resp; + + u8 poll_cmd_data; /* to perform OCC poll command */ + int (*send_cmd)(struct occ *occ, u8 *cmd); +}; + +int occ_setup(struct occ *occ, const char *name); + +#endif /* OCC_COMMON_H */ diff --git a/drivers/hwmon/occ/p8_i2c.c b/drivers/hwmon/occ/p8_i2c.c new file mode 100644 index 000000000000..4f3937dec480 --- /dev/null +++ b/drivers/hwmon/occ/p8_i2c.c @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include +#include + +#include "common.h" + +struct p8_i2c_occ { + struct occ occ; + struct i2c_client *client; +}; + +#define to_p8_i2c_occ(x) container_of((x), struct p8_i2c_occ, occ) + +static int p8_i2c_occ_send_cmd(struct occ *occ, u8 *cmd) +{ + return -EOPNOTSUPP; +} + +static int p8_i2c_occ_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct occ *occ; + struct p8_i2c_occ *ctx = devm_kzalloc(&client->dev, sizeof(*ctx), + GFP_KERNEL); + if (!ctx) + return -ENOMEM; + + ctx->client = client; + occ = &ctx->occ; + occ->bus_dev = &client->dev; + dev_set_drvdata(&client->dev, occ); + + occ->poll_cmd_data = 0x10; /* P8 OCC poll data */ + occ->send_cmd = p8_i2c_occ_send_cmd; + + return occ_setup(occ, "p8_occ"); +} + +static const struct of_device_id p8_i2c_occ_of_match[] = { + { .compatible = "ibm,p8-occ-hwmon" }, + {} +}; +MODULE_DEVICE_TABLE(of, p8_i2c_occ_of_match); + +static struct i2c_driver p8_i2c_occ_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "occ-hwmon", + .of_match_table = p8_i2c_occ_of_match, + }, + .probe = p8_i2c_occ_probe, +}; + +module_i2c_driver(p8_i2c_occ_driver); + +MODULE_AUTHOR("Eddie James "); +MODULE_DESCRIPTION("BMC P8 OCC hwmon driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/hwmon/occ/p9_sbe.c b/drivers/hwmon/occ/p9_sbe.c new file mode 100644 index 000000000000..c2fa34e30544 --- /dev/null +++ b/drivers/hwmon/occ/p9_sbe.c @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include +#include + +#include "common.h" + +struct p9_sbe_occ { + struct occ occ; + struct device *sbe; +}; + +#define to_p9_sbe_occ(x) container_of((x), struct p9_sbe_occ, occ) + +static int p9_sbe_occ_send_cmd(struct occ *occ, u8 *cmd) +{ + return -EOPNOTSUPP; +} + +static int p9_sbe_occ_probe(struct platform_device *pdev) +{ + int rc; + struct occ *occ; + struct p9_sbe_occ *ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), + GFP_KERNEL); + if (!ctx) + return -ENOMEM; + + ctx->sbe = pdev->dev.parent; + occ = &ctx->occ; + occ->bus_dev = &pdev->dev; + platform_set_drvdata(pdev, occ); + + occ->poll_cmd_data = 0x20; /* P9 OCC poll data */ + occ->send_cmd = p9_sbe_occ_send_cmd; + + rc = occ_setup(occ, "p9_occ"); + if (rc == -ESHUTDOWN) + rc = -ENODEV; /* Host is shutdown, don't spew errors */ + + return rc; +} + +static int p9_sbe_occ_remove(struct platform_device *pdev) +{ + struct occ *occ = platform_get_drvdata(pdev); + struct p9_sbe_occ *ctx = to_p9_sbe_occ(occ); + + ctx->sbe = NULL; + + return 0; +} + +static struct platform_driver p9_sbe_occ_driver = { + .driver = { + .name = "occ-hwmon", + }, + .probe = p9_sbe_occ_probe, + .remove = p9_sbe_occ_remove, +}; + +module_platform_driver(p9_sbe_occ_driver); + +MODULE_AUTHOR("Eddie James "); +MODULE_DESCRIPTION("BMC P9 OCC hwmon driver"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3 From 88be37c07c1524102aed5736094cfacf24407b46 Mon Sep 17 00:00:00 2001 From: Eddie James Date: Thu, 8 Nov 2018 15:05:25 -0600 Subject: hwmon (occ): Add command transport method for P8 and P9 For the P8 OCC, add the procedure to send a command to the OCC over I2C bus. This involves writing the OCC command registers with serial communication operations (SCOMs) interpreted by the I2C slave. For the P9 OCC, add a procedure to use the OCC in-kernel API to send a command to the OCC through the SBE. Signed-off-by: Eddie James Signed-off-by: Guenter Roeck --- drivers/hwmon/occ/p8_i2c.c | 185 ++++++++++++++++++++++++++++++++++++++++++++- drivers/hwmon/occ/p9_sbe.c | 38 +++++++++- 2 files changed, 221 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/occ/p8_i2c.c b/drivers/hwmon/occ/p8_i2c.c index 4f3937dec480..e3326ff869c5 100644 --- a/drivers/hwmon/occ/p8_i2c.c +++ b/drivers/hwmon/occ/p8_i2c.c @@ -2,11 +2,29 @@ #include #include +#include #include +#include #include +#include +#include #include "common.h" +#define OCC_TIMEOUT_MS 1000 +#define OCC_CMD_IN_PRG_WAIT_MS 50 + +/* OCB (on-chip control bridge - interface to OCC) registers */ +#define OCB_DATA1 0x6B035 +#define OCB_ADDR 0x6B070 +#define OCB_DATA3 0x6B075 + +/* OCC SRAM address space */ +#define OCC_SRAM_ADDR_CMD 0xFFFF6000 +#define OCC_SRAM_ADDR_RESP 0xFFFF7000 + +#define OCC_DATA_ATTN 0x20010000 + struct p8_i2c_occ { struct occ occ; struct i2c_client *client; @@ -14,9 +32,174 @@ struct p8_i2c_occ { #define to_p8_i2c_occ(x) container_of((x), struct p8_i2c_occ, occ) +static int p8_i2c_occ_getscom(struct i2c_client *client, u32 address, u8 *data) +{ + ssize_t rc; + __be64 buf; + struct i2c_msg msgs[2]; + + /* p8 i2c slave requires shift */ + address <<= 1; + + msgs[0].addr = client->addr; + msgs[0].flags = client->flags & I2C_M_TEN; + msgs[0].len = sizeof(u32); + /* address is a scom address; bus-endian */ + msgs[0].buf = (char *)&address; + + /* data from OCC is big-endian */ + msgs[1].addr = client->addr; + msgs[1].flags = (client->flags & I2C_M_TEN) | I2C_M_RD; + msgs[1].len = sizeof(u64); + msgs[1].buf = (char *)&buf; + + rc = i2c_transfer(client->adapter, msgs, 2); + if (rc < 0) + return rc; + + *(u64 *)data = be64_to_cpu(buf); + + return 0; +} + +static int p8_i2c_occ_putscom(struct i2c_client *client, u32 address, u8 *data) +{ + u32 buf[3]; + ssize_t rc; + + /* p8 i2c slave requires shift */ + address <<= 1; + + /* address is bus-endian; data passed through from user as-is */ + buf[0] = address; + memcpy(&buf[1], &data[4], sizeof(u32)); + memcpy(&buf[2], data, sizeof(u32)); + + rc = i2c_master_send(client, (const char *)buf, sizeof(buf)); + if (rc < 0) + return rc; + else if (rc != sizeof(buf)) + return -EIO; + + return 0; +} + +static int p8_i2c_occ_putscom_u32(struct i2c_client *client, u32 address, + u32 data0, u32 data1) +{ + u8 buf[8]; + + memcpy(buf, &data0, 4); + memcpy(buf + 4, &data1, 4); + + return p8_i2c_occ_putscom(client, address, buf); +} + +static int p8_i2c_occ_putscom_be(struct i2c_client *client, u32 address, + u8 *data) +{ + __be32 data0, data1; + + memcpy(&data0, data, 4); + memcpy(&data1, data + 4, 4); + + return p8_i2c_occ_putscom_u32(client, address, be32_to_cpu(data0), + be32_to_cpu(data1)); +} + static int p8_i2c_occ_send_cmd(struct occ *occ, u8 *cmd) { - return -EOPNOTSUPP; + int i, rc; + unsigned long start; + u16 data_length; + const unsigned long timeout = msecs_to_jiffies(OCC_TIMEOUT_MS); + const long wait_time = msecs_to_jiffies(OCC_CMD_IN_PRG_WAIT_MS); + struct p8_i2c_occ *ctx = to_p8_i2c_occ(occ); + struct i2c_client *client = ctx->client; + struct occ_response *resp = &occ->resp; + + start = jiffies; + + /* set sram address for command */ + rc = p8_i2c_occ_putscom_u32(client, OCB_ADDR, OCC_SRAM_ADDR_CMD, 0); + if (rc) + return rc; + + /* write command (expected to already be BE), we need bus-endian... */ + rc = p8_i2c_occ_putscom_be(client, OCB_DATA3, cmd); + if (rc) + return rc; + + /* trigger OCC attention */ + rc = p8_i2c_occ_putscom_u32(client, OCB_DATA1, OCC_DATA_ATTN, 0); + if (rc) + return rc; + + do { + /* set sram address for response */ + rc = p8_i2c_occ_putscom_u32(client, OCB_ADDR, + OCC_SRAM_ADDR_RESP, 0); + if (rc) + return rc; + + rc = p8_i2c_occ_getscom(client, OCB_DATA3, (u8 *)resp); + if (rc) + return rc; + + /* wait for OCC */ + if (resp->return_status == OCC_RESP_CMD_IN_PRG) { + rc = -EALREADY; + + if (time_after(jiffies, start + timeout)) + break; + + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(wait_time); + } + } while (rc); + + /* check the OCC response */ + switch (resp->return_status) { + case OCC_RESP_CMD_IN_PRG: + rc = -ETIMEDOUT; + break; + case OCC_RESP_SUCCESS: + rc = 0; + break; + case OCC_RESP_CMD_INVAL: + case OCC_RESP_CMD_LEN_INVAL: + case OCC_RESP_DATA_INVAL: + case OCC_RESP_CHKSUM_ERR: + rc = -EINVAL; + break; + case OCC_RESP_INT_ERR: + case OCC_RESP_BAD_STATE: + case OCC_RESP_CRIT_EXCEPT: + case OCC_RESP_CRIT_INIT: + case OCC_RESP_CRIT_WATCHDOG: + case OCC_RESP_CRIT_OCB: + case OCC_RESP_CRIT_HW: + rc = -EREMOTEIO; + break; + default: + rc = -EPROTO; + } + + if (rc < 0) + return rc; + + data_length = get_unaligned_be16(&resp->data_length); + if (data_length > OCC_RESP_DATA_BYTES) + return -EMSGSIZE; + + /* fetch the rest of the response data */ + for (i = 8; i < data_length + 7; i += 8) { + rc = p8_i2c_occ_getscom(client, OCB_DATA3, ((u8 *)resp) + i); + if (rc) + return rc; + } + + return 0; } static int p8_i2c_occ_probe(struct i2c_client *client, diff --git a/drivers/hwmon/occ/p9_sbe.c b/drivers/hwmon/occ/p9_sbe.c index c2fa34e30544..0ed5e22143ae 100644 --- a/drivers/hwmon/occ/p9_sbe.c +++ b/drivers/hwmon/occ/p9_sbe.c @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -16,7 +17,42 @@ struct p9_sbe_occ { static int p9_sbe_occ_send_cmd(struct occ *occ, u8 *cmd) { - return -EOPNOTSUPP; + struct occ_response *resp = &occ->resp; + struct p9_sbe_occ *ctx = to_p9_sbe_occ(occ); + size_t resp_len = sizeof(*resp); + int rc; + + rc = fsi_occ_submit(ctx->sbe, cmd, 8, resp, &resp_len); + if (rc < 0) + return rc; + + switch (resp->return_status) { + case OCC_RESP_CMD_IN_PRG: + rc = -ETIMEDOUT; + break; + case OCC_RESP_SUCCESS: + rc = 0; + break; + case OCC_RESP_CMD_INVAL: + case OCC_RESP_CMD_LEN_INVAL: + case OCC_RESP_DATA_INVAL: + case OCC_RESP_CHKSUM_ERR: + rc = -EINVAL; + break; + case OCC_RESP_INT_ERR: + case OCC_RESP_BAD_STATE: + case OCC_RESP_CRIT_EXCEPT: + case OCC_RESP_CRIT_INIT: + case OCC_RESP_CRIT_WATCHDOG: + case OCC_RESP_CRIT_OCB: + case OCC_RESP_CRIT_HW: + rc = -EREMOTEIO; + break; + default: + rc = -EPROTO; + } + + return rc; } static int p9_sbe_occ_probe(struct platform_device *pdev) -- cgit v1.2.3 From aa195fe49b033db545ad986cdb2c431c37bea557 Mon Sep 17 00:00:00 2001 From: Eddie James Date: Thu, 8 Nov 2018 15:05:26 -0600 Subject: hwmon (occ): Parse OCC poll response Add method to parse the response from the OCC poll command. This only needs to be done during probe(), since the OCC shouldn't change the number or format of sensors while it's running. The parsed response allows quick access to sensor data, as well as information on the number and version of sensors, which we need to instantiate hwmon attributes. Signed-off-by: Eddie James Signed-off-by: Guenter Roeck --- drivers/hwmon/occ/common.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/hwmon/occ/common.h | 55 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+) diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c index 81acd4b5020d..a066509a8e53 100644 --- a/drivers/hwmon/occ/common.c +++ b/drivers/hwmon/occ/common.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include "common.h" @@ -22,6 +23,64 @@ static int occ_poll(struct occ *occ) return occ->send_cmd(occ, cmd); } +/* only need to do this once at startup, as OCC won't change sensors on us */ +static void occ_parse_poll_response(struct occ *occ) +{ + unsigned int i, old_offset, offset = 0, size = 0; + struct occ_sensor *sensor; + struct occ_sensors *sensors = &occ->sensors; + struct occ_response *resp = &occ->resp; + struct occ_poll_response *poll = + (struct occ_poll_response *)&resp->data[0]; + struct occ_poll_response_header *header = &poll->header; + struct occ_sensor_data_block *block = &poll->block; + + dev_info(occ->bus_dev, "OCC found, code level: %.16s\n", + header->occ_code_level); + + for (i = 0; i < header->num_sensor_data_blocks; ++i) { + block = (struct occ_sensor_data_block *)((u8 *)block + offset); + old_offset = offset; + offset = (block->header.num_sensors * + block->header.sensor_length) + sizeof(block->header); + size += offset; + + /* validate all the length/size fields */ + if ((size + sizeof(*header)) >= OCC_RESP_DATA_BYTES) { + dev_warn(occ->bus_dev, "exceeded response buffer\n"); + return; + } + + dev_dbg(occ->bus_dev, " %04x..%04x: %.4s (%d sensors)\n", + old_offset, offset - 1, block->header.eye_catcher, + block->header.num_sensors); + + /* match sensor block type */ + if (strncmp(block->header.eye_catcher, "TEMP", 4) == 0) + sensor = &sensors->temp; + else if (strncmp(block->header.eye_catcher, "FREQ", 4) == 0) + sensor = &sensors->freq; + else if (strncmp(block->header.eye_catcher, "POWR", 4) == 0) + sensor = &sensors->power; + else if (strncmp(block->header.eye_catcher, "CAPS", 4) == 0) + sensor = &sensors->caps; + else if (strncmp(block->header.eye_catcher, "EXTN", 4) == 0) + sensor = &sensors->extended; + else { + dev_warn(occ->bus_dev, "sensor not supported %.4s\n", + block->header.eye_catcher); + continue; + } + + sensor->num_sensors = block->header.num_sensors; + sensor->version = block->header.sensor_format; + sensor->data = &block->data; + } + + dev_dbg(occ->bus_dev, "Max resp size: %u+%zd=%zd\n", size, + sizeof(*header), size + sizeof(*header)); +} + int occ_setup(struct occ *occ, const char *name) { int rc; @@ -36,5 +95,7 @@ int occ_setup(struct occ *occ, const char *name) return rc; } + occ_parse_poll_response(occ); + return 0; } diff --git a/drivers/hwmon/occ/common.h b/drivers/hwmon/occ/common.h index 0602196d6704..251a4b0ab154 100644 --- a/drivers/hwmon/occ/common.h +++ b/drivers/hwmon/occ/common.h @@ -20,10 +20,65 @@ struct occ_response { __be16 checksum; } __packed; +struct occ_sensor_data_block_header { + u8 eye_catcher[4]; + u8 reserved; + u8 sensor_format; + u8 sensor_length; + u8 num_sensors; +} __packed; + +struct occ_sensor_data_block { + struct occ_sensor_data_block_header header; + u32 data; +} __packed; + +struct occ_poll_response_header { + u8 status; + u8 ext_status; + u8 occs_present; + u8 config_data; + u8 occ_state; + u8 mode; + u8 ips_status; + u8 error_log_id; + __be32 error_log_start_address; + __be16 error_log_length; + u16 reserved; + u8 occ_code_level[16]; + u8 eye_catcher[6]; + u8 num_sensor_data_blocks; + u8 sensor_data_block_header_version; +} __packed; + +struct occ_poll_response { + struct occ_poll_response_header header; + struct occ_sensor_data_block block; +} __packed; + +struct occ_sensor { + u8 num_sensors; + u8 version; + void *data; /* pointer to sensor data start within response */ +}; + +/* + * OCC only provides one sensor data block of each type, but any number of + * sensors within that block. + */ +struct occ_sensors { + struct occ_sensor temp; + struct occ_sensor freq; + struct occ_sensor power; + struct occ_sensor caps; + struct occ_sensor extended; +}; + struct occ { struct device *bus_dev; struct occ_response resp; + struct occ_sensors sensors; u8 poll_cmd_data; /* to perform OCC poll command */ int (*send_cmd)(struct occ *occ, u8 *cmd); -- cgit v1.2.3 From c10e753d43ebd1d17e1c62bcee20c6124c2c7cca Mon Sep 17 00:00:00 2001 From: Eddie James Date: Thu, 8 Nov 2018 15:05:27 -0600 Subject: hwmon (occ): Add sensor types and versions Add structures to define all sensor types and versions. Add sysfs show and store functions for each sensor type. Add a method to construct the "set user power cap" command and send it to the OCC. Add rate limit to polling the OCC (in case user-space reads our hwmon entries rapidly). Signed-off-by: Eddie James Signed-off-by: Guenter Roeck --- drivers/hwmon/occ/common.c | 621 +++++++++++++++++++++++++++++++++++++++++++++ drivers/hwmon/occ/common.h | 6 + drivers/hwmon/occ/p8_i2c.c | 1 + drivers/hwmon/occ/p9_sbe.c | 1 + 4 files changed, 629 insertions(+) diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c index a066509a8e53..f7220132ff28 100644 --- a/drivers/hwmon/occ/common.c +++ b/drivers/hwmon/occ/common.c @@ -1,10 +1,116 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include +#include #include +#include +#include +#include #include "common.h" +#define EXTN_FLAG_SENSOR_ID BIT(7) + +#define OCC_UPDATE_FREQUENCY msecs_to_jiffies(1000) + +#define OCC_TEMP_SENSOR_FAULT 0xFF + +#define OCC_FRU_TYPE_VRM 3 + +/* OCC sensor type and version definitions */ + +struct temp_sensor_1 { + u16 sensor_id; + u16 value; +} __packed; + +struct temp_sensor_2 { + u32 sensor_id; + u8 fru_type; + u8 value; +} __packed; + +struct freq_sensor_1 { + u16 sensor_id; + u16 value; +} __packed; + +struct freq_sensor_2 { + u32 sensor_id; + u16 value; +} __packed; + +struct power_sensor_1 { + u16 sensor_id; + u32 update_tag; + u32 accumulator; + u16 value; +} __packed; + +struct power_sensor_2 { + u32 sensor_id; + u8 function_id; + u8 apss_channel; + u16 reserved; + u32 update_tag; + u64 accumulator; + u16 value; +} __packed; + +struct power_sensor_data { + u16 value; + u32 update_tag; + u64 accumulator; +} __packed; + +struct power_sensor_data_and_time { + u16 update_time; + u16 value; + u32 update_tag; + u64 accumulator; +} __packed; + +struct power_sensor_a0 { + u32 sensor_id; + struct power_sensor_data_and_time system; + u32 reserved; + struct power_sensor_data_and_time proc; + struct power_sensor_data vdd; + struct power_sensor_data vdn; +} __packed; + +struct caps_sensor_2 { + u16 cap; + u16 system_power; + u16 n_cap; + u16 max; + u16 min; + u16 user; + u8 user_source; +} __packed; + +struct caps_sensor_3 { + u16 cap; + u16 system_power; + u16 n_cap; + u16 max; + u16 hard_min; + u16 soft_min; + u16 user; + u8 user_source; +} __packed; + +struct extended_sensor { + union { + u8 name[4]; + u32 sensor_id; + }; + u8 flags; + u8 reserved; + u8 data[6]; +} __packed; + static int occ_poll(struct occ *occ) { u16 checksum = occ->poll_cmd_data + 1; @@ -20,9 +126,521 @@ static int occ_poll(struct occ *occ) cmd[6] = checksum & 0xFF; /* checksum lsb */ cmd[7] = 0; + /* mutex should already be locked if necessary */ return occ->send_cmd(occ, cmd); } +static int occ_set_user_power_cap(struct occ *occ, u16 user_power_cap) +{ + int rc; + u8 cmd[8]; + u16 checksum = 0x24; + __be16 user_power_cap_be = cpu_to_be16(user_power_cap); + + cmd[0] = 0; + cmd[1] = 0x22; + cmd[2] = 0; + cmd[3] = 2; + + memcpy(&cmd[4], &user_power_cap_be, 2); + + checksum += cmd[4] + cmd[5]; + cmd[6] = checksum >> 8; + cmd[7] = checksum & 0xFF; + + rc = mutex_lock_interruptible(&occ->lock); + if (rc) + return rc; + + rc = occ->send_cmd(occ, cmd); + + mutex_unlock(&occ->lock); + + return rc; +} + +static int occ_update_response(struct occ *occ) +{ + int rc = mutex_lock_interruptible(&occ->lock); + + if (rc) + return rc; + + /* limit the maximum rate of polling the OCC */ + if (time_after(jiffies, occ->last_update + OCC_UPDATE_FREQUENCY)) { + rc = occ_poll(occ); + occ->last_update = jiffies; + } + + mutex_unlock(&occ->lock); + return rc; +} + +static ssize_t occ_show_temp_1(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int rc; + u32 val = 0; + struct temp_sensor_1 *temp; + struct occ *occ = dev_get_drvdata(dev); + struct occ_sensors *sensors = &occ->sensors; + struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); + + rc = occ_update_response(occ); + if (rc) + return rc; + + temp = ((struct temp_sensor_1 *)sensors->temp.data) + sattr->index; + + switch (sattr->nr) { + case 0: + val = get_unaligned_be16(&temp->sensor_id); + break; + case 1: + val = get_unaligned_be16(&temp->value) * 1000; + break; + default: + return -EINVAL; + } + + return snprintf(buf, PAGE_SIZE - 1, "%u\n", val); +} + +static ssize_t occ_show_temp_2(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int rc; + u32 val = 0; + struct temp_sensor_2 *temp; + struct occ *occ = dev_get_drvdata(dev); + struct occ_sensors *sensors = &occ->sensors; + struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); + + rc = occ_update_response(occ); + if (rc) + return rc; + + temp = ((struct temp_sensor_2 *)sensors->temp.data) + sattr->index; + + switch (sattr->nr) { + case 0: + val = get_unaligned_be32(&temp->sensor_id); + break; + case 1: + val = temp->value; + if (val == OCC_TEMP_SENSOR_FAULT) + return -EREMOTEIO; + + /* + * VRM doesn't return temperature, only alarm bit. This + * attribute maps to tempX_alarm instead of tempX_input for + * VRM + */ + if (temp->fru_type != OCC_FRU_TYPE_VRM) { + /* sensor not ready */ + if (val == 0) + return -EAGAIN; + + val *= 1000; + } + break; + case 2: + val = temp->fru_type; + break; + case 3: + val = temp->value == OCC_TEMP_SENSOR_FAULT; + break; + default: + return -EINVAL; + } + + return snprintf(buf, PAGE_SIZE - 1, "%u\n", val); +} + +static ssize_t occ_show_freq_1(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int rc; + u16 val = 0; + struct freq_sensor_1 *freq; + struct occ *occ = dev_get_drvdata(dev); + struct occ_sensors *sensors = &occ->sensors; + struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); + + rc = occ_update_response(occ); + if (rc) + return rc; + + freq = ((struct freq_sensor_1 *)sensors->freq.data) + sattr->index; + + switch (sattr->nr) { + case 0: + val = get_unaligned_be16(&freq->sensor_id); + break; + case 1: + val = get_unaligned_be16(&freq->value); + break; + default: + return -EINVAL; + } + + return snprintf(buf, PAGE_SIZE - 1, "%u\n", val); +} + +static ssize_t occ_show_freq_2(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int rc; + u32 val = 0; + struct freq_sensor_2 *freq; + struct occ *occ = dev_get_drvdata(dev); + struct occ_sensors *sensors = &occ->sensors; + struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); + + rc = occ_update_response(occ); + if (rc) + return rc; + + freq = ((struct freq_sensor_2 *)sensors->freq.data) + sattr->index; + + switch (sattr->nr) { + case 0: + val = get_unaligned_be32(&freq->sensor_id); + break; + case 1: + val = get_unaligned_be16(&freq->value); + break; + default: + return -EINVAL; + } + + return snprintf(buf, PAGE_SIZE - 1, "%u\n", val); +} + +static ssize_t occ_show_power_1(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int rc; + u64 val = 0; + struct power_sensor_1 *power; + struct occ *occ = dev_get_drvdata(dev); + struct occ_sensors *sensors = &occ->sensors; + struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); + + rc = occ_update_response(occ); + if (rc) + return rc; + + power = ((struct power_sensor_1 *)sensors->power.data) + sattr->index; + + switch (sattr->nr) { + case 0: + val = get_unaligned_be16(&power->sensor_id); + break; + case 1: + val = get_unaligned_be32(&power->accumulator) / + get_unaligned_be32(&power->update_tag); + val *= 1000000ULL; + break; + case 2: + val = get_unaligned_be32(&power->update_tag) * + occ->powr_sample_time_us; + break; + case 3: + val = get_unaligned_be16(&power->value) * 1000000ULL; + break; + default: + return -EINVAL; + } + + return snprintf(buf, PAGE_SIZE - 1, "%llu\n", val); +} + +static u64 occ_get_powr_avg(u64 *accum, u32 *samples) +{ + return div64_u64(get_unaligned_be64(accum) * 1000000ULL, + get_unaligned_be32(samples)); +} + +static ssize_t occ_show_power_2(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int rc; + u64 val = 0; + struct power_sensor_2 *power; + struct occ *occ = dev_get_drvdata(dev); + struct occ_sensors *sensors = &occ->sensors; + struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); + + rc = occ_update_response(occ); + if (rc) + return rc; + + power = ((struct power_sensor_2 *)sensors->power.data) + sattr->index; + + switch (sattr->nr) { + case 0: + return snprintf(buf, PAGE_SIZE - 1, "%u_%u_%u\n", + get_unaligned_be32(&power->sensor_id), + power->function_id, power->apss_channel); + case 1: + val = occ_get_powr_avg(&power->accumulator, + &power->update_tag); + break; + case 2: + val = get_unaligned_be32(&power->update_tag) * + occ->powr_sample_time_us; + break; + case 3: + val = get_unaligned_be16(&power->value) * 1000000ULL; + break; + default: + return -EINVAL; + } + + return snprintf(buf, PAGE_SIZE - 1, "%llu\n", val); +} + +static ssize_t occ_show_power_a0(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int rc; + u64 val = 0; + struct power_sensor_a0 *power; + struct occ *occ = dev_get_drvdata(dev); + struct occ_sensors *sensors = &occ->sensors; + struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); + + rc = occ_update_response(occ); + if (rc) + return rc; + + power = ((struct power_sensor_a0 *)sensors->power.data) + sattr->index; + + switch (sattr->nr) { + case 0: + return snprintf(buf, PAGE_SIZE - 1, "%u_system\n", + get_unaligned_be32(&power->sensor_id)); + case 1: + val = occ_get_powr_avg(&power->system.accumulator, + &power->system.update_tag); + break; + case 2: + val = get_unaligned_be32(&power->system.update_tag) * + occ->powr_sample_time_us; + break; + case 3: + val = get_unaligned_be16(&power->system.value) * 1000000ULL; + break; + case 4: + return snprintf(buf, PAGE_SIZE - 1, "%u_proc\n", + get_unaligned_be32(&power->sensor_id)); + case 5: + val = occ_get_powr_avg(&power->proc.accumulator, + &power->proc.update_tag); + break; + case 6: + val = get_unaligned_be32(&power->proc.update_tag) * + occ->powr_sample_time_us; + break; + case 7: + val = get_unaligned_be16(&power->proc.value) * 1000000ULL; + break; + case 8: + return snprintf(buf, PAGE_SIZE - 1, "%u_vdd\n", + get_unaligned_be32(&power->sensor_id)); + case 9: + val = occ_get_powr_avg(&power->vdd.accumulator, + &power->vdd.update_tag); + break; + case 10: + val = get_unaligned_be32(&power->vdd.update_tag) * + occ->powr_sample_time_us; + break; + case 11: + val = get_unaligned_be16(&power->vdd.value) * 1000000ULL; + break; + case 12: + return snprintf(buf, PAGE_SIZE - 1, "%u_vdn\n", + get_unaligned_be32(&power->sensor_id)); + case 13: + val = occ_get_powr_avg(&power->vdn.accumulator, + &power->vdn.update_tag); + break; + case 14: + val = get_unaligned_be32(&power->vdn.update_tag) * + occ->powr_sample_time_us; + break; + case 15: + val = get_unaligned_be16(&power->vdn.value) * 1000000ULL; + break; + default: + return -EINVAL; + } + + return snprintf(buf, PAGE_SIZE - 1, "%llu\n", val); +} + +static ssize_t occ_show_caps_1_2(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int rc; + u64 val = 0; + struct caps_sensor_2 *caps; + struct occ *occ = dev_get_drvdata(dev); + struct occ_sensors *sensors = &occ->sensors; + struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); + + rc = occ_update_response(occ); + if (rc) + return rc; + + caps = ((struct caps_sensor_2 *)sensors->caps.data) + sattr->index; + + switch (sattr->nr) { + case 0: + return snprintf(buf, PAGE_SIZE - 1, "system\n"); + case 1: + val = get_unaligned_be16(&caps->cap) * 1000000ULL; + break; + case 2: + val = get_unaligned_be16(&caps->system_power) * 1000000ULL; + break; + case 3: + val = get_unaligned_be16(&caps->n_cap) * 1000000ULL; + break; + case 4: + val = get_unaligned_be16(&caps->max) * 1000000ULL; + break; + case 5: + val = get_unaligned_be16(&caps->min) * 1000000ULL; + break; + case 6: + val = get_unaligned_be16(&caps->user) * 1000000ULL; + break; + case 7: + if (occ->sensors.caps.version == 1) + return -EINVAL; + + val = caps->user_source; + break; + default: + return -EINVAL; + } + + return snprintf(buf, PAGE_SIZE - 1, "%llu\n", val); +} + +static ssize_t occ_show_caps_3(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int rc; + u64 val = 0; + struct caps_sensor_3 *caps; + struct occ *occ = dev_get_drvdata(dev); + struct occ_sensors *sensors = &occ->sensors; + struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); + + rc = occ_update_response(occ); + if (rc) + return rc; + + caps = ((struct caps_sensor_3 *)sensors->caps.data) + sattr->index; + + switch (sattr->nr) { + case 0: + return snprintf(buf, PAGE_SIZE - 1, "system\n"); + case 1: + val = get_unaligned_be16(&caps->cap) * 1000000ULL; + break; + case 2: + val = get_unaligned_be16(&caps->system_power) * 1000000ULL; + break; + case 3: + val = get_unaligned_be16(&caps->n_cap) * 1000000ULL; + break; + case 4: + val = get_unaligned_be16(&caps->max) * 1000000ULL; + break; + case 5: + val = get_unaligned_be16(&caps->hard_min) * 1000000ULL; + break; + case 6: + val = get_unaligned_be16(&caps->user) * 1000000ULL; + break; + case 7: + val = caps->user_source; + break; + default: + return -EINVAL; + } + + return snprintf(buf, PAGE_SIZE - 1, "%llu\n", val); +} + +static ssize_t occ_store_caps_user(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + int rc; + u16 user_power_cap; + unsigned long long value; + struct occ *occ = dev_get_drvdata(dev); + + rc = kstrtoull(buf, 0, &value); + if (rc) + return rc; + + user_power_cap = div64_u64(value, 1000000ULL); /* microwatt to watt */ + + rc = occ_set_user_power_cap(occ, user_power_cap); + if (rc) + return rc; + + return count; +} + +static ssize_t occ_show_extended(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int rc; + struct extended_sensor *extn; + struct occ *occ = dev_get_drvdata(dev); + struct occ_sensors *sensors = &occ->sensors; + struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); + + rc = occ_update_response(occ); + if (rc) + return rc; + + extn = ((struct extended_sensor *)sensors->extended.data) + + sattr->index; + + switch (sattr->nr) { + case 0: + if (extn->flags & EXTN_FLAG_SENSOR_ID) + rc = snprintf(buf, PAGE_SIZE - 1, "%u", + get_unaligned_be32(&extn->sensor_id)); + else + rc = snprintf(buf, PAGE_SIZE - 1, "%02x%02x%02x%02x\n", + extn->name[0], extn->name[1], + extn->name[2], extn->name[3]); + break; + case 1: + rc = snprintf(buf, PAGE_SIZE - 1, "%02x\n", extn->flags); + break; + case 2: + rc = snprintf(buf, PAGE_SIZE - 1, "%02x%02x%02x%02x%02x%02x\n", + extn->data[0], extn->data[1], extn->data[2], + extn->data[3], extn->data[4], extn->data[5]); + break; + default: + return -EINVAL; + } + + return rc; +} + /* only need to do this once at startup, as OCC won't change sensors on us */ static void occ_parse_poll_response(struct occ *occ) { @@ -85,6 +703,9 @@ int occ_setup(struct occ *occ, const char *name) { int rc; + mutex_init(&occ->lock); + + /* no need to lock */ rc = occ_poll(occ); if (rc == -ESHUTDOWN) { dev_info(occ->bus_dev, "host is not ready\n"); diff --git a/drivers/hwmon/occ/common.h b/drivers/hwmon/occ/common.h index 251a4b0ab154..a363462f5f30 100644 --- a/drivers/hwmon/occ/common.h +++ b/drivers/hwmon/occ/common.h @@ -3,6 +3,8 @@ #ifndef OCC_COMMON_H #define OCC_COMMON_H +#include + struct device; #define OCC_RESP_DATA_BYTES 4089 @@ -80,8 +82,12 @@ struct occ { struct occ_response resp; struct occ_sensors sensors; + int powr_sample_time_us; /* average power sample time */ u8 poll_cmd_data; /* to perform OCC poll command */ int (*send_cmd)(struct occ *occ, u8 *cmd); + + unsigned long last_update; + struct mutex lock; /* lock OCC access */ }; int occ_setup(struct occ *occ, const char *name); diff --git a/drivers/hwmon/occ/p8_i2c.c b/drivers/hwmon/occ/p8_i2c.c index e3326ff869c5..e4c2c047b99c 100644 --- a/drivers/hwmon/occ/p8_i2c.c +++ b/drivers/hwmon/occ/p8_i2c.c @@ -216,6 +216,7 @@ static int p8_i2c_occ_probe(struct i2c_client *client, occ->bus_dev = &client->dev; dev_set_drvdata(&client->dev, occ); + occ->powr_sample_time_us = 250; occ->poll_cmd_data = 0x10; /* P8 OCC poll data */ occ->send_cmd = p8_i2c_occ_send_cmd; diff --git a/drivers/hwmon/occ/p9_sbe.c b/drivers/hwmon/occ/p9_sbe.c index 0ed5e22143ae..b33f4fe63fbb 100644 --- a/drivers/hwmon/occ/p9_sbe.c +++ b/drivers/hwmon/occ/p9_sbe.c @@ -69,6 +69,7 @@ static int p9_sbe_occ_probe(struct platform_device *pdev) occ->bus_dev = &pdev->dev; platform_set_drvdata(pdev, occ); + occ->powr_sample_time_us = 500; occ->poll_cmd_data = 0x20; /* P9 OCC poll data */ occ->send_cmd = p9_sbe_occ_send_cmd; -- cgit v1.2.3 From 54076cb3b5ff21f6474f5fd254a0b018b24771df Mon Sep 17 00:00:00 2001 From: Eddie James Date: Thu, 8 Nov 2018 15:05:28 -0600 Subject: hwmon (occ): Add sensor attributes and register hwmon device Setup the sensor attributes for every OCC sensor found by the first poll response. Register the attributes with hwmon. Signed-off-by: Eddie James Signed-off-by: Guenter Roeck --- drivers/hwmon/occ/common.c | 337 +++++++++++++++++++++++++++++++++++++++++++++ drivers/hwmon/occ/common.h | 16 +++ 2 files changed, 353 insertions(+) diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c index f7220132ff28..c6c816135f67 100644 --- a/drivers/hwmon/occ/common.c +++ b/drivers/hwmon/occ/common.c @@ -1,11 +1,13 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include #include #include #include #include +#include #include #include "common.h" @@ -641,6 +643,324 @@ static ssize_t occ_show_extended(struct device *dev, return rc; } +/* + * Some helper macros to make it easier to define an occ_attribute. Since these + * are dynamically allocated, we shouldn't use the existing kernel macros which + * stringify the name argument. + */ +#define ATTR_OCC(_name, _mode, _show, _store) { \ + .attr = { \ + .name = _name, \ + .mode = VERIFY_OCTAL_PERMISSIONS(_mode), \ + }, \ + .show = _show, \ + .store = _store, \ +} + +#define SENSOR_ATTR_OCC(_name, _mode, _show, _store, _nr, _index) { \ + .dev_attr = ATTR_OCC(_name, _mode, _show, _store), \ + .index = _index, \ + .nr = _nr, \ +} + +#define OCC_INIT_ATTR(_name, _mode, _show, _store, _nr, _index) \ + ((struct sensor_device_attribute_2) \ + SENSOR_ATTR_OCC(_name, _mode, _show, _store, _nr, _index)) + +/* + * Allocate and instatiate sensor_device_attribute_2s. It's most efficient to + * use our own instead of the built-in hwmon attribute types. + */ +static int occ_setup_sensor_attrs(struct occ *occ) +{ + unsigned int i, s, num_attrs = 0; + struct device *dev = occ->bus_dev; + struct occ_sensors *sensors = &occ->sensors; + struct occ_attribute *attr; + struct temp_sensor_2 *temp; + ssize_t (*show_temp)(struct device *, struct device_attribute *, + char *) = occ_show_temp_1; + ssize_t (*show_freq)(struct device *, struct device_attribute *, + char *) = occ_show_freq_1; + ssize_t (*show_power)(struct device *, struct device_attribute *, + char *) = occ_show_power_1; + ssize_t (*show_caps)(struct device *, struct device_attribute *, + char *) = occ_show_caps_1_2; + + switch (sensors->temp.version) { + case 1: + num_attrs += (sensors->temp.num_sensors * 2); + break; + case 2: + num_attrs += (sensors->temp.num_sensors * 4); + show_temp = occ_show_temp_2; + break; + default: + sensors->temp.num_sensors = 0; + } + + switch (sensors->freq.version) { + case 2: + show_freq = occ_show_freq_2; + /* fall through */ + case 1: + num_attrs += (sensors->freq.num_sensors * 2); + break; + default: + sensors->freq.num_sensors = 0; + } + + switch (sensors->power.version) { + case 2: + show_power = occ_show_power_2; + /* fall through */ + case 1: + num_attrs += (sensors->power.num_sensors * 4); + break; + case 0xA0: + num_attrs += (sensors->power.num_sensors * 16); + show_power = occ_show_power_a0; + break; + default: + sensors->power.num_sensors = 0; + } + + switch (sensors->caps.version) { + case 1: + num_attrs += (sensors->caps.num_sensors * 7); + break; + case 3: + show_caps = occ_show_caps_3; + /* fall through */ + case 2: + num_attrs += (sensors->caps.num_sensors * 8); + break; + default: + sensors->caps.num_sensors = 0; + } + + switch (sensors->extended.version) { + case 1: + num_attrs += (sensors->extended.num_sensors * 3); + break; + default: + sensors->extended.num_sensors = 0; + } + + occ->attrs = devm_kzalloc(dev, sizeof(*occ->attrs) * num_attrs, + GFP_KERNEL); + if (!occ->attrs) + return -ENOMEM; + + /* null-terminated list */ + occ->group.attrs = devm_kzalloc(dev, sizeof(*occ->group.attrs) * + num_attrs + 1, GFP_KERNEL); + if (!occ->group.attrs) + return -ENOMEM; + + attr = occ->attrs; + + for (i = 0; i < sensors->temp.num_sensors; ++i) { + s = i + 1; + temp = ((struct temp_sensor_2 *)sensors->temp.data) + i; + + snprintf(attr->name, sizeof(attr->name), "temp%d_label", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, show_temp, NULL, + 0, i); + attr++; + + if (sensors->temp.version > 1 && + temp->fru_type == OCC_FRU_TYPE_VRM) { + snprintf(attr->name, sizeof(attr->name), + "temp%d_alarm", s); + } else { + snprintf(attr->name, sizeof(attr->name), + "temp%d_input", s); + } + + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, show_temp, NULL, + 1, i); + attr++; + + if (sensors->temp.version > 1) { + snprintf(attr->name, sizeof(attr->name), + "temp%d_fru_type", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, + show_temp, NULL, 2, i); + attr++; + + snprintf(attr->name, sizeof(attr->name), + "temp%d_fault", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, + show_temp, NULL, 3, i); + attr++; + } + } + + for (i = 0; i < sensors->freq.num_sensors; ++i) { + s = i + 1; + + snprintf(attr->name, sizeof(attr->name), "freq%d_label", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, show_freq, NULL, + 0, i); + attr++; + + snprintf(attr->name, sizeof(attr->name), "freq%d_input", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, show_freq, NULL, + 1, i); + attr++; + } + + if (sensors->power.version == 0xA0) { + /* + * Special case for many-attribute power sensor. Split it into + * a sensor number per power type, emulating several sensors. + */ + for (i = 0; i < sensors->power.num_sensors; ++i) { + unsigned int j; + unsigned int nr = 0; + + s = (i * 4) + 1; + + for (j = 0; j < 4; ++j) { + snprintf(attr->name, sizeof(attr->name), + "power%d_label", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, + show_power, NULL, + nr++, i); + attr++; + + snprintf(attr->name, sizeof(attr->name), + "power%d_average", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, + show_power, NULL, + nr++, i); + attr++; + + snprintf(attr->name, sizeof(attr->name), + "power%d_average_interval", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, + show_power, NULL, + nr++, i); + attr++; + + snprintf(attr->name, sizeof(attr->name), + "power%d_input", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, + show_power, NULL, + nr++, i); + attr++; + + s++; + } + } + } else { + for (i = 0; i < sensors->power.num_sensors; ++i) { + s = i + 1; + + snprintf(attr->name, sizeof(attr->name), + "power%d_label", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, + show_power, NULL, 0, i); + attr++; + + snprintf(attr->name, sizeof(attr->name), + "power%d_average", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, + show_power, NULL, 1, i); + attr++; + + snprintf(attr->name, sizeof(attr->name), + "power%d_average_interval", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, + show_power, NULL, 2, i); + attr++; + + snprintf(attr->name, sizeof(attr->name), + "power%d_input", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, + show_power, NULL, 3, i); + attr++; + } + } + + if (sensors->caps.num_sensors >= 1) { + s = sensors->power.num_sensors + 1; + + snprintf(attr->name, sizeof(attr->name), "power%d_label", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, show_caps, NULL, + 0, 0); + attr++; + + snprintf(attr->name, sizeof(attr->name), "power%d_cap", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, show_caps, NULL, + 1, 0); + attr++; + + snprintf(attr->name, sizeof(attr->name), "power%d_input", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, show_caps, NULL, + 2, 0); + attr++; + + snprintf(attr->name, sizeof(attr->name), + "power%d_cap_not_redundant", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, show_caps, NULL, + 3, 0); + attr++; + + snprintf(attr->name, sizeof(attr->name), "power%d_cap_max", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, show_caps, NULL, + 4, 0); + attr++; + + snprintf(attr->name, sizeof(attr->name), "power%d_cap_min", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, show_caps, NULL, + 5, 0); + attr++; + + snprintf(attr->name, sizeof(attr->name), "power%d_cap_user", + s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0644, show_caps, + occ_store_caps_user, 6, 0); + attr++; + + if (sensors->caps.version > 1) { + snprintf(attr->name, sizeof(attr->name), + "power%d_cap_user_source", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, + show_caps, NULL, 7, 0); + attr++; + } + } + + for (i = 0; i < sensors->extended.num_sensors; ++i) { + s = i + 1; + + snprintf(attr->name, sizeof(attr->name), "extn%d_label", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, + occ_show_extended, NULL, 0, i); + attr++; + + snprintf(attr->name, sizeof(attr->name), "extn%d_flags", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, + occ_show_extended, NULL, 1, i); + attr++; + + snprintf(attr->name, sizeof(attr->name), "extn%d_input", s); + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, + occ_show_extended, NULL, 2, i); + attr++; + } + + /* put the sensors in the group */ + for (i = 0; i < num_attrs; ++i) { + sysfs_attr_init(&occ->attrs[i].sensor.dev_attr.attr); + occ->group.attrs[i] = &occ->attrs[i].sensor.dev_attr.attr; + } + + return 0; +} + /* only need to do this once at startup, as OCC won't change sensors on us */ static void occ_parse_poll_response(struct occ *occ) { @@ -704,6 +1024,7 @@ int occ_setup(struct occ *occ, const char *name) int rc; mutex_init(&occ->lock); + occ->groups[0] = &occ->group; /* no need to lock */ rc = occ_poll(occ); @@ -718,5 +1039,21 @@ int occ_setup(struct occ *occ, const char *name) occ_parse_poll_response(occ); + rc = occ_setup_sensor_attrs(occ); + if (rc) { + dev_err(occ->bus_dev, "failed to setup sensor attrs: %d\n", + rc); + return rc; + } + + occ->hwmon = devm_hwmon_device_register_with_groups(occ->bus_dev, name, + occ, occ->groups); + if (IS_ERR(occ->hwmon)) { + rc = PTR_ERR(occ->hwmon); + dev_err(occ->bus_dev, "failed to register hwmon device: %d\n", + rc); + return rc; + } + return 0; } diff --git a/drivers/hwmon/occ/common.h b/drivers/hwmon/occ/common.h index a363462f5f30..9d01973d93d8 100644 --- a/drivers/hwmon/occ/common.h +++ b/drivers/hwmon/occ/common.h @@ -3,7 +3,9 @@ #ifndef OCC_COMMON_H #define OCC_COMMON_H +#include #include +#include struct device; @@ -76,6 +78,15 @@ struct occ_sensors { struct occ_sensor extended; }; +/* + * Use our own attribute struct so we can dynamically allocate space for the + * name. + */ +struct occ_attribute { + char name[32]; + struct sensor_device_attribute_2 sensor; +}; + struct occ { struct device *bus_dev; @@ -88,6 +99,11 @@ struct occ { unsigned long last_update; struct mutex lock; /* lock OCC access */ + + struct device *hwmon; + struct occ_attribute *attrs; + struct attribute_group group; + const struct attribute_group *groups[2]; }; int occ_setup(struct occ *occ, const char *name); -- cgit v1.2.3 From df04ced684d48f6ec5729ccd034702952160c6b3 Mon Sep 17 00:00:00 2001 From: Eddie James Date: Thu, 8 Nov 2018 15:05:29 -0600 Subject: hwmon (occ): Add sysfs attributes for additional OCC data The OCC provides a variety of additional information about the state of the host processor, such as throttling, error conditions, and the number of OCCs detected in the system. This information is essential to service processor applications such as fan control and host management. Therefore, export this data in the form of sysfs attributes attached to the platform device (to which the hwmon device is also attached). Signed-off-by: Eddie James Signed-off-by: Guenter Roeck --- drivers/hwmon/occ/Makefile | 4 +- drivers/hwmon/occ/common.c | 45 ++++++++++- drivers/hwmon/occ/common.h | 17 ++++ drivers/hwmon/occ/p8_i2c.c | 10 +++ drivers/hwmon/occ/p9_sbe.c | 1 + drivers/hwmon/occ/sysfs.c | 188 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 260 insertions(+), 5 deletions(-) create mode 100644 drivers/hwmon/occ/sysfs.c diff --git a/drivers/hwmon/occ/Makefile b/drivers/hwmon/occ/Makefile index 57c0e911005b..3fec12ddc7e7 100644 --- a/drivers/hwmon/occ/Makefile +++ b/drivers/hwmon/occ/Makefile @@ -1,5 +1,5 @@ -occ-p8-hwmon-objs := common.o p8_i2c.o -occ-p9-hwmon-objs := common.o p9_sbe.o +occ-p8-hwmon-objs := common.o sysfs.o p8_i2c.o +occ-p9-hwmon-objs := common.o sysfs.o p9_sbe.o obj-$(CONFIG_SENSORS_OCC_P8_I2C) += occ-p8-hwmon.o obj-$(CONFIG_SENSORS_OCC_P9_SBE) += occ-p9-hwmon.o diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c index c6c816135f67..423903f87955 100644 --- a/drivers/hwmon/occ/common.c +++ b/drivers/hwmon/occ/common.c @@ -14,6 +14,11 @@ #define EXTN_FLAG_SENSOR_ID BIT(7) +#define OCC_ERROR_COUNT_THRESHOLD 2 /* required by OCC spec */ + +#define OCC_STATE_SAFE 4 +#define OCC_SAFE_TIMEOUT msecs_to_jiffies(60000) /* 1 min */ + #define OCC_UPDATE_FREQUENCY msecs_to_jiffies(1000) #define OCC_TEMP_SENSOR_FAULT 0xFF @@ -115,8 +120,10 @@ struct extended_sensor { static int occ_poll(struct occ *occ) { + int rc; u16 checksum = occ->poll_cmd_data + 1; u8 cmd[8]; + struct occ_poll_response_header *header; /* big endian */ cmd[0] = 0; /* sequence number */ @@ -129,7 +136,35 @@ static int occ_poll(struct occ *occ) cmd[7] = 0; /* mutex should already be locked if necessary */ - return occ->send_cmd(occ, cmd); + rc = occ->send_cmd(occ, cmd); + if (rc) { + if (occ->error_count++ > OCC_ERROR_COUNT_THRESHOLD) + occ->error = rc; + + goto done; + } + + /* clear error since communication was successful */ + occ->error_count = 0; + occ->error = 0; + + /* check for safe state */ + header = (struct occ_poll_response_header *)occ->resp.data; + if (header->occ_state == OCC_STATE_SAFE) { + if (occ->last_safe) { + if (time_after(jiffies, + occ->last_safe + OCC_SAFE_TIMEOUT)) + occ->error = -EHOSTDOWN; + } else { + occ->last_safe = jiffies; + } + } else { + occ->last_safe = 0; + } + +done: + occ_sysfs_poll_done(occ); + return rc; } static int occ_set_user_power_cap(struct occ *occ, u16 user_power_cap) @@ -161,7 +196,7 @@ static int occ_set_user_power_cap(struct occ *occ, u16 user_power_cap) return rc; } -static int occ_update_response(struct occ *occ) +int occ_update_response(struct occ *occ) { int rc = mutex_lock_interruptible(&occ->lock); @@ -1055,5 +1090,9 @@ int occ_setup(struct occ *occ, const char *name) return rc; } - return 0; + rc = occ_setup_sysfs(occ); + if (rc) + dev_err(occ->bus_dev, "failed to setup sysfs: %d\n", rc); + + return rc; } diff --git a/drivers/hwmon/occ/common.h b/drivers/hwmon/occ/common.h index 9d01973d93d8..7c44df3f5631 100644 --- a/drivers/hwmon/occ/common.h +++ b/drivers/hwmon/occ/common.h @@ -104,8 +104,25 @@ struct occ { struct occ_attribute *attrs; struct attribute_group group; const struct attribute_group *groups[2]; + + int error; /* latest transfer error */ + unsigned int error_count; /* number of xfr errors observed */ + unsigned long last_safe; /* time OCC entered "safe" state */ + + /* + * Store the previous state data for comparison in order to notify + * sysfs readers of state changes. + */ + int prev_error; + u8 prev_stat; + u8 prev_ext_stat; + u8 prev_occs_present; }; int occ_setup(struct occ *occ, const char *name); +int occ_setup_sysfs(struct occ *occ); +void occ_shutdown(struct occ *occ); +void occ_sysfs_poll_done(struct occ *occ); +int occ_update_response(struct occ *occ); #endif /* OCC_COMMON_H */ diff --git a/drivers/hwmon/occ/p8_i2c.c b/drivers/hwmon/occ/p8_i2c.c index e4c2c047b99c..b59efc945e54 100644 --- a/drivers/hwmon/occ/p8_i2c.c +++ b/drivers/hwmon/occ/p8_i2c.c @@ -223,6 +223,15 @@ static int p8_i2c_occ_probe(struct i2c_client *client, return occ_setup(occ, "p8_occ"); } +static int p8_i2c_occ_remove(struct i2c_client *client) +{ + struct occ *occ = dev_get_drvdata(&client->dev); + + occ_shutdown(occ); + + return 0; +} + static const struct of_device_id p8_i2c_occ_of_match[] = { { .compatible = "ibm,p8-occ-hwmon" }, {} @@ -236,6 +245,7 @@ static struct i2c_driver p8_i2c_occ_driver = { .of_match_table = p8_i2c_occ_of_match, }, .probe = p8_i2c_occ_probe, + .remove = p8_i2c_occ_remove, }; module_i2c_driver(p8_i2c_occ_driver); diff --git a/drivers/hwmon/occ/p9_sbe.c b/drivers/hwmon/occ/p9_sbe.c index b33f4fe63fbb..b65c1d1dfb54 100644 --- a/drivers/hwmon/occ/p9_sbe.c +++ b/drivers/hwmon/occ/p9_sbe.c @@ -86,6 +86,7 @@ static int p9_sbe_occ_remove(struct platform_device *pdev) struct p9_sbe_occ *ctx = to_p9_sbe_occ(occ); ctx->sbe = NULL; + occ_shutdown(occ); return 0; } diff --git a/drivers/hwmon/occ/sysfs.c b/drivers/hwmon/occ/sysfs.c new file mode 100644 index 000000000000..743b26ec8e54 --- /dev/null +++ b/drivers/hwmon/occ/sysfs.c @@ -0,0 +1,188 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * OCC hwmon driver sysfs interface + * + * Copyright (C) IBM Corporation 2018 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include +#include + +#include "common.h" + +/* OCC status register */ +#define OCC_STAT_MASTER BIT(7) +#define OCC_STAT_ACTIVE BIT(0) + +/* OCC extended status register */ +#define OCC_EXT_STAT_DVFS_OT BIT(7) +#define OCC_EXT_STAT_DVFS_POWER BIT(6) +#define OCC_EXT_STAT_MEM_THROTTLE BIT(5) +#define OCC_EXT_STAT_QUICK_DROP BIT(4) + +static ssize_t occ_sysfs_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int rc; + int val = 0; + struct occ *occ = dev_get_drvdata(dev); + struct occ_poll_response_header *header; + struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr); + + rc = occ_update_response(occ); + if (rc) + return rc; + + header = (struct occ_poll_response_header *)occ->resp.data; + + switch (sattr->index) { + case 0: + val = !!(header->status & OCC_STAT_MASTER); + break; + case 1: + val = !!(header->status & OCC_STAT_ACTIVE); + break; + case 2: + val = !!(header->status & OCC_EXT_STAT_DVFS_OT); + break; + case 3: + val = !!(header->status & OCC_EXT_STAT_DVFS_POWER); + break; + case 4: + val = !!(header->status & OCC_EXT_STAT_MEM_THROTTLE); + break; + case 5: + val = !!(header->status & OCC_EXT_STAT_QUICK_DROP); + break; + case 6: + val = header->occ_state; + break; + case 7: + if (header->status & OCC_STAT_MASTER) + val = hweight8(header->occs_present); + else + val = 1; + break; + case 8: + val = occ->error; + break; + default: + return -EINVAL; + } + + return snprintf(buf, PAGE_SIZE - 1, "%d\n", val); +} + +static SENSOR_DEVICE_ATTR(occ_master, 0444, occ_sysfs_show, NULL, 0); +static SENSOR_DEVICE_ATTR(occ_active, 0444, occ_sysfs_show, NULL, 1); +static SENSOR_DEVICE_ATTR(occ_dvfs_overtemp, 0444, occ_sysfs_show, NULL, 2); +static SENSOR_DEVICE_ATTR(occ_dvfs_power, 0444, occ_sysfs_show, NULL, 3); +static SENSOR_DEVICE_ATTR(occ_mem_throttle, 0444, occ_sysfs_show, NULL, 4); +static SENSOR_DEVICE_ATTR(occ_quick_pwr_drop, 0444, occ_sysfs_show, NULL, 5); +static SENSOR_DEVICE_ATTR(occ_state, 0444, occ_sysfs_show, NULL, 6); +static SENSOR_DEVICE_ATTR(occs_present, 0444, occ_sysfs_show, NULL, 7); +static SENSOR_DEVICE_ATTR(occ_error, 0444, occ_sysfs_show, NULL, 8); + +static struct attribute *occ_attributes[] = { + &sensor_dev_attr_occ_master.dev_attr.attr, + &sensor_dev_attr_occ_active.dev_attr.attr, + &sensor_dev_attr_occ_dvfs_overtemp.dev_attr.attr, + &sensor_dev_attr_occ_dvfs_power.dev_attr.attr, + &sensor_dev_attr_occ_mem_throttle.dev_attr.attr, + &sensor_dev_attr_occ_quick_pwr_drop.dev_attr.attr, + &sensor_dev_attr_occ_state.dev_attr.attr, + &sensor_dev_attr_occs_present.dev_attr.attr, + &sensor_dev_attr_occ_error.dev_attr.attr, + NULL +}; + +static const struct attribute_group occ_sysfs = { + .attrs = occ_attributes, +}; + +void occ_sysfs_poll_done(struct occ *occ) +{ + const char *name; + struct occ_poll_response_header *header = + (struct occ_poll_response_header *)occ->resp.data; + + /* + * On the first poll response, we haven't yet created the sysfs + * attributes, so don't make any notify calls. + */ + if (!occ->hwmon) + goto done; + + if ((header->status & OCC_STAT_MASTER) != + (occ->prev_stat & OCC_STAT_MASTER)) { + name = sensor_dev_attr_occ_master.dev_attr.attr.name; + sysfs_notify(&occ->bus_dev->kobj, NULL, name); + } + + if ((header->status & OCC_STAT_ACTIVE) != + (occ->prev_stat & OCC_STAT_ACTIVE)) { + name = sensor_dev_attr_occ_active.dev_attr.attr.name; + sysfs_notify(&occ->bus_dev->kobj, NULL, name); + } + + if ((header->ext_status & OCC_EXT_STAT_DVFS_OT) != + (occ->prev_ext_stat & OCC_EXT_STAT_DVFS_OT)) { + name = sensor_dev_attr_occ_dvfs_overtemp.dev_attr.attr.name; + sysfs_notify(&occ->bus_dev->kobj, NULL, name); + } + + if ((header->ext_status & OCC_EXT_STAT_DVFS_POWER) != + (occ->prev_ext_stat & OCC_EXT_STAT_DVFS_POWER)) { + name = sensor_dev_attr_occ_dvfs_power.dev_attr.attr.name; + sysfs_notify(&occ->bus_dev->kobj, NULL, name); + } + + if ((header->ext_status & OCC_EXT_STAT_MEM_THROTTLE) != + (occ->prev_ext_stat & OCC_EXT_STAT_MEM_THROTTLE)) { + name = sensor_dev_attr_occ_mem_throttle.dev_attr.attr.name; + sysfs_notify(&occ->bus_dev->kobj, NULL, name); + } + + if ((header->ext_status & OCC_EXT_STAT_QUICK_DROP) != + (occ->prev_ext_stat & OCC_EXT_STAT_QUICK_DROP)) { + name = sensor_dev_attr_occ_quick_pwr_drop.dev_attr.attr.name; + sysfs_notify(&occ->bus_dev->kobj, NULL, name); + } + + if ((header->status & OCC_STAT_MASTER) && + header->occs_present != occ->prev_occs_present) { + name = sensor_dev_attr_occs_present.dev_attr.attr.name; + sysfs_notify(&occ->bus_dev->kobj, NULL, name); + } + + if (occ->error && occ->error != occ->prev_error) { + name = sensor_dev_attr_occ_error.dev_attr.attr.name; + sysfs_notify(&occ->bus_dev->kobj, NULL, name); + } + + /* no notifications for OCC state; doesn't indicate error condition */ + +done: + occ->prev_error = occ->error; + occ->prev_stat = header->status; + occ->prev_ext_stat = header->ext_status; + occ->prev_occs_present = header->occs_present; +} + +int occ_setup_sysfs(struct occ *occ) +{ + return sysfs_create_group(&occ->bus_dev->kobj, &occ_sysfs); +} + +void occ_shutdown(struct occ *occ) +{ + sysfs_remove_group(&occ->bus_dev->kobj, &occ_sysfs); +} -- cgit v1.2.3 From efb0489ea8fa12c6a5b51c0b3e35f4f3d5d54939 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 5 Nov 2018 12:48:40 -0800 Subject: hwmon: (ina3221) Check channel status for alarms attribute read There is nothing critically wrong to read these two attributes without having a is_enabled() check at this point. But reading the MASK_ENABLE register would clear the CVRF bit according to the datasheet. So it'd be safer to fence for disabled channels in order to add pm runtime feature. Signed-off-by: Nicolin Chen Signed-off-by: Guenter Roeck --- drivers/hwmon/ina3221.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c index d61688f04594..26cdf3342d80 100644 --- a/drivers/hwmon/ina3221.c +++ b/drivers/hwmon/ina3221.c @@ -200,6 +200,12 @@ static int ina3221_read_curr(struct device *dev, u32 attr, return 0; case hwmon_curr_crit_alarm: case hwmon_curr_max_alarm: + /* No actual register read if channel is disabled */ + if (!ina3221_is_enabled(ina, channel)) { + /* Return 0 for alert flags */ + *val = 0; + return 0; + } ret = regmap_field_read(ina->fields[reg], ®val); if (ret) return ret; -- cgit v1.2.3 From 87625b24986bc2aeea20cf8a795b01a799a471b0 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 5 Nov 2018 12:48:41 -0800 Subject: hwmon: (ina3221) Serialize sysfs ABI accesses This change adds a mutex to serialize accesses of sysfs attributes. This is required when polling CVRF bit of the MASK/ENABLE register because this bit is cleared on a read of this MASK/ENABLE register or a write to CONFIG register, which means that this bit might be accidentally cleared by reading other fields like alert flags. So this patch adds a mutex lock to protect the write() and read() callbacks. The read_string() callback won't need the lock since it just returns the label without touching any hardware register. Signed-off-by: Nicolin Chen Signed-off-by: Guenter Roeck --- drivers/hwmon/ina3221.c | 51 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c index 26cdf3342d80..10e8347a3c80 100644 --- a/drivers/hwmon/ina3221.c +++ b/drivers/hwmon/ina3221.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -94,12 +95,14 @@ struct ina3221_input { * @regmap: Register map of the device * @fields: Register fields of the device * @inputs: Array of channel input source specific structures + * @lock: mutex lock to serialize sysfs attribute accesses * @reg_config: Register value of INA3221_CONFIG */ struct ina3221_data { struct regmap *regmap; struct regmap_field *fields[F_MAX_FIELDS]; struct ina3221_input inputs[INA3221_NUM_CHANNELS]; + struct mutex lock; u32 reg_config; }; @@ -265,29 +268,53 @@ static int ina3221_write_enable(struct device *dev, int channel, bool enable) static int ina3221_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, long *val) { + struct ina3221_data *ina = dev_get_drvdata(dev); + int ret; + + mutex_lock(&ina->lock); + switch (type) { case hwmon_in: /* 0-align channel ID */ - return ina3221_read_in(dev, attr, channel - 1, val); + ret = ina3221_read_in(dev, attr, channel - 1, val); + break; case hwmon_curr: - return ina3221_read_curr(dev, attr, channel, val); + ret = ina3221_read_curr(dev, attr, channel, val); + break; default: - return -EOPNOTSUPP; + ret = -EOPNOTSUPP; + break; } + + mutex_unlock(&ina->lock); + + return ret; } static int ina3221_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, long val) { + struct ina3221_data *ina = dev_get_drvdata(dev); + int ret; + + mutex_lock(&ina->lock); + switch (type) { case hwmon_in: /* 0-align channel ID */ - return ina3221_write_enable(dev, channel - 1, val); + ret = ina3221_write_enable(dev, channel - 1, val); + break; case hwmon_curr: - return ina3221_write_curr(dev, attr, channel, val); + ret = ina3221_write_curr(dev, attr, channel, val); + break; default: - return -EOPNOTSUPP; + ret = -EOPNOTSUPP; + break; } + + mutex_unlock(&ina->lock); + + return ret; } static int ina3221_read_string(struct device *dev, enum hwmon_sensor_types type, @@ -582,6 +609,7 @@ static int ina3221_probe(struct i2c_client *client, if (ret) return ret; + mutex_init(&ina->lock); dev_set_drvdata(dev, ina); hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, ina, @@ -589,12 +617,22 @@ static int ina3221_probe(struct i2c_client *client, ina3221_groups); if (IS_ERR(hwmon_dev)) { dev_err(dev, "Unable to register hwmon device\n"); + mutex_destroy(&ina->lock); return PTR_ERR(hwmon_dev); } return 0; } +static int ina3221_remove(struct i2c_client *client) +{ + struct ina3221_data *ina = dev_get_drvdata(&client->dev); + + mutex_destroy(&ina->lock); + + return 0; +} + static int __maybe_unused ina3221_suspend(struct device *dev) { struct ina3221_data *ina = dev_get_drvdata(dev); @@ -663,6 +701,7 @@ MODULE_DEVICE_TABLE(i2c, ina3221_ids); static struct i2c_driver ina3221_i2c_driver = { .probe = ina3221_probe, + .remove = ina3221_remove, .driver = { .name = INA3221_DRIVER_NAME, .of_match_table = ina3221_of_match_table, -- cgit v1.2.3 From 4c0415a371fdbac6531d435a50745255e32d0e0e Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 5 Nov 2018 12:48:42 -0800 Subject: hwmon: (ina3221) Make sure data is ready before reading The data might need some time to get ready after channel enabling, although the data register is always readable. The CVRF bit is to indicate that data conversion is finished, so polling the CVRF bit before data reading could ensure the result being valid. An alternative way could be to wait for expected time between the channel enabling and the data reading. And this could avoid extra I2C communications. However, INA3221 seemly takes longer time than what's stated in the datasheet. Test results show that sometimes it couldn't finish data conversion in time. So this patch plays safe by adding a CVRF polling to make sure the data register is updated with the new data. Signed-off-by: Nicolin Chen Signed-off-by: Guenter Roeck --- drivers/hwmon/ina3221.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c index 10e8347a3c80..07dd6ef58d3e 100644 --- a/drivers/hwmon/ina3221.c +++ b/drivers/hwmon/ina3221.c @@ -44,6 +44,13 @@ #define INA3221_CONFIG_MODE_SHUNT BIT(0) #define INA3221_CONFIG_MODE_BUS BIT(1) #define INA3221_CONFIG_MODE_CONTINUOUS BIT(2) +#define INA3221_CONFIG_VSH_CT_SHIFT 3 +#define INA3221_CONFIG_VSH_CT_MASK GENMASK(5, 3) +#define INA3221_CONFIG_VSH_CT(x) (((x) & GENMASK(5, 3)) >> 3) +#define INA3221_CONFIG_VBUS_CT_SHIFT 6 +#define INA3221_CONFIG_VBUS_CT_MASK GENMASK(8, 6) +#define INA3221_CONFIG_VBUS_CT(x) (((x) & GENMASK(8, 6)) >> 6) +#define INA3221_CONFIG_CHs_EN_MASK GENMASK(14, 12) #define INA3221_CONFIG_CHx_EN(x) BIT(14 - (x)) #define INA3221_RSHUNT_DEFAULT 10000 @@ -52,6 +59,9 @@ enum ina3221_fields { /* Configuration */ F_RST, + /* Status Flags */ + F_CVRF, + /* Alert Flags */ F_WF3, F_WF2, F_WF1, F_CF3, F_CF2, F_CF1, @@ -63,6 +73,7 @@ enum ina3221_fields { static const struct reg_field ina3221_reg_fields[] = { [F_RST] = REG_FIELD(INA3221_CONFIG, 15, 15), + [F_CVRF] = REG_FIELD(INA3221_MASK_ENABLE, 0, 0), [F_WF3] = REG_FIELD(INA3221_MASK_ENABLE, 3, 3), [F_WF2] = REG_FIELD(INA3221_MASK_ENABLE, 4, 4), [F_WF1] = REG_FIELD(INA3221_MASK_ENABLE, 5, 5), @@ -111,6 +122,28 @@ static inline bool ina3221_is_enabled(struct ina3221_data *ina, int channel) return ina->reg_config & INA3221_CONFIG_CHx_EN(channel); } +/* Lookup table for Bus and Shunt conversion times in usec */ +static const u16 ina3221_conv_time[] = { + 140, 204, 332, 588, 1100, 2116, 4156, 8244, +}; + +static inline int ina3221_wait_for_data(struct ina3221_data *ina) +{ + u32 channels = hweight16(ina->reg_config & INA3221_CONFIG_CHs_EN_MASK); + u32 vbus_ct_idx = INA3221_CONFIG_VBUS_CT(ina->reg_config); + u32 vsh_ct_idx = INA3221_CONFIG_VSH_CT(ina->reg_config); + u32 vbus_ct = ina3221_conv_time[vbus_ct_idx]; + u32 vsh_ct = ina3221_conv_time[vsh_ct_idx]; + u32 wait, cvrf; + + /* Calculate total conversion time */ + wait = channels * (vbus_ct + vsh_ct); + + /* Polling the CVRF bit to make sure read data is ready */ + return regmap_field_read_poll_timeout(ina->fields[F_CVRF], + cvrf, cvrf, wait, 100000); +} + static int ina3221_read_value(struct ina3221_data *ina, unsigned int reg, int *val) { @@ -150,6 +183,10 @@ static int ina3221_read_in(struct device *dev, u32 attr, int channel, long *val) if (!ina3221_is_enabled(ina, channel)) return -ENODATA; + ret = ina3221_wait_for_data(ina); + if (ret) + return ret; + ret = ina3221_read_value(ina, reg, ®val); if (ret) return ret; @@ -189,6 +226,11 @@ static int ina3221_read_curr(struct device *dev, u32 attr, case hwmon_curr_input: if (!ina3221_is_enabled(ina, channel)) return -ENODATA; + + ret = ina3221_wait_for_data(ina); + if (ret) + return ret; + /* fall through */ case hwmon_curr_crit: case hwmon_curr_max: -- cgit v1.2.3 From 323aeb0eb5d9a6820130dfab1214a83edf385dcd Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 5 Nov 2018 12:48:43 -0800 Subject: hwmon: (ina3221) Add PM runtime support If all three channels are disabled via in[123]_enable ABI, the driver could suspend the chip for power saving purpose. So this patch adds the PM runtime support in order to gain more power control than system suspend and resume use case. For PM runtime, there are a few related changes happening: 1) Added a new pm_dev device pointer for all the PM runtime callbacks. This is because hwmon core registers a child device for each hwmon driver and passes it back to each driver. So there might be a mismatch between two device pointers in the driver if mixing using them. 2) Added a check in ina3221_is_enabled() to make sure that the chip is resumed. 3) Bypassed the unchanged status in ina3221_write_enable() in order to keep the PM runtime refcount being matched. 4) Removed the reset routine in the probe() by calling the resume() via pm_runtime_get_sync() instead, as they're similar. It's also necessary to do so to match initial PM refcount with the number of enabled channels. Signed-off-by: Nicolin Chen Signed-off-by: Guenter Roeck --- drivers/hwmon/ina3221.c | 93 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 74 insertions(+), 19 deletions(-) diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c index 07dd6ef58d3e..17a57dbc0424 100644 --- a/drivers/hwmon/ina3221.c +++ b/drivers/hwmon/ina3221.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #define INA3221_DRIVER_NAME "ina3221" @@ -53,6 +54,7 @@ #define INA3221_CONFIG_CHs_EN_MASK GENMASK(14, 12) #define INA3221_CONFIG_CHx_EN(x) BIT(14 - (x)) +#define INA3221_CONFIG_DEFAULT 0x7127 #define INA3221_RSHUNT_DEFAULT 10000 enum ina3221_fields { @@ -103,6 +105,7 @@ struct ina3221_input { /** * struct ina3221_data - device specific information + * @pm_dev: Device pointer for pm runtime * @regmap: Register map of the device * @fields: Register fields of the device * @inputs: Array of channel input source specific structures @@ -110,6 +113,7 @@ struct ina3221_input { * @reg_config: Register value of INA3221_CONFIG */ struct ina3221_data { + struct device *pm_dev; struct regmap *regmap; struct regmap_field *fields[F_MAX_FIELDS]; struct ina3221_input inputs[INA3221_NUM_CHANNELS]; @@ -119,7 +123,8 @@ struct ina3221_data { static inline bool ina3221_is_enabled(struct ina3221_data *ina, int channel) { - return ina->reg_config & INA3221_CONFIG_CHx_EN(channel); + return pm_runtime_active(ina->pm_dev) && + (ina->reg_config & INA3221_CONFIG_CHx_EN(channel)); } /* Lookup table for Bus and Shunt conversion times in usec */ @@ -290,21 +295,48 @@ static int ina3221_write_enable(struct device *dev, int channel, bool enable) { struct ina3221_data *ina = dev_get_drvdata(dev); u16 config, mask = INA3221_CONFIG_CHx_EN(channel); + u16 config_old = ina->reg_config & mask; int ret; config = enable ? mask : 0; + /* Bypass if enable status is not being changed */ + if (config_old == config) + return 0; + + /* For enabling routine, increase refcount and resume() at first */ + if (enable) { + ret = pm_runtime_get_sync(ina->pm_dev); + if (ret < 0) { + dev_err(dev, "Failed to get PM runtime\n"); + return ret; + } + } + /* Enable or disable the channel */ ret = regmap_update_bits(ina->regmap, INA3221_CONFIG, mask, config); if (ret) - return ret; + goto fail; /* Cache the latest config register value */ ret = regmap_read(ina->regmap, INA3221_CONFIG, &ina->reg_config); if (ret) - return ret; + goto fail; + + /* For disabling routine, decrease refcount or suspend() at last */ + if (!enable) + pm_runtime_put_sync(ina->pm_dev); return 0; + +fail: + if (enable) { + dev_err(dev, "Failed to enable channel %d: error %d\n", + channel, ret); + pm_runtime_put_sync(ina->pm_dev); + } + + return ret; } static int ina3221_read(struct device *dev, enum hwmon_sensor_types type, @@ -631,44 +663,65 @@ static int ina3221_probe(struct i2c_client *client, return ret; } - ret = regmap_field_write(ina->fields[F_RST], true); - if (ret) { - dev_err(dev, "Unable to reset device\n"); - return ret; - } - - /* Sync config register after reset */ - ret = regmap_read(ina->regmap, INA3221_CONFIG, &ina->reg_config); - if (ret) - return ret; + /* The driver will be reset, so use reset value */ + ina->reg_config = INA3221_CONFIG_DEFAULT; /* Disable channels if their inputs are disconnected */ for (i = 0; i < INA3221_NUM_CHANNELS; i++) { if (ina->inputs[i].disconnected) ina->reg_config &= ~INA3221_CONFIG_CHx_EN(i); } - ret = regmap_write(ina->regmap, INA3221_CONFIG, ina->reg_config); - if (ret) - return ret; + ina->pm_dev = dev; mutex_init(&ina->lock); dev_set_drvdata(dev, ina); + /* Enable PM runtime -- status is suspended by default */ + pm_runtime_enable(ina->pm_dev); + + /* Initialize (resume) the device */ + for (i = 0; i < INA3221_NUM_CHANNELS; i++) { + if (ina->inputs[i].disconnected) + continue; + /* Match the refcount with number of enabled channels */ + ret = pm_runtime_get_sync(ina->pm_dev); + if (ret < 0) + goto fail; + } + hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, ina, &ina3221_chip_info, ina3221_groups); if (IS_ERR(hwmon_dev)) { dev_err(dev, "Unable to register hwmon device\n"); - mutex_destroy(&ina->lock); - return PTR_ERR(hwmon_dev); + ret = PTR_ERR(hwmon_dev); + goto fail; } return 0; + +fail: + pm_runtime_disable(ina->pm_dev); + pm_runtime_set_suspended(ina->pm_dev); + /* pm_runtime_put_noidle() will decrease the PM refcount until 0 */ + for (i = 0; i < INA3221_NUM_CHANNELS; i++) + pm_runtime_put_noidle(ina->pm_dev); + mutex_destroy(&ina->lock); + + return ret; } static int ina3221_remove(struct i2c_client *client) { struct ina3221_data *ina = dev_get_drvdata(&client->dev); + int i; + + pm_runtime_disable(ina->pm_dev); + pm_runtime_set_suspended(ina->pm_dev); + + /* pm_runtime_put_noidle() will decrease the PM refcount until 0 */ + for (i = 0; i < INA3221_NUM_CHANNELS; i++) + pm_runtime_put_noidle(ina->pm_dev); mutex_destroy(&ina->lock); @@ -726,7 +779,9 @@ static int __maybe_unused ina3221_resume(struct device *dev) } static const struct dev_pm_ops ina3221_pm = { - SET_SYSTEM_SLEEP_PM_OPS(ina3221_suspend, ina3221_resume) + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) + SET_RUNTIME_PM_OPS(ina3221_suspend, ina3221_resume, NULL) }; static const struct of_device_id ina3221_of_match_table[] = { -- cgit v1.2.3 From b6611bcd5144e61a9cc21ee55c74aff688dff3f0 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 12 Nov 2018 20:36:56 -0800 Subject: hwmon (lm63) Do not overwrite data->kind According to the code right before the removed line, data->kind should be either from DT or from id pointer. So there shouldn't be an additional overwriting after the if-else statement. So this patch just removes the overwriting line. Signed-off-by: Nicolin Chen Signed-off-by: Guenter Roeck --- drivers/hwmon/lm63.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index 4c1770920d29..eac54b9cdeec 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c @@ -1120,7 +1120,6 @@ static int lm63_probe(struct i2c_client *client, data->kind = (enum chips)of_device_get_match_data(&client->dev); else data->kind = id->driver_data; - data->kind = id->driver_data; if (data->kind == lm64) data->temp2_offset = 16000; -- cgit v1.2.3 From 25bbdccfcd8c07c44feb74700f556546ef340f0f Mon Sep 17 00:00:00 2001 From: Heiko Stuebner Date: Wed, 7 Nov 2018 16:47:08 +0100 Subject: dt-bindings: hwmon: tmp108: add optional interrupts and #thermal-sensor-cells The tmp108 does have an alert output that can be used as interrupt source and can of course also be used as part of a thermal sensor setup for things like thermal-based cpu frequencies, so document the necessary properties. Signed-off-by: Heiko Stuebner Reviewed-by: Rob Herring Signed-off-by: Guenter Roeck --- Documentation/devicetree/bindings/hwmon/tmp108.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/tmp108.txt b/Documentation/devicetree/bindings/hwmon/tmp108.txt index 8c4b10df86d9..54d4beed4ee5 100644 --- a/Documentation/devicetree/bindings/hwmon/tmp108.txt +++ b/Documentation/devicetree/bindings/hwmon/tmp108.txt @@ -7,6 +7,10 @@ Requires node properties: - compatible : "ti,tmp108" - reg : the I2C address of the device. This is 0x48, 0x49, 0x4a, or 0x4b. +Optional properties: +- interrupts: Reference to the TMP108 alert interrupt. +- #thermal-sensor-cells: should be set to 0. + Example: tmp108@48 { compatible = "ti,tmp108"; -- cgit v1.2.3 From 1b1f4efab0e4c8a75b772369682ff423d2df59f3 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Fri, 16 Nov 2018 16:05:38 -0600 Subject: hwmon: (ina3221) Convert to using %pOFn instead of device_node.name In preparation to remove the node name pointer from struct device_node, convert printf users to use the %pOFn format specifier. Cc: Jean Delvare Cc: Guenter Roeck Signed-off-by: Rob Herring Signed-off-by: Guenter Roeck --- drivers/hwmon/ina3221.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c index 17a57dbc0424..e90ccac8bebb 100644 --- a/drivers/hwmon/ina3221.c +++ b/drivers/hwmon/ina3221.c @@ -576,10 +576,10 @@ static int ina3221_probe_child_from_dt(struct device *dev, ret = of_property_read_u32(child, "reg", &val); if (ret) { - dev_err(dev, "missing reg property of %s\n", child->name); + dev_err(dev, "missing reg property of %pOFn\n", child); return ret; } else if (val > INA3221_CHANNEL3) { - dev_err(dev, "invalid reg %d of %s\n", val, child->name); + dev_err(dev, "invalid reg %d of %pOFn\n", val, child); return ret; } @@ -597,8 +597,8 @@ static int ina3221_probe_child_from_dt(struct device *dev, /* Overwrite default shunt resistor value optionally */ if (!of_property_read_u32(child, "shunt-resistor-micro-ohms", &val)) { if (val < 1 || val > INT_MAX) { - dev_err(dev, "invalid shunt resistor value %u of %s\n", - val, child->name); + dev_err(dev, "invalid shunt resistor value %u of %pOFn\n", + val, child); return -EINVAL; } input->shunt_resistor = val; -- cgit v1.2.3 From 9a629d7ada78c32e2100eb5ca6a25c6248d90bd9 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 19 Nov 2018 12:31:16 -0800 Subject: Documentation: hwmon: Add descriptions for ina2xx sysfs entries There are a few sysfs entries being exposed to user space by the ina2xx hwmon driver while not getting explicitly documented. So this patch just adds a description section for them. Signed-off-by: Nicolin Chen Signed-off-by: Guenter Roeck --- Documentation/hwmon/ina2xx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Documentation/hwmon/ina2xx b/Documentation/hwmon/ina2xx index b8df81f6d6bc..0f36c021192d 100644 --- a/Documentation/hwmon/ina2xx +++ b/Documentation/hwmon/ina2xx @@ -62,3 +62,18 @@ bus and shunt voltage conversion times multiplied by the averaging rate. We don't touch the conversion times and only modify the number of averages. The lower limit of the update_interval is 2 ms, the upper limit is 2253 ms. The actual programmed interval may vary from the desired value. + +General sysfs entries +------------- + +in0_input Shunt voltage(mV) channel +in1_input Bus voltage(mV) channel +curr1_input Current(mA) measurement channel +power1_input Power(uW) measurement channel +shunt_resistor Shunt resistance(uOhm) channel + +Sysfs entries for ina226, ina230 and ina231 only +------------- + +update_interval data conversion time; affects number of samples used + to average results for shunt and bus voltages. -- cgit v1.2.3 From 3f9ffa5c3a25bf2a3c880b07f620c8ef029dc261 Mon Sep 17 00:00:00 2001 From: Vadim Pasternak Date: Tue, 20 Nov 2018 23:16:36 +0000 Subject: hwmon: (mlxreg-fan) Modify macros for tachometer fault status reading Modify macros for tachometer fault status reading for making it more simple and clear. Signed-off-by: Vadim Pasternak Signed-off-by: Guenter Roeck --- drivers/hwmon/mlxreg-fan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/mlxreg-fan.c b/drivers/hwmon/mlxreg-fan.c index d8fa4bea4bc8..db8c6de0b6a0 100644 --- a/drivers/hwmon/mlxreg-fan.c +++ b/drivers/hwmon/mlxreg-fan.c @@ -51,7 +51,7 @@ */ #define MLXREG_FAN_GET_RPM(rval, d, s) (DIV_ROUND_CLOSEST(15000000 * 100, \ ((rval) + (s)) * (d))) -#define MLXREG_FAN_GET_FAULT(val, mask) (!((val) ^ (mask))) +#define MLXREG_FAN_GET_FAULT(val, mask) ((val) == (mask)) #define MLXREG_FAN_PWM_DUTY2STATE(duty) (DIV_ROUND_CLOSEST((duty) * \ MLXREG_FAN_MAX_STATE, \ MLXREG_FAN_MAX_DUTY)) -- cgit v1.2.3 From 162372b08879e970a4ca4b65e5acede6ebe7d1dc Mon Sep 17 00:00:00 2001 From: Michele Sorcinelli Date: Fri, 30 Nov 2018 18:42:56 +0000 Subject: dell-smm-hwmon.c: Add XPS 9570 to supported devices list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow the module to be loaded on Dell XPS 9570, without having to provide the "force=1" option. Signed-off-by: Michele Sorcinelli Reviewed-by: Pali Rohár Signed-off-by: Guenter Roeck --- drivers/hwmon/dell-smm-hwmon.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index 9d3ef879dc51..367a8a61712c 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -1017,6 +1017,13 @@ static const struct dmi_system_id i8k_dmi_table[] __initconst = { DMI_MATCH(DMI_PRODUCT_NAME, "XPS 15 9560"), }, }, + { + .ident = "Dell XPS 15 9570", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "XPS 15 9570"), + }, + }, { } }; -- cgit v1.2.3 From b71464c937f19f4e33d03c8379f03142d2381811 Mon Sep 17 00:00:00 2001 From: Corentin Labbe Date: Thu, 29 Nov 2018 20:09:14 +0000 Subject: hwmon: fix typo build -> built This patch fix a typo where build is used instead of built. Signed-off-by: Corentin Labbe Signed-off-by: Guenter Roeck --- drivers/hwmon/Kconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index e3bef55451ae..ee177655b89f 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -179,7 +179,7 @@ config SENSORS_ADT7X10 This module contains common code shared by the ADT7310/ADT7320 and ADT7410/ADT7420 temperature monitoring chip drivers. - If build as a module, the module will be called adt7x10. + If built as a module, the module will be called adt7x10. config SENSORS_ADT7310 tristate "Analog Devices ADT7310/ADT7320" @@ -242,7 +242,7 @@ config SENSORS_ADT7475 ADT7473, ADT7475, ADT7476 and ADT7490 hardware monitoring chips. - This driver can also be build as a module. If so, the module + This driver can also be built as a module. If so, the module will be called adt7475. config SENSORS_ASC7621 @@ -666,7 +666,7 @@ config SENSORS_JZ4740 If you say yes here you get support for reading adc values from the ADCIN pin on Ingenic JZ4740 SoC based boards. - This driver can also be build as a module. If so, the module will be + This driver can also be built as a module. If so, the module will be called jz4740-hwmon. config SENSORS_JC42 @@ -1594,7 +1594,7 @@ config SENSORS_AMC6821 If you say yes here you get support for the Texas Instruments AMC6821 hardware monitoring chips. - This driver can also be build as a module. If so, the module + This driver can also be built as a module. If so, the module will be called amc6821. config SENSORS_INA209 -- cgit v1.2.3 From 772df3c51e808bb6a71f8540c3c9a2b4ce4e2ead Mon Sep 17 00:00:00 2001 From: Corentin Labbe Date: Thu, 29 Nov 2018 20:09:15 +0000 Subject: hwmon: Remove multiple space after dot This patch remove extra space after a dot. Signed-off-by: Corentin Labbe Signed-off-by: Guenter Roeck --- drivers/hwmon/Kconfig | 236 +++++++++++++++++++++++++------------------------- 1 file changed, 118 insertions(+), 118 deletions(-) diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index ee177655b89f..6c3e331ff44c 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -11,7 +11,7 @@ menuconfig HWMON of a system. Most modern motherboards include such a device. It can include temperature sensors, voltage sensors, fan speed sensors and various additional features such as the ability to - control the speed of the fans. If you want this support you + control the speed of the fans. If you want this support you should say Y here and also to the specific driver(s) for your sensors chip(s) below. @@ -19,7 +19,7 @@ menuconfig HWMON sensors-detect script from the lm_sensors package. Read for details. - This support can also be built as a module. If so, the module + This support can also be built as a module. If so, the module will be called hwmon. if HWMON @@ -46,7 +46,7 @@ config SENSORS_AB8500 AB8500 die and two GPADC channels. The GPADC channel are preferably used to access sensors outside the AB8500 chip. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called abx500-temp. config SENSORS_ABITUGURU @@ -61,7 +61,7 @@ config SENSORS_ABITUGURU of which motherboards have which revision see Documentation/hwmon/abituguru - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called abituguru. config SENSORS_ABITUGURU3 @@ -75,7 +75,7 @@ config SENSORS_ABITUGURU3 2005). For more info and a list of which motherboards have which revision see Documentation/hwmon/abituguru3 - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called abituguru3. config SENSORS_AD7314 @@ -116,7 +116,7 @@ config SENSORS_ADM1021 and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A, Genesys Logic GL523SM, National Semiconductor LM84 and TI THMC10. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called adm1021. config SENSORS_ADM1025 @@ -127,7 +127,7 @@ config SENSORS_ADM1025 If you say yes here you get support for Analog Devices ADM1025 and Philips NE1619 sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called adm1025. config SENSORS_ADM1026 @@ -138,7 +138,7 @@ config SENSORS_ADM1026 If you say yes here you get support for Analog Devices ADM1026 sensor chip. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called adm1026. config SENSORS_ADM1029 @@ -149,7 +149,7 @@ config SENSORS_ADM1029 sensor chip. Very rare chip, please let us know you use it. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called adm1029. config SENSORS_ADM1031 @@ -159,7 +159,7 @@ config SENSORS_ADM1031 If you say yes here you get support for Analog Devices ADM1031 and ADM1030 sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called adm1031. config SENSORS_ADM9240 @@ -170,7 +170,7 @@ config SENSORS_ADM9240 If you say yes here you get support for Analog Devices ADM9240, Dallas DS1780, National Semiconductor LM81 sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called adm9240. config SENSORS_ADT7X10 @@ -242,7 +242,7 @@ config SENSORS_ADT7475 ADT7473, ADT7475, ADT7476 and ADT7490 hardware monitoring chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called adt7475. config SENSORS_ASC7621 @@ -255,7 +255,7 @@ config SENSORS_ASC7621 aSC7621 aSC7621a - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called asc7621. config SENSORS_K8TEMP @@ -267,7 +267,7 @@ config SENSORS_K8TEMP microarchitecture. Please note that you will need at least lm-sensors 2.10.1 for proper userspace support. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called k8temp. config SENSORS_K10TEMP @@ -280,7 +280,7 @@ config SENSORS_K10TEMP 12h (Llano), 14h (Brazos), 15h (Bulldozer/Trinity/Kaveri/Carrizo) and 16h (Kabini/Mullins) microarchitectures. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called k10temp. config SENSORS_FAM15H_POWER @@ -290,7 +290,7 @@ config SENSORS_FAM15H_POWER If you say yes here you get support for processor power information of your AMD family 15h CPU. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called fam15h_power. config SENSORS_APPLESMC @@ -326,7 +326,7 @@ config SENSORS_ARM_SCMI and power sensors available on SCMI based platforms. The actual number and type of sensors exported depend on the platform. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called scmi-hwmon. config SENSORS_ARM_SCPI @@ -346,7 +346,7 @@ config SENSORS_ASB100 If you say yes here you get support for the ASB100 Bach sensor chip found on some Asus mainboards. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called asb100. config SENSORS_ASPEED @@ -371,7 +371,7 @@ config SENSORS_ATXP1 If your board have such a chip, you are able to control your CPU core and other voltages. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called atxp1. config SENSORS_DS620 @@ -381,7 +381,7 @@ config SENSORS_DS620 If you say yes here you get support for Dallas Semiconductor DS620 sensor chip. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called ds620. config SENSORS_DS1621 @@ -396,7 +396,7 @@ config SENSORS_DS1621 - Maxim Integrated DS1721 - Maxim Integrated DS1731 - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called ds1621. config SENSORS_DELL_SMM @@ -427,7 +427,7 @@ config SENSORS_DA9055 If you say yes here you get support for ADC on the Dialog Semiconductor DA9055 PMIC. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called da9055-hwmon. config SENSORS_I5K_AMB @@ -448,7 +448,7 @@ config SENSORS_F71805F features of the Fintek F71805F/FG, F71806F/FG and F71872F/FG Super-I/O chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called f71805f. config SENSORS_F71882FG @@ -470,7 +470,7 @@ config SENSORS_F71882FG F81801U F81865F - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called f71882fg. config SENSORS_F75375S @@ -480,7 +480,7 @@ config SENSORS_F75375S If you say yes here you get support for hardware monitoring features of the Fintek F75375S/SP, F75373 and F75387 - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called f75375s. config SENSORS_MC13783_ADC @@ -502,7 +502,7 @@ config SENSORS_FSCHMD fscscy and fscher drivers and adding support for several other FSC sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called fschmd. config SENSORS_FTSTEUTATES @@ -524,7 +524,7 @@ config SENSORS_GL518SM If you say yes here you get support for Genesys Logic GL518SM sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called gl518sm. config SENSORS_GL520SM @@ -535,7 +535,7 @@ config SENSORS_GL520SM If you say yes here you get support for Genesys Logic GL520SM sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called gl520sm. config SENSORS_G760A @@ -545,7 +545,7 @@ config SENSORS_G760A If you say yes here you get support for Global Mixed-mode Technology Inc G760A fan speed PWM controller chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called g760a. config SENSORS_G762 @@ -555,7 +555,7 @@ config SENSORS_G762 If you say yes here you get support for Global Mixed-mode Technology Inc G762 and G763 fan speed PWM controller chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called g762. config SENSORS_GPIO_FAN @@ -566,7 +566,7 @@ config SENSORS_GPIO_FAN help If you say yes here you get support for fans connected to GPIO lines. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called gpio-fan. config SENSORS_HIH6130 @@ -576,7 +576,7 @@ config SENSORS_HIH6130 If you say yes here you get support for Honeywell Humidicon HIH-6130 and HIH-6131 Humidicon humidity sensors. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called hih6130. config SENSORS_IBMAEM @@ -590,7 +590,7 @@ config SENSORS_IBMAEM the x3350, x3550, x3650, x3655, x3755, x3850 M2, x3950 M2, and certain HC10/HS2x/LS2x/QS2x blades. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called ibmaem. config SENSORS_IBMPEX @@ -604,7 +604,7 @@ config SENSORS_IBMPEX x3655, and x3755; the x3800, x3850, and x3950 models that have PCI Express; and some of the HS2x, LS2x, and QS2x blades. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called ibmpex. config SENSORS_IBMPOWERNV @@ -656,7 +656,7 @@ config SENSORS_IT87 IT8603E, IT8620E, IT8623E, and IT8628E sensor chips, and the SiS950 clone. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called it87. config SENSORS_JZ4740 @@ -680,7 +680,7 @@ config SENSORS_JC42 MCP9808, MCP98242, MCP98243, MCP98244, MCP9843, SE97, SE98, STTS424(E), STTS2002, STTS3000, TSE2002, TSE2004, TS3000, and TS3001. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called jc42. config SENSORS_POWR1220 @@ -691,7 +691,7 @@ config SENSORS_POWR1220 functions of the Lattice POWR1220 isp Power Supply Monitoring, Sequencing and Margining Controller. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called powr1220. config SENSORS_LINEAGE @@ -702,7 +702,7 @@ config SENSORS_LINEAGE series of DC/DC and AC/DC converters such as CP1800, CP2000AC, CP2000DC, CP2725, and others. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called lineage-pem. config SENSORS_LTC2945 @@ -803,7 +803,7 @@ config SENSORS_MAX1111 Say y here to support Maxim's MAX1110, MAX1111, MAX1112, and MAX1113 ADC chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called max1111. config SENSORS_MAX16065 @@ -819,7 +819,7 @@ config SENSORS_MAX16065 MAX16070 MAX16071 - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called max16065. config SENSORS_MAX1619 @@ -828,7 +828,7 @@ config SENSORS_MAX1619 help If you say yes here you get support for MAX1619 sensor chip. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called max1619. config SENSORS_MAX1668 @@ -838,7 +838,7 @@ config SENSORS_MAX1668 If you say yes here you get support for MAX1668, MAX1989 and MAX1805 chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called max1668. config SENSORS_MAX197 @@ -881,7 +881,7 @@ config SENSORS_MAX6639 If you say yes here you get support for the MAX6639 sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called max6639. config SENSORS_MAX6642 @@ -892,7 +892,7 @@ config SENSORS_MAX6642 MAX6642 is a SMBus-Compatible Remote/Local Temperature Sensor with Overtemperature Alarm from Maxim. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called max6642. config SENSORS_MAX6650 @@ -902,7 +902,7 @@ config SENSORS_MAX6650 If you say yes here you get support for the MAX6650 / MAX6651 sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called max6650. config SENSORS_MAX6697 @@ -913,7 +913,7 @@ config SENSORS_MAX6697 MAX6636, MAX6689, MAX6693, MAX6694, MAX6697, MAX6698, and MAX6699 temperature sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called max6697. config SENSORS_MAX31790 @@ -923,7 +923,7 @@ config SENSORS_MAX31790 If you say yes here you get support for 6-Channel PWM-Output Fan RPM Controller. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called max31790. config SENSORS_MCP3021 @@ -934,7 +934,7 @@ config SENSORS_MCP3021 The MCP3021 is a A/D converter (ADC) with 10-bit and the MCP3221 with 12-bit resolution. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called mcp3021. config SENSORS_MLXREG_FAN @@ -957,7 +957,7 @@ config SENSORS_TC654 The TC654 and TC655 are PWM mode fan speed controllers with FanSense technology for use with brushless DC fans. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called tc654. config SENSORS_MENF21BMC_HWMON @@ -983,7 +983,7 @@ config SENSORS_ADCXX Examples : ADC081S101, ADC124S501, ... - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called adcxx. config SENSORS_LM63 @@ -996,7 +996,7 @@ config SENSORS_LM63 on the Tyan S4882 (Thunder K8QS Pro) motherboard, among others. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called lm63. config SENSORS_LM70 @@ -1007,7 +1007,7 @@ config SENSORS_LM70 LM70, LM71, LM74 and Texas Instruments TMP121/TMP123 digital tempera- ture sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called lm70. config SENSORS_LM73 @@ -1016,7 +1016,7 @@ config SENSORS_LM73 help If you say yes here you get support for National Semiconductor LM73 sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called lm73. config SENSORS_LM75 @@ -1046,7 +1046,7 @@ config SENSORS_LM75 that with some chips which don't replicate LM75 quirks exactly, you may need the "force" module parameter. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called lm75. config SENSORS_LM77 @@ -1056,7 +1056,7 @@ config SENSORS_LM77 If you say yes here you get support for National Semiconductor LM77 sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called lm77. config SENSORS_LM78 @@ -1067,7 +1067,7 @@ config SENSORS_LM78 If you say yes here you get support for National Semiconductor LM78, LM78-J and LM79. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called lm78. config SENSORS_LM80 @@ -1077,7 +1077,7 @@ config SENSORS_LM80 If you say yes here you get support for National Semiconductor LM80 and LM96080 sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called lm80. config SENSORS_LM83 @@ -1087,7 +1087,7 @@ config SENSORS_LM83 If you say yes here you get support for National Semiconductor LM82 and LM83 sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called lm83. config SENSORS_LM85 @@ -1099,7 +1099,7 @@ config SENSORS_LM85 sensor chips and clones: ADM1027, ADT7463, ADT7468, EMC6D100, EMC6D101, EMC6D102, and EMC6D103. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called lm85. config SENSORS_LM87 @@ -1110,7 +1110,7 @@ config SENSORS_LM87 If you say yes here you get support for National Semiconductor LM87 and Analog Devices ADM1024 sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called lm87. config SENSORS_LM90 @@ -1124,7 +1124,7 @@ config SENSORS_LM90 Winbond/Nuvoton W83L771W/G/AWG/ASG, Philips SA56004, GMT G781, and Texas Instruments TMP451 sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called lm90. config SENSORS_LM92 @@ -1134,7 +1134,7 @@ config SENSORS_LM92 If you say yes here you get support for National Semiconductor LM92 and Maxim MAX6635 sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called lm92. config SENSORS_LM93 @@ -1145,7 +1145,7 @@ config SENSORS_LM93 If you say yes here you get support for National Semiconductor LM93, LM94, and compatible sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called lm93. config SENSORS_LM95234 @@ -1155,7 +1155,7 @@ config SENSORS_LM95234 If you say yes here you get support for the LM95233 and LM95234 temperature sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called lm95234. config SENSORS_LM95241 @@ -1165,7 +1165,7 @@ config SENSORS_LM95241 If you say yes here you get support for LM95231 and LM95241 sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called lm95241. config SENSORS_LM95245 @@ -1176,7 +1176,7 @@ config SENSORS_LM95245 If you say yes here you get support for LM95235 and LM95245 temperature sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called lm95245. config SENSORS_PC87360 @@ -1190,7 +1190,7 @@ config SENSORS_PC87360 control. The PC87365 and PC87366 additionally have voltage and temperature monitoring. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called pc87360. config SENSORS_PC87427 @@ -1204,7 +1204,7 @@ config SENSORS_PC87427 monitoring. Fan speed monitoring and control are supported, as well as temperature monitoring. Voltages aren't supported yet. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called pc87427. config SENSORS_NTC_THERMISTOR @@ -1220,7 +1220,7 @@ config SENSORS_NTC_THERMISTOR NCP15WB473, NCP18WB473, NCP21WB473, NCP03WB473, NCP15WL333, NCP03WF104 and NCP15XH103 from Murata and B57330V2103 from EPCOS. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called ntc-thermistor. config SENSORS_NCT6683 @@ -1230,7 +1230,7 @@ config SENSORS_NCT6683 If you say yes here you get support for the hardware monitoring functionality of the Nuvoton NCT6683D eSIO chip. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called nct6683. config SENSORS_NCT6775 @@ -1244,7 +1244,7 @@ config SENSORS_NCT6775 Super-I/O chips. This driver replaces the w83627ehf driver for NCT6775F and NCT6776F. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called nct6775. config SENSORS_NCT7802 @@ -1255,7 +1255,7 @@ config SENSORS_NCT7802 If you say yes here you get support for the Nuvoton NCT7802Y hardware monitoring chip. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called nct7802. config SENSORS_NCT7904 @@ -1265,7 +1265,7 @@ config SENSORS_NCT7904 If you say yes here you get support for the Nuvoton NCT7904 hardware monitoring chip, including manual fan speed control. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called nct7904. config SENSORS_NPCM7XX @@ -1302,11 +1302,11 @@ config SENSORS_PCF8591 If you say yes here you get support for Philips PCF8591 4-channel ADC, 1-channel DAC chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called pcf8591. These devices are hard to detect and rarely found on mainstream - hardware. If unsure, say N. + hardware. If unsure, say N. source drivers/hwmon/pmbus/Kconfig @@ -1319,7 +1319,7 @@ config SENSORS_PWM_FAN The driver uses the generic PWM interface, thus it will work on a variety of SoCs. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called pwm-fan. config SENSORS_RASPBERRYPI_HWMON @@ -1340,7 +1340,7 @@ config SENSORS_SHT15 If you say yes here you get support for the Sensiron SHT10, SHT11, SHT15, SHT71, SHT75 humidity and temperature sensors. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called sht15. config SENSORS_SHT21 @@ -1350,7 +1350,7 @@ config SENSORS_SHT21 If you say yes here you get support for the Sensiron SHT21, SHT25 humidity and temperature sensors. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called sht21. config SENSORS_SHT3x @@ -1361,7 +1361,7 @@ config SENSORS_SHT3x If you say yes here you get support for the Sensiron SHT30 and SHT31 humidity and temperature sensors. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called sht3x. config SENSORS_SHTC1 @@ -1371,7 +1371,7 @@ config SENSORS_SHTC1 If you say yes here you get support for the Sensiron SHTC1 and SHTW1 humidity and temperature sensors. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called shtc1. config SENSORS_S3C @@ -1398,7 +1398,7 @@ config SENSORS_SIS5595 If you say yes here you get support for the integrated sensors in SiS5595 South Bridges. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called sis5595. config SENSORS_DME1737 @@ -1410,7 +1410,7 @@ config SENSORS_DME1737 and fan control features of the SMSC DME1737, SCH311x, SCH5027, and Asus A8000 Super-I/O chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called dme1737. config SENSORS_EMC1403 @@ -1431,7 +1431,7 @@ config SENSORS_EMC2103 If you say yes here you get support for the temperature and fan sensors of the SMSC EMC2103 chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called emc2103. config SENSORS_EMC6W201 @@ -1441,7 +1441,7 @@ config SENSORS_EMC6W201 If you say yes here you get support for the SMSC EMC6W201 hardware monitoring chip. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called emc6w201. config SENSORS_SMSC47M1 @@ -1458,7 +1458,7 @@ config SENSORS_SMSC47M1 driver, select also "SMSC LPC47M192 and compatibles" below for those. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called smsc47m1. config SENSORS_SMSC47M192 @@ -1475,7 +1475,7 @@ config SENSORS_SMSC47M192 "SMSC LPC47M10x and compatibles" above. You need both drivers if you want fan control and voltage/temperature sensor support. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called smsc47m192. config SENSORS_SMSC47B397 @@ -1485,7 +1485,7 @@ config SENSORS_SMSC47B397 If you say yes here you get support for the SMSC LPC47B397-NC sensor chip. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called smsc47b397. config SENSORS_SCH56XX_COMMON @@ -1501,7 +1501,7 @@ config SENSORS_SCH5627 features of the SMSC SCH5627 Super-I/O chip including support for the integrated watchdog. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called sch5627. config SENSORS_SCH5636 @@ -1519,7 +1519,7 @@ config SENSORS_SCH5636 Theseus' hardware monitoring features including support for the integrated watchdog. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called sch5636. config SENSORS_STTS751 @@ -1529,7 +1529,7 @@ config SENSORS_STTS751 If you say yes here you get support for STTS751 temperature sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called stts751. config SENSORS_SMM665 @@ -1563,7 +1563,7 @@ config SENSORS_ADS1015 If you say yes here you get support for Texas Instruments ADS1015/ADS1115 12/16-bit 4-input ADC device. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called ads1015. config SENSORS_ADS7828 @@ -1575,7 +1575,7 @@ config SENSORS_ADS7828 ADS7830 8-channel A/D converters. ADS7828 resolution is 12-bit, while it is 8-bit on ADS7830. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called ads7828. config SENSORS_ADS7871 @@ -1584,7 +1584,7 @@ config SENSORS_ADS7871 help If you say yes here you get support for TI ADS7871 & ADS7870 - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called ads7871. config SENSORS_AMC6821 @@ -1594,7 +1594,7 @@ config SENSORS_AMC6821 If you say yes here you get support for the Texas Instruments AMC6821 hardware monitoring chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called amc6821. config SENSORS_INA209 @@ -1618,7 +1618,7 @@ config SENSORS_INA2XX The INA2xx driver is configured for the default configuration of the part as described in the datasheet. Default value for Rshunt is 10 mOhms. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called ina2xx. config SENSORS_INA3221 @@ -1629,7 +1629,7 @@ config SENSORS_INA3221 If you say yes here you get support for the TI INA3221 Triple Power Monitor. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called ina3221. config SENSORS_TC74 @@ -1639,7 +1639,7 @@ config SENSORS_TC74 If you say yes here you get support for Microchip TC74 single input temperature sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called tc74. config SENSORS_THMC50 @@ -1649,7 +1649,7 @@ config SENSORS_THMC50 If you say yes here you get support for Texas Instruments THMC50 sensor chips and clones: the Analog Devices ADM1022. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called thmc50. config SENSORS_TMP102 @@ -1660,7 +1660,7 @@ config SENSORS_TMP102 If you say yes here you get support for Texas Instruments TMP102 sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called tmp102. config SENSORS_TMP103 @@ -1671,7 +1671,7 @@ config SENSORS_TMP103 If you say yes here you get support for Texas Instruments TMP103 sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called tmp103. config SENSORS_TMP108 @@ -1682,7 +1682,7 @@ config SENSORS_TMP108 If you say yes here you get support for Texas Instruments TMP108 sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called tmp108. config SENSORS_TMP401 @@ -1692,7 +1692,7 @@ config SENSORS_TMP401 If you say yes here you get support for Texas Instruments TMP401, TMP411, TMP431, TMP432, TMP435, and TMP461 temperature sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called tmp401. config SENSORS_TMP421 @@ -1702,7 +1702,7 @@ config SENSORS_TMP421 If you say yes here you get support for Texas Instruments TMP421, TMP422, TMP423, TMP441, and TMP442 temperature sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called tmp421. config SENSORS_VEXPRESS @@ -1729,7 +1729,7 @@ config SENSORS_VIA686A If you say yes here you get support for the integrated sensors in Via 686A/B South Bridges. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called via686a. config SENSORS_VT1211 @@ -1740,7 +1740,7 @@ config SENSORS_VT1211 If you say yes here then you get support for hardware monitoring features of the VIA VT1211 Super-I/O chip. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called vt1211. config SENSORS_VT8231 @@ -1751,7 +1751,7 @@ config SENSORS_VT8231 If you say yes here then you get support for the integrated sensors in the VIA VT8231 device. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called vt8231. config SENSORS_W83773G @@ -1761,7 +1761,7 @@ config SENSORS_W83773G If you say yes here you get support for the Nuvoton W83773G hardware monitoring chip. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called w83773g. config SENSORS_W83781D @@ -1773,7 +1773,7 @@ config SENSORS_W83781D of sensor chips: the W83781D, W83782D and W83783S, and the similar Asus AS99127F. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called w83781d. config SENSORS_W83791D @@ -1783,7 +1783,7 @@ config SENSORS_W83791D help If you say yes here you get support for the Winbond W83791D chip. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called w83791d. config SENSORS_W83792D @@ -1792,7 +1792,7 @@ config SENSORS_W83792D help If you say yes here you get support for the Winbond W83792D chip. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called w83792d. config SENSORS_W83793 @@ -1804,7 +1804,7 @@ config SENSORS_W83793 hardware monitoring chip, including support for the integrated watchdog. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called w83793. config SENSORS_W83795 @@ -1815,7 +1815,7 @@ config SENSORS_W83795 W83795ADG hardware monitoring chip, including manual fan speed control. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called w83795. config SENSORS_W83795_FANCTRL @@ -1842,7 +1842,7 @@ config SENSORS_W83L785TS sensor chip, which is used on the Asus A7N8X, among other motherboards. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called w83l785ts. config SENSORS_W83L786NG @@ -1852,7 +1852,7 @@ config SENSORS_W83L786NG If you say yes here you get support for the Winbond W83L786NG and W83L786NR sensor chips. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called w83l786ng. config SENSORS_W83627HF @@ -1864,7 +1864,7 @@ config SENSORS_W83627HF of sensor chips: the W83627HF, W83627THF, W83637HF, W83687THF and W83697HF. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called w83627hf. config SENSORS_W83627EHF @@ -1884,7 +1884,7 @@ config SENSORS_W83627EHF This driver also supports Nuvoton W83667HG, W83667HG-B, NCT6775F (also known as W83667HG-I), and NCT6776F. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called w83627ehf. config SENSORS_WM831X @@ -1895,7 +1895,7 @@ config SENSORS_WM831X monitoring functionality of the Wolfson Microelectronics WM831x series of PMICs. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called wm831x-hwmon. config SENSORS_WM8350 @@ -1905,7 +1905,7 @@ config SENSORS_WM8350 If you say yes here you get support for the hardware monitoring features of the WM835x series of PMICs. - This driver can also be built as a module. If so, the module + This driver can also be built as a module. If so, the module will be called wm8350-hwmon. config SENSORS_ULTRA45 -- cgit v1.2.3 From 89688e8d1ecda59edc4e0ceb430aedaac18ca071 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 26 Nov 2018 16:28:32 +0000 Subject: hwmon: (ltc2978) Fix spelling mistake "comppatible" -> "compatible" There is a spelling mistake in the module description text, fix it. Signed-off-by: Colin Ian King Signed-off-by: Guenter Roeck --- drivers/hwmon/pmbus/ltc2978.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/pmbus/ltc2978.c b/drivers/hwmon/pmbus/ltc2978.c index 07afb92bb36b..29c0b7219aaa 100644 --- a/drivers/hwmon/pmbus/ltc2978.c +++ b/drivers/hwmon/pmbus/ltc2978.c @@ -795,5 +795,5 @@ static struct i2c_driver ltc2978_driver = { module_i2c_driver(ltc2978_driver); MODULE_AUTHOR("Guenter Roeck"); -MODULE_DESCRIPTION("PMBus driver for LTC2978 and comppatible chips"); +MODULE_DESCRIPTION("PMBus driver for LTC2978 and compatible chips"); MODULE_LICENSE("GPL"); -- cgit v1.2.3 From e1fd3be613e9d00c4b04ba0e9de1a6233fceedf2 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Sat, 17 Nov 2018 12:12:57 +0000 Subject: dt-bindings: hwmon: (ntc_thermistor) add B57891S0103 thermistor from Epcos These are Negative Temperature Coefficient thermistors, like the others in the list. Signed-off-by: Peter Rosin Signed-off-by: Guenter Roeck --- Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt b/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt index c3b9c4cfe8df..37f18d684f6a 100644 --- a/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt +++ b/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt @@ -4,6 +4,7 @@ NTC Thermistor hwmon sensors Requires node properties: - "compatible" value : one of "epcos,b57330v2103" + "epcos,b57891s0103" "murata,ncp15wb473" "murata,ncp18wb473" "murata,ncp21wb473" -- cgit v1.2.3 From e8fda2c8646e504a732fbe7507c543279323c3d9 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Sat, 17 Nov 2018 12:13:00 +0000 Subject: hwmon: (ntc_thermistor): add support for B57891S0103 from Epcos More of the same... Signed-off-by: Peter Rosin Signed-off-by: Guenter Roeck --- drivers/hwmon/Kconfig | 3 +- drivers/hwmon/ntc_thermistor.c | 57 +++++++++++++++++++++++++++- include/linux/platform_data/ntc_thermistor.h | 1 + 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 6c3e331ff44c..fe1e75051fd8 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1218,7 +1218,8 @@ config SENSORS_NTC_THERMISTOR Currently, this driver supports NCP15WB473, NCP18WB473, NCP21WB473, NCP03WB473, NCP15WL333, - NCP03WF104 and NCP15XH103 from Murata and B57330V2103 from EPCOS. + NCP03WF104 and NCP15XH103 from Murata and B57330V2103 and + B57891S0103 from EPCOS. This driver can also be built as a module. If so, the module will be called ntc-thermistor. diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c index c52d07c6b49f..e0c6b2f244a6 100644 --- a/drivers/hwmon/ntc_thermistor.c +++ b/drivers/hwmon/ntc_thermistor.c @@ -55,6 +55,7 @@ static const struct platform_device_id ntc_thermistor_id[] = { { "b57330v2103", TYPE_B57330V2103}, { "ncp03wf104", TYPE_NCPXXWF104 }, { "ncp15xh103", TYPE_NCPXXXH103 }, + { "b57891s0103", TYPE_B57891S0103 }, { }, }; @@ -212,8 +213,8 @@ static const struct ntc_compensation ncpXXxh103[] = { }; /* - * The following compensation table is from the specification of EPCOS NTC - * Thermistors Datasheet + * The following compensation tables are from the specifications in EPCOS NTC + * Thermistors Datasheets */ static const struct ntc_compensation b57330v2103[] = { { .temp_c = -40, .ohm = 190030 }, @@ -252,6 +253,52 @@ static const struct ntc_compensation b57330v2103[] = { { .temp_c = 125, .ohm = 531 }, }; +static const struct ntc_compensation b57891s0103[] = { + { .temp_c = -55.0, .ohm = 878900 }, + { .temp_c = -50.0, .ohm = 617590 }, + { .temp_c = -45.0, .ohm = 439340 }, + { .temp_c = -40.0, .ohm = 316180 }, + { .temp_c = -35.0, .ohm = 230060 }, + { .temp_c = -30.0, .ohm = 169150 }, + { .temp_c = -25.0, .ohm = 125550 }, + { .temp_c = -20.0, .ohm = 94143 }, + { .temp_c = -15.0, .ohm = 71172 }, + { .temp_c = -10.0, .ohm = 54308 }, + { .temp_c = -5.0, .ohm = 41505 }, + { .temp_c = 0.0, .ohm = 32014 }, + { .temp_c = 5.0, .ohm = 25011 }, + { .temp_c = 10.0, .ohm = 19691 }, + { .temp_c = 15.0, .ohm = 15618 }, + { .temp_c = 20.0, .ohm = 12474 }, + { .temp_c = 25.0, .ohm = 10000 }, + { .temp_c = 30.0, .ohm = 8080 }, + { .temp_c = 35.0, .ohm = 6569 }, + { .temp_c = 40.0, .ohm = 5372 }, + { .temp_c = 45.0, .ohm = 4424 }, + { .temp_c = 50.0, .ohm = 3661 }, + { .temp_c = 55.0, .ohm = 3039 }, + { .temp_c = 60.0, .ohm = 2536 }, + { .temp_c = 65.0, .ohm = 2128 }, + { .temp_c = 70.0, .ohm = 1794 }, + { .temp_c = 75.0, .ohm = 1518 }, + { .temp_c = 80.0, .ohm = 1290 }, + { .temp_c = 85.0, .ohm = 1100 }, + { .temp_c = 90.0, .ohm = 942 }, + { .temp_c = 95.0, .ohm = 809 }, + { .temp_c = 100.0, .ohm = 697 }, + { .temp_c = 105.0, .ohm = 604 }, + { .temp_c = 110.0, .ohm = 525 }, + { .temp_c = 115.0, .ohm = 457 }, + { .temp_c = 120.0, .ohm = 400 }, + { .temp_c = 125.0, .ohm = 351 }, + { .temp_c = 130.0, .ohm = 308 }, + { .temp_c = 135.0, .ohm = 272 }, + { .temp_c = 140.0, .ohm = 240 }, + { .temp_c = 145.0, .ohm = 213 }, + { .temp_c = 150.0, .ohm = 189 }, + { .temp_c = 155.0, .ohm = 168 }, +}; + struct ntc_data { struct ntc_thermistor_platform_data *pdata; const struct ntc_compensation *comp; @@ -296,6 +343,8 @@ static const struct of_device_id ntc_match[] = { .data = &ntc_thermistor_id[6] }, { .compatible = "murata,ncp15xh103", .data = &ntc_thermistor_id[7] }, + { .compatible = "epcos,b57891s0103", + .data = &ntc_thermistor_id[8] }, /* Usage of vendor name "ntc" is deprecated */ { .compatible = "ntc,ncp15wb473", @@ -627,6 +676,10 @@ static int ntc_thermistor_probe(struct platform_device *pdev) data->comp = ncpXXxh103; data->n_comp = ARRAY_SIZE(ncpXXxh103); break; + case TYPE_B57891S0103: + data->comp = b57891s0103; + data->n_comp = ARRAY_SIZE(b57891s0103); + break; default: dev_err(dev, "Unknown device type: %lu(%s)\n", pdev_id->driver_data, pdev_id->name); diff --git a/include/linux/platform_data/ntc_thermistor.h b/include/linux/platform_data/ntc_thermistor.h index 698d0d59db76..231a27c302ec 100644 --- a/include/linux/platform_data/ntc_thermistor.h +++ b/include/linux/platform_data/ntc_thermistor.h @@ -29,6 +29,7 @@ enum ntc_thermistor_type { TYPE_B57330V2103, TYPE_NCPXXWF104, TYPE_NCPXXXH103, + TYPE_B57891S0103, }; struct ntc_thermistor_platform_data { -- cgit v1.2.3 From e056fe25d9f021d45c3fb6068d11e56e9579754b Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Wed, 21 Nov 2018 16:03:39 +0000 Subject: hwmon: (ntc_thermistor) sort thermistor id lists alphabetically Use an enum to index the array, so that it is possible to add sorted entries without causing churn. Signed-off-by: Peter Rosin Signed-off-by: Guenter Roeck --- drivers/hwmon/ntc_thermistor.c | 82 +++++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 33 deletions(-) diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c index e0c6b2f244a6..7747c1ed1f02 100644 --- a/drivers/hwmon/ntc_thermistor.c +++ b/drivers/hwmon/ntc_thermistor.c @@ -45,18 +45,34 @@ struct ntc_compensation { unsigned int ohm; }; -/* Order matters, ntc_match references the entries by index */ +/* + * Used as index in a zero-terminated array, holes not allowed so + * that NTC_LAST is the first empty array entry. + */ +enum { + NTC_B57330V2103, + NTC_B57891S0103, + NTC_NCP03WB473, + NTC_NCP03WF104, + NTC_NCP15WB473, + NTC_NCP15WL333, + NTC_NCP15XH103, + NTC_NCP18WB473, + NTC_NCP21WB473, + NTC_LAST, +}; + static const struct platform_device_id ntc_thermistor_id[] = { - { "ncp15wb473", TYPE_NCPXXWB473 }, - { "ncp18wb473", TYPE_NCPXXWB473 }, - { "ncp21wb473", TYPE_NCPXXWB473 }, - { "ncp03wb473", TYPE_NCPXXWB473 }, - { "ncp15wl333", TYPE_NCPXXWL333 }, - { "b57330v2103", TYPE_B57330V2103}, - { "ncp03wf104", TYPE_NCPXXWF104 }, - { "ncp15xh103", TYPE_NCPXXXH103 }, - { "b57891s0103", TYPE_B57891S0103 }, - { }, + [NTC_B57330V2103] = { "b57330v2103", TYPE_B57330V2103 }, + [NTC_B57891S0103] = { "b57891s0103", TYPE_B57891S0103 }, + [NTC_NCP03WB473] = { "ncp03wb473", TYPE_NCPXXWB473 }, + [NTC_NCP03WF104] = { "ncp03wf104", TYPE_NCPXXWF104 }, + [NTC_NCP15WB473] = { "ncp15wb473", TYPE_NCPXXWB473 }, + [NTC_NCP15WL333] = { "ncp15wl333", TYPE_NCPXXWL333 }, + [NTC_NCP15XH103] = { "ncp15xh103", TYPE_NCPXXXH103 }, + [NTC_NCP18WB473] = { "ncp18wb473", TYPE_NCPXXWB473 }, + [NTC_NCP21WB473] = { "ncp21wb473", TYPE_NCPXXWB473 }, + [NTC_LAST] = { }, }; /* @@ -327,36 +343,36 @@ static int ntc_adc_iio_read(struct ntc_thermistor_platform_data *pdata) } static const struct of_device_id ntc_match[] = { - { .compatible = "murata,ncp15wb473", - .data = &ntc_thermistor_id[0] }, - { .compatible = "murata,ncp18wb473", - .data = &ntc_thermistor_id[1] }, - { .compatible = "murata,ncp21wb473", - .data = &ntc_thermistor_id[2] }, - { .compatible = "murata,ncp03wb473", - .data = &ntc_thermistor_id[3] }, - { .compatible = "murata,ncp15wl333", - .data = &ntc_thermistor_id[4] }, { .compatible = "epcos,b57330v2103", - .data = &ntc_thermistor_id[5]}, + .data = &ntc_thermistor_id[NTC_B57330V2103]}, + { .compatible = "epcos,b57891s0103", + .data = &ntc_thermistor_id[NTC_B57891S0103] }, + { .compatible = "murata,ncp03wb473", + .data = &ntc_thermistor_id[NTC_NCP03WB473] }, { .compatible = "murata,ncp03wf104", - .data = &ntc_thermistor_id[6] }, + .data = &ntc_thermistor_id[NTC_NCP03WF104] }, + { .compatible = "murata,ncp15wb473", + .data = &ntc_thermistor_id[NTC_NCP15WB473] }, + { .compatible = "murata,ncp15wl333", + .data = &ntc_thermistor_id[NTC_NCP15WL333] }, { .compatible = "murata,ncp15xh103", - .data = &ntc_thermistor_id[7] }, - { .compatible = "epcos,b57891s0103", - .data = &ntc_thermistor_id[8] }, + .data = &ntc_thermistor_id[NTC_NCP15XH103] }, + { .compatible = "murata,ncp18wb473", + .data = &ntc_thermistor_id[NTC_NCP18WB473] }, + { .compatible = "murata,ncp21wb473", + .data = &ntc_thermistor_id[NTC_NCP21WB473] }, /* Usage of vendor name "ntc" is deprecated */ + { .compatible = "ntc,ncp03wb473", + .data = &ntc_thermistor_id[NTC_NCP03WB473] }, { .compatible = "ntc,ncp15wb473", - .data = &ntc_thermistor_id[0] }, + .data = &ntc_thermistor_id[NTC_NCP15WB473] }, + { .compatible = "ntc,ncp15wl333", + .data = &ntc_thermistor_id[NTC_NCP15WL333] }, { .compatible = "ntc,ncp18wb473", - .data = &ntc_thermistor_id[1] }, + .data = &ntc_thermistor_id[NTC_NCP18WB473] }, { .compatible = "ntc,ncp21wb473", - .data = &ntc_thermistor_id[2] }, - { .compatible = "ntc,ncp03wb473", - .data = &ntc_thermistor_id[3] }, - { .compatible = "ntc,ncp15wl333", - .data = &ntc_thermistor_id[4] }, + .data = &ntc_thermistor_id[NTC_NCP21WB473] }, { }, }; MODULE_DEVICE_TABLE(of, ntc_match); -- cgit v1.2.3 From 737c086eddab6fae699ad7fc6963a91837b62b51 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Wed, 21 Nov 2018 16:03:46 +0000 Subject: hwmon: (ntc_thermistor) use a table to lookup the thermistor type Sort the entries while at it. Signed-off-by: Peter Rosin Signed-off-by: Guenter Roeck --- drivers/hwmon/ntc_thermistor.c | 47 +++++++++++++--------------- include/linux/platform_data/ntc_thermistor.h | 6 ++-- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c index 7747c1ed1f02..56d83b2472c8 100644 --- a/drivers/hwmon/ntc_thermistor.c +++ b/drivers/hwmon/ntc_thermistor.c @@ -315,6 +315,23 @@ static const struct ntc_compensation b57891s0103[] = { { .temp_c = 155.0, .ohm = 168 }, }; +struct ntc_type { + const struct ntc_compensation *comp; + int n_comp; +}; + +#define NTC_TYPE(ntc, compensation) \ +[(ntc)] = { .comp = (compensation), .n_comp = ARRAY_SIZE(compensation) } + +static const struct ntc_type ntc_type[] = { + NTC_TYPE(TYPE_B57330V2103, b57330v2103), + NTC_TYPE(TYPE_B57891S0103, b57891s0103), + NTC_TYPE(TYPE_NCPXXWB473, ncpXXwb473), + NTC_TYPE(TYPE_NCPXXWF104, ncpXXwf104), + NTC_TYPE(TYPE_NCPXXWL333, ncpXXwl333), + NTC_TYPE(TYPE_NCPXXXH103, ncpXXxh103), +}; + struct ntc_data { struct ntc_thermistor_platform_data *pdata; const struct ntc_compensation *comp; @@ -671,37 +688,15 @@ static int ntc_thermistor_probe(struct platform_device *pdev) data->pdata = pdata; - switch (pdev_id->driver_data) { - case TYPE_NCPXXWB473: - data->comp = ncpXXwb473; - data->n_comp = ARRAY_SIZE(ncpXXwb473); - break; - case TYPE_NCPXXWL333: - data->comp = ncpXXwl333; - data->n_comp = ARRAY_SIZE(ncpXXwl333); - break; - case TYPE_B57330V2103: - data->comp = b57330v2103; - data->n_comp = ARRAY_SIZE(b57330v2103); - break; - case TYPE_NCPXXWF104: - data->comp = ncpXXwf104; - data->n_comp = ARRAY_SIZE(ncpXXwf104); - break; - case TYPE_NCPXXXH103: - data->comp = ncpXXxh103; - data->n_comp = ARRAY_SIZE(ncpXXxh103); - break; - case TYPE_B57891S0103: - data->comp = b57891s0103; - data->n_comp = ARRAY_SIZE(b57891s0103); - break; - default: + if (pdev_id->driver_data >= ARRAY_SIZE(ntc_type)) { dev_err(dev, "Unknown device type: %lu(%s)\n", pdev_id->driver_data, pdev_id->name); return -EINVAL; } + data->comp = ntc_type[pdev_id->driver_data].comp; + data->n_comp = ntc_type[pdev_id->driver_data].n_comp; + hwmon_dev = devm_hwmon_device_register_with_groups(dev, pdev_id->name, data, ntc_groups); if (IS_ERR(hwmon_dev)) { diff --git a/include/linux/platform_data/ntc_thermistor.h b/include/linux/platform_data/ntc_thermistor.h index 231a27c302ec..ee03d429742b 100644 --- a/include/linux/platform_data/ntc_thermistor.h +++ b/include/linux/platform_data/ntc_thermistor.h @@ -24,12 +24,12 @@ struct iio_channel; enum ntc_thermistor_type { - TYPE_NCPXXWB473, - TYPE_NCPXXWL333, TYPE_B57330V2103, + TYPE_B57891S0103, + TYPE_NCPXXWB473, TYPE_NCPXXWF104, + TYPE_NCPXXWL333, TYPE_NCPXXXH103, - TYPE_B57891S0103, }; struct ntc_thermistor_platform_data { -- cgit v1.2.3 From 48049e205e7071c733508e12b036c3845d0e84a9 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Fri, 23 Nov 2018 13:08:46 +0100 Subject: dt-bindings: hwmon: (lm90) Document ti,tmp451 compatible string The TI TMP451 temperature sensors are compatible with the National LM90 temperature sensors. Signed-off-by: Thierry Reding Signed-off-by: Guenter Roeck --- Documentation/devicetree/bindings/hwmon/lm90.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/hwmon/lm90.txt b/Documentation/devicetree/bindings/hwmon/lm90.txt index 97581266e329..c76a7ac47c34 100644 --- a/Documentation/devicetree/bindings/hwmon/lm90.txt +++ b/Documentation/devicetree/bindings/hwmon/lm90.txt @@ -23,6 +23,7 @@ Required node properties: "onnn,nct1008" "winbond,w83l771" "nxp,sa56004" + "ti,tmp451" - reg: I2C bus address of the device -- cgit v1.2.3 From 2e9a41bbc1079776dabe42ed8113b086b99ae56c Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Thu, 6 Dec 2018 02:44:22 +0530 Subject: hwmon: (lm75) Add STLM75 support The STLM75 is a high-precision digital CMOS temperature sensor IC with a sigma-delta temperature-to-digital converter. The configuration register mapping is similar to existing lm75 but the sample rate is 150ms(max). Tested on real hardware and verified temperature readings are correct. Signed-off-by: Jagan Teki Signed-off-by: Guenter Roeck --- Documentation/hwmon/lm75 | 5 +++++ drivers/hwmon/Kconfig | 1 + drivers/hwmon/lm75.c | 10 ++++++++++ 3 files changed, 16 insertions(+) diff --git a/Documentation/hwmon/lm75 b/Documentation/hwmon/lm75 index 2f1120f88c16..010583608f12 100644 --- a/Documentation/hwmon/lm75 +++ b/Documentation/hwmon/lm75 @@ -42,6 +42,11 @@ Supported chips: Addresses scanned: none Datasheet: Publicly available at the ST website http://www.st.com/internet/analog/product/121769.jsp + * ST Microelectronics STLM75 + Prefix: 'stlm75' + Addresses scanned: none + Datasheet: Publicly available at the ST website + https://www.st.com/resource/en/datasheet/stlm75.pdf * Texas Instruments TMP100, TMP101, TMP105, TMP112, TMP75, TMP75C, TMP175, TMP275 Prefixes: 'tmp100', 'tmp101', 'tmp105', 'tmp112', 'tmp175', 'tmp75', 'tmp75c', 'tmp275' Addresses scanned: none diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index fe1e75051fd8..7bec39266402 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1035,6 +1035,7 @@ config SENSORS_LM75 - National Semiconductor LM75, LM75A - NXP's LM75A - ST Microelectronics STDS75 + - ST Microelectronics STLM75 - TelCom (now Microchip) TCN75 - Texas Instruments TMP100, TMP101, TMP105, TMP112, TMP75, TMP175, TMP275 diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index c7f20543b2bf..62acb9f16ec5 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -50,6 +50,7 @@ enum lm75_type { /* keep sorted in alphabetical order */ max31725, mcp980x, stds75, + stlm75, tcn75, tmp100, tmp101, @@ -316,6 +317,10 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id) data->resolution = 11; data->sample_time = MSEC_PER_SEC; break; + case stlm75: + data->resolution = 9; + data->sample_time = MSEC_PER_SEC / 5; + break; case ds7505: set_mask |= 3 << 5; /* 12-bit mode */ data->resolution = 12; @@ -424,6 +429,7 @@ static const struct i2c_device_id lm75_ids[] = { { "max31726", max31725, }, { "mcp980x", mcp980x, }, { "stds75", stds75, }, + { "stlm75", stlm75, }, { "tcn75", tcn75, }, { "tmp100", tmp100, }, { "tmp101", tmp101, }, @@ -494,6 +500,10 @@ static const struct of_device_id lm75_of_match[] = { .compatible = "st,stds75", .data = (void *)stds75 }, + { + .compatible = "st,stlm75", + .data = (void *)stlm75 + }, { .compatible = "microchip,tcn75", .data = (void *)tcn75 -- cgit v1.2.3 From a5c47c0d388b939dd578fd466aa804b7f2445390 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Tue, 27 Dec 2016 15:28:19 -0800 Subject: hwmon: Introduce SENSOR_DEVICE_ATTR_{RO, RW, WO} and variants Introduce SENSOR_DEVICE_ATTR_{RO,RW,WO} and SENSOR_DEVICE_ATTR_2_{RO,RW,WO} as simplified variants of SENSOR_DEVICE_ATTR and SENSOR_DEVICE_ATTR_2 to simplify the source code, improve readbility, and reduce the chance of inconsistencies. Signed-off-by: Guenter Roeck --- Documentation/hwmon/hwmon-kernel-api.txt | 24 +++++++++++++------- include/linux/hwmon-sysfs.h | 39 ++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/Documentation/hwmon/hwmon-kernel-api.txt b/Documentation/hwmon/hwmon-kernel-api.txt index eb7a78aebb38..8bdefb41be30 100644 --- a/Documentation/hwmon/hwmon-kernel-api.txt +++ b/Documentation/hwmon/hwmon-kernel-api.txt @@ -299,17 +299,25 @@ functions is used. The header file linux/hwmon-sysfs.h provides a number of useful macros to declare and use hardware monitoring sysfs attributes. -In many cases, you can use the exsting define DEVICE_ATTR to declare such -attributes. This is feasible if an attribute has no additional context. However, -in many cases there will be additional information such as a sensor index which -will need to be passed to the sysfs attribute handling function. +In many cases, you can use the exsting define DEVICE_ATTR or its variants +DEVICE_ATTR_{RW,RO,WO} to declare such attributes. This is feasible if an +attribute has no additional context. However, in many cases there will be +additional information such as a sensor index which will need to be passed +to the sysfs attribute handling function. SENSOR_DEVICE_ATTR and SENSOR_DEVICE_ATTR_2 can be used to define attributes which need such additional context information. SENSOR_DEVICE_ATTR requires one additional argument, SENSOR_DEVICE_ATTR_2 requires two. -SENSOR_DEVICE_ATTR defines a struct sensor_device_attribute variable. -This structure has the following fields. +Simplified variants of SENSOR_DEVICE_ATTR and SENSOR_DEVICE_ATTR_2 are available +and should be used if standard attribute permissions and function names are +feasible. Standard permissions are 0644 for SENSOR_DEVICE_ATTR[_2]_RW, +0444 for SENSOR_DEVICE_ATTR[_2]_RO, and 0200 for SENSOR_DEVICE_ATTR[_2]_WO. +Standard functions, similar to DEVICE_ATTR_{RW,RO,WO}, have _show and _store +appended to the provided function name. + +SENSOR_DEVICE_ATTR and its variants define a struct sensor_device_attribute +variable. This structure has the following fields. struct sensor_device_attribute { struct device_attribute dev_attr; @@ -320,8 +328,8 @@ You can use to_sensor_dev_attr to get the pointer to this structure from the attribute read or write function. Its parameter is the device to which the attribute is attached. -SENSOR_DEVICE_ATTR_2 defines a struct sensor_device_attribute_2 variable, -which is defined as follows. +SENSOR_DEVICE_ATTR_2 and its variants define a struct sensor_device_attribute_2 +variable, which is defined as follows. struct sensor_device_attribute_2 { struct device_attribute dev_attr; diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h index 1c7b89ae6bdc..473897bbd898 100644 --- a/include/linux/hwmon-sysfs.h +++ b/include/linux/hwmon-sysfs.h @@ -33,10 +33,28 @@ struct sensor_device_attribute{ { .dev_attr = __ATTR(_name, _mode, _show, _store), \ .index = _index } +#define SENSOR_ATTR_RO(_name, _func, _index) \ + SENSOR_ATTR(_name, 0444, _func##_show, NULL, _index) + +#define SENSOR_ATTR_RW(_name, _func, _index) \ + SENSOR_ATTR(_name, 0644, _func##_show, _func##_store, _index) + +#define SENSOR_ATTR_WO(_name, _func, _index) \ + SENSOR_ATTR(_name, 0200, NULL, _func##_store, _index) + #define SENSOR_DEVICE_ATTR(_name, _mode, _show, _store, _index) \ struct sensor_device_attribute sensor_dev_attr_##_name \ = SENSOR_ATTR(_name, _mode, _show, _store, _index) +#define SENSOR_DEVICE_ATTR_RO(_name, _func, _index) \ + SENSOR_DEVICE_ATTR(_name, 0444, _func##_show, NULL, _index) + +#define SENSOR_DEVICE_ATTR_RW(_name, _func, _index) \ + SENSOR_DEVICE_ATTR(_name, 0644, _func##_show, _func##_store, _index) + +#define SENSOR_DEVICE_ATTR_WO(_name, _func, _index) \ + SENSOR_DEVICE_ATTR(_name, 0200, NULL, _func##_store, _index) + struct sensor_device_attribute_2 { struct device_attribute dev_attr; u8 index; @@ -50,8 +68,29 @@ struct sensor_device_attribute_2 { .index = _index, \ .nr = _nr } +#define SENSOR_ATTR_2_RO(_name, _func, _nr, _index) \ + SENSOR_ATTR_2(_name, 0444, _func##_show, NULL, _nr, _index) + +#define SENSOR_ATTR_2_RW(_name, _func, _nr, _index) \ + SENSOR_ATTR_2(_name, 0644, _func##_show, _func##_store, _nr, _index) + +#define SENSOR_ATTR_2_WO(_name, _func, _nr, _index) \ + SENSOR_ATTR_2(_name, 0200, NULL, _func##_store, _nr, _index) + #define SENSOR_DEVICE_ATTR_2(_name,_mode,_show,_store,_nr,_index) \ struct sensor_device_attribute_2 sensor_dev_attr_##_name \ = SENSOR_ATTR_2(_name, _mode, _show, _store, _nr, _index) +#define SENSOR_DEVICE_ATTR_2_RO(_name, _func, _nr, _index) \ + SENSOR_DEVICE_ATTR_2(_name, 0444, _func##_show, NULL, \ + _nr, _index) + +#define SENSOR_DEVICE_ATTR_2_RW(_name, _func, _nr, _index) \ + SENSOR_DEVICE_ATTR_2(_name, 0644, _func##_show, _func##_store, \ + _nr, _index) + +#define SENSOR_DEVICE_ATTR_2_WO(_name, _func, _nr, _index) \ + SENSOR_DEVICE_ATTR_2(_name, 0200, NULL, _func##_store, \ + _nr, _index) + #endif /* _LINUX_HWMON_SYSFS_H */ -- cgit v1.2.3 From 5614e26d84a99a83f8b7092f1f68d3b04895506f Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 6 Dec 2018 10:23:25 -0800 Subject: hwmon: (ltc2945): Auto-convert to use SENSOR_DEVICE_ATTR_{RO, RW, WO} Conversion was done done using the coccinelle script at https://github.com/groeck/coccinelle-patches/raw/master/hwmon/sensor-devattr-w6.cocci Signed-off-by: Guenter Roeck --- drivers/hwmon/ltc2945.c | 121 ++++++++++++++++++++---------------------------- 1 file changed, 50 insertions(+), 71 deletions(-) diff --git a/drivers/hwmon/ltc2945.c b/drivers/hwmon/ltc2945.c index 1b92e4f6e234..f16716a1fead 100644 --- a/drivers/hwmon/ltc2945.c +++ b/drivers/hwmon/ltc2945.c @@ -226,7 +226,7 @@ static int ltc2945_val_to_reg(struct device *dev, u8 reg, return val; } -static ssize_t ltc2945_show_value(struct device *dev, +static ssize_t ltc2945_value_show(struct device *dev, struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); @@ -238,9 +238,9 @@ static ssize_t ltc2945_show_value(struct device *dev, return snprintf(buf, PAGE_SIZE, "%lld\n", value); } -static ssize_t ltc2945_set_value(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) +static ssize_t ltc2945_value_store(struct device *dev, + struct device_attribute *da, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct regmap *regmap = dev_get_drvdata(dev); @@ -273,7 +273,7 @@ static ssize_t ltc2945_set_value(struct device *dev, return ret < 0 ? ret : count; } -static ssize_t ltc2945_reset_history(struct device *dev, +static ssize_t ltc2945_history_store(struct device *dev, struct device_attribute *da, const char *buf, size_t count) { @@ -326,7 +326,7 @@ static ssize_t ltc2945_reset_history(struct device *dev, return ret ? : count; } -static ssize_t ltc2945_show_bool(struct device *dev, +static ssize_t ltc2945_bool_show(struct device *dev, struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); @@ -347,86 +347,65 @@ static ssize_t ltc2945_show_bool(struct device *dev, /* Input voltages */ -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ltc2945_show_value, NULL, - LTC2945_VIN_H); -static SENSOR_DEVICE_ATTR(in1_min, S_IRUGO | S_IWUSR, ltc2945_show_value, - ltc2945_set_value, LTC2945_MIN_VIN_THRES_H); -static SENSOR_DEVICE_ATTR(in1_max, S_IRUGO | S_IWUSR, ltc2945_show_value, - ltc2945_set_value, LTC2945_MAX_VIN_THRES_H); -static SENSOR_DEVICE_ATTR(in1_lowest, S_IRUGO, ltc2945_show_value, NULL, - LTC2945_MIN_VIN_H); -static SENSOR_DEVICE_ATTR(in1_highest, S_IRUGO, ltc2945_show_value, NULL, - LTC2945_MAX_VIN_H); -static SENSOR_DEVICE_ATTR(in1_reset_history, S_IWUSR, NULL, - ltc2945_reset_history, LTC2945_MIN_VIN_H); - -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ltc2945_show_value, NULL, - LTC2945_ADIN_H); -static SENSOR_DEVICE_ATTR(in2_min, S_IRUGO | S_IWUSR, ltc2945_show_value, - ltc2945_set_value, LTC2945_MIN_ADIN_THRES_H); -static SENSOR_DEVICE_ATTR(in2_max, S_IRUGO | S_IWUSR, ltc2945_show_value, - ltc2945_set_value, LTC2945_MAX_ADIN_THRES_H); -static SENSOR_DEVICE_ATTR(in2_lowest, S_IRUGO, ltc2945_show_value, NULL, - LTC2945_MIN_ADIN_H); -static SENSOR_DEVICE_ATTR(in2_highest, S_IRUGO, ltc2945_show_value, NULL, - LTC2945_MAX_ADIN_H); -static SENSOR_DEVICE_ATTR(in2_reset_history, S_IWUSR, NULL, - ltc2945_reset_history, LTC2945_MIN_ADIN_H); +static SENSOR_DEVICE_ATTR_RO(in1_input, ltc2945_value, LTC2945_VIN_H); +static SENSOR_DEVICE_ATTR_RW(in1_min, ltc2945_value, LTC2945_MIN_VIN_THRES_H); +static SENSOR_DEVICE_ATTR_RW(in1_max, ltc2945_value, LTC2945_MAX_VIN_THRES_H); +static SENSOR_DEVICE_ATTR_RO(in1_lowest, ltc2945_value, LTC2945_MIN_VIN_H); +static SENSOR_DEVICE_ATTR_RO(in1_highest, ltc2945_value, LTC2945_MAX_VIN_H); +static SENSOR_DEVICE_ATTR_WO(in1_reset_history, ltc2945_history, + LTC2945_MIN_VIN_H); + +static SENSOR_DEVICE_ATTR_RO(in2_input, ltc2945_value, LTC2945_ADIN_H); +static SENSOR_DEVICE_ATTR_RW(in2_min, ltc2945_value, LTC2945_MIN_ADIN_THRES_H); +static SENSOR_DEVICE_ATTR_RW(in2_max, ltc2945_value, LTC2945_MAX_ADIN_THRES_H); +static SENSOR_DEVICE_ATTR_RO(in2_lowest, ltc2945_value, LTC2945_MIN_ADIN_H); +static SENSOR_DEVICE_ATTR_RO(in2_highest, ltc2945_value, LTC2945_MAX_ADIN_H); +static SENSOR_DEVICE_ATTR_WO(in2_reset_history, ltc2945_history, + LTC2945_MIN_ADIN_H); /* Voltage alarms */ -static SENSOR_DEVICE_ATTR(in1_min_alarm, S_IRUGO, ltc2945_show_bool, NULL, - FAULT_VIN_UV); -static SENSOR_DEVICE_ATTR(in1_max_alarm, S_IRUGO, ltc2945_show_bool, NULL, - FAULT_VIN_OV); -static SENSOR_DEVICE_ATTR(in2_min_alarm, S_IRUGO, ltc2945_show_bool, NULL, - FAULT_ADIN_UV); -static SENSOR_DEVICE_ATTR(in2_max_alarm, S_IRUGO, ltc2945_show_bool, NULL, - FAULT_ADIN_OV); +static SENSOR_DEVICE_ATTR_RO(in1_min_alarm, ltc2945_bool, FAULT_VIN_UV); +static SENSOR_DEVICE_ATTR_RO(in1_max_alarm, ltc2945_bool, FAULT_VIN_OV); +static SENSOR_DEVICE_ATTR_RO(in2_min_alarm, ltc2945_bool, FAULT_ADIN_UV); +static SENSOR_DEVICE_ATTR_RO(in2_max_alarm, ltc2945_bool, FAULT_ADIN_OV); /* Currents (via sense resistor) */ -static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, ltc2945_show_value, NULL, - LTC2945_SENSE_H); -static SENSOR_DEVICE_ATTR(curr1_min, S_IRUGO | S_IWUSR, ltc2945_show_value, - ltc2945_set_value, LTC2945_MIN_SENSE_THRES_H); -static SENSOR_DEVICE_ATTR(curr1_max, S_IRUGO | S_IWUSR, ltc2945_show_value, - ltc2945_set_value, LTC2945_MAX_SENSE_THRES_H); -static SENSOR_DEVICE_ATTR(curr1_lowest, S_IRUGO, ltc2945_show_value, NULL, - LTC2945_MIN_SENSE_H); -static SENSOR_DEVICE_ATTR(curr1_highest, S_IRUGO, ltc2945_show_value, NULL, - LTC2945_MAX_SENSE_H); -static SENSOR_DEVICE_ATTR(curr1_reset_history, S_IWUSR, NULL, - ltc2945_reset_history, LTC2945_MIN_SENSE_H); +static SENSOR_DEVICE_ATTR_RO(curr1_input, ltc2945_value, LTC2945_SENSE_H); +static SENSOR_DEVICE_ATTR_RW(curr1_min, ltc2945_value, + LTC2945_MIN_SENSE_THRES_H); +static SENSOR_DEVICE_ATTR_RW(curr1_max, ltc2945_value, + LTC2945_MAX_SENSE_THRES_H); +static SENSOR_DEVICE_ATTR_RO(curr1_lowest, ltc2945_value, LTC2945_MIN_SENSE_H); +static SENSOR_DEVICE_ATTR_RO(curr1_highest, ltc2945_value, + LTC2945_MAX_SENSE_H); +static SENSOR_DEVICE_ATTR_WO(curr1_reset_history, ltc2945_history, + LTC2945_MIN_SENSE_H); /* Current alarms */ -static SENSOR_DEVICE_ATTR(curr1_min_alarm, S_IRUGO, ltc2945_show_bool, NULL, - FAULT_SENSE_UV); -static SENSOR_DEVICE_ATTR(curr1_max_alarm, S_IRUGO, ltc2945_show_bool, NULL, - FAULT_SENSE_OV); +static SENSOR_DEVICE_ATTR_RO(curr1_min_alarm, ltc2945_bool, FAULT_SENSE_UV); +static SENSOR_DEVICE_ATTR_RO(curr1_max_alarm, ltc2945_bool, FAULT_SENSE_OV); /* Power */ -static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, ltc2945_show_value, NULL, - LTC2945_POWER_H); -static SENSOR_DEVICE_ATTR(power1_min, S_IRUGO | S_IWUSR, ltc2945_show_value, - ltc2945_set_value, LTC2945_MIN_POWER_THRES_H); -static SENSOR_DEVICE_ATTR(power1_max, S_IRUGO | S_IWUSR, ltc2945_show_value, - ltc2945_set_value, LTC2945_MAX_POWER_THRES_H); -static SENSOR_DEVICE_ATTR(power1_input_lowest, S_IRUGO, ltc2945_show_value, - NULL, LTC2945_MIN_POWER_H); -static SENSOR_DEVICE_ATTR(power1_input_highest, S_IRUGO, ltc2945_show_value, - NULL, LTC2945_MAX_POWER_H); -static SENSOR_DEVICE_ATTR(power1_reset_history, S_IWUSR, NULL, - ltc2945_reset_history, LTC2945_MIN_POWER_H); +static SENSOR_DEVICE_ATTR_RO(power1_input, ltc2945_value, LTC2945_POWER_H); +static SENSOR_DEVICE_ATTR_RW(power1_min, ltc2945_value, + LTC2945_MIN_POWER_THRES_H); +static SENSOR_DEVICE_ATTR_RW(power1_max, ltc2945_value, + LTC2945_MAX_POWER_THRES_H); +static SENSOR_DEVICE_ATTR_RO(power1_input_lowest, ltc2945_value, + LTC2945_MIN_POWER_H); +static SENSOR_DEVICE_ATTR_RO(power1_input_highest, ltc2945_value, + LTC2945_MAX_POWER_H); +static SENSOR_DEVICE_ATTR_WO(power1_reset_history, ltc2945_history, + LTC2945_MIN_POWER_H); /* Power alarms */ -static SENSOR_DEVICE_ATTR(power1_min_alarm, S_IRUGO, ltc2945_show_bool, NULL, - FAULT_POWER_UV); -static SENSOR_DEVICE_ATTR(power1_max_alarm, S_IRUGO, ltc2945_show_bool, NULL, - FAULT_POWER_OV); +static SENSOR_DEVICE_ATTR_RO(power1_min_alarm, ltc2945_bool, FAULT_POWER_UV); +static SENSOR_DEVICE_ATTR_RO(power1_max_alarm, ltc2945_bool, FAULT_POWER_OV); static struct attribute *ltc2945_attrs[] = { &sensor_dev_attr_in1_input.dev_attr.attr, -- cgit v1.2.3 From fac5ba6f5bf7fe9d2923ac4bbd85fa905f249633 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 6 Dec 2018 10:33:21 -0800 Subject: hwmon: (k10temp) Auto-convert to use SENSOR_DEVICE_ATTR_{RO, RW, WO} Auto-conversion was done done using the coccinelle script at https://github.com/groeck/coccinelle-patches/blob/master/hwmon/sensor-devattr-w6.cocci Signed-off-by: Guenter Roeck --- drivers/hwmon/k10temp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index 2cef0c37ff6f..cd601cd6f88a 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -191,7 +191,7 @@ static ssize_t temp1_max_show(struct device *dev, return sprintf(buf, "%d\n", 70 * 1000); } -static ssize_t show_temp_crit(struct device *dev, +static ssize_t temp_crit_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); @@ -209,12 +209,12 @@ static ssize_t show_temp_crit(struct device *dev, static DEVICE_ATTR_RO(temp1_input); static DEVICE_ATTR_RO(temp1_max); -static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp_crit, NULL, 0); -static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, show_temp_crit, NULL, 1); +static SENSOR_DEVICE_ATTR_RO(temp1_crit, temp_crit, 0); +static SENSOR_DEVICE_ATTR_RO(temp1_crit_hyst, temp_crit, 1); -static SENSOR_DEVICE_ATTR(temp1_label, 0444, temp_label_show, NULL, 0); +static SENSOR_DEVICE_ATTR_RO(temp1_label, temp_label, 0); static DEVICE_ATTR_RO(temp2_input); -static SENSOR_DEVICE_ATTR(temp2_label, 0444, temp_label_show, NULL, 1); +static SENSOR_DEVICE_ATTR_RO(temp2_label, temp_label, 1); static umode_t k10temp_is_visible(struct kobject *kobj, struct attribute *attr, int index) -- cgit v1.2.3 From 33721d90c0444133219f9773cb6d88f380699fa4 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 6 Dec 2018 10:38:29 -0800 Subject: hwmon: (lm95234) Auto-convert to use SENSOR_DEVICE_ATTR_{RO, RW, WO} Auto-conversion was done done using the coccinelle script at https://github.com/groeck/coccinelle-patches/blob/master/hwmon/sensor-devattr-w6.cocci Signed-off-by: Guenter Roeck --- drivers/hwmon/lm95234.c | 161 ++++++++++++++++++++---------------------------- 1 file changed, 67 insertions(+), 94 deletions(-) diff --git a/drivers/hwmon/lm95234.c b/drivers/hwmon/lm95234.c index c7fcc9e7f57a..02cd48bdde8d 100644 --- a/drivers/hwmon/lm95234.c +++ b/drivers/hwmon/lm95234.c @@ -211,7 +211,7 @@ abort: return ret; } -static ssize_t show_temp(struct device *dev, struct device_attribute *attr, +static ssize_t temp_show(struct device *dev, struct device_attribute *attr, char *buf) { struct lm95234_data *data = dev_get_drvdata(dev); @@ -225,8 +225,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr, DIV_ROUND_CLOSEST(data->temp[index] * 125, 32)); } -static ssize_t show_alarm(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, + char *buf) { struct lm95234_data *data = dev_get_drvdata(dev); u32 mask = to_sensor_dev_attr(attr)->index; @@ -238,7 +238,7 @@ static ssize_t show_alarm(struct device *dev, return sprintf(buf, "%u", !!(data->status & mask)); } -static ssize_t show_type(struct device *dev, struct device_attribute *attr, +static ssize_t type_show(struct device *dev, struct device_attribute *attr, char *buf) { struct lm95234_data *data = dev_get_drvdata(dev); @@ -251,8 +251,8 @@ static ssize_t show_type(struct device *dev, struct device_attribute *attr, return sprintf(buf, data->sensor_type & mask ? "1\n" : "2\n"); } -static ssize_t set_type(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t type_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct lm95234_data *data = dev_get_drvdata(dev); unsigned long val; @@ -282,7 +282,7 @@ static ssize_t set_type(struct device *dev, struct device_attribute *attr, return count; } -static ssize_t show_tcrit2(struct device *dev, struct device_attribute *attr, +static ssize_t tcrit2_show(struct device *dev, struct device_attribute *attr, char *buf) { struct lm95234_data *data = dev_get_drvdata(dev); @@ -295,8 +295,8 @@ static ssize_t show_tcrit2(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%u", data->tcrit2[index] * 1000); } -static ssize_t set_tcrit2(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t tcrit2_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct lm95234_data *data = dev_get_drvdata(dev); int index = to_sensor_dev_attr(attr)->index; @@ -320,7 +320,7 @@ static ssize_t set_tcrit2(struct device *dev, struct device_attribute *attr, return count; } -static ssize_t show_tcrit2_hyst(struct device *dev, +static ssize_t tcrit2_hyst_show(struct device *dev, struct device_attribute *attr, char *buf) { struct lm95234_data *data = dev_get_drvdata(dev); @@ -335,7 +335,7 @@ static ssize_t show_tcrit2_hyst(struct device *dev, ((int)data->tcrit2[index] - (int)data->thyst) * 1000); } -static ssize_t show_tcrit1(struct device *dev, struct device_attribute *attr, +static ssize_t tcrit1_show(struct device *dev, struct device_attribute *attr, char *buf) { struct lm95234_data *data = dev_get_drvdata(dev); @@ -344,8 +344,8 @@ static ssize_t show_tcrit1(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%u", data->tcrit1[index] * 1000); } -static ssize_t set_tcrit1(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t tcrit1_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct lm95234_data *data = dev_get_drvdata(dev); int index = to_sensor_dev_attr(attr)->index; @@ -369,7 +369,7 @@ static ssize_t set_tcrit1(struct device *dev, struct device_attribute *attr, return count; } -static ssize_t show_tcrit1_hyst(struct device *dev, +static ssize_t tcrit1_hyst_show(struct device *dev, struct device_attribute *attr, char *buf) { struct lm95234_data *data = dev_get_drvdata(dev); @@ -384,9 +384,9 @@ static ssize_t show_tcrit1_hyst(struct device *dev, ((int)data->tcrit1[index] - (int)data->thyst) * 1000); } -static ssize_t set_tcrit1_hyst(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t tcrit1_hyst_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { struct lm95234_data *data = dev_get_drvdata(dev); int index = to_sensor_dev_attr(attr)->index; @@ -411,7 +411,7 @@ static ssize_t set_tcrit1_hyst(struct device *dev, return count; } -static ssize_t show_offset(struct device *dev, struct device_attribute *attr, +static ssize_t offset_show(struct device *dev, struct device_attribute *attr, char *buf) { struct lm95234_data *data = dev_get_drvdata(dev); @@ -424,8 +424,8 @@ static ssize_t show_offset(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%d", data->toffset[index] * 500); } -static ssize_t set_offset(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t offset_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct lm95234_data *data = dev_get_drvdata(dev); int index = to_sensor_dev_attr(attr)->index; @@ -492,80 +492,53 @@ static ssize_t update_interval_store(struct device *dev, return count; } -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); -static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3); -static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO, show_temp, NULL, 4); - -static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, - BIT(0) | BIT(1)); -static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, - BIT(2) | BIT(3)); -static SENSOR_DEVICE_ATTR(temp4_fault, S_IRUGO, show_alarm, NULL, - BIT(4) | BIT(5)); -static SENSOR_DEVICE_ATTR(temp5_fault, S_IRUGO, show_alarm, NULL, - BIT(6) | BIT(7)); - -static SENSOR_DEVICE_ATTR(temp2_type, S_IWUSR | S_IRUGO, show_type, set_type, - BIT(1)); -static SENSOR_DEVICE_ATTR(temp3_type, S_IWUSR | S_IRUGO, show_type, set_type, - BIT(2)); -static SENSOR_DEVICE_ATTR(temp4_type, S_IWUSR | S_IRUGO, show_type, set_type, - BIT(3)); -static SENSOR_DEVICE_ATTR(temp5_type, S_IWUSR | S_IRUGO, show_type, set_type, - BIT(4)); - -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_tcrit1, - set_tcrit1, 0); -static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_tcrit2, - set_tcrit2, 0); -static SENSOR_DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_tcrit2, - set_tcrit2, 1); -static SENSOR_DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_tcrit1, - set_tcrit1, 3); -static SENSOR_DEVICE_ATTR(temp5_max, S_IWUSR | S_IRUGO, show_tcrit1, - set_tcrit1, 4); - -static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, show_tcrit1_hyst, - set_tcrit1_hyst, 0); -static SENSOR_DEVICE_ATTR(temp2_max_hyst, S_IRUGO, show_tcrit2_hyst, NULL, 0); -static SENSOR_DEVICE_ATTR(temp3_max_hyst, S_IRUGO, show_tcrit2_hyst, NULL, 1); -static SENSOR_DEVICE_ATTR(temp4_max_hyst, S_IRUGO, show_tcrit1_hyst, NULL, 3); -static SENSOR_DEVICE_ATTR(temp5_max_hyst, S_IRUGO, show_tcrit1_hyst, NULL, 4); - -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, - BIT(0 + 8)); -static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, - BIT(1 + 16)); -static SENSOR_DEVICE_ATTR(temp3_max_alarm, S_IRUGO, show_alarm, NULL, - BIT(2 + 16)); -static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_alarm, NULL, - BIT(3 + 8)); -static SENSOR_DEVICE_ATTR(temp5_max_alarm, S_IRUGO, show_alarm, NULL, - BIT(4 + 8)); - -static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_tcrit1, - set_tcrit1, 1); -static SENSOR_DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_tcrit1, - set_tcrit1, 2); - -static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_tcrit1_hyst, NULL, 1); -static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO, show_tcrit1_hyst, NULL, 2); - -static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, - BIT(1 + 8)); -static SENSOR_DEVICE_ATTR(temp3_crit_alarm, S_IRUGO, show_alarm, NULL, - BIT(2 + 8)); - -static SENSOR_DEVICE_ATTR(temp2_offset, S_IWUSR | S_IRUGO, show_offset, - set_offset, 0); -static SENSOR_DEVICE_ATTR(temp3_offset, S_IWUSR | S_IRUGO, show_offset, - set_offset, 1); -static SENSOR_DEVICE_ATTR(temp4_offset, S_IWUSR | S_IRUGO, show_offset, - set_offset, 2); -static SENSOR_DEVICE_ATTR(temp5_offset, S_IWUSR | S_IRUGO, show_offset, - set_offset, 3); +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2); +static SENSOR_DEVICE_ATTR_RO(temp4_input, temp, 3); +static SENSOR_DEVICE_ATTR_RO(temp5_input, temp, 4); + +static SENSOR_DEVICE_ATTR_RO(temp2_fault, alarm, BIT(0) | BIT(1)); +static SENSOR_DEVICE_ATTR_RO(temp3_fault, alarm, BIT(2) | BIT(3)); +static SENSOR_DEVICE_ATTR_RO(temp4_fault, alarm, BIT(4) | BIT(5)); +static SENSOR_DEVICE_ATTR_RO(temp5_fault, alarm, BIT(6) | BIT(7)); + +static SENSOR_DEVICE_ATTR_RW(temp2_type, type, BIT(1)); +static SENSOR_DEVICE_ATTR_RW(temp3_type, type, BIT(2)); +static SENSOR_DEVICE_ATTR_RW(temp4_type, type, BIT(3)); +static SENSOR_DEVICE_ATTR_RW(temp5_type, type, BIT(4)); + +static SENSOR_DEVICE_ATTR_RW(temp1_max, tcrit1, 0); +static SENSOR_DEVICE_ATTR_RW(temp2_max, tcrit2, 0); +static SENSOR_DEVICE_ATTR_RW(temp3_max, tcrit2, 1); +static SENSOR_DEVICE_ATTR_RW(temp4_max, tcrit1, 3); +static SENSOR_DEVICE_ATTR_RW(temp5_max, tcrit1, 4); + +static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, tcrit1_hyst, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_max_hyst, tcrit2_hyst, 0); +static SENSOR_DEVICE_ATTR_RO(temp3_max_hyst, tcrit2_hyst, 1); +static SENSOR_DEVICE_ATTR_RO(temp4_max_hyst, tcrit1_hyst, 3); +static SENSOR_DEVICE_ATTR_RO(temp5_max_hyst, tcrit1_hyst, 4); + +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, BIT(0 + 8)); +static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, alarm, BIT(1 + 16)); +static SENSOR_DEVICE_ATTR_RO(temp3_max_alarm, alarm, BIT(2 + 16)); +static SENSOR_DEVICE_ATTR_RO(temp4_max_alarm, alarm, BIT(3 + 8)); +static SENSOR_DEVICE_ATTR_RO(temp5_max_alarm, alarm, BIT(4 + 8)); + +static SENSOR_DEVICE_ATTR_RW(temp2_crit, tcrit1, 1); +static SENSOR_DEVICE_ATTR_RW(temp3_crit, tcrit1, 2); + +static SENSOR_DEVICE_ATTR_RO(temp2_crit_hyst, tcrit1_hyst, 1); +static SENSOR_DEVICE_ATTR_RO(temp3_crit_hyst, tcrit1_hyst, 2); + +static SENSOR_DEVICE_ATTR_RO(temp2_crit_alarm, alarm, BIT(1 + 8)); +static SENSOR_DEVICE_ATTR_RO(temp3_crit_alarm, alarm, BIT(2 + 8)); + +static SENSOR_DEVICE_ATTR_RW(temp2_offset, offset, 0); +static SENSOR_DEVICE_ATTR_RW(temp3_offset, offset, 1); +static SENSOR_DEVICE_ATTR_RW(temp4_offset, offset, 2); +static SENSOR_DEVICE_ATTR_RW(temp5_offset, offset, 3); static DEVICE_ATTR_RW(update_interval); -- cgit v1.2.3 From 4aabaf30976eac011b70aa7c0e1fb385331e22f2 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 6 Dec 2018 10:41:54 -0800 Subject: hwmon: (nct7802) Auto-convert to use SENSOR_DEVICE_ATTR_{RO, RW, WO} Auto-conversion was done done using the coccinelle script at https://github.com/groeck/coccinelle-patches/raw/master/hwmon/sensor-devattr-w6.cocci Signed-off-by: Guenter Roeck --- drivers/hwmon/nct7802.c | 408 +++++++++++++++++++----------------------------- 1 file changed, 157 insertions(+), 251 deletions(-) diff --git a/drivers/hwmon/nct7802.c b/drivers/hwmon/nct7802.c index 2876c18ed841..6aa44492ae30 100644 --- a/drivers/hwmon/nct7802.c +++ b/drivers/hwmon/nct7802.c @@ -69,8 +69,8 @@ struct nct7802_data { struct mutex access_lock; /* for multi-byte read and write operations */ }; -static ssize_t show_temp_type(struct device *dev, struct device_attribute *attr, - char *buf) +static ssize_t temp_type_show(struct device *dev, + struct device_attribute *attr, char *buf) { struct nct7802_data *data = dev_get_drvdata(dev); struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr); @@ -84,9 +84,9 @@ static ssize_t show_temp_type(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%u\n", (mode >> (2 * sattr->index) & 3) + 2); } -static ssize_t store_temp_type(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t temp_type_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t count) { struct nct7802_data *data = dev_get_drvdata(dev); struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr); @@ -105,8 +105,8 @@ static ssize_t store_temp_type(struct device *dev, return err ? : count; } -static ssize_t show_pwm_mode(struct device *dev, struct device_attribute *attr, - char *buf) +static ssize_t pwm_mode_show(struct device *dev, + struct device_attribute *attr, char *buf) { struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr); struct nct7802_data *data = dev_get_drvdata(dev); @@ -123,7 +123,7 @@ static ssize_t show_pwm_mode(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%u\n", !(regval & (1 << sattr->index))); } -static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, +static ssize_t pwm_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); @@ -141,7 +141,7 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, return sprintf(buf, "%d\n", val); } -static ssize_t store_pwm(struct device *dev, struct device_attribute *devattr, +static ssize_t pwm_store(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); @@ -157,7 +157,7 @@ static ssize_t store_pwm(struct device *dev, struct device_attribute *devattr, return err ? : count; } -static ssize_t show_pwm_enable(struct device *dev, +static ssize_t pwm_enable_show(struct device *dev, struct device_attribute *attr, char *buf) { struct nct7802_data *data = dev_get_drvdata(dev); @@ -172,7 +172,7 @@ static ssize_t show_pwm_enable(struct device *dev, return sprintf(buf, "%u\n", enabled + 1); } -static ssize_t store_pwm_enable(struct device *dev, +static ssize_t pwm_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -345,7 +345,7 @@ abort: return err; } -static ssize_t show_in(struct device *dev, struct device_attribute *attr, +static ssize_t in_show(struct device *dev, struct device_attribute *attr, char *buf) { struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); @@ -359,7 +359,7 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%d\n", voltage); } -static ssize_t store_in(struct device *dev, struct device_attribute *attr, +static ssize_t in_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); @@ -377,7 +377,7 @@ static ssize_t store_in(struct device *dev, struct device_attribute *attr, return err ? : count; } -static ssize_t show_temp(struct device *dev, struct device_attribute *attr, +static ssize_t temp_show(struct device *dev, struct device_attribute *attr, char *buf) { struct nct7802_data *data = dev_get_drvdata(dev); @@ -391,7 +391,7 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%d\n", temp); } -static ssize_t store_temp(struct device *dev, struct device_attribute *attr, +static ssize_t temp_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); @@ -410,7 +410,7 @@ static ssize_t store_temp(struct device *dev, struct device_attribute *attr, return err ? : count; } -static ssize_t show_fan(struct device *dev, struct device_attribute *attr, +static ssize_t fan_show(struct device *dev, struct device_attribute *attr, char *buf) { struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr); @@ -424,7 +424,7 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%d\n", speed); } -static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, +static ssize_t fan_min_show(struct device *dev, struct device_attribute *attr, char *buf) { struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); @@ -438,8 +438,9 @@ static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%d\n", speed); } -static ssize_t store_fan_min(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t fan_min_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t count) { struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); struct nct7802_data *data = dev_get_drvdata(dev); @@ -454,7 +455,7 @@ static ssize_t store_fan_min(struct device *dev, struct device_attribute *attr, return err ? : count; } -static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, +static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, char *buf) { struct nct7802_data *data = dev_get_drvdata(dev); @@ -471,7 +472,7 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, } static ssize_t -show_beep(struct device *dev, struct device_attribute *attr, char *buf) +beep_show(struct device *dev, struct device_attribute *attr, char *buf) { struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); struct nct7802_data *data = dev_get_drvdata(dev); @@ -486,7 +487,7 @@ show_beep(struct device *dev, struct device_attribute *attr, char *buf) } static ssize_t -store_beep(struct device *dev, struct device_attribute *attr, const char *buf, +beep_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); @@ -505,108 +506,64 @@ store_beep(struct device *dev, struct device_attribute *attr, const char *buf, return err ? : count; } -static SENSOR_DEVICE_ATTR(temp1_type, S_IRUGO | S_IWUSR, - show_temp_type, store_temp_type, 0); -static SENSOR_DEVICE_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, 0x01, - REG_TEMP_LSB); -static SENSOR_DEVICE_ATTR_2(temp1_min, S_IRUGO | S_IWUSR, show_temp, - store_temp, 0x31, 0); -static SENSOR_DEVICE_ATTR_2(temp1_max, S_IRUGO | S_IWUSR, show_temp, - store_temp, 0x30, 0); -static SENSOR_DEVICE_ATTR_2(temp1_crit, S_IRUGO | S_IWUSR, show_temp, - store_temp, 0x3a, 0); - -static SENSOR_DEVICE_ATTR(temp2_type, S_IRUGO | S_IWUSR, - show_temp_type, store_temp_type, 1); -static SENSOR_DEVICE_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, 0x02, - REG_TEMP_LSB); -static SENSOR_DEVICE_ATTR_2(temp2_min, S_IRUGO | S_IWUSR, show_temp, - store_temp, 0x33, 0); -static SENSOR_DEVICE_ATTR_2(temp2_max, S_IRUGO | S_IWUSR, show_temp, - store_temp, 0x32, 0); -static SENSOR_DEVICE_ATTR_2(temp2_crit, S_IRUGO | S_IWUSR, show_temp, - store_temp, 0x3b, 0); - -static SENSOR_DEVICE_ATTR(temp3_type, S_IRUGO | S_IWUSR, - show_temp_type, store_temp_type, 2); -static SENSOR_DEVICE_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, 0x03, - REG_TEMP_LSB); -static SENSOR_DEVICE_ATTR_2(temp3_min, S_IRUGO | S_IWUSR, show_temp, - store_temp, 0x35, 0); -static SENSOR_DEVICE_ATTR_2(temp3_max, S_IRUGO | S_IWUSR, show_temp, - store_temp, 0x34, 0); -static SENSOR_DEVICE_ATTR_2(temp3_crit, S_IRUGO | S_IWUSR, show_temp, - store_temp, 0x3c, 0); - -static SENSOR_DEVICE_ATTR_2(temp4_input, S_IRUGO, show_temp, NULL, 0x04, 0); -static SENSOR_DEVICE_ATTR_2(temp4_min, S_IRUGO | S_IWUSR, show_temp, - store_temp, 0x37, 0); -static SENSOR_DEVICE_ATTR_2(temp4_max, S_IRUGO | S_IWUSR, show_temp, - store_temp, 0x36, 0); -static SENSOR_DEVICE_ATTR_2(temp4_crit, S_IRUGO | S_IWUSR, show_temp, - store_temp, 0x3d, 0); - -static SENSOR_DEVICE_ATTR_2(temp5_input, S_IRUGO, show_temp, NULL, 0x06, - REG_TEMP_PECI_LSB); -static SENSOR_DEVICE_ATTR_2(temp5_min, S_IRUGO | S_IWUSR, show_temp, - store_temp, 0x39, 0); -static SENSOR_DEVICE_ATTR_2(temp5_max, S_IRUGO | S_IWUSR, show_temp, - store_temp, 0x38, 0); -static SENSOR_DEVICE_ATTR_2(temp5_crit, S_IRUGO | S_IWUSR, show_temp, - store_temp, 0x3e, 0); - -static SENSOR_DEVICE_ATTR_2(temp6_input, S_IRUGO, show_temp, NULL, 0x07, - REG_TEMP_PECI_LSB); - -static SENSOR_DEVICE_ATTR_2(temp1_min_alarm, S_IRUGO, show_alarm, NULL, - 0x18, 0); -static SENSOR_DEVICE_ATTR_2(temp2_min_alarm, S_IRUGO, show_alarm, NULL, - 0x18, 1); -static SENSOR_DEVICE_ATTR_2(temp3_min_alarm, S_IRUGO, show_alarm, NULL, - 0x18, 2); -static SENSOR_DEVICE_ATTR_2(temp4_min_alarm, S_IRUGO, show_alarm, NULL, - 0x18, 3); -static SENSOR_DEVICE_ATTR_2(temp5_min_alarm, S_IRUGO, show_alarm, NULL, - 0x18, 4); - -static SENSOR_DEVICE_ATTR_2(temp1_max_alarm, S_IRUGO, show_alarm, NULL, - 0x19, 0); -static SENSOR_DEVICE_ATTR_2(temp2_max_alarm, S_IRUGO, show_alarm, NULL, - 0x19, 1); -static SENSOR_DEVICE_ATTR_2(temp3_max_alarm, S_IRUGO, show_alarm, NULL, - 0x19, 2); -static SENSOR_DEVICE_ATTR_2(temp4_max_alarm, S_IRUGO, show_alarm, NULL, - 0x19, 3); -static SENSOR_DEVICE_ATTR_2(temp5_max_alarm, S_IRUGO, show_alarm, NULL, - 0x19, 4); - -static SENSOR_DEVICE_ATTR_2(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, - 0x1b, 0); -static SENSOR_DEVICE_ATTR_2(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, - 0x1b, 1); -static SENSOR_DEVICE_ATTR_2(temp3_crit_alarm, S_IRUGO, show_alarm, NULL, - 0x1b, 2); -static SENSOR_DEVICE_ATTR_2(temp4_crit_alarm, S_IRUGO, show_alarm, NULL, - 0x1b, 3); -static SENSOR_DEVICE_ATTR_2(temp5_crit_alarm, S_IRUGO, show_alarm, NULL, - 0x1b, 4); - -static SENSOR_DEVICE_ATTR_2(temp1_fault, S_IRUGO, show_alarm, NULL, 0x17, 0); -static SENSOR_DEVICE_ATTR_2(temp2_fault, S_IRUGO, show_alarm, NULL, 0x17, 1); -static SENSOR_DEVICE_ATTR_2(temp3_fault, S_IRUGO, show_alarm, NULL, 0x17, 2); - -static SENSOR_DEVICE_ATTR_2(temp1_beep, S_IRUGO | S_IWUSR, show_beep, - store_beep, 0x5c, 0); -static SENSOR_DEVICE_ATTR_2(temp2_beep, S_IRUGO | S_IWUSR, show_beep, - store_beep, 0x5c, 1); -static SENSOR_DEVICE_ATTR_2(temp3_beep, S_IRUGO | S_IWUSR, show_beep, - store_beep, 0x5c, 2); -static SENSOR_DEVICE_ATTR_2(temp4_beep, S_IRUGO | S_IWUSR, show_beep, - store_beep, 0x5c, 3); -static SENSOR_DEVICE_ATTR_2(temp5_beep, S_IRUGO | S_IWUSR, show_beep, - store_beep, 0x5c, 4); -static SENSOR_DEVICE_ATTR_2(temp6_beep, S_IRUGO | S_IWUSR, show_beep, - store_beep, 0x5c, 5); +static SENSOR_DEVICE_ATTR_RW(temp1_type, temp_type, 0); +static SENSOR_DEVICE_ATTR_2_RO(temp1_input, temp, 0x01, REG_TEMP_LSB); +static SENSOR_DEVICE_ATTR_2_RW(temp1_min, temp, 0x31, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp1_max, temp, 0x30, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp1_crit, temp, 0x3a, 0); + +static SENSOR_DEVICE_ATTR_RW(temp2_type, temp_type, 1); +static SENSOR_DEVICE_ATTR_2_RO(temp2_input, temp, 0x02, REG_TEMP_LSB); +static SENSOR_DEVICE_ATTR_2_RW(temp2_min, temp, 0x33, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp2_max, temp, 0x32, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp2_crit, temp, 0x3b, 0); + +static SENSOR_DEVICE_ATTR_RW(temp3_type, temp_type, 2); +static SENSOR_DEVICE_ATTR_2_RO(temp3_input, temp, 0x03, REG_TEMP_LSB); +static SENSOR_DEVICE_ATTR_2_RW(temp3_min, temp, 0x35, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp3_max, temp, 0x34, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp3_crit, temp, 0x3c, 0); + +static SENSOR_DEVICE_ATTR_2_RO(temp4_input, temp, 0x04, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp4_min, temp, 0x37, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp4_max, temp, 0x36, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp4_crit, temp, 0x3d, 0); + +static SENSOR_DEVICE_ATTR_2_RO(temp5_input, temp, 0x06, REG_TEMP_PECI_LSB); +static SENSOR_DEVICE_ATTR_2_RW(temp5_min, temp, 0x39, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp5_max, temp, 0x38, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp5_crit, temp, 0x3e, 0); + +static SENSOR_DEVICE_ATTR_2_RO(temp6_input, temp, 0x07, REG_TEMP_PECI_LSB); + +static SENSOR_DEVICE_ATTR_2_RO(temp1_min_alarm, alarm, 0x18, 0); +static SENSOR_DEVICE_ATTR_2_RO(temp2_min_alarm, alarm, 0x18, 1); +static SENSOR_DEVICE_ATTR_2_RO(temp3_min_alarm, alarm, 0x18, 2); +static SENSOR_DEVICE_ATTR_2_RO(temp4_min_alarm, alarm, 0x18, 3); +static SENSOR_DEVICE_ATTR_2_RO(temp5_min_alarm, alarm, 0x18, 4); + +static SENSOR_DEVICE_ATTR_2_RO(temp1_max_alarm, alarm, 0x19, 0); +static SENSOR_DEVICE_ATTR_2_RO(temp2_max_alarm, alarm, 0x19, 1); +static SENSOR_DEVICE_ATTR_2_RO(temp3_max_alarm, alarm, 0x19, 2); +static SENSOR_DEVICE_ATTR_2_RO(temp4_max_alarm, alarm, 0x19, 3); +static SENSOR_DEVICE_ATTR_2_RO(temp5_max_alarm, alarm, 0x19, 4); + +static SENSOR_DEVICE_ATTR_2_RO(temp1_crit_alarm, alarm, 0x1b, 0); +static SENSOR_DEVICE_ATTR_2_RO(temp2_crit_alarm, alarm, 0x1b, 1); +static SENSOR_DEVICE_ATTR_2_RO(temp3_crit_alarm, alarm, 0x1b, 2); +static SENSOR_DEVICE_ATTR_2_RO(temp4_crit_alarm, alarm, 0x1b, 3); +static SENSOR_DEVICE_ATTR_2_RO(temp5_crit_alarm, alarm, 0x1b, 4); + +static SENSOR_DEVICE_ATTR_2_RO(temp1_fault, alarm, 0x17, 0); +static SENSOR_DEVICE_ATTR_2_RO(temp2_fault, alarm, 0x17, 1); +static SENSOR_DEVICE_ATTR_2_RO(temp3_fault, alarm, 0x17, 2); + +static SENSOR_DEVICE_ATTR_2_RW(temp1_beep, beep, 0x5c, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp2_beep, beep, 0x5c, 1); +static SENSOR_DEVICE_ATTR_2_RW(temp3_beep, beep, 0x5c, 2); +static SENSOR_DEVICE_ATTR_2_RW(temp4_beep, beep, 0x5c, 3); +static SENSOR_DEVICE_ATTR_2_RW(temp5_beep, beep, 0x5c, 4); +static SENSOR_DEVICE_ATTR_2_RW(temp6_beep, beep, 0x5c, 5); static struct attribute *nct7802_temp_attrs[] = { &sensor_dev_attr_temp1_type.dev_attr.attr, @@ -709,43 +666,31 @@ static const struct attribute_group nct7802_temp_group = { .is_visible = nct7802_temp_is_visible, }; -static SENSOR_DEVICE_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0); -static SENSOR_DEVICE_ATTR_2(in0_min, S_IRUGO | S_IWUSR, show_in, store_in, - 0, 1); -static SENSOR_DEVICE_ATTR_2(in0_max, S_IRUGO | S_IWUSR, show_in, store_in, - 0, 2); -static SENSOR_DEVICE_ATTR_2(in0_alarm, S_IRUGO, show_alarm, NULL, 0x1e, 3); -static SENSOR_DEVICE_ATTR_2(in0_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, - 0x5a, 3); - -static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, show_in, NULL, 1, 0); - -static SENSOR_DEVICE_ATTR_2(in2_input, S_IRUGO, show_in, NULL, 2, 0); -static SENSOR_DEVICE_ATTR_2(in2_min, S_IRUGO | S_IWUSR, show_in, store_in, - 2, 1); -static SENSOR_DEVICE_ATTR_2(in2_max, S_IRUGO | S_IWUSR, show_in, store_in, - 2, 2); -static SENSOR_DEVICE_ATTR_2(in2_alarm, S_IRUGO, show_alarm, NULL, 0x1e, 0); -static SENSOR_DEVICE_ATTR_2(in2_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, - 0x5a, 0); - -static SENSOR_DEVICE_ATTR_2(in3_input, S_IRUGO, show_in, NULL, 3, 0); -static SENSOR_DEVICE_ATTR_2(in3_min, S_IRUGO | S_IWUSR, show_in, store_in, - 3, 1); -static SENSOR_DEVICE_ATTR_2(in3_max, S_IRUGO | S_IWUSR, show_in, store_in, - 3, 2); -static SENSOR_DEVICE_ATTR_2(in3_alarm, S_IRUGO, show_alarm, NULL, 0x1e, 1); -static SENSOR_DEVICE_ATTR_2(in3_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, - 0x5a, 1); - -static SENSOR_DEVICE_ATTR_2(in4_input, S_IRUGO, show_in, NULL, 4, 0); -static SENSOR_DEVICE_ATTR_2(in4_min, S_IRUGO | S_IWUSR, show_in, store_in, - 4, 1); -static SENSOR_DEVICE_ATTR_2(in4_max, S_IRUGO | S_IWUSR, show_in, store_in, - 4, 2); -static SENSOR_DEVICE_ATTR_2(in4_alarm, S_IRUGO, show_alarm, NULL, 0x1e, 2); -static SENSOR_DEVICE_ATTR_2(in4_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, - 0x5a, 2); +static SENSOR_DEVICE_ATTR_2_RO(in0_input, in, 0, 0); +static SENSOR_DEVICE_ATTR_2_RW(in0_min, in, 0, 1); +static SENSOR_DEVICE_ATTR_2_RW(in0_max, in, 0, 2); +static SENSOR_DEVICE_ATTR_2_RO(in0_alarm, alarm, 0x1e, 3); +static SENSOR_DEVICE_ATTR_2_RW(in0_beep, beep, 0x5a, 3); + +static SENSOR_DEVICE_ATTR_2_RO(in1_input, in, 1, 0); + +static SENSOR_DEVICE_ATTR_2_RO(in2_input, in, 2, 0); +static SENSOR_DEVICE_ATTR_2_RW(in2_min, in, 2, 1); +static SENSOR_DEVICE_ATTR_2_RW(in2_max, in, 2, 2); +static SENSOR_DEVICE_ATTR_2_RO(in2_alarm, alarm, 0x1e, 0); +static SENSOR_DEVICE_ATTR_2_RW(in2_beep, beep, 0x5a, 0); + +static SENSOR_DEVICE_ATTR_2_RO(in3_input, in, 3, 0); +static SENSOR_DEVICE_ATTR_2_RW(in3_min, in, 3, 1); +static SENSOR_DEVICE_ATTR_2_RW(in3_max, in, 3, 2); +static SENSOR_DEVICE_ATTR_2_RO(in3_alarm, alarm, 0x1e, 1); +static SENSOR_DEVICE_ATTR_2_RW(in3_beep, beep, 0x5a, 1); + +static SENSOR_DEVICE_ATTR_2_RO(in4_input, in, 4, 0); +static SENSOR_DEVICE_ATTR_2_RW(in4_min, in, 4, 1); +static SENSOR_DEVICE_ATTR_2_RW(in4_max, in, 4, 2); +static SENSOR_DEVICE_ATTR_2_RO(in4_alarm, alarm, 0x1e, 2); +static SENSOR_DEVICE_ATTR_2_RW(in4_beep, beep, 0x5a, 2); static struct attribute *nct7802_in_attrs[] = { &sensor_dev_attr_in0_input.dev_attr.attr, @@ -807,45 +752,33 @@ static const struct attribute_group nct7802_in_group = { .is_visible = nct7802_in_is_visible, }; -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0x10); -static SENSOR_DEVICE_ATTR_2(fan1_min, S_IRUGO | S_IWUSR, show_fan_min, - store_fan_min, 0x49, 0x4c); -static SENSOR_DEVICE_ATTR_2(fan1_alarm, S_IRUGO, show_alarm, NULL, 0x1a, 0); -static SENSOR_DEVICE_ATTR_2(fan1_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, - 0x5b, 0); -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 0x11); -static SENSOR_DEVICE_ATTR_2(fan2_min, S_IRUGO | S_IWUSR, show_fan_min, - store_fan_min, 0x4a, 0x4d); -static SENSOR_DEVICE_ATTR_2(fan2_alarm, S_IRUGO, show_alarm, NULL, 0x1a, 1); -static SENSOR_DEVICE_ATTR_2(fan2_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, - 0x5b, 1); -static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 0x12); -static SENSOR_DEVICE_ATTR_2(fan3_min, S_IRUGO | S_IWUSR, show_fan_min, - store_fan_min, 0x4b, 0x4e); -static SENSOR_DEVICE_ATTR_2(fan3_alarm, S_IRUGO, show_alarm, NULL, 0x1a, 2); -static SENSOR_DEVICE_ATTR_2(fan3_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, - 0x5b, 2); +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0x10); +static SENSOR_DEVICE_ATTR_2_RW(fan1_min, fan_min, 0x49, 0x4c); +static SENSOR_DEVICE_ATTR_2_RO(fan1_alarm, alarm, 0x1a, 0); +static SENSOR_DEVICE_ATTR_2_RW(fan1_beep, beep, 0x5b, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 0x11); +static SENSOR_DEVICE_ATTR_2_RW(fan2_min, fan_min, 0x4a, 0x4d); +static SENSOR_DEVICE_ATTR_2_RO(fan2_alarm, alarm, 0x1a, 1); +static SENSOR_DEVICE_ATTR_2_RW(fan2_beep, beep, 0x5b, 1); +static SENSOR_DEVICE_ATTR_RO(fan3_input, fan, 0x12); +static SENSOR_DEVICE_ATTR_2_RW(fan3_min, fan_min, 0x4b, 0x4e); +static SENSOR_DEVICE_ATTR_2_RO(fan3_alarm, alarm, 0x1a, 2); +static SENSOR_DEVICE_ATTR_2_RW(fan3_beep, beep, 0x5b, 2); /* 7.2.89 Fan Control Output Type */ -static SENSOR_DEVICE_ATTR(pwm1_mode, S_IRUGO, show_pwm_mode, NULL, 0); -static SENSOR_DEVICE_ATTR(pwm2_mode, S_IRUGO, show_pwm_mode, NULL, 1); -static SENSOR_DEVICE_ATTR(pwm3_mode, S_IRUGO, show_pwm_mode, NULL, 2); +static SENSOR_DEVICE_ATTR_RO(pwm1_mode, pwm_mode, 0); +static SENSOR_DEVICE_ATTR_RO(pwm2_mode, pwm_mode, 1); +static SENSOR_DEVICE_ATTR_RO(pwm3_mode, pwm_mode, 2); /* 7.2.91... Fan Control Output Value */ -static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm, store_pwm, - REG_PWM(0)); -static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, show_pwm, store_pwm, - REG_PWM(1)); -static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, show_pwm, store_pwm, - REG_PWM(2)); +static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, REG_PWM(0)); +static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, REG_PWM(1)); +static SENSOR_DEVICE_ATTR_RW(pwm3, pwm, REG_PWM(2)); /* 7.2.95... Temperature to Fan mapping Relationships Register */ -static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, show_pwm_enable, - store_pwm_enable, 0); -static SENSOR_DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR, show_pwm_enable, - store_pwm_enable, 1); -static SENSOR_DEVICE_ATTR(pwm3_enable, S_IRUGO | S_IWUSR, show_pwm_enable, - store_pwm_enable, 2); +static SENSOR_DEVICE_ATTR_RW(pwm1_enable, pwm_enable, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2_enable, pwm_enable, 1); +static SENSOR_DEVICE_ATTR_RW(pwm3_enable, pwm_enable, 2); static struct attribute *nct7802_fan_attrs[] = { &sensor_dev_attr_fan1_input.dev_attr.attr, @@ -903,73 +836,46 @@ static const struct attribute_group nct7802_pwm_group = { }; /* 7.2.115... 0x80-0x83, 0x84 Temperature (X-axis) transition */ -static SENSOR_DEVICE_ATTR_2(pwm1_auto_point1_temp, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x80, 0); -static SENSOR_DEVICE_ATTR_2(pwm1_auto_point2_temp, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x81, 0); -static SENSOR_DEVICE_ATTR_2(pwm1_auto_point3_temp, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x82, 0); -static SENSOR_DEVICE_ATTR_2(pwm1_auto_point4_temp, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x83, 0); -static SENSOR_DEVICE_ATTR_2(pwm1_auto_point5_temp, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x84, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point1_temp, temp, 0x80, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point2_temp, temp, 0x81, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point3_temp, temp, 0x82, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point4_temp, temp, 0x83, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point5_temp, temp, 0x84, 0); /* 7.2.120... 0x85-0x88 PWM (Y-axis) transition */ -static SENSOR_DEVICE_ATTR(pwm1_auto_point1_pwm, S_IRUGO | S_IWUSR, - show_pwm, store_pwm, 0x85); -static SENSOR_DEVICE_ATTR(pwm1_auto_point2_pwm, S_IRUGO | S_IWUSR, - show_pwm, store_pwm, 0x86); -static SENSOR_DEVICE_ATTR(pwm1_auto_point3_pwm, S_IRUGO | S_IWUSR, - show_pwm, store_pwm, 0x87); -static SENSOR_DEVICE_ATTR(pwm1_auto_point4_pwm, S_IRUGO | S_IWUSR, - show_pwm, store_pwm, 0x88); -static SENSOR_DEVICE_ATTR(pwm1_auto_point5_pwm, S_IRUGO, show_pwm, NULL, 0); +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point1_pwm, pwm, 0x85); +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point2_pwm, pwm, 0x86); +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point3_pwm, pwm, 0x87); +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point4_pwm, pwm, 0x88); +static SENSOR_DEVICE_ATTR_RO(pwm1_auto_point5_pwm, pwm, 0); /* 7.2.124 Table 2 X-axis Transition Point 1 Register */ -static SENSOR_DEVICE_ATTR_2(pwm2_auto_point1_temp, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x90, 0); -static SENSOR_DEVICE_ATTR_2(pwm2_auto_point2_temp, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x91, 0); -static SENSOR_DEVICE_ATTR_2(pwm2_auto_point3_temp, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x92, 0); -static SENSOR_DEVICE_ATTR_2(pwm2_auto_point4_temp, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x93, 0); -static SENSOR_DEVICE_ATTR_2(pwm2_auto_point5_temp, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x94, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point1_temp, temp, 0x90, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point2_temp, temp, 0x91, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point3_temp, temp, 0x92, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point4_temp, temp, 0x93, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point5_temp, temp, 0x94, 0); /* 7.2.129 Table 2 Y-axis Transition Point 1 Register */ -static SENSOR_DEVICE_ATTR(pwm2_auto_point1_pwm, S_IRUGO | S_IWUSR, - show_pwm, store_pwm, 0x95); -static SENSOR_DEVICE_ATTR(pwm2_auto_point2_pwm, S_IRUGO | S_IWUSR, - show_pwm, store_pwm, 0x96); -static SENSOR_DEVICE_ATTR(pwm2_auto_point3_pwm, S_IRUGO | S_IWUSR, - show_pwm, store_pwm, 0x97); -static SENSOR_DEVICE_ATTR(pwm2_auto_point4_pwm, S_IRUGO | S_IWUSR, - show_pwm, store_pwm, 0x98); -static SENSOR_DEVICE_ATTR(pwm2_auto_point5_pwm, S_IRUGO, show_pwm, NULL, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point1_pwm, pwm, 0x95); +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point2_pwm, pwm, 0x96); +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point3_pwm, pwm, 0x97); +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point4_pwm, pwm, 0x98); +static SENSOR_DEVICE_ATTR_RO(pwm2_auto_point5_pwm, pwm, 0); /* 7.2.133 Table 3 X-axis Transition Point 1 Register */ -static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_temp, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0xA0, 0); -static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_temp, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0xA1, 0); -static SENSOR_DEVICE_ATTR_2(pwm3_auto_point3_temp, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0xA2, 0); -static SENSOR_DEVICE_ATTR_2(pwm3_auto_point4_temp, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0xA3, 0); -static SENSOR_DEVICE_ATTR_2(pwm3_auto_point5_temp, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0xA4, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_point1_temp, temp, 0xA0, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_point2_temp, temp, 0xA1, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_point3_temp, temp, 0xA2, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_point4_temp, temp, 0xA3, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_point5_temp, temp, 0xA4, 0); /* 7.2.138 Table 3 Y-axis Transition Point 1 Register */ -static SENSOR_DEVICE_ATTR(pwm3_auto_point1_pwm, S_IRUGO | S_IWUSR, - show_pwm, store_pwm, 0xA5); -static SENSOR_DEVICE_ATTR(pwm3_auto_point2_pwm, S_IRUGO | S_IWUSR, - show_pwm, store_pwm, 0xA6); -static SENSOR_DEVICE_ATTR(pwm3_auto_point3_pwm, S_IRUGO | S_IWUSR, - show_pwm, store_pwm, 0xA7); -static SENSOR_DEVICE_ATTR(pwm3_auto_point4_pwm, S_IRUGO | S_IWUSR, - show_pwm, store_pwm, 0xA8); -static SENSOR_DEVICE_ATTR(pwm3_auto_point5_pwm, S_IRUGO, show_pwm, NULL, 0); +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point1_pwm, pwm, 0xA5); +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point2_pwm, pwm, 0xA6); +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point3_pwm, pwm, 0xA7); +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point4_pwm, pwm, 0xA8); +static SENSOR_DEVICE_ATTR_RO(pwm3_auto_point5_pwm, pwm, 0); static struct attribute *nct7802_auto_point_attrs[] = { &sensor_dev_attr_pwm1_auto_point1_temp.dev_attr.attr, -- cgit v1.2.3 From 3d628b29dbec70d7a0eda3d6bcf30198586666e2 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 6 Dec 2018 10:44:42 -0800 Subject: hwmon: (ltc4260) Auto-convert to use SENSOR_DEVICE_ATTR_{RO, RW, WO} Conversion was done done using the coccinelle script at https://github.com/groeck/coccinelle-patches/raw/master/hwmon/sensor-devattr-w6.cocci Signed-off-by: Guenter Roeck --- drivers/hwmon/ltc4260.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/drivers/hwmon/ltc4260.c b/drivers/hwmon/ltc4260.c index afb09574b12c..011b1ae98ff1 100644 --- a/drivers/hwmon/ltc4260.c +++ b/drivers/hwmon/ltc4260.c @@ -79,7 +79,7 @@ static int ltc4260_get_value(struct device *dev, u8 reg) return val; } -static ssize_t ltc4260_show_value(struct device *dev, +static ssize_t ltc4260_value_show(struct device *dev, struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); @@ -91,7 +91,7 @@ static ssize_t ltc4260_show_value(struct device *dev, return snprintf(buf, PAGE_SIZE, "%d\n", value); } -static ssize_t ltc4260_show_bool(struct device *dev, +static ssize_t ltc4260_bool_show(struct device *dev, struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); @@ -111,30 +111,24 @@ static ssize_t ltc4260_show_bool(struct device *dev, } /* Voltages */ -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ltc4260_show_value, NULL, - LTC4260_SOURCE); -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ltc4260_show_value, NULL, - LTC4260_ADIN); +static SENSOR_DEVICE_ATTR_RO(in1_input, ltc4260_value, LTC4260_SOURCE); +static SENSOR_DEVICE_ATTR_RO(in2_input, ltc4260_value, LTC4260_ADIN); /* * Voltage alarms * UV/OV faults are associated with the input voltage, and the POWER BAD and * FET SHORT faults are associated with the output voltage. */ -static SENSOR_DEVICE_ATTR(in1_min_alarm, S_IRUGO, ltc4260_show_bool, NULL, - FAULT_UV); -static SENSOR_DEVICE_ATTR(in1_max_alarm, S_IRUGO, ltc4260_show_bool, NULL, - FAULT_OV); -static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, ltc4260_show_bool, NULL, - FAULT_POWER_BAD | FAULT_FET_SHORT); +static SENSOR_DEVICE_ATTR_RO(in1_min_alarm, ltc4260_bool, FAULT_UV); +static SENSOR_DEVICE_ATTR_RO(in1_max_alarm, ltc4260_bool, FAULT_OV); +static SENSOR_DEVICE_ATTR_RO(in2_alarm, ltc4260_bool, + FAULT_POWER_BAD | FAULT_FET_SHORT); /* Current (via sense resistor) */ -static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, ltc4260_show_value, NULL, - LTC4260_SENSE); +static SENSOR_DEVICE_ATTR_RO(curr1_input, ltc4260_value, LTC4260_SENSE); /* Overcurrent alarm */ -static SENSOR_DEVICE_ATTR(curr1_max_alarm, S_IRUGO, ltc4260_show_bool, NULL, - FAULT_OC); +static SENSOR_DEVICE_ATTR_RO(curr1_max_alarm, ltc4260_bool, FAULT_OC); static struct attribute *ltc4260_attrs[] = { &sensor_dev_attr_in1_input.dev_attr.attr, -- cgit v1.2.3 From 4400711732fb1f9451d4f86319118148c3da670b Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 6 Dec 2018 10:46:16 -0800 Subject: hwmon: (max6650) Auto-convert to use SENSOR_DEVICE_ATTR_{RO, RW, WO} Conversion was done done using the coccinelle script at https://github.com/groeck/coccinelle-patches/raw/master/hwmon/sensor-devattr-w6.cocci Signed-off-by: Guenter Roeck --- drivers/hwmon/max6650.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c index 65be4b19fe47..4752a9ee9645 100644 --- a/drivers/hwmon/max6650.c +++ b/drivers/hwmon/max6650.c @@ -209,8 +209,8 @@ static int max6650_set_operating_mode(struct max6650_data *data, u8 mode) return 0; } -static ssize_t get_fan(struct device *dev, struct device_attribute *devattr, - char *buf) +static ssize_t fan_show(struct device *dev, struct device_attribute *devattr, + char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct max6650_data *data = max6650_update_device(dev); @@ -514,8 +514,8 @@ static ssize_t fan1_div_store(struct device *dev, * 1 = alarm */ -static ssize_t get_alarm(struct device *dev, struct device_attribute *devattr, - char *buf) +static ssize_t alarm_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct max6650_data *data = max6650_update_device(dev); @@ -534,24 +534,19 @@ static ssize_t get_alarm(struct device *dev, struct device_attribute *devattr, return sprintf(buf, "%d\n", alarm); } -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, get_fan, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, get_fan, NULL, 1); -static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, get_fan, NULL, 2); -static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, get_fan, NULL, 3); +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1); +static SENSOR_DEVICE_ATTR_RO(fan3_input, fan, 2); +static SENSOR_DEVICE_ATTR_RO(fan4_input, fan, 3); static DEVICE_ATTR_RW(fan1_target); static DEVICE_ATTR_RW(fan1_div); static DEVICE_ATTR_RW(pwm1_enable); static DEVICE_ATTR_RW(pwm1); -static SENSOR_DEVICE_ATTR(fan1_max_alarm, S_IRUGO, get_alarm, NULL, - MAX6650_ALRM_MAX); -static SENSOR_DEVICE_ATTR(fan1_min_alarm, S_IRUGO, get_alarm, NULL, - MAX6650_ALRM_MIN); -static SENSOR_DEVICE_ATTR(fan1_fault, S_IRUGO, get_alarm, NULL, - MAX6650_ALRM_TACH); -static SENSOR_DEVICE_ATTR(gpio1_alarm, S_IRUGO, get_alarm, NULL, - MAX6650_ALRM_GPIO1); -static SENSOR_DEVICE_ATTR(gpio2_alarm, S_IRUGO, get_alarm, NULL, - MAX6650_ALRM_GPIO2); +static SENSOR_DEVICE_ATTR_RO(fan1_max_alarm, alarm, MAX6650_ALRM_MAX); +static SENSOR_DEVICE_ATTR_RO(fan1_min_alarm, alarm, MAX6650_ALRM_MIN); +static SENSOR_DEVICE_ATTR_RO(fan1_fault, alarm, MAX6650_ALRM_TACH); +static SENSOR_DEVICE_ATTR_RO(gpio1_alarm, alarm, MAX6650_ALRM_GPIO1); +static SENSOR_DEVICE_ATTR_RO(gpio2_alarm, alarm, MAX6650_ALRM_GPIO2); static umode_t max6650_attrs_visible(struct kobject *kobj, struct attribute *a, int n) -- cgit v1.2.3 From c4043410f73d76e07b85685366758e4e16ee0082 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 6 Dec 2018 10:47:37 -0800 Subject: hwmon: (ntc_thermistor) Auto-convert to use SENSOR_DEVICE_ATTR_{RO, RW, WO} Conversion was done done using the coccinelle script at https://github.com/groeck/coccinelle-patches/raw/master/hwmon/sensor-devattr-w6.cocci Signed-off-by: Guenter Roeck --- drivers/hwmon/ntc_thermistor.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c index 56d83b2472c8..2823aff82c82 100644 --- a/drivers/hwmon/ntc_thermistor.c +++ b/drivers/hwmon/ntc_thermistor.c @@ -601,14 +601,14 @@ static int ntc_read_temp(void *data, int *temp) return 0; } -static ssize_t ntc_show_type(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t ntc_type_show(struct device *dev, + struct device_attribute *attr, char *buf) { return sprintf(buf, "4\n"); } -static ssize_t ntc_show_temp(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t ntc_temp_show(struct device *dev, + struct device_attribute *attr, char *buf) { struct ntc_data *data = dev_get_drvdata(dev); int ohm; @@ -620,8 +620,8 @@ static ssize_t ntc_show_temp(struct device *dev, return sprintf(buf, "%d\n", get_temp_mc(data, ohm)); } -static SENSOR_DEVICE_ATTR(temp1_type, S_IRUGO, ntc_show_type, NULL, 0); -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, ntc_show_temp, NULL, 0); +static SENSOR_DEVICE_ATTR_RO(temp1_type, ntc_type, 0); +static SENSOR_DEVICE_ATTR_RO(temp1_input, ntc_temp, 0); static struct attribute *ntc_attrs[] = { &sensor_dev_attr_temp1_type.dev_attr.attr, -- cgit v1.2.3 From cb1d85341fd781ef166525cfd5e3b33c5c05f7c9 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 6 Dec 2018 10:48:56 -0800 Subject: hwmon: (pwm-fan) Auto-convert to use SENSOR_DEVICE_ATTR_{RO, RW, WO} Conversion was done done using the coccinelle script at https://github.com/groeck/coccinelle-patches/raw/master/hwmon/sensor-devattr-w6.cocci Signed-off-by: Guenter Roeck --- drivers/hwmon/pwm-fan.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c index 7da6a160d45a..2c944825026f 100644 --- a/drivers/hwmon/pwm-fan.c +++ b/drivers/hwmon/pwm-fan.c @@ -72,8 +72,8 @@ static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm) ctx->pwm_fan_state = i; } -static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t pwm_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); unsigned long pwm; @@ -90,8 +90,8 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, return count; } -static ssize_t show_pwm(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t pwm_show(struct device *dev, struct device_attribute *attr, + char *buf) { struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); @@ -99,7 +99,7 @@ static ssize_t show_pwm(struct device *dev, } -static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm, set_pwm, 0); +static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0); static struct attribute *pwm_fan_attrs[] = { &sensor_dev_attr_pwm1.dev_attr.attr, -- cgit v1.2.3 From 740c2f2b86a71ad673f329241ac25cfe647aacd4 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 6 Dec 2018 10:54:38 -0800 Subject: hwmon: (max6697) Auto-convert to use SENSOR_DEVICE_ATTR_{RO, RW, WO} Conversion was done done using the coccinelle script at https://github.com/groeck/coccinelle-patches/raw/master/hwmon/sensor-devattr-w6.cocci Signed-off-by: Guenter Roeck --- drivers/hwmon/max6697.c | 144 +++++++++++++++++++++--------------------------- 1 file changed, 64 insertions(+), 80 deletions(-) diff --git a/drivers/hwmon/max6697.c b/drivers/hwmon/max6697.c index 221fd1492057..da43f7ae3de1 100644 --- a/drivers/hwmon/max6697.c +++ b/drivers/hwmon/max6697.c @@ -250,7 +250,7 @@ abort: return ret; } -static ssize_t show_temp_input(struct device *dev, +static ssize_t temp_input_show(struct device *dev, struct device_attribute *devattr, char *buf) { int index = to_sensor_dev_attr(devattr)->index; @@ -266,8 +266,8 @@ static ssize_t show_temp_input(struct device *dev, return sprintf(buf, "%d\n", temp * 125); } -static ssize_t show_temp(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t temp_show(struct device *dev, struct device_attribute *devattr, + char *buf) { int nr = to_sensor_dev_attr_2(devattr)->nr; int index = to_sensor_dev_attr_2(devattr)->index; @@ -283,7 +283,7 @@ static ssize_t show_temp(struct device *dev, return sprintf(buf, "%d\n", temp * 1000); } -static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, +static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, char *buf) { int index = to_sensor_dev_attr(attr)->index; @@ -298,9 +298,9 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%u\n", (data->alarms >> index) & 0x1); } -static ssize_t set_temp(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) +static ssize_t temp_store(struct device *dev, + struct device_attribute *devattr, const char *buf, + size_t count) { int nr = to_sensor_dev_attr_2(devattr)->nr; int index = to_sensor_dev_attr_2(devattr)->index; @@ -325,79 +325,63 @@ static ssize_t set_temp(struct device *dev, return ret < 0 ? ret : count; } -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input, NULL, 0); -static SENSOR_DEVICE_ATTR_2(temp1_max, S_IRUGO | S_IWUSR, show_temp, set_temp, - 0, MAX6697_TEMP_MAX); -static SENSOR_DEVICE_ATTR_2(temp1_crit, S_IRUGO | S_IWUSR, show_temp, set_temp, - 0, MAX6697_TEMP_CRIT); - -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input, NULL, 1); -static SENSOR_DEVICE_ATTR_2(temp2_max, S_IRUGO | S_IWUSR, show_temp, set_temp, - 1, MAX6697_TEMP_MAX); -static SENSOR_DEVICE_ATTR_2(temp2_crit, S_IRUGO | S_IWUSR, show_temp, set_temp, - 1, MAX6697_TEMP_CRIT); - -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp_input, NULL, 2); -static SENSOR_DEVICE_ATTR_2(temp3_max, S_IRUGO | S_IWUSR, show_temp, set_temp, - 2, MAX6697_TEMP_MAX); -static SENSOR_DEVICE_ATTR_2(temp3_crit, S_IRUGO | S_IWUSR, show_temp, set_temp, - 2, MAX6697_TEMP_CRIT); - -static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp_input, NULL, 3); -static SENSOR_DEVICE_ATTR_2(temp4_max, S_IRUGO | S_IWUSR, show_temp, set_temp, - 3, MAX6697_TEMP_MAX); -static SENSOR_DEVICE_ATTR_2(temp4_crit, S_IRUGO | S_IWUSR, show_temp, set_temp, - 3, MAX6697_TEMP_CRIT); - -static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO, show_temp_input, NULL, 4); -static SENSOR_DEVICE_ATTR_2(temp5_max, S_IRUGO | S_IWUSR, show_temp, set_temp, - 4, MAX6697_TEMP_MAX); -static SENSOR_DEVICE_ATTR_2(temp5_crit, S_IRUGO | S_IWUSR, show_temp, set_temp, - 4, MAX6697_TEMP_CRIT); - -static SENSOR_DEVICE_ATTR(temp6_input, S_IRUGO, show_temp_input, NULL, 5); -static SENSOR_DEVICE_ATTR_2(temp6_max, S_IRUGO | S_IWUSR, show_temp, set_temp, - 5, MAX6697_TEMP_MAX); -static SENSOR_DEVICE_ATTR_2(temp6_crit, S_IRUGO | S_IWUSR, show_temp, set_temp, - 5, MAX6697_TEMP_CRIT); - -static SENSOR_DEVICE_ATTR(temp7_input, S_IRUGO, show_temp_input, NULL, 6); -static SENSOR_DEVICE_ATTR_2(temp7_max, S_IRUGO | S_IWUSR, show_temp, set_temp, - 6, MAX6697_TEMP_MAX); -static SENSOR_DEVICE_ATTR_2(temp7_crit, S_IRUGO | S_IWUSR, show_temp, set_temp, - 6, MAX6697_TEMP_CRIT); - -static SENSOR_DEVICE_ATTR(temp8_input, S_IRUGO, show_temp_input, NULL, 7); -static SENSOR_DEVICE_ATTR_2(temp8_max, S_IRUGO | S_IWUSR, show_temp, set_temp, - 7, MAX6697_TEMP_MAX); -static SENSOR_DEVICE_ATTR_2(temp8_crit, S_IRUGO | S_IWUSR, show_temp, set_temp, - 7, MAX6697_TEMP_CRIT); - -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 22); -static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 16); -static SENSOR_DEVICE_ATTR(temp3_max_alarm, S_IRUGO, show_alarm, NULL, 17); -static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_alarm, NULL, 18); -static SENSOR_DEVICE_ATTR(temp5_max_alarm, S_IRUGO, show_alarm, NULL, 19); -static SENSOR_DEVICE_ATTR(temp6_max_alarm, S_IRUGO, show_alarm, NULL, 20); -static SENSOR_DEVICE_ATTR(temp7_max_alarm, S_IRUGO, show_alarm, NULL, 21); -static SENSOR_DEVICE_ATTR(temp8_max_alarm, S_IRUGO, show_alarm, NULL, 23); - -static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 14); -static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 8); -static SENSOR_DEVICE_ATTR(temp3_crit_alarm, S_IRUGO, show_alarm, NULL, 9); -static SENSOR_DEVICE_ATTR(temp4_crit_alarm, S_IRUGO, show_alarm, NULL, 10); -static SENSOR_DEVICE_ATTR(temp5_crit_alarm, S_IRUGO, show_alarm, NULL, 11); -static SENSOR_DEVICE_ATTR(temp6_crit_alarm, S_IRUGO, show_alarm, NULL, 12); -static SENSOR_DEVICE_ATTR(temp7_crit_alarm, S_IRUGO, show_alarm, NULL, 13); -static SENSOR_DEVICE_ATTR(temp8_crit_alarm, S_IRUGO, show_alarm, NULL, 15); - -static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 1); -static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 2); -static SENSOR_DEVICE_ATTR(temp4_fault, S_IRUGO, show_alarm, NULL, 3); -static SENSOR_DEVICE_ATTR(temp5_fault, S_IRUGO, show_alarm, NULL, 4); -static SENSOR_DEVICE_ATTR(temp6_fault, S_IRUGO, show_alarm, NULL, 5); -static SENSOR_DEVICE_ATTR(temp7_fault, S_IRUGO, show_alarm, NULL, 6); -static SENSOR_DEVICE_ATTR(temp8_fault, S_IRUGO, show_alarm, NULL, 7); +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp_input, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp1_max, temp, 0, MAX6697_TEMP_MAX); +static SENSOR_DEVICE_ATTR_2_RW(temp1_crit, temp, 0, MAX6697_TEMP_CRIT); + +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp_input, 1); +static SENSOR_DEVICE_ATTR_2_RW(temp2_max, temp, 1, MAX6697_TEMP_MAX); +static SENSOR_DEVICE_ATTR_2_RW(temp2_crit, temp, 1, MAX6697_TEMP_CRIT); + +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp_input, 2); +static SENSOR_DEVICE_ATTR_2_RW(temp3_max, temp, 2, MAX6697_TEMP_MAX); +static SENSOR_DEVICE_ATTR_2_RW(temp3_crit, temp, 2, MAX6697_TEMP_CRIT); + +static SENSOR_DEVICE_ATTR_RO(temp4_input, temp_input, 3); +static SENSOR_DEVICE_ATTR_2_RW(temp4_max, temp, 3, MAX6697_TEMP_MAX); +static SENSOR_DEVICE_ATTR_2_RW(temp4_crit, temp, 3, MAX6697_TEMP_CRIT); + +static SENSOR_DEVICE_ATTR_RO(temp5_input, temp_input, 4); +static SENSOR_DEVICE_ATTR_2_RW(temp5_max, temp, 4, MAX6697_TEMP_MAX); +static SENSOR_DEVICE_ATTR_2_RW(temp5_crit, temp, 4, MAX6697_TEMP_CRIT); + +static SENSOR_DEVICE_ATTR_RO(temp6_input, temp_input, 5); +static SENSOR_DEVICE_ATTR_2_RW(temp6_max, temp, 5, MAX6697_TEMP_MAX); +static SENSOR_DEVICE_ATTR_2_RW(temp6_crit, temp, 5, MAX6697_TEMP_CRIT); + +static SENSOR_DEVICE_ATTR_RO(temp7_input, temp_input, 6); +static SENSOR_DEVICE_ATTR_2_RW(temp7_max, temp, 6, MAX6697_TEMP_MAX); +static SENSOR_DEVICE_ATTR_2_RW(temp7_crit, temp, 6, MAX6697_TEMP_CRIT); + +static SENSOR_DEVICE_ATTR_RO(temp8_input, temp_input, 7); +static SENSOR_DEVICE_ATTR_2_RW(temp8_max, temp, 7, MAX6697_TEMP_MAX); +static SENSOR_DEVICE_ATTR_2_RW(temp8_crit, temp, 7, MAX6697_TEMP_CRIT); + +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 22); +static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, alarm, 16); +static SENSOR_DEVICE_ATTR_RO(temp3_max_alarm, alarm, 17); +static SENSOR_DEVICE_ATTR_RO(temp4_max_alarm, alarm, 18); +static SENSOR_DEVICE_ATTR_RO(temp5_max_alarm, alarm, 19); +static SENSOR_DEVICE_ATTR_RO(temp6_max_alarm, alarm, 20); +static SENSOR_DEVICE_ATTR_RO(temp7_max_alarm, alarm, 21); +static SENSOR_DEVICE_ATTR_RO(temp8_max_alarm, alarm, 23); + +static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, alarm, 14); +static SENSOR_DEVICE_ATTR_RO(temp2_crit_alarm, alarm, 8); +static SENSOR_DEVICE_ATTR_RO(temp3_crit_alarm, alarm, 9); +static SENSOR_DEVICE_ATTR_RO(temp4_crit_alarm, alarm, 10); +static SENSOR_DEVICE_ATTR_RO(temp5_crit_alarm, alarm, 11); +static SENSOR_DEVICE_ATTR_RO(temp6_crit_alarm, alarm, 12); +static SENSOR_DEVICE_ATTR_RO(temp7_crit_alarm, alarm, 13); +static SENSOR_DEVICE_ATTR_RO(temp8_crit_alarm, alarm, 15); + +static SENSOR_DEVICE_ATTR_RO(temp2_fault, alarm, 1); +static SENSOR_DEVICE_ATTR_RO(temp3_fault, alarm, 2); +static SENSOR_DEVICE_ATTR_RO(temp4_fault, alarm, 3); +static SENSOR_DEVICE_ATTR_RO(temp5_fault, alarm, 4); +static SENSOR_DEVICE_ATTR_RO(temp6_fault, alarm, 5); +static SENSOR_DEVICE_ATTR_RO(temp7_fault, alarm, 6); +static SENSOR_DEVICE_ATTR_RO(temp8_fault, alarm, 7); static DEVICE_ATTR(dummy, 0, NULL, NULL); -- cgit v1.2.3 From e36917f486a85e81ed02490a476cde8179e6b14f Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 6 Dec 2018 10:59:49 -0800 Subject: hwmon: (tmp401) Auto-convert to use SENSOR_DEVICE_ATTR_{RO, RW, WO} Conversion was done done using the coccinelle script at https://github.com/groeck/coccinelle-patches/raw/master/hwmon/sensor-devattr-w6.cocci Signed-off-by: Guenter Roeck --- drivers/hwmon/tmp401.c | 126 ++++++++++++++++++++++--------------------------- 1 file changed, 57 insertions(+), 69 deletions(-) diff --git a/drivers/hwmon/tmp401.c b/drivers/hwmon/tmp401.c index 1f2d13dc9439..ff66cf1bfb2e 100644 --- a/drivers/hwmon/tmp401.c +++ b/drivers/hwmon/tmp401.c @@ -288,8 +288,8 @@ abort: return ret; } -static ssize_t show_temp(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t temp_show(struct device *dev, struct device_attribute *devattr, + char *buf) { int nr = to_sensor_dev_attr_2(devattr)->nr; int index = to_sensor_dev_attr_2(devattr)->index; @@ -302,8 +302,9 @@ static ssize_t show_temp(struct device *dev, tmp401_register_to_temp(data->temp[nr][index], data->config)); } -static ssize_t show_temp_crit_hyst(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t temp_crit_hyst_show(struct device *dev, + struct device_attribute *devattr, + char *buf) { int temp, index = to_sensor_dev_attr(devattr)->index; struct tmp401_data *data = tmp401_update_device(dev); @@ -319,8 +320,8 @@ static ssize_t show_temp_crit_hyst(struct device *dev, return sprintf(buf, "%d\n", temp); } -static ssize_t show_status(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t status_show(struct device *dev, + struct device_attribute *devattr, char *buf) { int nr = to_sensor_dev_attr_2(devattr)->nr; int mask = to_sensor_dev_attr_2(devattr)->index; @@ -332,8 +333,9 @@ static ssize_t show_status(struct device *dev, return sprintf(buf, "%d\n", !!(data->status[nr] & mask)); } -static ssize_t store_temp(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) +static ssize_t temp_store(struct device *dev, + struct device_attribute *devattr, const char *buf, + size_t count) { int nr = to_sensor_dev_attr_2(devattr)->nr; int index = to_sensor_dev_attr_2(devattr)->index; @@ -365,8 +367,9 @@ static ssize_t store_temp(struct device *dev, struct device_attribute *devattr, return count; } -static ssize_t store_temp_crit_hyst(struct device *dev, struct device_attribute - *devattr, const char *buf, size_t count) +static ssize_t temp_crit_hyst_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { int temp, index = to_sensor_dev_attr(devattr)->index; struct tmp401_data *data = tmp401_update_device(dev); @@ -404,8 +407,9 @@ static ssize_t store_temp_crit_hyst(struct device *dev, struct device_attribute * This is done by writing any value to any of the minimum/maximum registers * (0x30-0x37). */ -static ssize_t reset_temp_history(struct device *dev, - struct device_attribute *devattr, const char *buf, size_t count) +static ssize_t reset_temp_history_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct tmp401_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; @@ -467,38 +471,29 @@ static ssize_t update_interval_store(struct device *dev, return count; } -static SENSOR_DEVICE_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, 0, 0); -static SENSOR_DEVICE_ATTR_2(temp1_min, S_IWUSR | S_IRUGO, show_temp, - store_temp, 1, 0); -static SENSOR_DEVICE_ATTR_2(temp1_max, S_IWUSR | S_IRUGO, show_temp, - store_temp, 2, 0); -static SENSOR_DEVICE_ATTR_2(temp1_crit, S_IWUSR | S_IRUGO, show_temp, - store_temp, 3, 0); -static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, - show_temp_crit_hyst, store_temp_crit_hyst, 0); -static SENSOR_DEVICE_ATTR_2(temp1_min_alarm, S_IRUGO, show_status, NULL, - 1, TMP432_STATUS_LOCAL); -static SENSOR_DEVICE_ATTR_2(temp1_max_alarm, S_IRUGO, show_status, NULL, - 2, TMP432_STATUS_LOCAL); -static SENSOR_DEVICE_ATTR_2(temp1_crit_alarm, S_IRUGO, show_status, NULL, - 3, TMP432_STATUS_LOCAL); -static SENSOR_DEVICE_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, 0, 1); -static SENSOR_DEVICE_ATTR_2(temp2_min, S_IWUSR | S_IRUGO, show_temp, - store_temp, 1, 1); -static SENSOR_DEVICE_ATTR_2(temp2_max, S_IWUSR | S_IRUGO, show_temp, - store_temp, 2, 1); -static SENSOR_DEVICE_ATTR_2(temp2_crit, S_IWUSR | S_IRUGO, show_temp, - store_temp, 3, 1); -static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temp_crit_hyst, - NULL, 1); -static SENSOR_DEVICE_ATTR_2(temp2_fault, S_IRUGO, show_status, NULL, - 0, TMP432_STATUS_REMOTE1); -static SENSOR_DEVICE_ATTR_2(temp2_min_alarm, S_IRUGO, show_status, NULL, - 1, TMP432_STATUS_REMOTE1); -static SENSOR_DEVICE_ATTR_2(temp2_max_alarm, S_IRUGO, show_status, NULL, - 2, TMP432_STATUS_REMOTE1); -static SENSOR_DEVICE_ATTR_2(temp2_crit_alarm, S_IRUGO, show_status, NULL, - 3, TMP432_STATUS_REMOTE1); +static SENSOR_DEVICE_ATTR_2_RO(temp1_input, temp, 0, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp1_min, temp, 1, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp1_max, temp, 2, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp1_crit, temp, 3, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_crit_hyst, temp_crit_hyst, 0); +static SENSOR_DEVICE_ATTR_2_RO(temp1_min_alarm, status, 1, + TMP432_STATUS_LOCAL); +static SENSOR_DEVICE_ATTR_2_RO(temp1_max_alarm, status, 2, + TMP432_STATUS_LOCAL); +static SENSOR_DEVICE_ATTR_2_RO(temp1_crit_alarm, status, 3, + TMP432_STATUS_LOCAL); +static SENSOR_DEVICE_ATTR_2_RO(temp2_input, temp, 0, 1); +static SENSOR_DEVICE_ATTR_2_RW(temp2_min, temp, 1, 1); +static SENSOR_DEVICE_ATTR_2_RW(temp2_max, temp, 2, 1); +static SENSOR_DEVICE_ATTR_2_RW(temp2_crit, temp, 3, 1); +static SENSOR_DEVICE_ATTR_RO(temp2_crit_hyst, temp_crit_hyst, 1); +static SENSOR_DEVICE_ATTR_2_RO(temp2_fault, status, 0, TMP432_STATUS_REMOTE1); +static SENSOR_DEVICE_ATTR_2_RO(temp2_min_alarm, status, 1, + TMP432_STATUS_REMOTE1); +static SENSOR_DEVICE_ATTR_2_RO(temp2_max_alarm, status, 2, + TMP432_STATUS_REMOTE1); +static SENSOR_DEVICE_ATTR_2_RO(temp2_crit_alarm, status, 3, + TMP432_STATUS_REMOTE1); static DEVICE_ATTR_RW(update_interval); @@ -538,12 +533,11 @@ static const struct attribute_group tmp401_group = { * minimum and maximum register reset for both the local * and remote channels. */ -static SENSOR_DEVICE_ATTR_2(temp1_lowest, S_IRUGO, show_temp, NULL, 4, 0); -static SENSOR_DEVICE_ATTR_2(temp1_highest, S_IRUGO, show_temp, NULL, 5, 0); -static SENSOR_DEVICE_ATTR_2(temp2_lowest, S_IRUGO, show_temp, NULL, 4, 1); -static SENSOR_DEVICE_ATTR_2(temp2_highest, S_IRUGO, show_temp, NULL, 5, 1); -static SENSOR_DEVICE_ATTR(temp_reset_history, S_IWUSR, NULL, reset_temp_history, - 0); +static SENSOR_DEVICE_ATTR_2_RO(temp1_lowest, temp, 4, 0); +static SENSOR_DEVICE_ATTR_2_RO(temp1_highest, temp, 5, 0); +static SENSOR_DEVICE_ATTR_2_RO(temp2_lowest, temp, 4, 1); +static SENSOR_DEVICE_ATTR_2_RO(temp2_highest, temp, 5, 1); +static SENSOR_DEVICE_ATTR_WO(temp_reset_history, reset_temp_history, 0); static struct attribute *tmp411_attributes[] = { &sensor_dev_attr_temp1_highest.dev_attr.attr, @@ -558,23 +552,18 @@ static const struct attribute_group tmp411_group = { .attrs = tmp411_attributes, }; -static SENSOR_DEVICE_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, 0, 2); -static SENSOR_DEVICE_ATTR_2(temp3_min, S_IWUSR | S_IRUGO, show_temp, - store_temp, 1, 2); -static SENSOR_DEVICE_ATTR_2(temp3_max, S_IWUSR | S_IRUGO, show_temp, - store_temp, 2, 2); -static SENSOR_DEVICE_ATTR_2(temp3_crit, S_IWUSR | S_IRUGO, show_temp, - store_temp, 3, 2); -static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO, show_temp_crit_hyst, - NULL, 2); -static SENSOR_DEVICE_ATTR_2(temp3_fault, S_IRUGO, show_status, NULL, - 0, TMP432_STATUS_REMOTE2); -static SENSOR_DEVICE_ATTR_2(temp3_min_alarm, S_IRUGO, show_status, NULL, - 1, TMP432_STATUS_REMOTE2); -static SENSOR_DEVICE_ATTR_2(temp3_max_alarm, S_IRUGO, show_status, NULL, - 2, TMP432_STATUS_REMOTE2); -static SENSOR_DEVICE_ATTR_2(temp3_crit_alarm, S_IRUGO, show_status, NULL, - 3, TMP432_STATUS_REMOTE2); +static SENSOR_DEVICE_ATTR_2_RO(temp3_input, temp, 0, 2); +static SENSOR_DEVICE_ATTR_2_RW(temp3_min, temp, 1, 2); +static SENSOR_DEVICE_ATTR_2_RW(temp3_max, temp, 2, 2); +static SENSOR_DEVICE_ATTR_2_RW(temp3_crit, temp, 3, 2); +static SENSOR_DEVICE_ATTR_RO(temp3_crit_hyst, temp_crit_hyst, 2); +static SENSOR_DEVICE_ATTR_2_RO(temp3_fault, status, 0, TMP432_STATUS_REMOTE2); +static SENSOR_DEVICE_ATTR_2_RO(temp3_min_alarm, status, 1, + TMP432_STATUS_REMOTE2); +static SENSOR_DEVICE_ATTR_2_RO(temp3_max_alarm, status, 2, + TMP432_STATUS_REMOTE2); +static SENSOR_DEVICE_ATTR_2_RO(temp3_crit_alarm, status, 3, + TMP432_STATUS_REMOTE2); static struct attribute *tmp432_attributes[] = { &sensor_dev_attr_temp3_input.dev_attr.attr, @@ -598,8 +587,7 @@ static const struct attribute_group tmp432_group = { * Additional features of the TMP461 chip. * The TMP461 temperature offset for the remote channel. */ -static SENSOR_DEVICE_ATTR_2(temp2_offset, S_IWUSR | S_IRUGO, show_temp, - store_temp, 6, 1); +static SENSOR_DEVICE_ATTR_2_RW(temp2_offset, temp, 6, 1); static struct attribute *tmp461_attributes[] = { &sensor_dev_attr_temp2_offset.dev_attr.attr, -- cgit v1.2.3 From 6a0f234fb42111545f071971b25e5f8462621a8a Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 6 Dec 2018 11:06:23 -0800 Subject: hwmon: (ina2xx) Auto-convert to use SENSOR_DEVICE_ATTR_{RO, RW, WO} Conversion was done done using the coccinelle script at https://github.com/groeck/coccinelle-patches/raw/master/hwmon/sensor-devattr-w6.cocci Signed-off-by: Guenter Roeck --- drivers/hwmon/ina2xx.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c index 07ee19573b3f..290379c49be9 100644 --- a/drivers/hwmon/ina2xx.c +++ b/drivers/hwmon/ina2xx.c @@ -290,7 +290,7 @@ static int ina2xx_get_value(struct ina2xx_data *data, u8 reg, return val; } -static ssize_t ina2xx_show_value(struct device *dev, +static ssize_t ina2xx_value_show(struct device *dev, struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); @@ -329,16 +329,15 @@ static int ina2xx_set_shunt(struct ina2xx_data *data, long val) return 0; } -static ssize_t ina2xx_show_shunt(struct device *dev, - struct device_attribute *da, - char *buf) +static ssize_t ina2xx_shunt_show(struct device *dev, + struct device_attribute *da, char *buf) { struct ina2xx_data *data = dev_get_drvdata(dev); return snprintf(buf, PAGE_SIZE, "%li\n", data->rshunt); } -static ssize_t ina2xx_store_shunt(struct device *dev, +static ssize_t ina2xx_shunt_store(struct device *dev, struct device_attribute *da, const char *buf, size_t count) { @@ -356,9 +355,9 @@ static ssize_t ina2xx_store_shunt(struct device *dev, return count; } -static ssize_t ina226_set_interval(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) +static ssize_t ina226_interval_store(struct device *dev, + struct device_attribute *da, + const char *buf, size_t count) { struct ina2xx_data *data = dev_get_drvdata(dev); unsigned long val; @@ -380,7 +379,7 @@ static ssize_t ina226_set_interval(struct device *dev, return count; } -static ssize_t ina226_show_interval(struct device *dev, +static ssize_t ina226_interval_show(struct device *dev, struct device_attribute *da, char *buf) { struct ina2xx_data *data = dev_get_drvdata(dev); @@ -395,29 +394,22 @@ static ssize_t ina226_show_interval(struct device *dev, } /* shunt voltage */ -static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, ina2xx_show_value, NULL, - INA2XX_SHUNT_VOLTAGE); +static SENSOR_DEVICE_ATTR_RO(in0_input, ina2xx_value, INA2XX_SHUNT_VOLTAGE); /* bus voltage */ -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ina2xx_show_value, NULL, - INA2XX_BUS_VOLTAGE); +static SENSOR_DEVICE_ATTR_RO(in1_input, ina2xx_value, INA2XX_BUS_VOLTAGE); /* calculated current */ -static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, ina2xx_show_value, NULL, - INA2XX_CURRENT); +static SENSOR_DEVICE_ATTR_RO(curr1_input, ina2xx_value, INA2XX_CURRENT); /* calculated power */ -static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, ina2xx_show_value, NULL, - INA2XX_POWER); +static SENSOR_DEVICE_ATTR_RO(power1_input, ina2xx_value, INA2XX_POWER); /* shunt resistance */ -static SENSOR_DEVICE_ATTR(shunt_resistor, S_IRUGO | S_IWUSR, - ina2xx_show_shunt, ina2xx_store_shunt, - INA2XX_CALIBRATION); +static SENSOR_DEVICE_ATTR_RW(shunt_resistor, ina2xx_shunt, INA2XX_CALIBRATION); /* update interval (ina226 only) */ -static SENSOR_DEVICE_ATTR(update_interval, S_IRUGO | S_IWUSR, - ina226_show_interval, ina226_set_interval, 0); +static SENSOR_DEVICE_ATTR_RW(update_interval, ina226_interval, 0); /* pointers to created device attributes */ static struct attribute *ina2xx_attrs[] = { -- cgit v1.2.3 From d7f2a8f596ba2a8c7b7cc6d7a86f1e419def87b6 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 6 Dec 2018 11:07:32 -0800 Subject: hwmon: (ltc4215) Auto-convert to use SENSOR_DEVICE_ATTR_{RO, RW, WO} Conversion was done done using the coccinelle script at https://github.com/groeck/coccinelle-patches/raw/master/hwmon/sensor-devattr-w6.cocci Signed-off-by: Guenter Roeck --- drivers/hwmon/ltc4215.c | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/drivers/hwmon/ltc4215.c b/drivers/hwmon/ltc4215.c index c8a9bd9b050f..d4a1d033d3e8 100644 --- a/drivers/hwmon/ltc4215.c +++ b/drivers/hwmon/ltc4215.c @@ -136,9 +136,8 @@ static unsigned int ltc4215_get_current(struct device *dev) return curr; } -static ssize_t ltc4215_show_voltage(struct device *dev, - struct device_attribute *da, - char *buf) +static ssize_t ltc4215_voltage_show(struct device *dev, + struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); const int voltage = ltc4215_get_voltage(dev, attr->index); @@ -146,18 +145,16 @@ static ssize_t ltc4215_show_voltage(struct device *dev, return snprintf(buf, PAGE_SIZE, "%d\n", voltage); } -static ssize_t ltc4215_show_current(struct device *dev, - struct device_attribute *da, - char *buf) +static ssize_t ltc4215_current_show(struct device *dev, + struct device_attribute *da, char *buf) { const unsigned int curr = ltc4215_get_current(dev); return snprintf(buf, PAGE_SIZE, "%u\n", curr); } -static ssize_t ltc4215_show_power(struct device *dev, - struct device_attribute *da, - char *buf) +static ssize_t ltc4215_power_show(struct device *dev, + struct device_attribute *da, char *buf) { const unsigned int curr = ltc4215_get_current(dev); const int output_voltage = ltc4215_get_voltage(dev, LTC4215_ADIN); @@ -168,9 +165,8 @@ static ssize_t ltc4215_show_power(struct device *dev, return snprintf(buf, PAGE_SIZE, "%u\n", power); } -static ssize_t ltc4215_show_alarm(struct device *dev, - struct device_attribute *da, - char *buf) +static ssize_t ltc4215_alarm_show(struct device *dev, + struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct ltc4215_data *data = ltc4215_update_device(dev); @@ -189,26 +185,20 @@ static ssize_t ltc4215_show_alarm(struct device *dev, /* Construct a sensor_device_attribute structure for each register */ /* Current */ -static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, ltc4215_show_current, NULL, 0); -static SENSOR_DEVICE_ATTR(curr1_max_alarm, S_IRUGO, ltc4215_show_alarm, NULL, - 1 << 2); +static SENSOR_DEVICE_ATTR_RO(curr1_input, ltc4215_current, 0); +static SENSOR_DEVICE_ATTR_RO(curr1_max_alarm, ltc4215_alarm, 1 << 2); /* Power (virtual) */ -static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, ltc4215_show_power, NULL, 0); +static SENSOR_DEVICE_ATTR_RO(power1_input, ltc4215_power, 0); /* Input Voltage */ -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ltc4215_show_voltage, NULL, - LTC4215_ADIN); -static SENSOR_DEVICE_ATTR(in1_max_alarm, S_IRUGO, ltc4215_show_alarm, NULL, - 1 << 0); -static SENSOR_DEVICE_ATTR(in1_min_alarm, S_IRUGO, ltc4215_show_alarm, NULL, - 1 << 1); +static SENSOR_DEVICE_ATTR_RO(in1_input, ltc4215_voltage, LTC4215_ADIN); +static SENSOR_DEVICE_ATTR_RO(in1_max_alarm, ltc4215_alarm, 1 << 0); +static SENSOR_DEVICE_ATTR_RO(in1_min_alarm, ltc4215_alarm, 1 << 1); /* Output Voltage */ -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ltc4215_show_voltage, NULL, - LTC4215_SOURCE); -static SENSOR_DEVICE_ATTR(in2_min_alarm, S_IRUGO, ltc4215_show_alarm, NULL, - 1 << 3); +static SENSOR_DEVICE_ATTR_RO(in2_input, ltc4215_voltage, LTC4215_SOURCE); +static SENSOR_DEVICE_ATTR_RO(in2_min_alarm, ltc4215_alarm, 1 << 3); /* * Finally, construct an array of pointers to members of the above objects, -- cgit v1.2.3 From d93217d84c6c7ef74bfeb606a1fb1ee28720646b Mon Sep 17 00:00:00 2001 From: Pu Wen Date: Sat, 8 Dec 2018 14:33:28 +0800 Subject: hwmon: (k10temp) Add Hygon Dhyana support Add support for Hygon Dhyana family 18h processor for k10temp to get the temperature. As Hygon Dhyana shares the same function interface with AMD family 17h, so add Hygon PCI Vendor ID and reuse the code path of AMD. Signed-off-by: Pu Wen Acked-by: Borislav Petkov Signed-off-by: Guenter Roeck --- drivers/hwmon/k10temp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index cd601cd6f88a..1eb954daa2c8 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -330,7 +330,7 @@ static int k10temp_probe(struct pci_dev *pdev, (boot_cpu_data.x86_model & 0xf0) == 0x70)) { data->read_htcreg = read_htcreg_nb_f15; data->read_tempreg = read_tempreg_nb_f15; - } else if (boot_cpu_data.x86 == 0x17) { + } else if (boot_cpu_data.x86 == 0x17 || boot_cpu_data.x86 == 0x18) { data->temp_adjust_mask = 0x80000; data->read_tempreg = read_tempreg_nb_f17; data->show_tdie = true; @@ -367,6 +367,7 @@ static const struct pci_device_id k10temp_id_table[] = { { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) }, { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) }, { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_M10H_DF_F3) }, + { PCI_VDEVICE(HYGON, PCI_DEVICE_ID_AMD_17H_DF_F3) }, {} }; MODULE_DEVICE_TABLE(pci, k10temp_id_table); -- cgit v1.2.3 From 4708e96831aa21df56aad1b65c74e265687042ea Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:01:58 -0800 Subject: hwmon: (abx500) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/abx500.c | 96 ++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 50 deletions(-) diff --git a/drivers/hwmon/abx500.c b/drivers/hwmon/abx500.c index d87cae8c635f..d4ad91d9f200 100644 --- a/drivers/hwmon/abx500.c +++ b/drivers/hwmon/abx500.c @@ -121,7 +121,7 @@ static void gpadc_monitor(struct work_struct *work) } /* HWMON sysfs interfaces */ -static ssize_t show_name(struct device *dev, struct device_attribute *devattr, +static ssize_t name_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct abx500_temp *data = dev_get_drvdata(dev); @@ -129,7 +129,7 @@ static ssize_t show_name(struct device *dev, struct device_attribute *devattr, return data->ops.show_name(dev, devattr, buf); } -static ssize_t show_label(struct device *dev, +static ssize_t label_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct abx500_temp *data = dev_get_drvdata(dev); @@ -137,7 +137,7 @@ static ssize_t show_label(struct device *dev, return data->ops.show_label(dev, devattr, buf); } -static ssize_t show_input(struct device *dev, +static ssize_t input_show(struct device *dev, struct device_attribute *devattr, char *buf) { int ret, temp; @@ -153,8 +153,8 @@ static ssize_t show_input(struct device *dev, } /* Set functions (RW nodes) */ -static ssize_t set_min(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) +static ssize_t min_store(struct device *dev, struct device_attribute *devattr, + const char *buf, size_t count) { unsigned long val; struct abx500_temp *data = dev_get_drvdata(dev); @@ -173,8 +173,8 @@ static ssize_t set_min(struct device *dev, struct device_attribute *devattr, return count; } -static ssize_t set_max(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) +static ssize_t max_store(struct device *dev, struct device_attribute *devattr, + const char *buf, size_t count) { unsigned long val; struct abx500_temp *data = dev_get_drvdata(dev); @@ -193,9 +193,9 @@ static ssize_t set_max(struct device *dev, struct device_attribute *devattr, return count; } -static ssize_t set_max_hyst(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) +static ssize_t max_hyst_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { unsigned long val; struct abx500_temp *data = dev_get_drvdata(dev); @@ -215,8 +215,8 @@ static ssize_t set_max_hyst(struct device *dev, } /* Show functions (RO nodes) */ -static ssize_t show_min(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t min_show(struct device *dev, struct device_attribute *devattr, + char *buf) { struct abx500_temp *data = dev_get_drvdata(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); @@ -224,8 +224,8 @@ static ssize_t show_min(struct device *dev, return sprintf(buf, "%lu\n", data->min[attr->index]); } -static ssize_t show_max(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t max_show(struct device *dev, struct device_attribute *devattr, + char *buf) { struct abx500_temp *data = dev_get_drvdata(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); @@ -233,7 +233,7 @@ static ssize_t show_max(struct device *dev, return sprintf(buf, "%lu\n", data->max[attr->index]); } -static ssize_t show_max_hyst(struct device *dev, +static ssize_t max_hyst_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct abx500_temp *data = dev_get_drvdata(dev); @@ -242,7 +242,7 @@ static ssize_t show_max_hyst(struct device *dev, return sprintf(buf, "%lu\n", data->max_hyst[attr->index]); } -static ssize_t show_min_alarm(struct device *dev, +static ssize_t min_alarm_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct abx500_temp *data = dev_get_drvdata(dev); @@ -251,7 +251,7 @@ static ssize_t show_min_alarm(struct device *dev, return sprintf(buf, "%d\n", data->min_alarm[attr->index]); } -static ssize_t show_max_alarm(struct device *dev, +static ssize_t max_alarm_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct abx500_temp *data = dev_get_drvdata(dev); @@ -273,47 +273,43 @@ static umode_t abx500_attrs_visible(struct kobject *kobj, } /* Chip name, required by hwmon */ -static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, 0); +static SENSOR_DEVICE_ATTR_RO(name, name, 0); /* GPADC - SENSOR1 */ -static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, show_label, NULL, 0); -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_input, NULL, 0); -static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_min, set_min, 0); -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_max, set_max, 0); -static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, - show_max_hyst, set_max_hyst, 0); -static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_min_alarm, NULL, 0); -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_max_alarm, NULL, 0); +static SENSOR_DEVICE_ATTR_RO(temp1_label, label, 0); +static SENSOR_DEVICE_ATTR_RO(temp1_input, input, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_min, min, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_max, max, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, max_hyst, 0); +static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, min_alarm, 0); +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, max_alarm, 0); /* GPADC - SENSOR2 */ -static SENSOR_DEVICE_ATTR(temp2_label, S_IRUGO, show_label, NULL, 1); -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_input, NULL, 1); -static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_min, set_min, 1); -static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_max, set_max, 1); -static SENSOR_DEVICE_ATTR(temp2_max_hyst, S_IWUSR | S_IRUGO, - show_max_hyst, set_max_hyst, 1); -static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_min_alarm, NULL, 1); -static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_max_alarm, NULL, 1); +static SENSOR_DEVICE_ATTR_RO(temp2_label, label, 1); +static SENSOR_DEVICE_ATTR_RO(temp2_input, input, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_min, min, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_max, max, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_max_hyst, max_hyst, 1); +static SENSOR_DEVICE_ATTR_RO(temp2_min_alarm, min_alarm, 1); +static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, max_alarm, 1); /* GPADC - SENSOR3 */ -static SENSOR_DEVICE_ATTR(temp3_label, S_IRUGO, show_label, NULL, 2); -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_input, NULL, 2); -static SENSOR_DEVICE_ATTR(temp3_min, S_IWUSR | S_IRUGO, show_min, set_min, 2); -static SENSOR_DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_max, set_max, 2); -static SENSOR_DEVICE_ATTR(temp3_max_hyst, S_IWUSR | S_IRUGO, - show_max_hyst, set_max_hyst, 2); -static SENSOR_DEVICE_ATTR(temp3_min_alarm, S_IRUGO, show_min_alarm, NULL, 2); -static SENSOR_DEVICE_ATTR(temp3_max_alarm, S_IRUGO, show_max_alarm, NULL, 2); +static SENSOR_DEVICE_ATTR_RO(temp3_label, label, 2); +static SENSOR_DEVICE_ATTR_RO(temp3_input, input, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_min, min, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_max, max, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_max_hyst, max_hyst, 2); +static SENSOR_DEVICE_ATTR_RO(temp3_min_alarm, min_alarm, 2); +static SENSOR_DEVICE_ATTR_RO(temp3_max_alarm, max_alarm, 2); /* GPADC - SENSOR4 */ -static SENSOR_DEVICE_ATTR(temp4_label, S_IRUGO, show_label, NULL, 3); -static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_input, NULL, 3); -static SENSOR_DEVICE_ATTR(temp4_min, S_IWUSR | S_IRUGO, show_min, set_min, 3); -static SENSOR_DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_max, set_max, 3); -static SENSOR_DEVICE_ATTR(temp4_max_hyst, S_IWUSR | S_IRUGO, - show_max_hyst, set_max_hyst, 3); -static SENSOR_DEVICE_ATTR(temp4_min_alarm, S_IRUGO, show_min_alarm, NULL, 3); -static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_max_alarm, NULL, 3); +static SENSOR_DEVICE_ATTR_RO(temp4_label, label, 3); +static SENSOR_DEVICE_ATTR_RO(temp4_input, input, 3); +static SENSOR_DEVICE_ATTR_RW(temp4_min, min, 3); +static SENSOR_DEVICE_ATTR_RW(temp4_max, max, 3); +static SENSOR_DEVICE_ATTR_RW(temp4_max_hyst, max_hyst, 3); +static SENSOR_DEVICE_ATTR_RO(temp4_min_alarm, min_alarm, 3); +static SENSOR_DEVICE_ATTR_RO(temp4_max_alarm, max_alarm, 3); static struct attribute *abx500_temp_attributes[] = { &sensor_dev_attr_name.dev_attr.attr, -- cgit v1.2.3 From 419eeabc0df6a13e03ed175b85d74d9c1b599d52 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:01:58 -0800 Subject: hwmon: (acpi_power_meter) Replace S_ with octal values Replace S_ with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/acpi_power_meter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c index 34e45b97629e..e98591fa2528 100644 --- a/drivers/hwmon/acpi_power_meter.c +++ b/drivers/hwmon/acpi_power_meter.c @@ -638,12 +638,12 @@ static int register_attrs(struct acpi_power_meter_resource *resource, while (attrs->label) { sensors->dev_attr.attr.name = attrs->label; - sensors->dev_attr.attr.mode = S_IRUGO; + sensors->dev_attr.attr.mode = 0444; sensors->dev_attr.show = attrs->show; sensors->index = attrs->index; if (attrs->set) { - sensors->dev_attr.attr.mode |= S_IWUSR; + sensors->dev_attr.attr.mode |= 0200; sensors->dev_attr.store = attrs->set; } -- cgit v1.2.3 From 1ba3e02376497661348f6ad9a734287d171f4fd7 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:01:59 -0800 Subject: hwmon: (ad7314) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/ad7314.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/ad7314.c b/drivers/hwmon/ad7314.c index 8ea35932fbaa..be521bdae114 100644 --- a/drivers/hwmon/ad7314.c +++ b/drivers/hwmon/ad7314.c @@ -53,9 +53,9 @@ static int ad7314_spi_read(struct ad7314_data *chip) return be16_to_cpu(chip->rx); } -static ssize_t ad7314_show_temperature(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t ad7314_temperature_show(struct device *dev, + struct device_attribute *attr, + char *buf) { struct ad7314_data *chip = dev_get_drvdata(dev); s16 data; @@ -87,8 +87,7 @@ static ssize_t ad7314_show_temperature(struct device *dev, } } -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, - ad7314_show_temperature, NULL, 0); +static SENSOR_DEVICE_ATTR_RO(temp1_input, ad7314_temperature, 0); static struct attribute *ad7314_attrs[] = { &sensor_dev_attr_temp1_input.dev_attr.attr, -- cgit v1.2.3 From cbf6cb2b7eeac1a87386f3275b3c724019e4401d Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:01:59 -0800 Subject: hwmon: (ad7414) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/ad7414.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/hwmon/ad7414.c b/drivers/hwmon/ad7414.c index cec227f13874..f13806d731fa 100644 --- a/drivers/hwmon/ad7414.c +++ b/drivers/hwmon/ad7414.c @@ -107,25 +107,25 @@ static struct ad7414_data *ad7414_update_device(struct device *dev) return data; } -static ssize_t show_temp_input(struct device *dev, +static ssize_t temp_input_show(struct device *dev, struct device_attribute *attr, char *buf) { struct ad7414_data *data = ad7414_update_device(dev); return sprintf(buf, "%d\n", ad7414_temp_from_reg(data->temp_input)); } -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input, NULL, 0); +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp_input, 0); -static ssize_t show_max_min(struct device *dev, struct device_attribute *attr, - char *buf) +static ssize_t max_min_show(struct device *dev, struct device_attribute *attr, + char *buf) { int index = to_sensor_dev_attr(attr)->index; struct ad7414_data *data = ad7414_update_device(dev); return sprintf(buf, "%d\n", data->temps[index] * 1000); } -static ssize_t set_max_min(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t max_min_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t count) { struct ad7414_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; @@ -147,12 +147,10 @@ static ssize_t set_max_min(struct device *dev, return count; } -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, - show_max_min, set_max_min, 0); -static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, - show_max_min, set_max_min, 1); +static SENSOR_DEVICE_ATTR_RW(temp1_max, max_min, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_min, max_min, 1); -static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, +static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, char *buf) { int bitnr = to_sensor_dev_attr(attr)->index; @@ -161,8 +159,8 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%d\n", value); } -static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 3); -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 4); +static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, 3); +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 4); static struct attribute *ad7414_attrs[] = { &sensor_dev_attr_temp1_input.dev_attr.attr, -- cgit v1.2.3 From 6fdc5d7fa9471aba8eba6a1950dab704d313227f Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:01:59 -0800 Subject: hwmon: (ad7418) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/ad7418.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/hwmon/ad7418.c b/drivers/hwmon/ad7418.c index a01b731ba5d7..76f0a5c01e8a 100644 --- a/drivers/hwmon/ad7418.c +++ b/drivers/hwmon/ad7418.c @@ -103,8 +103,8 @@ static struct ad7418_data *ad7418_update_device(struct device *dev) return data; } -static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, - char *buf) +static ssize_t temp_show(struct device *dev, struct device_attribute *devattr, + char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct ad7418_data *data = ad7418_update_device(dev); @@ -112,7 +112,7 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, LM75_TEMP_FROM_REG(data->temp[attr->index])); } -static ssize_t show_adc(struct device *dev, struct device_attribute *devattr, +static ssize_t adc_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); @@ -122,8 +122,9 @@ static ssize_t show_adc(struct device *dev, struct device_attribute *devattr, ((data->in[attr->index] >> 6) * 2500 + 512) / 1024); } -static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) +static ssize_t temp_store(struct device *dev, + struct device_attribute *devattr, const char *buf, + size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct ad7418_data *data = dev_get_drvdata(dev); @@ -143,16 +144,14 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, return count; } -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); -static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, - show_temp, set_temp, 1); -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, - show_temp, set_temp, 2); +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, temp, 1); +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, 2); -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_adc, NULL, 0); -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_adc, NULL, 1); -static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_adc, NULL, 2); -static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_adc, NULL, 3); +static SENSOR_DEVICE_ATTR_RO(in1_input, adc, 0); +static SENSOR_DEVICE_ATTR_RO(in2_input, adc, 1); +static SENSOR_DEVICE_ATTR_RO(in3_input, adc, 2); +static SENSOR_DEVICE_ATTR_RO(in4_input, adc, 3); static struct attribute *ad7416_attrs[] = { &sensor_dev_attr_temp1_max.dev_attr.attr, -- cgit v1.2.3 From 0594462f97058cb620ffb849b2ffb85e34cb43fe Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:00 -0800 Subject: hwmon: (adc128d818) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/adc128d818.c | 135 ++++++++++++++++++--------------------------- 1 file changed, 55 insertions(+), 80 deletions(-) diff --git a/drivers/hwmon/adc128d818.c b/drivers/hwmon/adc128d818.c index bd2ca315c9d8..ca794bf904de 100644 --- a/drivers/hwmon/adc128d818.c +++ b/drivers/hwmon/adc128d818.c @@ -153,8 +153,8 @@ done: return ret; } -static ssize_t adc128_show_in(struct device *dev, struct device_attribute *attr, - char *buf) +static ssize_t adc128_in_show(struct device *dev, + struct device_attribute *attr, char *buf) { struct adc128_data *data = adc128_update_device(dev); int index = to_sensor_dev_attr_2(attr)->index; @@ -168,8 +168,9 @@ static ssize_t adc128_show_in(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%d\n", val); } -static ssize_t adc128_set_in(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t adc128_in_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t count) { struct adc128_data *data = dev_get_drvdata(dev); int index = to_sensor_dev_attr_2(attr)->index; @@ -193,7 +194,7 @@ static ssize_t adc128_set_in(struct device *dev, struct device_attribute *attr, return count; } -static ssize_t adc128_show_temp(struct device *dev, +static ssize_t adc128_temp_show(struct device *dev, struct device_attribute *attr, char *buf) { struct adc128_data *data = adc128_update_device(dev); @@ -207,9 +208,9 @@ static ssize_t adc128_show_temp(struct device *dev, return sprintf(buf, "%d\n", temp * 500);/* 0.5 degrees C resolution */ } -static ssize_t adc128_set_temp(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t adc128_temp_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { struct adc128_data *data = dev_get_drvdata(dev); int index = to_sensor_dev_attr(attr)->index; @@ -233,7 +234,7 @@ static ssize_t adc128_set_temp(struct device *dev, return count; } -static ssize_t adc128_show_alarm(struct device *dev, +static ssize_t adc128_alarm_show(struct device *dev, struct device_attribute *attr, char *buf) { struct adc128_data *data = adc128_update_device(dev); @@ -272,77 +273,51 @@ static umode_t adc128_is_visible(struct kobject *kobj, return attr->mode; } -static SENSOR_DEVICE_ATTR_2(in0_input, S_IRUGO, - adc128_show_in, NULL, 0, 0); -static SENSOR_DEVICE_ATTR_2(in0_min, S_IWUSR | S_IRUGO, - adc128_show_in, adc128_set_in, 0, 1); -static SENSOR_DEVICE_ATTR_2(in0_max, S_IWUSR | S_IRUGO, - adc128_show_in, adc128_set_in, 0, 2); - -static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, - adc128_show_in, NULL, 1, 0); -static SENSOR_DEVICE_ATTR_2(in1_min, S_IWUSR | S_IRUGO, - adc128_show_in, adc128_set_in, 1, 1); -static SENSOR_DEVICE_ATTR_2(in1_max, S_IWUSR | S_IRUGO, - adc128_show_in, adc128_set_in, 1, 2); - -static SENSOR_DEVICE_ATTR_2(in2_input, S_IRUGO, - adc128_show_in, NULL, 2, 0); -static SENSOR_DEVICE_ATTR_2(in2_min, S_IWUSR | S_IRUGO, - adc128_show_in, adc128_set_in, 2, 1); -static SENSOR_DEVICE_ATTR_2(in2_max, S_IWUSR | S_IRUGO, - adc128_show_in, adc128_set_in, 2, 2); - -static SENSOR_DEVICE_ATTR_2(in3_input, S_IRUGO, - adc128_show_in, NULL, 3, 0); -static SENSOR_DEVICE_ATTR_2(in3_min, S_IWUSR | S_IRUGO, - adc128_show_in, adc128_set_in, 3, 1); -static SENSOR_DEVICE_ATTR_2(in3_max, S_IWUSR | S_IRUGO, - adc128_show_in, adc128_set_in, 3, 2); - -static SENSOR_DEVICE_ATTR_2(in4_input, S_IRUGO, - adc128_show_in, NULL, 4, 0); -static SENSOR_DEVICE_ATTR_2(in4_min, S_IWUSR | S_IRUGO, - adc128_show_in, adc128_set_in, 4, 1); -static SENSOR_DEVICE_ATTR_2(in4_max, S_IWUSR | S_IRUGO, - adc128_show_in, adc128_set_in, 4, 2); - -static SENSOR_DEVICE_ATTR_2(in5_input, S_IRUGO, - adc128_show_in, NULL, 5, 0); -static SENSOR_DEVICE_ATTR_2(in5_min, S_IWUSR | S_IRUGO, - adc128_show_in, adc128_set_in, 5, 1); -static SENSOR_DEVICE_ATTR_2(in5_max, S_IWUSR | S_IRUGO, - adc128_show_in, adc128_set_in, 5, 2); - -static SENSOR_DEVICE_ATTR_2(in6_input, S_IRUGO, - adc128_show_in, NULL, 6, 0); -static SENSOR_DEVICE_ATTR_2(in6_min, S_IWUSR | S_IRUGO, - adc128_show_in, adc128_set_in, 6, 1); -static SENSOR_DEVICE_ATTR_2(in6_max, S_IWUSR | S_IRUGO, - adc128_show_in, adc128_set_in, 6, 2); - -static SENSOR_DEVICE_ATTR_2(in7_input, S_IRUGO, - adc128_show_in, NULL, 7, 0); -static SENSOR_DEVICE_ATTR_2(in7_min, S_IWUSR | S_IRUGO, - adc128_show_in, adc128_set_in, 7, 1); -static SENSOR_DEVICE_ATTR_2(in7_max, S_IWUSR | S_IRUGO, - adc128_show_in, adc128_set_in, 7, 2); - -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, adc128_show_temp, NULL, 0); -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, - adc128_show_temp, adc128_set_temp, 1); -static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, - adc128_show_temp, adc128_set_temp, 2); - -static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, adc128_show_alarm, NULL, 0); -static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, adc128_show_alarm, NULL, 1); -static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, adc128_show_alarm, NULL, 2); -static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, adc128_show_alarm, NULL, 3); -static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, adc128_show_alarm, NULL, 4); -static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, adc128_show_alarm, NULL, 5); -static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, adc128_show_alarm, NULL, 6); -static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, adc128_show_alarm, NULL, 7); -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, adc128_show_alarm, NULL, 7); +static SENSOR_DEVICE_ATTR_2_RO(in0_input, adc128_in, 0, 0); +static SENSOR_DEVICE_ATTR_2_RW(in0_min, adc128_in, 0, 1); +static SENSOR_DEVICE_ATTR_2_RW(in0_max, adc128_in, 0, 2); + +static SENSOR_DEVICE_ATTR_2_RO(in1_input, adc128_in, 1, 0); +static SENSOR_DEVICE_ATTR_2_RW(in1_min, adc128_in, 1, 1); +static SENSOR_DEVICE_ATTR_2_RW(in1_max, adc128_in, 1, 2); + +static SENSOR_DEVICE_ATTR_2_RO(in2_input, adc128_in, 2, 0); +static SENSOR_DEVICE_ATTR_2_RW(in2_min, adc128_in, 2, 1); +static SENSOR_DEVICE_ATTR_2_RW(in2_max, adc128_in, 2, 2); + +static SENSOR_DEVICE_ATTR_2_RO(in3_input, adc128_in, 3, 0); +static SENSOR_DEVICE_ATTR_2_RW(in3_min, adc128_in, 3, 1); +static SENSOR_DEVICE_ATTR_2_RW(in3_max, adc128_in, 3, 2); + +static SENSOR_DEVICE_ATTR_2_RO(in4_input, adc128_in, 4, 0); +static SENSOR_DEVICE_ATTR_2_RW(in4_min, adc128_in, 4, 1); +static SENSOR_DEVICE_ATTR_2_RW(in4_max, adc128_in, 4, 2); + +static SENSOR_DEVICE_ATTR_2_RO(in5_input, adc128_in, 5, 0); +static SENSOR_DEVICE_ATTR_2_RW(in5_min, adc128_in, 5, 1); +static SENSOR_DEVICE_ATTR_2_RW(in5_max, adc128_in, 5, 2); + +static SENSOR_DEVICE_ATTR_2_RO(in6_input, adc128_in, 6, 0); +static SENSOR_DEVICE_ATTR_2_RW(in6_min, adc128_in, 6, 1); +static SENSOR_DEVICE_ATTR_2_RW(in6_max, adc128_in, 6, 2); + +static SENSOR_DEVICE_ATTR_2_RO(in7_input, adc128_in, 7, 0); +static SENSOR_DEVICE_ATTR_2_RW(in7_min, adc128_in, 7, 1); +static SENSOR_DEVICE_ATTR_2_RW(in7_max, adc128_in, 7, 2); + +static SENSOR_DEVICE_ATTR_RO(temp1_input, adc128_temp, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_max, adc128_temp, 1); +static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, adc128_temp, 2); + +static SENSOR_DEVICE_ATTR_RO(in0_alarm, adc128_alarm, 0); +static SENSOR_DEVICE_ATTR_RO(in1_alarm, adc128_alarm, 1); +static SENSOR_DEVICE_ATTR_RO(in2_alarm, adc128_alarm, 2); +static SENSOR_DEVICE_ATTR_RO(in3_alarm, adc128_alarm, 3); +static SENSOR_DEVICE_ATTR_RO(in4_alarm, adc128_alarm, 4); +static SENSOR_DEVICE_ATTR_RO(in5_alarm, adc128_alarm, 5); +static SENSOR_DEVICE_ATTR_RO(in6_alarm, adc128_alarm, 6); +static SENSOR_DEVICE_ATTR_RO(in7_alarm, adc128_alarm, 7); +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, adc128_alarm, 7); static struct attribute *adc128_attrs[] = { &sensor_dev_attr_in0_alarm.dev_attr.attr, -- cgit v1.2.3 From b0c130fdaac18b69abcf577dfd21f84ec53c1eb9 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:00 -0800 Subject: hwmon: (adcxx) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/adcxx.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/hwmon/adcxx.c b/drivers/hwmon/adcxx.c index 69e0bb97e597..c8feb2295fe2 100644 --- a/drivers/hwmon/adcxx.c +++ b/drivers/hwmon/adcxx.c @@ -57,8 +57,8 @@ struct adcxx { }; /* sysfs hook function */ -static ssize_t adcxx_read(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t adcxx_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct spi_device *spi = to_spi_device(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); @@ -94,15 +94,15 @@ out: return status; } -static ssize_t adcxx_show_min(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t adcxx_min_show(struct device *dev, + struct device_attribute *devattr, char *buf) { /* The minimum reference is 0 for this chip family */ return sprintf(buf, "0\n"); } -static ssize_t adcxx_show_max(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t adcxx_max_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct spi_device *spi = to_spi_device(dev); struct adcxx *adc = spi_get_drvdata(spi); @@ -118,8 +118,9 @@ static ssize_t adcxx_show_max(struct device *dev, return sprintf(buf, "%d\n", reference); } -static ssize_t adcxx_set_max(struct device *dev, - struct device_attribute *devattr, const char *buf, size_t count) +static ssize_t adcxx_max_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct spi_device *spi = to_spi_device(dev); struct adcxx *adc = spi_get_drvdata(spi); @@ -138,25 +139,24 @@ static ssize_t adcxx_set_max(struct device *dev, return count; } -static ssize_t adcxx_show_name(struct device *dev, struct device_attribute - *devattr, char *buf) +static ssize_t adcxx_name_show(struct device *dev, + struct device_attribute *devattr, char *buf) { return sprintf(buf, "%s\n", to_spi_device(dev)->modalias); } static struct sensor_device_attribute ad_input[] = { - SENSOR_ATTR(name, S_IRUGO, adcxx_show_name, NULL, 0), - SENSOR_ATTR(in_min, S_IRUGO, adcxx_show_min, NULL, 0), - SENSOR_ATTR(in_max, S_IWUSR | S_IRUGO, adcxx_show_max, - adcxx_set_max, 0), - SENSOR_ATTR(in0_input, S_IRUGO, adcxx_read, NULL, 0), - SENSOR_ATTR(in1_input, S_IRUGO, adcxx_read, NULL, 1), - SENSOR_ATTR(in2_input, S_IRUGO, adcxx_read, NULL, 2), - SENSOR_ATTR(in3_input, S_IRUGO, adcxx_read, NULL, 3), - SENSOR_ATTR(in4_input, S_IRUGO, adcxx_read, NULL, 4), - SENSOR_ATTR(in5_input, S_IRUGO, adcxx_read, NULL, 5), - SENSOR_ATTR(in6_input, S_IRUGO, adcxx_read, NULL, 6), - SENSOR_ATTR(in7_input, S_IRUGO, adcxx_read, NULL, 7), + SENSOR_ATTR_RO(name, adcxx_name, 0), + SENSOR_ATTR_RO(in_min, adcxx_min, 0), + SENSOR_ATTR_RW(in_max, adcxx_max, 0), + SENSOR_ATTR_RO(in0_input, adcxx, 0), + SENSOR_ATTR_RO(in1_input, adcxx, 1), + SENSOR_ATTR_RO(in2_input, adcxx, 2), + SENSOR_ATTR_RO(in3_input, adcxx, 3), + SENSOR_ATTR_RO(in4_input, adcxx, 4), + SENSOR_ATTR_RO(in5_input, adcxx, 5), + SENSOR_ATTR_RO(in6_input, adcxx, 6), + SENSOR_ATTR_RO(in7_input, adcxx, 7), }; /*----------------------------------------------------------------------*/ -- cgit v1.2.3 From cfc5bca6db53eb9ddc062a89993a29731d96c619 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:00 -0800 Subject: hwmon: (adm1021) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/adm1021.c | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index eacf10fadbc6..49461b60e296 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c @@ -156,8 +156,8 @@ static struct adm1021_data *adm1021_update_device(struct device *dev) return data; } -static ssize_t show_temp(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t temp_show(struct device *dev, struct device_attribute *devattr, + char *buf) { int index = to_sensor_dev_attr(devattr)->index; struct adm1021_data *data = adm1021_update_device(dev); @@ -165,7 +165,7 @@ static ssize_t show_temp(struct device *dev, return sprintf(buf, "%d\n", data->temp[index]); } -static ssize_t show_temp_max(struct device *dev, +static ssize_t temp_max_show(struct device *dev, struct device_attribute *devattr, char *buf) { int index = to_sensor_dev_attr(devattr)->index; @@ -174,7 +174,7 @@ static ssize_t show_temp_max(struct device *dev, return sprintf(buf, "%d\n", data->temp_max[index]); } -static ssize_t show_temp_min(struct device *dev, +static ssize_t temp_min_show(struct device *dev, struct device_attribute *devattr, char *buf) { int index = to_sensor_dev_attr(devattr)->index; @@ -183,7 +183,7 @@ static ssize_t show_temp_min(struct device *dev, return sprintf(buf, "%d\n", data->temp_min[index]); } -static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, +static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, char *buf) { int index = to_sensor_dev_attr(attr)->index; @@ -199,9 +199,9 @@ static ssize_t alarms_show(struct device *dev, return sprintf(buf, "%u\n", data->alarms); } -static ssize_t set_temp_max(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) +static ssize_t temp_max_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { int index = to_sensor_dev_attr(devattr)->index; struct adm1021_data *data = dev_get_drvdata(dev); @@ -225,9 +225,9 @@ static ssize_t set_temp_max(struct device *dev, return count; } -static ssize_t set_temp_min(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) +static ssize_t temp_min_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { int index = to_sensor_dev_attr(devattr)->index; struct adm1021_data *data = dev_get_drvdata(dev); @@ -287,21 +287,17 @@ static ssize_t low_power_store(struct device *dev, } -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, - set_temp_max, 0); -static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp_min, - set_temp_min, 0); -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); -static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_max, - set_temp_max, 1); -static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp_min, - set_temp_min, 1); -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6); -static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 5); -static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4); -static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 3); -static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2); +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1); +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 6); +static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, 5); +static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, alarm, 4); +static SENSOR_DEVICE_ATTR_RO(temp2_min_alarm, alarm, 3); +static SENSOR_DEVICE_ATTR_RO(temp2_fault, alarm, 2); static DEVICE_ATTR_RO(alarms); static DEVICE_ATTR_RW(low_power); -- cgit v1.2.3 From 7e77d1e76d36a231498d17265a1dae9dd337d397 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:00 -0800 Subject: hwmon: (ads1015) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Cc: Dirk Eibach Signed-off-by: Guenter Roeck --- drivers/hwmon/ads1015.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/hwmon/ads1015.c b/drivers/hwmon/ads1015.c index 98c704d3366a..c21b0529adb2 100644 --- a/drivers/hwmon/ads1015.c +++ b/drivers/hwmon/ads1015.c @@ -133,8 +133,8 @@ static int ads1015_reg_to_mv(struct i2c_client *client, unsigned int channel, } /* sysfs callback function */ -static ssize_t show_in(struct device *dev, struct device_attribute *da, - char *buf) +static ssize_t in_show(struct device *dev, struct device_attribute *da, + char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct i2c_client *client = to_i2c_client(dev); @@ -149,14 +149,14 @@ static ssize_t show_in(struct device *dev, struct device_attribute *da, } static const struct sensor_device_attribute ads1015_in[] = { - SENSOR_ATTR(in0_input, S_IRUGO, show_in, NULL, 0), - SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1), - SENSOR_ATTR(in2_input, S_IRUGO, show_in, NULL, 2), - SENSOR_ATTR(in3_input, S_IRUGO, show_in, NULL, 3), - SENSOR_ATTR(in4_input, S_IRUGO, show_in, NULL, 4), - SENSOR_ATTR(in5_input, S_IRUGO, show_in, NULL, 5), - SENSOR_ATTR(in6_input, S_IRUGO, show_in, NULL, 6), - SENSOR_ATTR(in7_input, S_IRUGO, show_in, NULL, 7), + SENSOR_ATTR_RO(in0_input, in, 0), + SENSOR_ATTR_RO(in1_input, in, 1), + SENSOR_ATTR_RO(in2_input, in, 2), + SENSOR_ATTR_RO(in3_input, in, 3), + SENSOR_ATTR_RO(in4_input, in, 4), + SENSOR_ATTR_RO(in5_input, in, 5), + SENSOR_ATTR_RO(in6_input, in, 6), + SENSOR_ATTR_RO(in7_input, in, 7), }; /* -- cgit v1.2.3 From 3ecd2783839c28e41baff1a7f8e9dfa6aa805616 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:01 -0800 Subject: hwmon: (ads7828) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/ads7828.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/hwmon/ads7828.c b/drivers/hwmon/ads7828.c index 898607bf682b..12c56d3783ed 100644 --- a/drivers/hwmon/ads7828.c +++ b/drivers/hwmon/ads7828.c @@ -62,8 +62,8 @@ static inline u8 ads7828_cmd_byte(u8 cmd, int ch) } /* sysfs callback function */ -static ssize_t ads7828_show_in(struct device *dev, struct device_attribute *da, - char *buf) +static ssize_t ads7828_in_show(struct device *dev, + struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct ads7828_data *data = dev_get_drvdata(dev); @@ -79,14 +79,14 @@ static ssize_t ads7828_show_in(struct device *dev, struct device_attribute *da, DIV_ROUND_CLOSEST(regval * data->lsb_resol, 1000)); } -static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, ads7828_show_in, NULL, 0); -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ads7828_show_in, NULL, 1); -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ads7828_show_in, NULL, 2); -static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, ads7828_show_in, NULL, 3); -static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, ads7828_show_in, NULL, 4); -static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, ads7828_show_in, NULL, 5); -static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, ads7828_show_in, NULL, 6); -static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, ads7828_show_in, NULL, 7); +static SENSOR_DEVICE_ATTR_RO(in0_input, ads7828_in, 0); +static SENSOR_DEVICE_ATTR_RO(in1_input, ads7828_in, 1); +static SENSOR_DEVICE_ATTR_RO(in2_input, ads7828_in, 2); +static SENSOR_DEVICE_ATTR_RO(in3_input, ads7828_in, 3); +static SENSOR_DEVICE_ATTR_RO(in4_input, ads7828_in, 4); +static SENSOR_DEVICE_ATTR_RO(in5_input, ads7828_in, 5); +static SENSOR_DEVICE_ATTR_RO(in6_input, ads7828_in, 6); +static SENSOR_DEVICE_ATTR_RO(in7_input, ads7828_in, 7); static struct attribute *ads7828_attrs[] = { &sensor_dev_attr_in0_input.dev_attr.attr, -- cgit v1.2.3 From 595a86af49f0bfba8bf89a69b4b91c1aa038a373 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:01 -0800 Subject: hwmon: (ads7871) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/ads7871.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/hwmon/ads7871.c b/drivers/hwmon/ads7871.c index 59bd7b9e1772..cd14c1501508 100644 --- a/drivers/hwmon/ads7871.c +++ b/drivers/hwmon/ads7871.c @@ -96,8 +96,8 @@ static int ads7871_write_reg8(struct spi_device *spi, int reg, u8 val) return spi_write(spi, tmp, sizeof(tmp)); } -static ssize_t show_voltage(struct device *dev, - struct device_attribute *da, char *buf) +static ssize_t voltage_show(struct device *dev, struct device_attribute *da, + char *buf) { struct ads7871_data *pdata = dev_get_drvdata(dev); struct spi_device *spi = pdata->spi; @@ -138,14 +138,14 @@ static ssize_t show_voltage(struct device *dev, } } -static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_voltage, NULL, 0); -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_voltage, NULL, 1); -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_voltage, NULL, 2); -static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_voltage, NULL, 3); -static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_voltage, NULL, 4); -static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, show_voltage, NULL, 5); -static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_voltage, NULL, 6); -static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_voltage, NULL, 7); +static SENSOR_DEVICE_ATTR_RO(in0_input, voltage, 0); +static SENSOR_DEVICE_ATTR_RO(in1_input, voltage, 1); +static SENSOR_DEVICE_ATTR_RO(in2_input, voltage, 2); +static SENSOR_DEVICE_ATTR_RO(in3_input, voltage, 3); +static SENSOR_DEVICE_ATTR_RO(in4_input, voltage, 4); +static SENSOR_DEVICE_ATTR_RO(in5_input, voltage, 5); +static SENSOR_DEVICE_ATTR_RO(in6_input, voltage, 6); +static SENSOR_DEVICE_ATTR_RO(in7_input, voltage, 7); static struct attribute *ads7871_attrs[] = { &sensor_dev_attr_in0_input.dev_attr.attr, -- cgit v1.2.3 From d60a51a690dd359a2973c4f6a58319abbf20a0b0 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:01 -0800 Subject: hwmon: (adt7462) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/adt7462.c | 646 ++++++++++++++++++++---------------------------- 1 file changed, 271 insertions(+), 375 deletions(-) diff --git a/drivers/hwmon/adt7462.c b/drivers/hwmon/adt7462.c index 19f2a6d48bac..b0211f731251 100644 --- a/drivers/hwmon/adt7462.c +++ b/drivers/hwmon/adt7462.c @@ -784,9 +784,8 @@ out: return data; } -static ssize_t show_temp_min(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t temp_min_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = adt7462_update_device(dev); @@ -797,10 +796,9 @@ static ssize_t show_temp_min(struct device *dev, return sprintf(buf, "%d\n", 1000 * (data->temp_min[attr->index] - 64)); } -static ssize_t set_temp_min(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t temp_min_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = dev_get_drvdata(dev); @@ -822,9 +820,8 @@ static ssize_t set_temp_min(struct device *dev, return count; } -static ssize_t show_temp_max(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t temp_max_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = adt7462_update_device(dev); @@ -835,10 +832,9 @@ static ssize_t show_temp_max(struct device *dev, return sprintf(buf, "%d\n", 1000 * (data->temp_max[attr->index] - 64)); } -static ssize_t set_temp_max(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t temp_max_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = dev_get_drvdata(dev); @@ -860,7 +856,7 @@ static ssize_t set_temp_max(struct device *dev, return count; } -static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, +static ssize_t temp_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); @@ -874,9 +870,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, 250 * frac); } -static ssize_t show_temp_label(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t temp_label_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = adt7462_update_device(dev); @@ -884,9 +879,8 @@ static ssize_t show_temp_label(struct device *dev, return sprintf(buf, "%s\n", temp_label(data, attr->index)); } -static ssize_t show_volt_max(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t volt_max_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = adt7462_update_device(dev); @@ -898,10 +892,9 @@ static ssize_t show_volt_max(struct device *dev, return sprintf(buf, "%d\n", x); } -static ssize_t set_volt_max(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t volt_max_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = dev_get_drvdata(dev); @@ -926,9 +919,8 @@ static ssize_t set_volt_max(struct device *dev, return count; } -static ssize_t show_volt_min(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t volt_min_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = adt7462_update_device(dev); @@ -940,10 +932,9 @@ static ssize_t show_volt_min(struct device *dev, return sprintf(buf, "%d\n", x); } -static ssize_t set_volt_min(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t volt_min_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = dev_get_drvdata(dev); @@ -968,9 +959,8 @@ static ssize_t set_volt_min(struct device *dev, return count; } -static ssize_t show_voltage(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t voltage_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = adt7462_update_device(dev); @@ -982,9 +972,8 @@ static ssize_t show_voltage(struct device *dev, return sprintf(buf, "%d\n", x); } -static ssize_t show_voltage_label(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t voltage_label_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = adt7462_update_device(dev); @@ -992,9 +981,8 @@ static ssize_t show_voltage_label(struct device *dev, return sprintf(buf, "%s\n", voltage_label(data, attr->index)); } -static ssize_t show_alarm(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t alarm_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = adt7462_update_device(dev); @@ -1012,9 +1000,8 @@ static int fan_enabled(struct adt7462_data *data, int fan) return data->fan_enabled & (1 << fan); } -static ssize_t show_fan_min(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t fan_min_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = adt7462_update_device(dev); @@ -1031,9 +1018,9 @@ static ssize_t show_fan_min(struct device *dev, return sprintf(buf, "%d\n", FAN_PERIOD_TO_RPM(temp)); } -static ssize_t set_fan_min(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) +static ssize_t fan_min_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = dev_get_drvdata(dev); @@ -1057,7 +1044,7 @@ static ssize_t set_fan_min(struct device *dev, return count; } -static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, +static ssize_t fan_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); @@ -1071,18 +1058,16 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, FAN_PERIOD_TO_RPM(data->fan[attr->index])); } -static ssize_t show_force_pwm_max(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t force_pwm_max_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct adt7462_data *data = adt7462_update_device(dev); return sprintf(buf, "%d\n", (data->cfg2 & ADT7462_FSPD_MASK ? 1 : 0)); } -static ssize_t set_force_pwm_max(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t force_pwm_max_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct adt7462_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; @@ -1105,7 +1090,7 @@ static ssize_t set_force_pwm_max(struct device *dev, return count; } -static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, +static ssize_t pwm_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); @@ -1113,8 +1098,8 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, return sprintf(buf, "%d\n", data->pwm[attr->index]); } -static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) +static ssize_t pwm_store(struct device *dev, struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = dev_get_drvdata(dev); @@ -1134,18 +1119,16 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, return count; } -static ssize_t show_pwm_max(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t pwm_max_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct adt7462_data *data = adt7462_update_device(dev); return sprintf(buf, "%d\n", data->pwm_max); } -static ssize_t set_pwm_max(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t pwm_max_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct adt7462_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; @@ -1164,19 +1147,17 @@ static ssize_t set_pwm_max(struct device *dev, return count; } -static ssize_t show_pwm_min(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t pwm_min_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = adt7462_update_device(dev); return sprintf(buf, "%d\n", data->pwm_min[attr->index]); } -static ssize_t set_pwm_min(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t pwm_min_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = dev_get_drvdata(dev); @@ -1197,9 +1178,8 @@ static ssize_t set_pwm_min(struct device *dev, return count; } -static ssize_t show_pwm_hyst(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t pwm_hyst_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = adt7462_update_device(dev); @@ -1207,10 +1187,9 @@ static ssize_t show_pwm_hyst(struct device *dev, (data->pwm_trange[attr->index] & ADT7462_PWM_HYST_MASK)); } -static ssize_t set_pwm_hyst(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t pwm_hyst_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = dev_get_drvdata(dev); @@ -1236,9 +1215,8 @@ static ssize_t set_pwm_hyst(struct device *dev, return count; } -static ssize_t show_pwm_tmax(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t pwm_tmax_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = adt7462_update_device(dev); @@ -1251,10 +1229,9 @@ static ssize_t show_pwm_tmax(struct device *dev, return sprintf(buf, "%d\n", tmin + trange); } -static ssize_t set_pwm_tmax(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t pwm_tmax_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { int temp; struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); @@ -1284,19 +1261,17 @@ static ssize_t set_pwm_tmax(struct device *dev, return count; } -static ssize_t show_pwm_tmin(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t pwm_tmin_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = adt7462_update_device(dev); return sprintf(buf, "%d\n", 1000 * (data->pwm_tmin[attr->index] - 64)); } -static ssize_t set_pwm_tmin(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t pwm_tmin_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = dev_get_drvdata(dev); @@ -1318,9 +1293,8 @@ static ssize_t set_pwm_tmin(struct device *dev, return count; } -static ssize_t show_pwm_auto(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t pwm_auto_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = adt7462_update_device(dev); @@ -1350,10 +1324,9 @@ static void set_pwm_channel(struct i2c_client *client, mutex_unlock(&data->lock); } -static ssize_t set_pwm_auto(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t pwm_auto_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = dev_get_drvdata(dev); @@ -1375,9 +1348,8 @@ static ssize_t set_pwm_auto(struct device *dev, } } -static ssize_t show_pwm_auto_temp(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t pwm_auto_temp_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = adt7462_update_device(dev); @@ -1409,10 +1381,9 @@ static int cvt_auto_temp(int input) return ilog2(input); } -static ssize_t set_pwm_auto_temp(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t pwm_auto_temp_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = dev_get_drvdata(dev); @@ -1431,274 +1402,199 @@ static ssize_t set_pwm_auto_temp(struct device *dev, return count; } -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, - set_temp_max, 0); -static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_max, - set_temp_max, 1); -static SENSOR_DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_temp_max, - set_temp_max, 2); -static SENSOR_DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_temp_max, - set_temp_max, 3); - -static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp_min, - set_temp_min, 0); -static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp_min, - set_temp_min, 1); -static SENSOR_DEVICE_ATTR(temp3_min, S_IWUSR | S_IRUGO, show_temp_min, - set_temp_min, 2); -static SENSOR_DEVICE_ATTR(temp4_min, S_IWUSR | S_IRUGO, show_temp_min, - set_temp_min, 3); - -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); -static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3); - -static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, show_temp_label, NULL, 0); -static SENSOR_DEVICE_ATTR(temp2_label, S_IRUGO, show_temp_label, NULL, 1); -static SENSOR_DEVICE_ATTR(temp3_label, S_IRUGO, show_temp_label, NULL, 2); -static SENSOR_DEVICE_ATTR(temp4_label, S_IRUGO, show_temp_label, NULL, 3); - -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM1 | ADT7462_LT_ALARM); -static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM1 | ADT7462_R1T_ALARM); -static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM1 | ADT7462_R2T_ALARM); -static SENSOR_DEVICE_ATTR(temp4_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM1 | ADT7462_R3T_ALARM); - -static SENSOR_DEVICE_ATTR(in1_max, S_IWUSR | S_IRUGO, show_volt_max, - set_volt_max, 0); -static SENSOR_DEVICE_ATTR(in2_max, S_IWUSR | S_IRUGO, show_volt_max, - set_volt_max, 1); -static SENSOR_DEVICE_ATTR(in3_max, S_IWUSR | S_IRUGO, show_volt_max, - set_volt_max, 2); -static SENSOR_DEVICE_ATTR(in4_max, S_IWUSR | S_IRUGO, show_volt_max, - set_volt_max, 3); -static SENSOR_DEVICE_ATTR(in5_max, S_IWUSR | S_IRUGO, show_volt_max, - set_volt_max, 4); -static SENSOR_DEVICE_ATTR(in6_max, S_IWUSR | S_IRUGO, show_volt_max, - set_volt_max, 5); -static SENSOR_DEVICE_ATTR(in7_max, S_IWUSR | S_IRUGO, show_volt_max, - set_volt_max, 6); -static SENSOR_DEVICE_ATTR(in8_max, S_IWUSR | S_IRUGO, show_volt_max, - set_volt_max, 7); -static SENSOR_DEVICE_ATTR(in9_max, S_IWUSR | S_IRUGO, show_volt_max, - set_volt_max, 8); -static SENSOR_DEVICE_ATTR(in10_max, S_IWUSR | S_IRUGO, show_volt_max, - set_volt_max, 9); -static SENSOR_DEVICE_ATTR(in11_max, S_IWUSR | S_IRUGO, show_volt_max, - set_volt_max, 10); -static SENSOR_DEVICE_ATTR(in12_max, S_IWUSR | S_IRUGO, show_volt_max, - set_volt_max, 11); -static SENSOR_DEVICE_ATTR(in13_max, S_IWUSR | S_IRUGO, show_volt_max, - set_volt_max, 12); - -static SENSOR_DEVICE_ATTR(in1_min, S_IWUSR | S_IRUGO, show_volt_min, - set_volt_min, 0); -static SENSOR_DEVICE_ATTR(in2_min, S_IWUSR | S_IRUGO, show_volt_min, - set_volt_min, 1); -static SENSOR_DEVICE_ATTR(in3_min, S_IWUSR | S_IRUGO, show_volt_min, - set_volt_min, 2); -static SENSOR_DEVICE_ATTR(in4_min, S_IWUSR | S_IRUGO, show_volt_min, - set_volt_min, 3); -static SENSOR_DEVICE_ATTR(in5_min, S_IWUSR | S_IRUGO, show_volt_min, - set_volt_min, 4); -static SENSOR_DEVICE_ATTR(in6_min, S_IWUSR | S_IRUGO, show_volt_min, - set_volt_min, 5); -static SENSOR_DEVICE_ATTR(in7_min, S_IWUSR | S_IRUGO, show_volt_min, - set_volt_min, 6); -static SENSOR_DEVICE_ATTR(in8_min, S_IWUSR | S_IRUGO, show_volt_min, - set_volt_min, 7); -static SENSOR_DEVICE_ATTR(in9_min, S_IWUSR | S_IRUGO, show_volt_min, - set_volt_min, 8); -static SENSOR_DEVICE_ATTR(in10_min, S_IWUSR | S_IRUGO, show_volt_min, - set_volt_min, 9); -static SENSOR_DEVICE_ATTR(in11_min, S_IWUSR | S_IRUGO, show_volt_min, - set_volt_min, 10); -static SENSOR_DEVICE_ATTR(in12_min, S_IWUSR | S_IRUGO, show_volt_min, - set_volt_min, 11); -static SENSOR_DEVICE_ATTR(in13_min, S_IWUSR | S_IRUGO, show_volt_min, - set_volt_min, 12); - -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_voltage, NULL, 0); -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_voltage, NULL, 1); -static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_voltage, NULL, 2); -static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_voltage, NULL, 3); -static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, show_voltage, NULL, 4); -static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_voltage, NULL, 5); -static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_voltage, NULL, 6); -static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, show_voltage, NULL, 7); -static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, show_voltage, NULL, 8); -static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, show_voltage, NULL, 9); -static SENSOR_DEVICE_ATTR(in11_input, S_IRUGO, show_voltage, NULL, 10); -static SENSOR_DEVICE_ATTR(in12_input, S_IRUGO, show_voltage, NULL, 11); -static SENSOR_DEVICE_ATTR(in13_input, S_IRUGO, show_voltage, NULL, 12); - -static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, show_voltage_label, NULL, 0); -static SENSOR_DEVICE_ATTR(in2_label, S_IRUGO, show_voltage_label, NULL, 1); -static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_voltage_label, NULL, 2); -static SENSOR_DEVICE_ATTR(in4_label, S_IRUGO, show_voltage_label, NULL, 3); -static SENSOR_DEVICE_ATTR(in5_label, S_IRUGO, show_voltage_label, NULL, 4); -static SENSOR_DEVICE_ATTR(in6_label, S_IRUGO, show_voltage_label, NULL, 5); -static SENSOR_DEVICE_ATTR(in7_label, S_IRUGO, show_voltage_label, NULL, 6); -static SENSOR_DEVICE_ATTR(in8_label, S_IRUGO, show_voltage_label, NULL, 7); -static SENSOR_DEVICE_ATTR(in9_label, S_IRUGO, show_voltage_label, NULL, 8); -static SENSOR_DEVICE_ATTR(in10_label, S_IRUGO, show_voltage_label, NULL, 9); -static SENSOR_DEVICE_ATTR(in11_label, S_IRUGO, show_voltage_label, NULL, 10); -static SENSOR_DEVICE_ATTR(in12_label, S_IRUGO, show_voltage_label, NULL, 11); -static SENSOR_DEVICE_ATTR(in13_label, S_IRUGO, show_voltage_label, NULL, 12); - -static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM2 | ADT7462_V0_ALARM); -static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM2 | ADT7462_V7_ALARM); -static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM2 | ADT7462_V2_ALARM); -static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM2 | ADT7462_V6_ALARM); -static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM2 | ADT7462_V5_ALARM); -static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM2 | ADT7462_V4_ALARM); -static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM2 | ADT7462_V3_ALARM); -static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM2 | ADT7462_V1_ALARM); -static SENSOR_DEVICE_ATTR(in9_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM3 | ADT7462_V10_ALARM); -static SENSOR_DEVICE_ATTR(in10_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM3 | ADT7462_V9_ALARM); -static SENSOR_DEVICE_ATTR(in11_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM3 | ADT7462_V8_ALARM); -static SENSOR_DEVICE_ATTR(in12_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM3 | ADT7462_V11_ALARM); -static SENSOR_DEVICE_ATTR(in13_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM3 | ADT7462_V12_ALARM); - -static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, - set_fan_min, 0); -static SENSOR_DEVICE_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, - set_fan_min, 1); -static SENSOR_DEVICE_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, - set_fan_min, 2); -static SENSOR_DEVICE_ATTR(fan4_min, S_IWUSR | S_IRUGO, show_fan_min, - set_fan_min, 3); -static SENSOR_DEVICE_ATTR(fan5_min, S_IWUSR | S_IRUGO, show_fan_min, - set_fan_min, 4); -static SENSOR_DEVICE_ATTR(fan6_min, S_IWUSR | S_IRUGO, show_fan_min, - set_fan_min, 5); -static SENSOR_DEVICE_ATTR(fan7_min, S_IWUSR | S_IRUGO, show_fan_min, - set_fan_min, 6); -static SENSOR_DEVICE_ATTR(fan8_min, S_IWUSR | S_IRUGO, show_fan_min, - set_fan_min, 7); - -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); -static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2); -static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3); -static SENSOR_DEVICE_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 4); -static SENSOR_DEVICE_ATTR(fan6_input, S_IRUGO, show_fan, NULL, 5); -static SENSOR_DEVICE_ATTR(fan7_input, S_IRUGO, show_fan, NULL, 6); -static SENSOR_DEVICE_ATTR(fan8_input, S_IRUGO, show_fan, NULL, 7); - -static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM4 | ADT7462_F0_ALARM); -static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM4 | ADT7462_F1_ALARM); -static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM4 | ADT7462_F2_ALARM); -static SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM4 | ADT7462_F3_ALARM); -static SENSOR_DEVICE_ATTR(fan5_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM4 | ADT7462_F4_ALARM); -static SENSOR_DEVICE_ATTR(fan6_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM4 | ADT7462_F5_ALARM); -static SENSOR_DEVICE_ATTR(fan7_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM4 | ADT7462_F6_ALARM); -static SENSOR_DEVICE_ATTR(fan8_alarm, S_IRUGO, show_alarm, NULL, - ADT7462_ALARM4 | ADT7462_F7_ALARM); - -static SENSOR_DEVICE_ATTR(force_pwm_max, S_IWUSR | S_IRUGO, - show_force_pwm_max, set_force_pwm_max, 0); - -static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0); -static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1); -static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2); -static SENSOR_DEVICE_ATTR(pwm4, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 3); - -static SENSOR_DEVICE_ATTR(pwm1_auto_point1_pwm, S_IWUSR | S_IRUGO, - show_pwm_min, set_pwm_min, 0); -static SENSOR_DEVICE_ATTR(pwm2_auto_point1_pwm, S_IWUSR | S_IRUGO, - show_pwm_min, set_pwm_min, 1); -static SENSOR_DEVICE_ATTR(pwm3_auto_point1_pwm, S_IWUSR | S_IRUGO, - show_pwm_min, set_pwm_min, 2); -static SENSOR_DEVICE_ATTR(pwm4_auto_point1_pwm, S_IWUSR | S_IRUGO, - show_pwm_min, set_pwm_min, 3); - -static SENSOR_DEVICE_ATTR(pwm1_auto_point2_pwm, S_IWUSR | S_IRUGO, - show_pwm_max, set_pwm_max, 0); -static SENSOR_DEVICE_ATTR(pwm2_auto_point2_pwm, S_IWUSR | S_IRUGO, - show_pwm_max, set_pwm_max, 1); -static SENSOR_DEVICE_ATTR(pwm3_auto_point2_pwm, S_IWUSR | S_IRUGO, - show_pwm_max, set_pwm_max, 2); -static SENSOR_DEVICE_ATTR(pwm4_auto_point2_pwm, S_IWUSR | S_IRUGO, - show_pwm_max, set_pwm_max, 3); - -static SENSOR_DEVICE_ATTR(temp1_auto_point1_hyst, S_IWUSR | S_IRUGO, - show_pwm_hyst, set_pwm_hyst, 0); -static SENSOR_DEVICE_ATTR(temp2_auto_point1_hyst, S_IWUSR | S_IRUGO, - show_pwm_hyst, set_pwm_hyst, 1); -static SENSOR_DEVICE_ATTR(temp3_auto_point1_hyst, S_IWUSR | S_IRUGO, - show_pwm_hyst, set_pwm_hyst, 2); -static SENSOR_DEVICE_ATTR(temp4_auto_point1_hyst, S_IWUSR | S_IRUGO, - show_pwm_hyst, set_pwm_hyst, 3); - -static SENSOR_DEVICE_ATTR(temp1_auto_point2_hyst, S_IWUSR | S_IRUGO, - show_pwm_hyst, set_pwm_hyst, 0); -static SENSOR_DEVICE_ATTR(temp2_auto_point2_hyst, S_IWUSR | S_IRUGO, - show_pwm_hyst, set_pwm_hyst, 1); -static SENSOR_DEVICE_ATTR(temp3_auto_point2_hyst, S_IWUSR | S_IRUGO, - show_pwm_hyst, set_pwm_hyst, 2); -static SENSOR_DEVICE_ATTR(temp4_auto_point2_hyst, S_IWUSR | S_IRUGO, - show_pwm_hyst, set_pwm_hyst, 3); - -static SENSOR_DEVICE_ATTR(temp1_auto_point1_temp, S_IWUSR | S_IRUGO, - show_pwm_tmin, set_pwm_tmin, 0); -static SENSOR_DEVICE_ATTR(temp2_auto_point1_temp, S_IWUSR | S_IRUGO, - show_pwm_tmin, set_pwm_tmin, 1); -static SENSOR_DEVICE_ATTR(temp3_auto_point1_temp, S_IWUSR | S_IRUGO, - show_pwm_tmin, set_pwm_tmin, 2); -static SENSOR_DEVICE_ATTR(temp4_auto_point1_temp, S_IWUSR | S_IRUGO, - show_pwm_tmin, set_pwm_tmin, 3); - -static SENSOR_DEVICE_ATTR(temp1_auto_point2_temp, S_IWUSR | S_IRUGO, - show_pwm_tmax, set_pwm_tmax, 0); -static SENSOR_DEVICE_ATTR(temp2_auto_point2_temp, S_IWUSR | S_IRUGO, - show_pwm_tmax, set_pwm_tmax, 1); -static SENSOR_DEVICE_ATTR(temp3_auto_point2_temp, S_IWUSR | S_IRUGO, - show_pwm_tmax, set_pwm_tmax, 2); -static SENSOR_DEVICE_ATTR(temp4_auto_point2_temp, S_IWUSR | S_IRUGO, - show_pwm_tmax, set_pwm_tmax, 3); - -static SENSOR_DEVICE_ATTR(pwm1_enable, S_IWUSR | S_IRUGO, show_pwm_auto, - set_pwm_auto, 0); -static SENSOR_DEVICE_ATTR(pwm2_enable, S_IWUSR | S_IRUGO, show_pwm_auto, - set_pwm_auto, 1); -static SENSOR_DEVICE_ATTR(pwm3_enable, S_IWUSR | S_IRUGO, show_pwm_auto, - set_pwm_auto, 2); -static SENSOR_DEVICE_ATTR(pwm4_enable, S_IWUSR | S_IRUGO, show_pwm_auto, - set_pwm_auto, 3); - -static SENSOR_DEVICE_ATTR(pwm1_auto_channels_temp, S_IWUSR | S_IRUGO, - show_pwm_auto_temp, set_pwm_auto_temp, 0); -static SENSOR_DEVICE_ATTR(pwm2_auto_channels_temp, S_IWUSR | S_IRUGO, - show_pwm_auto_temp, set_pwm_auto_temp, 1); -static SENSOR_DEVICE_ATTR(pwm3_auto_channels_temp, S_IWUSR | S_IRUGO, - show_pwm_auto_temp, set_pwm_auto_temp, 2); -static SENSOR_DEVICE_ATTR(pwm4_auto_channels_temp, S_IWUSR | S_IRUGO, - show_pwm_auto_temp, set_pwm_auto_temp, 3); +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); +static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_max, 2); +static SENSOR_DEVICE_ATTR_RW(temp4_max, temp_max, 3); + +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0); +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1); +static SENSOR_DEVICE_ATTR_RW(temp3_min, temp_min, 2); +static SENSOR_DEVICE_ATTR_RW(temp4_min, temp_min, 3); + +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2); +static SENSOR_DEVICE_ATTR_RO(temp4_input, temp, 3); + +static SENSOR_DEVICE_ATTR_RO(temp1_label, temp_label, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_label, temp_label, 1); +static SENSOR_DEVICE_ATTR_RO(temp3_label, temp_label, 2); +static SENSOR_DEVICE_ATTR_RO(temp4_label, temp_label, 3); + +static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, + ADT7462_ALARM1 | ADT7462_LT_ALARM); +static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm, + ADT7462_ALARM1 | ADT7462_R1T_ALARM); +static SENSOR_DEVICE_ATTR_RO(temp3_alarm, alarm, + ADT7462_ALARM1 | ADT7462_R2T_ALARM); +static SENSOR_DEVICE_ATTR_RO(temp4_alarm, alarm, + ADT7462_ALARM1 | ADT7462_R3T_ALARM); + +static SENSOR_DEVICE_ATTR_RW(in1_max, volt_max, 0); +static SENSOR_DEVICE_ATTR_RW(in2_max, volt_max, 1); +static SENSOR_DEVICE_ATTR_RW(in3_max, volt_max, 2); +static SENSOR_DEVICE_ATTR_RW(in4_max, volt_max, 3); +static SENSOR_DEVICE_ATTR_RW(in5_max, volt_max, 4); +static SENSOR_DEVICE_ATTR_RW(in6_max, volt_max, 5); +static SENSOR_DEVICE_ATTR_RW(in7_max, volt_max, 6); +static SENSOR_DEVICE_ATTR_RW(in8_max, volt_max, 7); +static SENSOR_DEVICE_ATTR_RW(in9_max, volt_max, 8); +static SENSOR_DEVICE_ATTR_RW(in10_max, volt_max, 9); +static SENSOR_DEVICE_ATTR_RW(in11_max, volt_max, 10); +static SENSOR_DEVICE_ATTR_RW(in12_max, volt_max, 11); +static SENSOR_DEVICE_ATTR_RW(in13_max, volt_max, 12); + +static SENSOR_DEVICE_ATTR_RW(in1_min, volt_min, 0); +static SENSOR_DEVICE_ATTR_RW(in2_min, volt_min, 1); +static SENSOR_DEVICE_ATTR_RW(in3_min, volt_min, 2); +static SENSOR_DEVICE_ATTR_RW(in4_min, volt_min, 3); +static SENSOR_DEVICE_ATTR_RW(in5_min, volt_min, 4); +static SENSOR_DEVICE_ATTR_RW(in6_min, volt_min, 5); +static SENSOR_DEVICE_ATTR_RW(in7_min, volt_min, 6); +static SENSOR_DEVICE_ATTR_RW(in8_min, volt_min, 7); +static SENSOR_DEVICE_ATTR_RW(in9_min, volt_min, 8); +static SENSOR_DEVICE_ATTR_RW(in10_min, volt_min, 9); +static SENSOR_DEVICE_ATTR_RW(in11_min, volt_min, 10); +static SENSOR_DEVICE_ATTR_RW(in12_min, volt_min, 11); +static SENSOR_DEVICE_ATTR_RW(in13_min, volt_min, 12); + +static SENSOR_DEVICE_ATTR_RO(in1_input, voltage, 0); +static SENSOR_DEVICE_ATTR_RO(in2_input, voltage, 1); +static SENSOR_DEVICE_ATTR_RO(in3_input, voltage, 2); +static SENSOR_DEVICE_ATTR_RO(in4_input, voltage, 3); +static SENSOR_DEVICE_ATTR_RO(in5_input, voltage, 4); +static SENSOR_DEVICE_ATTR_RO(in6_input, voltage, 5); +static SENSOR_DEVICE_ATTR_RO(in7_input, voltage, 6); +static SENSOR_DEVICE_ATTR_RO(in8_input, voltage, 7); +static SENSOR_DEVICE_ATTR_RO(in9_input, voltage, 8); +static SENSOR_DEVICE_ATTR_RO(in10_input, voltage, 9); +static SENSOR_DEVICE_ATTR_RO(in11_input, voltage, 10); +static SENSOR_DEVICE_ATTR_RO(in12_input, voltage, 11); +static SENSOR_DEVICE_ATTR_RO(in13_input, voltage, 12); + +static SENSOR_DEVICE_ATTR_RO(in1_label, voltage_label, 0); +static SENSOR_DEVICE_ATTR_RO(in2_label, voltage_label, 1); +static SENSOR_DEVICE_ATTR_RO(in3_label, voltage_label, 2); +static SENSOR_DEVICE_ATTR_RO(in4_label, voltage_label, 3); +static SENSOR_DEVICE_ATTR_RO(in5_label, voltage_label, 4); +static SENSOR_DEVICE_ATTR_RO(in6_label, voltage_label, 5); +static SENSOR_DEVICE_ATTR_RO(in7_label, voltage_label, 6); +static SENSOR_DEVICE_ATTR_RO(in8_label, voltage_label, 7); +static SENSOR_DEVICE_ATTR_RO(in9_label, voltage_label, 8); +static SENSOR_DEVICE_ATTR_RO(in10_label, voltage_label, 9); +static SENSOR_DEVICE_ATTR_RO(in11_label, voltage_label, 10); +static SENSOR_DEVICE_ATTR_RO(in12_label, voltage_label, 11); +static SENSOR_DEVICE_ATTR_RO(in13_label, voltage_label, 12); + +static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, + ADT7462_ALARM2 | ADT7462_V0_ALARM); +static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, + ADT7462_ALARM2 | ADT7462_V7_ALARM); +static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, + ADT7462_ALARM2 | ADT7462_V2_ALARM); +static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, + ADT7462_ALARM2 | ADT7462_V6_ALARM); +static SENSOR_DEVICE_ATTR_RO(in5_alarm, alarm, + ADT7462_ALARM2 | ADT7462_V5_ALARM); +static SENSOR_DEVICE_ATTR_RO(in6_alarm, alarm, + ADT7462_ALARM2 | ADT7462_V4_ALARM); +static SENSOR_DEVICE_ATTR_RO(in7_alarm, alarm, + ADT7462_ALARM2 | ADT7462_V3_ALARM); +static SENSOR_DEVICE_ATTR_RO(in8_alarm, alarm, + ADT7462_ALARM2 | ADT7462_V1_ALARM); +static SENSOR_DEVICE_ATTR_RO(in9_alarm, alarm, + ADT7462_ALARM3 | ADT7462_V10_ALARM); +static SENSOR_DEVICE_ATTR_RO(in10_alarm, alarm, + ADT7462_ALARM3 | ADT7462_V9_ALARM); +static SENSOR_DEVICE_ATTR_RO(in11_alarm, alarm, + ADT7462_ALARM3 | ADT7462_V8_ALARM); +static SENSOR_DEVICE_ATTR_RO(in12_alarm, alarm, + ADT7462_ALARM3 | ADT7462_V11_ALARM); +static SENSOR_DEVICE_ATTR_RO(in13_alarm, alarm, + ADT7462_ALARM3 | ADT7462_V12_ALARM); + +static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0); +static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1); +static SENSOR_DEVICE_ATTR_RW(fan3_min, fan_min, 2); +static SENSOR_DEVICE_ATTR_RW(fan4_min, fan_min, 3); +static SENSOR_DEVICE_ATTR_RW(fan5_min, fan_min, 4); +static SENSOR_DEVICE_ATTR_RW(fan6_min, fan_min, 5); +static SENSOR_DEVICE_ATTR_RW(fan7_min, fan_min, 6); +static SENSOR_DEVICE_ATTR_RW(fan8_min, fan_min, 7); + +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1); +static SENSOR_DEVICE_ATTR_RO(fan3_input, fan, 2); +static SENSOR_DEVICE_ATTR_RO(fan4_input, fan, 3); +static SENSOR_DEVICE_ATTR_RO(fan5_input, fan, 4); +static SENSOR_DEVICE_ATTR_RO(fan6_input, fan, 5); +static SENSOR_DEVICE_ATTR_RO(fan7_input, fan, 6); +static SENSOR_DEVICE_ATTR_RO(fan8_input, fan, 7); + +static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, + ADT7462_ALARM4 | ADT7462_F0_ALARM); +static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, + ADT7462_ALARM4 | ADT7462_F1_ALARM); +static SENSOR_DEVICE_ATTR_RO(fan3_alarm, alarm, + ADT7462_ALARM4 | ADT7462_F2_ALARM); +static SENSOR_DEVICE_ATTR_RO(fan4_alarm, alarm, + ADT7462_ALARM4 | ADT7462_F3_ALARM); +static SENSOR_DEVICE_ATTR_RO(fan5_alarm, alarm, + ADT7462_ALARM4 | ADT7462_F4_ALARM); +static SENSOR_DEVICE_ATTR_RO(fan6_alarm, alarm, + ADT7462_ALARM4 | ADT7462_F5_ALARM); +static SENSOR_DEVICE_ATTR_RO(fan7_alarm, alarm, + ADT7462_ALARM4 | ADT7462_F6_ALARM); +static SENSOR_DEVICE_ATTR_RO(fan8_alarm, alarm, + ADT7462_ALARM4 | ADT7462_F7_ALARM); + +static SENSOR_DEVICE_ATTR_RW(force_pwm_max, force_pwm_max, 0); + +static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, 1); +static SENSOR_DEVICE_ATTR_RW(pwm3, pwm, 2); +static SENSOR_DEVICE_ATTR_RW(pwm4, pwm, 3); + +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point1_pwm, pwm_min, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point1_pwm, pwm_min, 1); +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point1_pwm, pwm_min, 2); +static SENSOR_DEVICE_ATTR_RW(pwm4_auto_point1_pwm, pwm_min, 3); + +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point2_pwm, pwm_max, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point2_pwm, pwm_max, 1); +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point2_pwm, pwm_max, 2); +static SENSOR_DEVICE_ATTR_RW(pwm4_auto_point2_pwm, pwm_max, 3); + +static SENSOR_DEVICE_ATTR_RW(temp1_auto_point1_hyst, pwm_hyst, 0); +static SENSOR_DEVICE_ATTR_RW(temp2_auto_point1_hyst, pwm_hyst, 1); +static SENSOR_DEVICE_ATTR_RW(temp3_auto_point1_hyst, pwm_hyst, 2); +static SENSOR_DEVICE_ATTR_RW(temp4_auto_point1_hyst, pwm_hyst, 3); + +static SENSOR_DEVICE_ATTR_RW(temp1_auto_point2_hyst, pwm_hyst, 0); +static SENSOR_DEVICE_ATTR_RW(temp2_auto_point2_hyst, pwm_hyst, 1); +static SENSOR_DEVICE_ATTR_RW(temp3_auto_point2_hyst, pwm_hyst, 2); +static SENSOR_DEVICE_ATTR_RW(temp4_auto_point2_hyst, pwm_hyst, 3); + +static SENSOR_DEVICE_ATTR_RW(temp1_auto_point1_temp, pwm_tmin, 0); +static SENSOR_DEVICE_ATTR_RW(temp2_auto_point1_temp, pwm_tmin, 1); +static SENSOR_DEVICE_ATTR_RW(temp3_auto_point1_temp, pwm_tmin, 2); +static SENSOR_DEVICE_ATTR_RW(temp4_auto_point1_temp, pwm_tmin, 3); + +static SENSOR_DEVICE_ATTR_RW(temp1_auto_point2_temp, pwm_tmax, 0); +static SENSOR_DEVICE_ATTR_RW(temp2_auto_point2_temp, pwm_tmax, 1); +static SENSOR_DEVICE_ATTR_RW(temp3_auto_point2_temp, pwm_tmax, 2); +static SENSOR_DEVICE_ATTR_RW(temp4_auto_point2_temp, pwm_tmax, 3); + +static SENSOR_DEVICE_ATTR_RW(pwm1_enable, pwm_auto, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2_enable, pwm_auto, 1); +static SENSOR_DEVICE_ATTR_RW(pwm3_enable, pwm_auto, 2); +static SENSOR_DEVICE_ATTR_RW(pwm4_enable, pwm_auto, 3); + +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_channels_temp, pwm_auto_temp, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_channels_temp, pwm_auto_temp, 1); +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_channels_temp, pwm_auto_temp, 2); +static SENSOR_DEVICE_ATTR_RW(pwm4_auto_channels_temp, pwm_auto_temp, 3); static struct attribute *adt7462_attrs[] = { &sensor_dev_attr_temp1_max.dev_attr.attr, -- cgit v1.2.3 From 42291a5aaed748a88dc69c0854a8101cf8f3b3eb Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:02 -0800 Subject: hwmon: (adt7470) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/adt7470.c | 403 +++++++++++++++++++----------------------------- 1 file changed, 158 insertions(+), 245 deletions(-) diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c index 2cd920751441..6d87daf18809 100644 --- a/drivers/hwmon/adt7470.c +++ b/drivers/hwmon/adt7470.c @@ -459,19 +459,17 @@ static ssize_t num_temp_sensors_store(struct device *dev, return count; } -static ssize_t show_temp_min(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t temp_min_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = adt7470_update_device(dev); return sprintf(buf, "%d\n", 1000 * data->temp_min[attr->index]); } -static ssize_t set_temp_min(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t temp_min_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = dev_get_drvdata(dev); @@ -493,19 +491,17 @@ static ssize_t set_temp_min(struct device *dev, return count; } -static ssize_t show_temp_max(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t temp_max_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = adt7470_update_device(dev); return sprintf(buf, "%d\n", 1000 * data->temp_max[attr->index]); } -static ssize_t set_temp_max(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t temp_max_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = dev_get_drvdata(dev); @@ -527,7 +523,7 @@ static ssize_t set_temp_max(struct device *dev, return count; } -static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, +static ssize_t temp_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); @@ -565,9 +561,8 @@ static ssize_t alarm_mask_store(struct device *dev, return count; } -static ssize_t show_fan_max(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t fan_max_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = adt7470_update_device(dev); @@ -579,9 +574,9 @@ static ssize_t show_fan_max(struct device *dev, return sprintf(buf, "0\n"); } -static ssize_t set_fan_max(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) +static ssize_t fan_max_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = dev_get_drvdata(dev); @@ -602,9 +597,8 @@ static ssize_t set_fan_max(struct device *dev, return count; } -static ssize_t show_fan_min(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t fan_min_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = adt7470_update_device(dev); @@ -616,9 +610,9 @@ static ssize_t show_fan_min(struct device *dev, return sprintf(buf, "0\n"); } -static ssize_t set_fan_min(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) +static ssize_t fan_min_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = dev_get_drvdata(dev); @@ -639,7 +633,7 @@ static ssize_t set_fan_min(struct device *dev, return count; } -static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, +static ssize_t fan_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); @@ -652,18 +646,16 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, return sprintf(buf, "0\n"); } -static ssize_t show_force_pwm_max(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t force_pwm_max_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct adt7470_data *data = adt7470_update_device(dev); return sprintf(buf, "%d\n", data->force_pwm_max); } -static ssize_t set_force_pwm_max(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t force_pwm_max_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct adt7470_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; @@ -686,7 +678,7 @@ static ssize_t set_force_pwm_max(struct device *dev, return count; } -static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, +static ssize_t pwm_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); @@ -694,8 +686,8 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, return sprintf(buf, "%d\n", data->pwm[attr->index]); } -static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) +static ssize_t pwm_store(struct device *dev, struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = dev_get_drvdata(dev); @@ -779,19 +771,17 @@ static ssize_t pwm1_freq_store(struct device *dev, return count; } -static ssize_t show_pwm_max(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t pwm_max_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = adt7470_update_device(dev); return sprintf(buf, "%d\n", data->pwm_max[attr->index]); } -static ssize_t set_pwm_max(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t pwm_max_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = dev_get_drvdata(dev); @@ -812,19 +802,17 @@ static ssize_t set_pwm_max(struct device *dev, return count; } -static ssize_t show_pwm_min(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t pwm_min_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = adt7470_update_device(dev); return sprintf(buf, "%d\n", data->pwm_min[attr->index]); } -static ssize_t set_pwm_min(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t pwm_min_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = dev_get_drvdata(dev); @@ -845,9 +833,8 @@ static ssize_t set_pwm_min(struct device *dev, return count; } -static ssize_t show_pwm_tmax(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t pwm_tmax_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = adt7470_update_device(dev); @@ -855,19 +842,17 @@ static ssize_t show_pwm_tmax(struct device *dev, return sprintf(buf, "%d\n", 1000 * (20 + data->pwm_tmin[attr->index])); } -static ssize_t show_pwm_tmin(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t pwm_tmin_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = adt7470_update_device(dev); return sprintf(buf, "%d\n", 1000 * data->pwm_tmin[attr->index]); } -static ssize_t set_pwm_tmin(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t pwm_tmin_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = dev_get_drvdata(dev); @@ -889,19 +874,17 @@ static ssize_t set_pwm_tmin(struct device *dev, return count; } -static ssize_t show_pwm_auto(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t pwm_auto_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = adt7470_update_device(dev); return sprintf(buf, "%d\n", 1 + data->pwm_automatic[attr->index]); } -static ssize_t set_pwm_auto(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t pwm_auto_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = dev_get_drvdata(dev); @@ -936,9 +919,8 @@ static ssize_t set_pwm_auto(struct device *dev, return count; } -static ssize_t show_pwm_auto_temp(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t pwm_auto_temp_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = adt7470_update_device(dev); @@ -959,10 +941,9 @@ static int cvt_auto_temp(int input) return ilog2(input) + 1; } -static ssize_t set_pwm_auto_temp(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t pwm_auto_temp_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = dev_get_drvdata(dev); @@ -996,9 +977,8 @@ static ssize_t set_pwm_auto_temp(struct device *dev, return count; } -static ssize_t show_alarm(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t alarm_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7470_data *data = adt7470_update_device(dev); @@ -1013,175 +993,108 @@ static DEVICE_ATTR_RW(alarm_mask); static DEVICE_ATTR_RW(num_temp_sensors); static DEVICE_ATTR_RW(auto_update_interval); -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, - set_temp_max, 0); -static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_max, - set_temp_max, 1); -static SENSOR_DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_temp_max, - set_temp_max, 2); -static SENSOR_DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_temp_max, - set_temp_max, 3); -static SENSOR_DEVICE_ATTR(temp5_max, S_IWUSR | S_IRUGO, show_temp_max, - set_temp_max, 4); -static SENSOR_DEVICE_ATTR(temp6_max, S_IWUSR | S_IRUGO, show_temp_max, - set_temp_max, 5); -static SENSOR_DEVICE_ATTR(temp7_max, S_IWUSR | S_IRUGO, show_temp_max, - set_temp_max, 6); -static SENSOR_DEVICE_ATTR(temp8_max, S_IWUSR | S_IRUGO, show_temp_max, - set_temp_max, 7); -static SENSOR_DEVICE_ATTR(temp9_max, S_IWUSR | S_IRUGO, show_temp_max, - set_temp_max, 8); -static SENSOR_DEVICE_ATTR(temp10_max, S_IWUSR | S_IRUGO, show_temp_max, - set_temp_max, 9); - -static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp_min, - set_temp_min, 0); -static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp_min, - set_temp_min, 1); -static SENSOR_DEVICE_ATTR(temp3_min, S_IWUSR | S_IRUGO, show_temp_min, - set_temp_min, 2); -static SENSOR_DEVICE_ATTR(temp4_min, S_IWUSR | S_IRUGO, show_temp_min, - set_temp_min, 3); -static SENSOR_DEVICE_ATTR(temp5_min, S_IWUSR | S_IRUGO, show_temp_min, - set_temp_min, 4); -static SENSOR_DEVICE_ATTR(temp6_min, S_IWUSR | S_IRUGO, show_temp_min, - set_temp_min, 5); -static SENSOR_DEVICE_ATTR(temp7_min, S_IWUSR | S_IRUGO, show_temp_min, - set_temp_min, 6); -static SENSOR_DEVICE_ATTR(temp8_min, S_IWUSR | S_IRUGO, show_temp_min, - set_temp_min, 7); -static SENSOR_DEVICE_ATTR(temp9_min, S_IWUSR | S_IRUGO, show_temp_min, - set_temp_min, 8); -static SENSOR_DEVICE_ATTR(temp10_min, S_IWUSR | S_IRUGO, show_temp_min, - set_temp_min, 9); - -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); -static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3); -static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO, show_temp, NULL, 4); -static SENSOR_DEVICE_ATTR(temp6_input, S_IRUGO, show_temp, NULL, 5); -static SENSOR_DEVICE_ATTR(temp7_input, S_IRUGO, show_temp, NULL, 6); -static SENSOR_DEVICE_ATTR(temp8_input, S_IRUGO, show_temp, NULL, 7); -static SENSOR_DEVICE_ATTR(temp9_input, S_IRUGO, show_temp, NULL, 8); -static SENSOR_DEVICE_ATTR(temp10_input, S_IRUGO, show_temp, NULL, 9); - -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, - ADT7470_R1T_ALARM); -static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, - ADT7470_R2T_ALARM); -static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, - ADT7470_R3T_ALARM); -static SENSOR_DEVICE_ATTR(temp4_alarm, S_IRUGO, show_alarm, NULL, - ADT7470_R4T_ALARM); -static SENSOR_DEVICE_ATTR(temp5_alarm, S_IRUGO, show_alarm, NULL, - ADT7470_R5T_ALARM); -static SENSOR_DEVICE_ATTR(temp6_alarm, S_IRUGO, show_alarm, NULL, - ADT7470_R6T_ALARM); -static SENSOR_DEVICE_ATTR(temp7_alarm, S_IRUGO, show_alarm, NULL, - ADT7470_R7T_ALARM); -static SENSOR_DEVICE_ATTR(temp8_alarm, S_IRUGO, show_alarm, NULL, - ALARM2(ADT7470_R8T_ALARM)); -static SENSOR_DEVICE_ATTR(temp9_alarm, S_IRUGO, show_alarm, NULL, - ALARM2(ADT7470_R9T_ALARM)); -static SENSOR_DEVICE_ATTR(temp10_alarm, S_IRUGO, show_alarm, NULL, - ALARM2(ADT7470_R10T_ALARM)); - -static SENSOR_DEVICE_ATTR(fan1_max, S_IWUSR | S_IRUGO, show_fan_max, - set_fan_max, 0); -static SENSOR_DEVICE_ATTR(fan2_max, S_IWUSR | S_IRUGO, show_fan_max, - set_fan_max, 1); -static SENSOR_DEVICE_ATTR(fan3_max, S_IWUSR | S_IRUGO, show_fan_max, - set_fan_max, 2); -static SENSOR_DEVICE_ATTR(fan4_max, S_IWUSR | S_IRUGO, show_fan_max, - set_fan_max, 3); - -static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, - set_fan_min, 0); -static SENSOR_DEVICE_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, - set_fan_min, 1); -static SENSOR_DEVICE_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, - set_fan_min, 2); -static SENSOR_DEVICE_ATTR(fan4_min, S_IWUSR | S_IRUGO, show_fan_min, - set_fan_min, 3); - -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); -static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2); -static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3); - -static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, - ALARM2(ADT7470_FAN1_ALARM)); -static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, - ALARM2(ADT7470_FAN2_ALARM)); -static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, - ALARM2(ADT7470_FAN3_ALARM)); -static SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL, - ALARM2(ADT7470_FAN4_ALARM)); - -static SENSOR_DEVICE_ATTR(force_pwm_max, S_IWUSR | S_IRUGO, - show_force_pwm_max, set_force_pwm_max, 0); - -static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0); -static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1); -static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2); -static SENSOR_DEVICE_ATTR(pwm4, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 3); +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); +static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_max, 2); +static SENSOR_DEVICE_ATTR_RW(temp4_max, temp_max, 3); +static SENSOR_DEVICE_ATTR_RW(temp5_max, temp_max, 4); +static SENSOR_DEVICE_ATTR_RW(temp6_max, temp_max, 5); +static SENSOR_DEVICE_ATTR_RW(temp7_max, temp_max, 6); +static SENSOR_DEVICE_ATTR_RW(temp8_max, temp_max, 7); +static SENSOR_DEVICE_ATTR_RW(temp9_max, temp_max, 8); +static SENSOR_DEVICE_ATTR_RW(temp10_max, temp_max, 9); + +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0); +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1); +static SENSOR_DEVICE_ATTR_RW(temp3_min, temp_min, 2); +static SENSOR_DEVICE_ATTR_RW(temp4_min, temp_min, 3); +static SENSOR_DEVICE_ATTR_RW(temp5_min, temp_min, 4); +static SENSOR_DEVICE_ATTR_RW(temp6_min, temp_min, 5); +static SENSOR_DEVICE_ATTR_RW(temp7_min, temp_min, 6); +static SENSOR_DEVICE_ATTR_RW(temp8_min, temp_min, 7); +static SENSOR_DEVICE_ATTR_RW(temp9_min, temp_min, 8); +static SENSOR_DEVICE_ATTR_RW(temp10_min, temp_min, 9); + +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2); +static SENSOR_DEVICE_ATTR_RO(temp4_input, temp, 3); +static SENSOR_DEVICE_ATTR_RO(temp5_input, temp, 4); +static SENSOR_DEVICE_ATTR_RO(temp6_input, temp, 5); +static SENSOR_DEVICE_ATTR_RO(temp7_input, temp, 6); +static SENSOR_DEVICE_ATTR_RO(temp8_input, temp, 7); +static SENSOR_DEVICE_ATTR_RO(temp9_input, temp, 8); +static SENSOR_DEVICE_ATTR_RO(temp10_input, temp, 9); + +static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, ADT7470_R1T_ALARM); +static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm, ADT7470_R2T_ALARM); +static SENSOR_DEVICE_ATTR_RO(temp3_alarm, alarm, ADT7470_R3T_ALARM); +static SENSOR_DEVICE_ATTR_RO(temp4_alarm, alarm, ADT7470_R4T_ALARM); +static SENSOR_DEVICE_ATTR_RO(temp5_alarm, alarm, ADT7470_R5T_ALARM); +static SENSOR_DEVICE_ATTR_RO(temp6_alarm, alarm, ADT7470_R6T_ALARM); +static SENSOR_DEVICE_ATTR_RO(temp7_alarm, alarm, ADT7470_R7T_ALARM); +static SENSOR_DEVICE_ATTR_RO(temp8_alarm, alarm, ALARM2(ADT7470_R8T_ALARM)); +static SENSOR_DEVICE_ATTR_RO(temp9_alarm, alarm, ALARM2(ADT7470_R9T_ALARM)); +static SENSOR_DEVICE_ATTR_RO(temp10_alarm, alarm, ALARM2(ADT7470_R10T_ALARM)); + +static SENSOR_DEVICE_ATTR_RW(fan1_max, fan_max, 0); +static SENSOR_DEVICE_ATTR_RW(fan2_max, fan_max, 1); +static SENSOR_DEVICE_ATTR_RW(fan3_max, fan_max, 2); +static SENSOR_DEVICE_ATTR_RW(fan4_max, fan_max, 3); + +static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0); +static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1); +static SENSOR_DEVICE_ATTR_RW(fan3_min, fan_min, 2); +static SENSOR_DEVICE_ATTR_RW(fan4_min, fan_min, 3); + +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1); +static SENSOR_DEVICE_ATTR_RO(fan3_input, fan, 2); +static SENSOR_DEVICE_ATTR_RO(fan4_input, fan, 3); + +static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, ALARM2(ADT7470_FAN1_ALARM)); +static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, ALARM2(ADT7470_FAN2_ALARM)); +static SENSOR_DEVICE_ATTR_RO(fan3_alarm, alarm, ALARM2(ADT7470_FAN3_ALARM)); +static SENSOR_DEVICE_ATTR_RO(fan4_alarm, alarm, ALARM2(ADT7470_FAN4_ALARM)); + +static SENSOR_DEVICE_ATTR_RW(force_pwm_max, force_pwm_max, 0); + +static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, 1); +static SENSOR_DEVICE_ATTR_RW(pwm3, pwm, 2); +static SENSOR_DEVICE_ATTR_RW(pwm4, pwm, 3); static DEVICE_ATTR_RW(pwm1_freq); -static SENSOR_DEVICE_ATTR(pwm1_auto_point1_pwm, S_IWUSR | S_IRUGO, - show_pwm_min, set_pwm_min, 0); -static SENSOR_DEVICE_ATTR(pwm2_auto_point1_pwm, S_IWUSR | S_IRUGO, - show_pwm_min, set_pwm_min, 1); -static SENSOR_DEVICE_ATTR(pwm3_auto_point1_pwm, S_IWUSR | S_IRUGO, - show_pwm_min, set_pwm_min, 2); -static SENSOR_DEVICE_ATTR(pwm4_auto_point1_pwm, S_IWUSR | S_IRUGO, - show_pwm_min, set_pwm_min, 3); - -static SENSOR_DEVICE_ATTR(pwm1_auto_point2_pwm, S_IWUSR | S_IRUGO, - show_pwm_max, set_pwm_max, 0); -static SENSOR_DEVICE_ATTR(pwm2_auto_point2_pwm, S_IWUSR | S_IRUGO, - show_pwm_max, set_pwm_max, 1); -static SENSOR_DEVICE_ATTR(pwm3_auto_point2_pwm, S_IWUSR | S_IRUGO, - show_pwm_max, set_pwm_max, 2); -static SENSOR_DEVICE_ATTR(pwm4_auto_point2_pwm, S_IWUSR | S_IRUGO, - show_pwm_max, set_pwm_max, 3); - -static SENSOR_DEVICE_ATTR(pwm1_auto_point1_temp, S_IWUSR | S_IRUGO, - show_pwm_tmin, set_pwm_tmin, 0); -static SENSOR_DEVICE_ATTR(pwm2_auto_point1_temp, S_IWUSR | S_IRUGO, - show_pwm_tmin, set_pwm_tmin, 1); -static SENSOR_DEVICE_ATTR(pwm3_auto_point1_temp, S_IWUSR | S_IRUGO, - show_pwm_tmin, set_pwm_tmin, 2); -static SENSOR_DEVICE_ATTR(pwm4_auto_point1_temp, S_IWUSR | S_IRUGO, - show_pwm_tmin, set_pwm_tmin, 3); - -static SENSOR_DEVICE_ATTR(pwm1_auto_point2_temp, S_IRUGO, show_pwm_tmax, - NULL, 0); -static SENSOR_DEVICE_ATTR(pwm2_auto_point2_temp, S_IRUGO, show_pwm_tmax, - NULL, 1); -static SENSOR_DEVICE_ATTR(pwm3_auto_point2_temp, S_IRUGO, show_pwm_tmax, - NULL, 2); -static SENSOR_DEVICE_ATTR(pwm4_auto_point2_temp, S_IRUGO, show_pwm_tmax, - NULL, 3); - -static SENSOR_DEVICE_ATTR(pwm1_enable, S_IWUSR | S_IRUGO, show_pwm_auto, - set_pwm_auto, 0); -static SENSOR_DEVICE_ATTR(pwm2_enable, S_IWUSR | S_IRUGO, show_pwm_auto, - set_pwm_auto, 1); -static SENSOR_DEVICE_ATTR(pwm3_enable, S_IWUSR | S_IRUGO, show_pwm_auto, - set_pwm_auto, 2); -static SENSOR_DEVICE_ATTR(pwm4_enable, S_IWUSR | S_IRUGO, show_pwm_auto, - set_pwm_auto, 3); - -static SENSOR_DEVICE_ATTR(pwm1_auto_channels_temp, S_IWUSR | S_IRUGO, - show_pwm_auto_temp, set_pwm_auto_temp, 0); -static SENSOR_DEVICE_ATTR(pwm2_auto_channels_temp, S_IWUSR | S_IRUGO, - show_pwm_auto_temp, set_pwm_auto_temp, 1); -static SENSOR_DEVICE_ATTR(pwm3_auto_channels_temp, S_IWUSR | S_IRUGO, - show_pwm_auto_temp, set_pwm_auto_temp, 2); -static SENSOR_DEVICE_ATTR(pwm4_auto_channels_temp, S_IWUSR | S_IRUGO, - show_pwm_auto_temp, set_pwm_auto_temp, 3); +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point1_pwm, pwm_min, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point1_pwm, pwm_min, 1); +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point1_pwm, pwm_min, 2); +static SENSOR_DEVICE_ATTR_RW(pwm4_auto_point1_pwm, pwm_min, 3); + +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point2_pwm, pwm_max, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point2_pwm, pwm_max, 1); +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point2_pwm, pwm_max, 2); +static SENSOR_DEVICE_ATTR_RW(pwm4_auto_point2_pwm, pwm_max, 3); + +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point1_temp, pwm_tmin, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point1_temp, pwm_tmin, 1); +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point1_temp, pwm_tmin, 2); +static SENSOR_DEVICE_ATTR_RW(pwm4_auto_point1_temp, pwm_tmin, 3); + +static SENSOR_DEVICE_ATTR_RO(pwm1_auto_point2_temp, pwm_tmax, 0); +static SENSOR_DEVICE_ATTR_RO(pwm2_auto_point2_temp, pwm_tmax, 1); +static SENSOR_DEVICE_ATTR_RO(pwm3_auto_point2_temp, pwm_tmax, 2); +static SENSOR_DEVICE_ATTR_RO(pwm4_auto_point2_temp, pwm_tmax, 3); + +static SENSOR_DEVICE_ATTR_RW(pwm1_enable, pwm_auto, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2_enable, pwm_auto, 1); +static SENSOR_DEVICE_ATTR_RW(pwm3_enable, pwm_auto, 2); +static SENSOR_DEVICE_ATTR_RW(pwm4_enable, pwm_auto, 3); + +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_channels_temp, pwm_auto_temp, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_channels_temp, pwm_auto_temp, 1); +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_channels_temp, pwm_auto_temp, 2); +static SENSOR_DEVICE_ATTR_RW(pwm4_auto_channels_temp, pwm_auto_temp, 3); static struct attribute *adt7470_attrs[] = { &dev_attr_alarm_mask.attr, -- cgit v1.2.3 From c24f9ba9adfb0de712da83c626355da29a9e5462 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:02 -0800 Subject: hwmon: (adt7475) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/adt7475.c | 308 ++++++++++++++++++++---------------------------- 1 file changed, 126 insertions(+), 182 deletions(-) diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c index f4c7516eb989..0dbb8df74e44 100644 --- a/drivers/hwmon/adt7475.c +++ b/drivers/hwmon/adt7475.c @@ -322,7 +322,7 @@ static void adt7475_write_word(struct i2c_client *client, int reg, u16 val) i2c_smbus_write_byte_data(client, reg, val & 0xFF); } -static ssize_t show_voltage(struct device *dev, struct device_attribute *attr, +static ssize_t voltage_show(struct device *dev, struct device_attribute *attr, char *buf) { struct adt7475_data *data = adt7475_update_device(dev); @@ -343,8 +343,9 @@ static ssize_t show_voltage(struct device *dev, struct device_attribute *attr, } } -static ssize_t set_voltage(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t voltage_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t count) { struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); @@ -380,7 +381,7 @@ static ssize_t set_voltage(struct device *dev, struct device_attribute *attr, return count; } -static ssize_t show_temp(struct device *dev, struct device_attribute *attr, +static ssize_t temp_show(struct device *dev, struct device_attribute *attr, char *buf) { struct adt7475_data *data = adt7475_update_device(dev); @@ -438,8 +439,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%d\n", out); } -static ssize_t set_temp(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t temp_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); struct i2c_client *client = to_i2c_client(dev); @@ -540,8 +541,8 @@ static const int ad7475_st_map[] = { 37500, 18800, 12500, 7500, 4700, 3100, 1600, 800, }; -static ssize_t show_temp_st(struct device *dev, struct device_attribute *attr, - char *buf) +static ssize_t temp_st_show(struct device *dev, struct device_attribute *attr, + char *buf) { struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); struct i2c_client *client = to_i2c_client(dev); @@ -567,8 +568,9 @@ static ssize_t show_temp_st(struct device *dev, struct device_attribute *attr, return sprintf(buf, "0\n"); } -static ssize_t set_temp_st(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t temp_st_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t count) { struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); struct i2c_client *client = to_i2c_client(dev); @@ -627,7 +629,7 @@ static const int autorange_table[] = { 53330, 80000 }; -static ssize_t show_point2(struct device *dev, struct device_attribute *attr, +static ssize_t point2_show(struct device *dev, struct device_attribute *attr, char *buf) { struct adt7475_data *data = adt7475_update_device(dev); @@ -645,8 +647,8 @@ static ssize_t show_point2(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%d\n", val + autorange_table[out]); } -static ssize_t set_point2(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t point2_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct i2c_client *client = to_i2c_client(dev); struct adt7475_data *data = i2c_get_clientdata(client); @@ -688,7 +690,7 @@ static ssize_t set_point2(struct device *dev, struct device_attribute *attr, return count; } -static ssize_t show_tach(struct device *dev, struct device_attribute *attr, +static ssize_t tach_show(struct device *dev, struct device_attribute *attr, char *buf) { struct adt7475_data *data = adt7475_update_device(dev); @@ -706,8 +708,8 @@ static ssize_t show_tach(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%d\n", out); } -static ssize_t set_tach(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t tach_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); @@ -729,7 +731,7 @@ static ssize_t set_tach(struct device *dev, struct device_attribute *attr, return count; } -static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, +static ssize_t pwm_show(struct device *dev, struct device_attribute *attr, char *buf) { struct adt7475_data *data = adt7475_update_device(dev); @@ -741,7 +743,7 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%d\n", data->pwm[sattr->nr][sattr->index]); } -static ssize_t show_pwmchan(struct device *dev, struct device_attribute *attr, +static ssize_t pwmchan_show(struct device *dev, struct device_attribute *attr, char *buf) { struct adt7475_data *data = adt7475_update_device(dev); @@ -753,7 +755,7 @@ static ssize_t show_pwmchan(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%d\n", data->pwmchan[sattr->index]); } -static ssize_t show_pwmctrl(struct device *dev, struct device_attribute *attr, +static ssize_t pwmctrl_show(struct device *dev, struct device_attribute *attr, char *buf) { struct adt7475_data *data = adt7475_update_device(dev); @@ -765,8 +767,8 @@ static ssize_t show_pwmctrl(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%d\n", data->pwmctl[sattr->index]); } -static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t pwm_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); @@ -815,7 +817,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, return count; } -static ssize_t show_stall_disable(struct device *dev, +static ssize_t stall_disable_show(struct device *dev, struct device_attribute *attr, char *buf) { struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); @@ -826,9 +828,9 @@ static ssize_t show_stall_disable(struct device *dev, return sprintf(buf, "%d\n", !!(data->enh_acoustics[0] & mask)); } -static ssize_t set_stall_disable(struct device *dev, - struct device_attribute *attr, const char *buf, - size_t count) +static ssize_t stall_disable_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); struct i2c_client *client = to_i2c_client(dev); @@ -910,8 +912,9 @@ static int hw_set_pwm(struct i2c_client *client, int index, return 0; } -static ssize_t set_pwmchan(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t pwmchan_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t count) { struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); struct i2c_client *client = to_i2c_client(dev); @@ -933,8 +936,9 @@ static ssize_t set_pwmchan(struct device *dev, struct device_attribute *attr, return count; } -static ssize_t set_pwmctrl(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t pwmctrl_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t count) { struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); struct i2c_client *client = to_i2c_client(dev); @@ -961,7 +965,7 @@ static const int pwmfreq_table[] = { 11, 14, 22, 29, 35, 44, 58, 88, 22500 }; -static ssize_t show_pwmfreq(struct device *dev, struct device_attribute *attr, +static ssize_t pwmfreq_show(struct device *dev, struct device_attribute *attr, char *buf) { struct adt7475_data *data = adt7475_update_device(dev); @@ -976,8 +980,9 @@ static ssize_t show_pwmfreq(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%d\n", pwmfreq_table[idx]); } -static ssize_t set_pwmfreq(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t pwmfreq_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t count) { struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); struct i2c_client *client = to_i2c_client(dev); @@ -1074,156 +1079,95 @@ static ssize_t cpu0_vid_show(struct device *dev, return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); } -static SENSOR_DEVICE_ATTR_2(in0_input, S_IRUGO, show_voltage, NULL, INPUT, 0); -static SENSOR_DEVICE_ATTR_2(in0_max, S_IRUGO | S_IWUSR, show_voltage, - set_voltage, MAX, 0); -static SENSOR_DEVICE_ATTR_2(in0_min, S_IRUGO | S_IWUSR, show_voltage, - set_voltage, MIN, 0); -static SENSOR_DEVICE_ATTR_2(in0_alarm, S_IRUGO, show_voltage, NULL, ALARM, 0); -static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, show_voltage, NULL, INPUT, 1); -static SENSOR_DEVICE_ATTR_2(in1_max, S_IRUGO | S_IWUSR, show_voltage, - set_voltage, MAX, 1); -static SENSOR_DEVICE_ATTR_2(in1_min, S_IRUGO | S_IWUSR, show_voltage, - set_voltage, MIN, 1); -static SENSOR_DEVICE_ATTR_2(in1_alarm, S_IRUGO, show_voltage, NULL, ALARM, 1); -static SENSOR_DEVICE_ATTR_2(in2_input, S_IRUGO, show_voltage, NULL, INPUT, 2); -static SENSOR_DEVICE_ATTR_2(in2_max, S_IRUGO | S_IWUSR, show_voltage, - set_voltage, MAX, 2); -static SENSOR_DEVICE_ATTR_2(in2_min, S_IRUGO | S_IWUSR, show_voltage, - set_voltage, MIN, 2); -static SENSOR_DEVICE_ATTR_2(in2_alarm, S_IRUGO, show_voltage, NULL, ALARM, 2); -static SENSOR_DEVICE_ATTR_2(in3_input, S_IRUGO, show_voltage, NULL, INPUT, 3); -static SENSOR_DEVICE_ATTR_2(in3_max, S_IRUGO | S_IWUSR, show_voltage, - set_voltage, MAX, 3); -static SENSOR_DEVICE_ATTR_2(in3_min, S_IRUGO | S_IWUSR, show_voltage, - set_voltage, MIN, 3); -static SENSOR_DEVICE_ATTR_2(in3_alarm, S_IRUGO, show_voltage, NULL, ALARM, 3); -static SENSOR_DEVICE_ATTR_2(in4_input, S_IRUGO, show_voltage, NULL, INPUT, 4); -static SENSOR_DEVICE_ATTR_2(in4_max, S_IRUGO | S_IWUSR, show_voltage, - set_voltage, MAX, 4); -static SENSOR_DEVICE_ATTR_2(in4_min, S_IRUGO | S_IWUSR, show_voltage, - set_voltage, MIN, 4); -static SENSOR_DEVICE_ATTR_2(in4_alarm, S_IRUGO, show_voltage, NULL, ALARM, 8); -static SENSOR_DEVICE_ATTR_2(in5_input, S_IRUGO, show_voltage, NULL, INPUT, 5); -static SENSOR_DEVICE_ATTR_2(in5_max, S_IRUGO | S_IWUSR, show_voltage, - set_voltage, MAX, 5); -static SENSOR_DEVICE_ATTR_2(in5_min, S_IRUGO | S_IWUSR, show_voltage, - set_voltage, MIN, 5); -static SENSOR_DEVICE_ATTR_2(in5_alarm, S_IRUGO, show_voltage, NULL, ALARM, 31); -static SENSOR_DEVICE_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, INPUT, 0); -static SENSOR_DEVICE_ATTR_2(temp1_alarm, S_IRUGO, show_temp, NULL, ALARM, 0); -static SENSOR_DEVICE_ATTR_2(temp1_fault, S_IRUGO, show_temp, NULL, FAULT, 0); -static SENSOR_DEVICE_ATTR_2(temp1_max, S_IRUGO | S_IWUSR, show_temp, set_temp, - MAX, 0); -static SENSOR_DEVICE_ATTR_2(temp1_min, S_IRUGO | S_IWUSR, show_temp, set_temp, - MIN, 0); -static SENSOR_DEVICE_ATTR_2(temp1_offset, S_IRUGO | S_IWUSR, show_temp, - set_temp, OFFSET, 0); -static SENSOR_DEVICE_ATTR_2(temp1_auto_point1_temp, S_IRUGO | S_IWUSR, - show_temp, set_temp, AUTOMIN, 0); -static SENSOR_DEVICE_ATTR_2(temp1_auto_point2_temp, S_IRUGO | S_IWUSR, - show_point2, set_point2, 0, 0); -static SENSOR_DEVICE_ATTR_2(temp1_crit, S_IRUGO | S_IWUSR, show_temp, set_temp, - THERM, 0); -static SENSOR_DEVICE_ATTR_2(temp1_crit_hyst, S_IRUGO | S_IWUSR, show_temp, - set_temp, HYSTERSIS, 0); -static SENSOR_DEVICE_ATTR_2(temp1_smoothing, S_IRUGO | S_IWUSR, show_temp_st, - set_temp_st, 0, 0); -static SENSOR_DEVICE_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, INPUT, 1); -static SENSOR_DEVICE_ATTR_2(temp2_alarm, S_IRUGO, show_temp, NULL, ALARM, 1); -static SENSOR_DEVICE_ATTR_2(temp2_max, S_IRUGO | S_IWUSR, show_temp, set_temp, - MAX, 1); -static SENSOR_DEVICE_ATTR_2(temp2_min, S_IRUGO | S_IWUSR, show_temp, set_temp, - MIN, 1); -static SENSOR_DEVICE_ATTR_2(temp2_offset, S_IRUGO | S_IWUSR, show_temp, - set_temp, OFFSET, 1); -static SENSOR_DEVICE_ATTR_2(temp2_auto_point1_temp, S_IRUGO | S_IWUSR, - show_temp, set_temp, AUTOMIN, 1); -static SENSOR_DEVICE_ATTR_2(temp2_auto_point2_temp, S_IRUGO | S_IWUSR, - show_point2, set_point2, 0, 1); -static SENSOR_DEVICE_ATTR_2(temp2_crit, S_IRUGO | S_IWUSR, show_temp, set_temp, - THERM, 1); -static SENSOR_DEVICE_ATTR_2(temp2_crit_hyst, S_IRUGO | S_IWUSR, show_temp, - set_temp, HYSTERSIS, 1); -static SENSOR_DEVICE_ATTR_2(temp2_smoothing, S_IRUGO | S_IWUSR, show_temp_st, - set_temp_st, 0, 1); -static SENSOR_DEVICE_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, INPUT, 2); -static SENSOR_DEVICE_ATTR_2(temp3_alarm, S_IRUGO, show_temp, NULL, ALARM, 2); -static SENSOR_DEVICE_ATTR_2(temp3_fault, S_IRUGO, show_temp, NULL, FAULT, 2); -static SENSOR_DEVICE_ATTR_2(temp3_max, S_IRUGO | S_IWUSR, show_temp, set_temp, - MAX, 2); -static SENSOR_DEVICE_ATTR_2(temp3_min, S_IRUGO | S_IWUSR, show_temp, set_temp, - MIN, 2); -static SENSOR_DEVICE_ATTR_2(temp3_offset, S_IRUGO | S_IWUSR, show_temp, - set_temp, OFFSET, 2); -static SENSOR_DEVICE_ATTR_2(temp3_auto_point1_temp, S_IRUGO | S_IWUSR, - show_temp, set_temp, AUTOMIN, 2); -static SENSOR_DEVICE_ATTR_2(temp3_auto_point2_temp, S_IRUGO | S_IWUSR, - show_point2, set_point2, 0, 2); -static SENSOR_DEVICE_ATTR_2(temp3_crit, S_IRUGO | S_IWUSR, show_temp, set_temp, - THERM, 2); -static SENSOR_DEVICE_ATTR_2(temp3_crit_hyst, S_IRUGO | S_IWUSR, show_temp, - set_temp, HYSTERSIS, 2); -static SENSOR_DEVICE_ATTR_2(temp3_smoothing, S_IRUGO | S_IWUSR, show_temp_st, - set_temp_st, 0, 2); -static SENSOR_DEVICE_ATTR_2(fan1_input, S_IRUGO, show_tach, NULL, INPUT, 0); -static SENSOR_DEVICE_ATTR_2(fan1_min, S_IRUGO | S_IWUSR, show_tach, set_tach, - MIN, 0); -static SENSOR_DEVICE_ATTR_2(fan1_alarm, S_IRUGO, show_tach, NULL, ALARM, 0); -static SENSOR_DEVICE_ATTR_2(fan2_input, S_IRUGO, show_tach, NULL, INPUT, 1); -static SENSOR_DEVICE_ATTR_2(fan2_min, S_IRUGO | S_IWUSR, show_tach, set_tach, - MIN, 1); -static SENSOR_DEVICE_ATTR_2(fan2_alarm, S_IRUGO, show_tach, NULL, ALARM, 1); -static SENSOR_DEVICE_ATTR_2(fan3_input, S_IRUGO, show_tach, NULL, INPUT, 2); -static SENSOR_DEVICE_ATTR_2(fan3_min, S_IRUGO | S_IWUSR, show_tach, set_tach, - MIN, 2); -static SENSOR_DEVICE_ATTR_2(fan3_alarm, S_IRUGO, show_tach, NULL, ALARM, 2); -static SENSOR_DEVICE_ATTR_2(fan4_input, S_IRUGO, show_tach, NULL, INPUT, 3); -static SENSOR_DEVICE_ATTR_2(fan4_min, S_IRUGO | S_IWUSR, show_tach, set_tach, - MIN, 3); -static SENSOR_DEVICE_ATTR_2(fan4_alarm, S_IRUGO, show_tach, NULL, ALARM, 3); -static SENSOR_DEVICE_ATTR_2(pwm1, S_IRUGO | S_IWUSR, show_pwm, set_pwm, INPUT, - 0); -static SENSOR_DEVICE_ATTR_2(pwm1_freq, S_IRUGO | S_IWUSR, show_pwmfreq, - set_pwmfreq, INPUT, 0); -static SENSOR_DEVICE_ATTR_2(pwm1_enable, S_IRUGO | S_IWUSR, show_pwmctrl, - set_pwmctrl, INPUT, 0); -static SENSOR_DEVICE_ATTR_2(pwm1_auto_channels_temp, S_IRUGO | S_IWUSR, - show_pwmchan, set_pwmchan, INPUT, 0); -static SENSOR_DEVICE_ATTR_2(pwm1_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm, - set_pwm, MIN, 0); -static SENSOR_DEVICE_ATTR_2(pwm1_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm, - set_pwm, MAX, 0); -static SENSOR_DEVICE_ATTR_2(pwm1_stall_disable, S_IRUGO | S_IWUSR, - show_stall_disable, set_stall_disable, 0, 0); -static SENSOR_DEVICE_ATTR_2(pwm2, S_IRUGO | S_IWUSR, show_pwm, set_pwm, INPUT, - 1); -static SENSOR_DEVICE_ATTR_2(pwm2_freq, S_IRUGO | S_IWUSR, show_pwmfreq, - set_pwmfreq, INPUT, 1); -static SENSOR_DEVICE_ATTR_2(pwm2_enable, S_IRUGO | S_IWUSR, show_pwmctrl, - set_pwmctrl, INPUT, 1); -static SENSOR_DEVICE_ATTR_2(pwm2_auto_channels_temp, S_IRUGO | S_IWUSR, - show_pwmchan, set_pwmchan, INPUT, 1); -static SENSOR_DEVICE_ATTR_2(pwm2_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm, - set_pwm, MIN, 1); -static SENSOR_DEVICE_ATTR_2(pwm2_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm, - set_pwm, MAX, 1); -static SENSOR_DEVICE_ATTR_2(pwm2_stall_disable, S_IRUGO | S_IWUSR, - show_stall_disable, set_stall_disable, 0, 1); -static SENSOR_DEVICE_ATTR_2(pwm3, S_IRUGO | S_IWUSR, show_pwm, set_pwm, INPUT, - 2); -static SENSOR_DEVICE_ATTR_2(pwm3_freq, S_IRUGO | S_IWUSR, show_pwmfreq, - set_pwmfreq, INPUT, 2); -static SENSOR_DEVICE_ATTR_2(pwm3_enable, S_IRUGO | S_IWUSR, show_pwmctrl, - set_pwmctrl, INPUT, 2); -static SENSOR_DEVICE_ATTR_2(pwm3_auto_channels_temp, S_IRUGO | S_IWUSR, - show_pwmchan, set_pwmchan, INPUT, 2); -static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm, - set_pwm, MIN, 2); -static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm, - set_pwm, MAX, 2); -static SENSOR_DEVICE_ATTR_2(pwm3_stall_disable, S_IRUGO | S_IWUSR, - show_stall_disable, set_stall_disable, 0, 2); +static SENSOR_DEVICE_ATTR_2_RO(in0_input, voltage, INPUT, 0); +static SENSOR_DEVICE_ATTR_2_RW(in0_max, voltage, MAX, 0); +static SENSOR_DEVICE_ATTR_2_RW(in0_min, voltage, MIN, 0); +static SENSOR_DEVICE_ATTR_2_RO(in0_alarm, voltage, ALARM, 0); +static SENSOR_DEVICE_ATTR_2_RO(in1_input, voltage, INPUT, 1); +static SENSOR_DEVICE_ATTR_2_RW(in1_max, voltage, MAX, 1); +static SENSOR_DEVICE_ATTR_2_RW(in1_min, voltage, MIN, 1); +static SENSOR_DEVICE_ATTR_2_RO(in1_alarm, voltage, ALARM, 1); +static SENSOR_DEVICE_ATTR_2_RO(in2_input, voltage, INPUT, 2); +static SENSOR_DEVICE_ATTR_2_RW(in2_max, voltage, MAX, 2); +static SENSOR_DEVICE_ATTR_2_RW(in2_min, voltage, MIN, 2); +static SENSOR_DEVICE_ATTR_2_RO(in2_alarm, voltage, ALARM, 2); +static SENSOR_DEVICE_ATTR_2_RO(in3_input, voltage, INPUT, 3); +static SENSOR_DEVICE_ATTR_2_RW(in3_max, voltage, MAX, 3); +static SENSOR_DEVICE_ATTR_2_RW(in3_min, voltage, MIN, 3); +static SENSOR_DEVICE_ATTR_2_RO(in3_alarm, voltage, ALARM, 3); +static SENSOR_DEVICE_ATTR_2_RO(in4_input, voltage, INPUT, 4); +static SENSOR_DEVICE_ATTR_2_RW(in4_max, voltage, MAX, 4); +static SENSOR_DEVICE_ATTR_2_RW(in4_min, voltage, MIN, 4); +static SENSOR_DEVICE_ATTR_2_RO(in4_alarm, voltage, ALARM, 8); +static SENSOR_DEVICE_ATTR_2_RO(in5_input, voltage, INPUT, 5); +static SENSOR_DEVICE_ATTR_2_RW(in5_max, voltage, MAX, 5); +static SENSOR_DEVICE_ATTR_2_RW(in5_min, voltage, MIN, 5); +static SENSOR_DEVICE_ATTR_2_RO(in5_alarm, voltage, ALARM, 31); +static SENSOR_DEVICE_ATTR_2_RO(temp1_input, temp, INPUT, 0); +static SENSOR_DEVICE_ATTR_2_RO(temp1_alarm, temp, ALARM, 0); +static SENSOR_DEVICE_ATTR_2_RO(temp1_fault, temp, FAULT, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp1_max, temp, MAX, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp1_min, temp, MIN, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp1_offset, temp, OFFSET, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp1_auto_point1_temp, temp, AUTOMIN, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp1_auto_point2_temp, point2, 0, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp1_crit, temp, THERM, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp1_crit_hyst, temp, HYSTERSIS, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp1_smoothing, temp_st, 0, 0); +static SENSOR_DEVICE_ATTR_2_RO(temp2_input, temp, INPUT, 1); +static SENSOR_DEVICE_ATTR_2_RO(temp2_alarm, temp, ALARM, 1); +static SENSOR_DEVICE_ATTR_2_RW(temp2_max, temp, MAX, 1); +static SENSOR_DEVICE_ATTR_2_RW(temp2_min, temp, MIN, 1); +static SENSOR_DEVICE_ATTR_2_RW(temp2_offset, temp, OFFSET, 1); +static SENSOR_DEVICE_ATTR_2_RW(temp2_auto_point1_temp, temp, AUTOMIN, 1); +static SENSOR_DEVICE_ATTR_2_RW(temp2_auto_point2_temp, point2, 0, 1); +static SENSOR_DEVICE_ATTR_2_RW(temp2_crit, temp, THERM, 1); +static SENSOR_DEVICE_ATTR_2_RW(temp2_crit_hyst, temp, HYSTERSIS, 1); +static SENSOR_DEVICE_ATTR_2_RW(temp2_smoothing, temp_st, 0, 1); +static SENSOR_DEVICE_ATTR_2_RO(temp3_input, temp, INPUT, 2); +static SENSOR_DEVICE_ATTR_2_RO(temp3_alarm, temp, ALARM, 2); +static SENSOR_DEVICE_ATTR_2_RO(temp3_fault, temp, FAULT, 2); +static SENSOR_DEVICE_ATTR_2_RW(temp3_max, temp, MAX, 2); +static SENSOR_DEVICE_ATTR_2_RW(temp3_min, temp, MIN, 2); +static SENSOR_DEVICE_ATTR_2_RW(temp3_offset, temp, OFFSET, 2); +static SENSOR_DEVICE_ATTR_2_RW(temp3_auto_point1_temp, temp, AUTOMIN, 2); +static SENSOR_DEVICE_ATTR_2_RW(temp3_auto_point2_temp, point2, 0, 2); +static SENSOR_DEVICE_ATTR_2_RW(temp3_crit, temp, THERM, 2); +static SENSOR_DEVICE_ATTR_2_RW(temp3_crit_hyst, temp, HYSTERSIS, 2); +static SENSOR_DEVICE_ATTR_2_RW(temp3_smoothing, temp_st, 0, 2); +static SENSOR_DEVICE_ATTR_2_RO(fan1_input, tach, INPUT, 0); +static SENSOR_DEVICE_ATTR_2_RW(fan1_min, tach, MIN, 0); +static SENSOR_DEVICE_ATTR_2_RO(fan1_alarm, tach, ALARM, 0); +static SENSOR_DEVICE_ATTR_2_RO(fan2_input, tach, INPUT, 1); +static SENSOR_DEVICE_ATTR_2_RW(fan2_min, tach, MIN, 1); +static SENSOR_DEVICE_ATTR_2_RO(fan2_alarm, tach, ALARM, 1); +static SENSOR_DEVICE_ATTR_2_RO(fan3_input, tach, INPUT, 2); +static SENSOR_DEVICE_ATTR_2_RW(fan3_min, tach, MIN, 2); +static SENSOR_DEVICE_ATTR_2_RO(fan3_alarm, tach, ALARM, 2); +static SENSOR_DEVICE_ATTR_2_RO(fan4_input, tach, INPUT, 3); +static SENSOR_DEVICE_ATTR_2_RW(fan4_min, tach, MIN, 3); +static SENSOR_DEVICE_ATTR_2_RO(fan4_alarm, tach, ALARM, 3); +static SENSOR_DEVICE_ATTR_2_RW(pwm1, pwm, INPUT, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm1_freq, pwmfreq, INPUT, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm1_enable, pwmctrl, INPUT, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_channels_temp, pwmchan, INPUT, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point1_pwm, pwm, MIN, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point2_pwm, pwm, MAX, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm1_stall_disable, stall_disable, 0, 0); +static SENSOR_DEVICE_ATTR_2_RW(pwm2, pwm, INPUT, 1); +static SENSOR_DEVICE_ATTR_2_RW(pwm2_freq, pwmfreq, INPUT, 1); +static SENSOR_DEVICE_ATTR_2_RW(pwm2_enable, pwmctrl, INPUT, 1); +static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_channels_temp, pwmchan, INPUT, 1); +static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point1_pwm, pwm, MIN, 1); +static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point2_pwm, pwm, MAX, 1); +static SENSOR_DEVICE_ATTR_2_RW(pwm2_stall_disable, stall_disable, 0, 1); +static SENSOR_DEVICE_ATTR_2_RW(pwm3, pwm, INPUT, 2); +static SENSOR_DEVICE_ATTR_2_RW(pwm3_freq, pwmfreq, INPUT, 2); +static SENSOR_DEVICE_ATTR_2_RW(pwm3_enable, pwmctrl, INPUT, 2); +static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_channels_temp, pwmchan, INPUT, 2); +static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_point1_pwm, pwm, MIN, 2); +static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_point2_pwm, pwm, MAX, 2); +static SENSOR_DEVICE_ATTR_2_RW(pwm3_stall_disable, stall_disable, 0, 2); /* Non-standard name, might need revisiting */ static DEVICE_ATTR_RW(pwm_use_point2_pwm_at_crit); -- cgit v1.2.3 From f9fe9de0e62d02a1e64abfde55b1032f0d43aec8 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:02 -0800 Subject: hwmon: (adt7x10) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/adt7x10.c | 59 +++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/drivers/hwmon/adt7x10.c b/drivers/hwmon/adt7x10.c index 0f538f8be6bf..2ab5c2519ff0 100644 --- a/drivers/hwmon/adt7x10.c +++ b/drivers/hwmon/adt7x10.c @@ -230,9 +230,8 @@ static int ADT7X10_REG_TO_TEMP(struct adt7x10_data *data, s16 reg) /* sysfs attributes for hwmon */ -static ssize_t adt7x10_show_temp(struct device *dev, - struct device_attribute *da, - char *buf) +static ssize_t adt7x10_temp_show(struct device *dev, + struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct adt7x10_data *data = dev_get_drvdata(dev); @@ -250,9 +249,9 @@ static ssize_t adt7x10_show_temp(struct device *dev, data->temp[attr->index])); } -static ssize_t adt7x10_set_temp(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) +static ssize_t adt7x10_temp_store(struct device *dev, + struct device_attribute *da, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct adt7x10_data *data = dev_get_drvdata(dev); @@ -273,9 +272,8 @@ static ssize_t adt7x10_set_temp(struct device *dev, return count; } -static ssize_t adt7x10_show_t_hyst(struct device *dev, - struct device_attribute *da, - char *buf) +static ssize_t adt7x10_t_hyst_show(struct device *dev, + struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct adt7x10_data *data = dev_get_drvdata(dev); @@ -294,9 +292,9 @@ static ssize_t adt7x10_show_t_hyst(struct device *dev, ADT7X10_REG_TO_TEMP(data, data->temp[nr]) - hyst); } -static ssize_t adt7x10_set_t_hyst(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) +static ssize_t adt7x10_t_hyst_store(struct device *dev, + struct device_attribute *da, + const char *buf, size_t count) { struct adt7x10_data *data = dev_get_drvdata(dev); int limit, ret; @@ -317,9 +315,8 @@ static ssize_t adt7x10_set_t_hyst(struct device *dev, return count; } -static ssize_t adt7x10_show_alarm(struct device *dev, - struct device_attribute *da, - char *buf) +static ssize_t adt7x10_alarm_show(struct device *dev, + struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); int ret; @@ -339,25 +336,19 @@ static ssize_t name_show(struct device *dev, struct device_attribute *da, return sprintf(buf, "%s\n", data->name); } -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, adt7x10_show_temp, NULL, 0); -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, - adt7x10_show_temp, adt7x10_set_temp, 1); -static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, - adt7x10_show_temp, adt7x10_set_temp, 2); -static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, - adt7x10_show_temp, adt7x10_set_temp, 3); -static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, - adt7x10_show_t_hyst, adt7x10_set_t_hyst, 1); -static SENSOR_DEVICE_ATTR(temp1_min_hyst, S_IRUGO, - adt7x10_show_t_hyst, NULL, 2); -static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, - adt7x10_show_t_hyst, NULL, 3); -static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, adt7x10_show_alarm, - NULL, ADT7X10_STAT_T_LOW); -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, adt7x10_show_alarm, - NULL, ADT7X10_STAT_T_HIGH); -static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, adt7x10_show_alarm, - NULL, ADT7X10_STAT_T_CRIT); +static SENSOR_DEVICE_ATTR_RO(temp1_input, adt7x10_temp, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_max, adt7x10_temp, 1); +static SENSOR_DEVICE_ATTR_RW(temp1_min, adt7x10_temp, 2); +static SENSOR_DEVICE_ATTR_RW(temp1_crit, adt7x10_temp, 3); +static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, adt7x10_t_hyst, 1); +static SENSOR_DEVICE_ATTR_RO(temp1_min_hyst, adt7x10_t_hyst, 2); +static SENSOR_DEVICE_ATTR_RO(temp1_crit_hyst, adt7x10_t_hyst, 3); +static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, adt7x10_alarm, + ADT7X10_STAT_T_LOW); +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, adt7x10_alarm, + ADT7X10_STAT_T_HIGH); +static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, adt7x10_alarm, + ADT7X10_STAT_T_CRIT); static DEVICE_ATTR_RO(name); static struct attribute *adt7x10_attributes[] = { -- cgit v1.2.3 From a7818350f60e69737fa053f6b1fb9441bc4d11a6 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:02 -0800 Subject: hwmon: (amc6821) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/amc6821.c | 229 ++++++++++++++++++------------------------------ 1 file changed, 87 insertions(+), 142 deletions(-) diff --git a/drivers/hwmon/amc6821.c b/drivers/hwmon/amc6821.c index 46b4e35fd555..2cc5d3c63a4d 100644 --- a/drivers/hwmon/amc6821.c +++ b/drivers/hwmon/amc6821.c @@ -44,10 +44,10 @@ static const unsigned short normal_i2c[] = {0x18, 0x19, 0x1a, 0x2c, 0x2d, 0x2e, */ static int pwminv; /*Inverted PWM output. */ -module_param(pwminv, int, S_IRUGO); +module_param(pwminv, int, 0444); static int init = 1; /*Power-on initialization.*/ -module_param(init, int, S_IRUGO); +module_param(init, int, 0444); enum chips { amc6821 }; @@ -277,10 +277,8 @@ static struct amc6821_data *amc6821_update_device(struct device *dev) return data; } -static ssize_t get_temp( - struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t temp_show(struct device *dev, struct device_attribute *devattr, + char *buf) { struct amc6821_data *data = amc6821_update_device(dev); int ix = to_sensor_dev_attr(devattr)->index; @@ -288,11 +286,8 @@ static ssize_t get_temp( return sprintf(buf, "%d\n", data->temp[ix] * 1000); } -static ssize_t set_temp( - struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t count) +static ssize_t temp_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct amc6821_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; @@ -314,10 +309,8 @@ static ssize_t set_temp( return count; } -static ssize_t get_temp_alarm( - struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t temp_alarm_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct amc6821_data *data = amc6821_update_device(dev); int ix = to_sensor_dev_attr(devattr)->index; @@ -352,10 +345,8 @@ static ssize_t get_temp_alarm( return sprintf(buf, "0"); } -static ssize_t get_temp2_fault( - struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t temp2_fault_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct amc6821_data *data = amc6821_update_device(dev); if (data->stat1 & AMC6821_STAT1_RTF) @@ -364,20 +355,16 @@ static ssize_t get_temp2_fault( return sprintf(buf, "0"); } -static ssize_t get_pwm1( - struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t pwm1_show(struct device *dev, struct device_attribute *devattr, + char *buf) { struct amc6821_data *data = amc6821_update_device(dev); return sprintf(buf, "%d\n", data->pwm1); } -static ssize_t set_pwm1( - struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) +static ssize_t pwm1_store(struct device *dev, + struct device_attribute *devattr, const char *buf, + size_t count) { struct amc6821_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; @@ -393,20 +380,16 @@ static ssize_t set_pwm1( return count; } -static ssize_t get_pwm1_enable( - struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t pwm1_enable_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct amc6821_data *data = amc6821_update_device(dev); return sprintf(buf, "%d\n", data->pwm1_enable); } -static ssize_t set_pwm1_enable( - struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t count) +static ssize_t pwm1_enable_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { struct amc6821_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; @@ -451,19 +434,17 @@ unlock: return count; } -static ssize_t get_pwm1_auto_channels_temp( - struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t pwm1_auto_channels_temp_show(struct device *dev, + struct device_attribute *devattr, + char *buf) { struct amc6821_data *data = amc6821_update_device(dev); return sprintf(buf, "%d\n", data->pwm1_auto_channels_temp); } -static ssize_t get_temp_auto_point_temp( - struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t temp_auto_point_temp_show(struct device *dev, + struct device_attribute *devattr, + char *buf) { int ix = to_sensor_dev_attr_2(devattr)->index; int nr = to_sensor_dev_attr_2(devattr)->nr; @@ -481,10 +462,9 @@ static ssize_t get_temp_auto_point_temp( } } -static ssize_t get_pwm1_auto_point_pwm( - struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t pwm1_auto_point_pwm_show(struct device *dev, + struct device_attribute *devattr, + char *buf) { int ix = to_sensor_dev_attr(devattr)->index; struct amc6821_data *data = amc6821_update_device(dev); @@ -513,11 +493,9 @@ static inline ssize_t set_slope_register(struct i2c_client *client, return 0; } -static ssize_t set_temp_auto_point_temp( - struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t count) +static ssize_t temp_auto_point_temp_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { struct amc6821_data *data = amc6821_update_device(dev); struct i2c_client *client = data->client; @@ -586,11 +564,9 @@ EXIT: return count; } -static ssize_t set_pwm1_auto_point_pwm( - struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t count) +static ssize_t pwm1_auto_point_pwm_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { struct amc6821_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; @@ -626,10 +602,8 @@ EXIT: return count; } -static ssize_t get_fan( - struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t fan_show(struct device *dev, struct device_attribute *devattr, + char *buf) { struct amc6821_data *data = amc6821_update_device(dev); int ix = to_sensor_dev_attr(devattr)->index; @@ -638,10 +612,8 @@ static ssize_t get_fan( return sprintf(buf, "%d\n", (int)(6000000 / data->fan[ix])); } -static ssize_t get_fan1_fault( - struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t fan1_fault_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct amc6821_data *data = amc6821_update_device(dev); if (data->stat1 & AMC6821_STAT1_FANS) @@ -650,10 +622,8 @@ static ssize_t get_fan1_fault( return sprintf(buf, "0"); } -static ssize_t set_fan( - struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t fan_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct amc6821_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; @@ -682,19 +652,16 @@ EXIT: return count; } -static ssize_t get_fan1_div( - struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t fan1_div_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct amc6821_data *data = amc6821_update_device(dev); return sprintf(buf, "%d\n", data->fan1_div); } -static ssize_t set_fan1_div( - struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t fan1_div_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t count) { struct amc6821_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; @@ -734,69 +701,47 @@ EXIT: return count; } -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, - get_temp, NULL, IDX_TEMP1_INPUT); -static SENSOR_DEVICE_ATTR(temp1_min, S_IRUGO | S_IWUSR, get_temp, - set_temp, IDX_TEMP1_MIN); -static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, get_temp, - set_temp, IDX_TEMP1_MAX); -static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO | S_IWUSR, get_temp, - set_temp, IDX_TEMP1_CRIT); -static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, - get_temp_alarm, NULL, IDX_TEMP1_MIN); -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, - get_temp_alarm, NULL, IDX_TEMP1_MAX); -static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, - get_temp_alarm, NULL, IDX_TEMP1_CRIT); -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, - get_temp, NULL, IDX_TEMP2_INPUT); -static SENSOR_DEVICE_ATTR(temp2_min, S_IRUGO | S_IWUSR, get_temp, - set_temp, IDX_TEMP2_MIN); -static SENSOR_DEVICE_ATTR(temp2_max, S_IRUGO | S_IWUSR, get_temp, - set_temp, IDX_TEMP2_MAX); -static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO | S_IWUSR, get_temp, - set_temp, IDX_TEMP2_CRIT); -static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, - get_temp2_fault, NULL, 0); -static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, - get_temp_alarm, NULL, IDX_TEMP2_MIN); -static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, - get_temp_alarm, NULL, IDX_TEMP2_MAX); -static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, - get_temp_alarm, NULL, IDX_TEMP2_CRIT); -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, get_fan, NULL, IDX_FAN1_INPUT); -static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO | S_IWUSR, - get_fan, set_fan, IDX_FAN1_MIN); -static SENSOR_DEVICE_ATTR(fan1_max, S_IRUGO | S_IWUSR, - get_fan, set_fan, IDX_FAN1_MAX); -static SENSOR_DEVICE_ATTR(fan1_fault, S_IRUGO, get_fan1_fault, NULL, 0); -static SENSOR_DEVICE_ATTR(fan1_div, S_IRUGO | S_IWUSR, - get_fan1_div, set_fan1_div, 0); - -static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, get_pwm1, set_pwm1, 0); -static SENSOR_DEVICE_ATTR(pwm1_enable, S_IWUSR | S_IRUGO, - get_pwm1_enable, set_pwm1_enable, 0); -static SENSOR_DEVICE_ATTR(pwm1_auto_point1_pwm, S_IRUGO, - get_pwm1_auto_point_pwm, NULL, 0); -static SENSOR_DEVICE_ATTR(pwm1_auto_point2_pwm, S_IWUSR | S_IRUGO, - get_pwm1_auto_point_pwm, set_pwm1_auto_point_pwm, 1); -static SENSOR_DEVICE_ATTR(pwm1_auto_point3_pwm, S_IRUGO, - get_pwm1_auto_point_pwm, NULL, 2); -static SENSOR_DEVICE_ATTR(pwm1_auto_channels_temp, S_IRUGO, - get_pwm1_auto_channels_temp, NULL, 0); -static SENSOR_DEVICE_ATTR_2(temp1_auto_point1_temp, S_IRUGO, - get_temp_auto_point_temp, NULL, 1, 0); -static SENSOR_DEVICE_ATTR_2(temp1_auto_point2_temp, S_IWUSR | S_IRUGO, - get_temp_auto_point_temp, set_temp_auto_point_temp, 1, 1); -static SENSOR_DEVICE_ATTR_2(temp1_auto_point3_temp, S_IWUSR | S_IRUGO, - get_temp_auto_point_temp, set_temp_auto_point_temp, 1, 2); - -static SENSOR_DEVICE_ATTR_2(temp2_auto_point1_temp, S_IWUSR | S_IRUGO, - get_temp_auto_point_temp, set_temp_auto_point_temp, 2, 0); -static SENSOR_DEVICE_ATTR_2(temp2_auto_point2_temp, S_IWUSR | S_IRUGO, - get_temp_auto_point_temp, set_temp_auto_point_temp, 2, 1); -static SENSOR_DEVICE_ATTR_2(temp2_auto_point3_temp, S_IWUSR | S_IRUGO, - get_temp_auto_point_temp, set_temp_auto_point_temp, 2, 2); +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, IDX_TEMP1_INPUT); +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp, IDX_TEMP1_MIN); +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, IDX_TEMP1_MAX); +static SENSOR_DEVICE_ATTR_RW(temp1_crit, temp, IDX_TEMP1_CRIT); +static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, temp_alarm, IDX_TEMP1_MIN); +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, temp_alarm, IDX_TEMP1_MAX); +static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, temp_alarm, IDX_TEMP1_CRIT); +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, IDX_TEMP2_INPUT); +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp, IDX_TEMP2_MIN); +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp, IDX_TEMP2_MAX); +static SENSOR_DEVICE_ATTR_RW(temp2_crit, temp, IDX_TEMP2_CRIT); +static SENSOR_DEVICE_ATTR_RO(temp2_fault, temp2_fault, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_min_alarm, temp_alarm, IDX_TEMP2_MIN); +static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, temp_alarm, IDX_TEMP2_MAX); +static SENSOR_DEVICE_ATTR_RO(temp2_crit_alarm, temp_alarm, IDX_TEMP2_CRIT); +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, IDX_FAN1_INPUT); +static SENSOR_DEVICE_ATTR_RW(fan1_min, fan, IDX_FAN1_MIN); +static SENSOR_DEVICE_ATTR_RW(fan1_max, fan, IDX_FAN1_MAX); +static SENSOR_DEVICE_ATTR_RO(fan1_fault, fan1_fault, 0); +static SENSOR_DEVICE_ATTR_RW(fan1_div, fan1_div, 0); + +static SENSOR_DEVICE_ATTR_RW(pwm1, pwm1, 0); +static SENSOR_DEVICE_ATTR_RW(pwm1_enable, pwm1_enable, 0); +static SENSOR_DEVICE_ATTR_RO(pwm1_auto_point1_pwm, pwm1_auto_point_pwm, 0); +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point2_pwm, pwm1_auto_point_pwm, 1); +static SENSOR_DEVICE_ATTR_RO(pwm1_auto_point3_pwm, pwm1_auto_point_pwm, 2); +static SENSOR_DEVICE_ATTR_RO(pwm1_auto_channels_temp, pwm1_auto_channels_temp, + 0); +static SENSOR_DEVICE_ATTR_2_RO(temp1_auto_point1_temp, temp_auto_point_temp, + 1, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp1_auto_point2_temp, temp_auto_point_temp, + 1, 1); +static SENSOR_DEVICE_ATTR_2_RW(temp1_auto_point3_temp, temp_auto_point_temp, + 1, 2); + +static SENSOR_DEVICE_ATTR_2_RW(temp2_auto_point1_temp, temp_auto_point_temp, + 2, 0); +static SENSOR_DEVICE_ATTR_2_RW(temp2_auto_point2_temp, temp_auto_point_temp, + 2, 1); +static SENSOR_DEVICE_ATTR_2_RW(temp2_auto_point3_temp, temp_auto_point_temp, + 2, 2); static struct attribute *amc6821_attrs[] = { &sensor_dev_attr_temp1_input.dev_attr.attr, -- cgit v1.2.3 From 71ee4a400013ad187393b9cb32faee98d520516e Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:03 -0800 Subject: hwmon: (applesmc) Replace S_ with octal values Replace S_ with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Cc: Henrik Rydberg Signed-off-by: Guenter Roeck --- drivers/hwmon/applesmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c index 5c677ba44014..a24e8fa7fba8 100644 --- a/drivers/hwmon/applesmc.c +++ b/drivers/hwmon/applesmc.c @@ -1128,7 +1128,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num) attr = &node->sda.dev_attr.attr; sysfs_attr_init(attr); attr->name = node->name; - attr->mode = S_IRUGO | (grp->store ? S_IWUSR : 0); + attr->mode = 0444 | (grp->store ? 0200 : 0); ret = sysfs_create_file(&pdev->dev.kobj, attr); if (ret) { attr->name = NULL; -- cgit v1.2.3 From e98dd5388b24f8516a058e83a251681dbccfb0c0 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:03 -0800 Subject: hwmon: (aspeed-pwm-tacho) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Cc: Joel Stanley Cc: Andrew Jeffery Tested-by: Joel Stanley Signed-off-by: Guenter Roeck --- drivers/hwmon/aspeed-pwm-tacho.c | 80 ++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 52 deletions(-) diff --git a/drivers/hwmon/aspeed-pwm-tacho.c b/drivers/hwmon/aspeed-pwm-tacho.c index 92de8139d398..c4dd6301e7c8 100644 --- a/drivers/hwmon/aspeed-pwm-tacho.c +++ b/drivers/hwmon/aspeed-pwm-tacho.c @@ -570,8 +570,8 @@ static int aspeed_get_fan_tach_ch_rpm(struct aspeed_pwm_tacho_data *priv, return (clk_source * 60) / (2 * raw_data * tach_div); } -static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t pwm_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); int index = sensor_attr->index; @@ -595,7 +595,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, return count; } -static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, +static ssize_t pwm_show(struct device *dev, struct device_attribute *attr, char *buf) { struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); @@ -605,7 +605,7 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%u\n", priv->pwm_port_fan_ctrl[index]); } -static ssize_t show_rpm(struct device *dev, struct device_attribute *attr, +static ssize_t rpm_show(struct device *dev, struct device_attribute *attr, char *buf) { struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); @@ -642,22 +642,14 @@ static umode_t fan_dev_is_visible(struct kobject *kobj, return a->mode; } -static SENSOR_DEVICE_ATTR(pwm1, 0644, - show_pwm, set_pwm, 0); -static SENSOR_DEVICE_ATTR(pwm2, 0644, - show_pwm, set_pwm, 1); -static SENSOR_DEVICE_ATTR(pwm3, 0644, - show_pwm, set_pwm, 2); -static SENSOR_DEVICE_ATTR(pwm4, 0644, - show_pwm, set_pwm, 3); -static SENSOR_DEVICE_ATTR(pwm5, 0644, - show_pwm, set_pwm, 4); -static SENSOR_DEVICE_ATTR(pwm6, 0644, - show_pwm, set_pwm, 5); -static SENSOR_DEVICE_ATTR(pwm7, 0644, - show_pwm, set_pwm, 6); -static SENSOR_DEVICE_ATTR(pwm8, 0644, - show_pwm, set_pwm, 7); +static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, 1); +static SENSOR_DEVICE_ATTR_RW(pwm3, pwm, 2); +static SENSOR_DEVICE_ATTR_RW(pwm4, pwm, 3); +static SENSOR_DEVICE_ATTR_RW(pwm5, pwm, 4); +static SENSOR_DEVICE_ATTR_RW(pwm6, pwm, 5); +static SENSOR_DEVICE_ATTR_RW(pwm7, pwm, 6); +static SENSOR_DEVICE_ATTR_RW(pwm8, pwm, 7); static struct attribute *pwm_dev_attrs[] = { &sensor_dev_attr_pwm1.dev_attr.attr, &sensor_dev_attr_pwm2.dev_attr.attr, @@ -675,38 +667,22 @@ static const struct attribute_group pwm_dev_group = { .is_visible = pwm_is_visible, }; -static SENSOR_DEVICE_ATTR(fan1_input, 0444, - show_rpm, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_input, 0444, - show_rpm, NULL, 1); -static SENSOR_DEVICE_ATTR(fan3_input, 0444, - show_rpm, NULL, 2); -static SENSOR_DEVICE_ATTR(fan4_input, 0444, - show_rpm, NULL, 3); -static SENSOR_DEVICE_ATTR(fan5_input, 0444, - show_rpm, NULL, 4); -static SENSOR_DEVICE_ATTR(fan6_input, 0444, - show_rpm, NULL, 5); -static SENSOR_DEVICE_ATTR(fan7_input, 0444, - show_rpm, NULL, 6); -static SENSOR_DEVICE_ATTR(fan8_input, 0444, - show_rpm, NULL, 7); -static SENSOR_DEVICE_ATTR(fan9_input, 0444, - show_rpm, NULL, 8); -static SENSOR_DEVICE_ATTR(fan10_input, 0444, - show_rpm, NULL, 9); -static SENSOR_DEVICE_ATTR(fan11_input, 0444, - show_rpm, NULL, 10); -static SENSOR_DEVICE_ATTR(fan12_input, 0444, - show_rpm, NULL, 11); -static SENSOR_DEVICE_ATTR(fan13_input, 0444, - show_rpm, NULL, 12); -static SENSOR_DEVICE_ATTR(fan14_input, 0444, - show_rpm, NULL, 13); -static SENSOR_DEVICE_ATTR(fan15_input, 0444, - show_rpm, NULL, 14); -static SENSOR_DEVICE_ATTR(fan16_input, 0444, - show_rpm, NULL, 15); +static SENSOR_DEVICE_ATTR_RO(fan1_input, rpm, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, rpm, 1); +static SENSOR_DEVICE_ATTR_RO(fan3_input, rpm, 2); +static SENSOR_DEVICE_ATTR_RO(fan4_input, rpm, 3); +static SENSOR_DEVICE_ATTR_RO(fan5_input, rpm, 4); +static SENSOR_DEVICE_ATTR_RO(fan6_input, rpm, 5); +static SENSOR_DEVICE_ATTR_RO(fan7_input, rpm, 6); +static SENSOR_DEVICE_ATTR_RO(fan8_input, rpm, 7); +static SENSOR_DEVICE_ATTR_RO(fan9_input, rpm, 8); +static SENSOR_DEVICE_ATTR_RO(fan10_input, rpm, 9); +static SENSOR_DEVICE_ATTR_RO(fan11_input, rpm, 10); +static SENSOR_DEVICE_ATTR_RO(fan12_input, rpm, 11); +static SENSOR_DEVICE_ATTR_RO(fan13_input, rpm, 12); +static SENSOR_DEVICE_ATTR_RO(fan14_input, rpm, 13); +static SENSOR_DEVICE_ATTR_RO(fan15_input, rpm, 14); +static SENSOR_DEVICE_ATTR_RO(fan16_input, rpm, 15); static struct attribute *fan_dev_attrs[] = { &sensor_dev_attr_fan1_input.dev_attr.attr, &sensor_dev_attr_fan2_input.dev_attr.attr, -- cgit v1.2.3 From b51c14c736e355c7c7c642a2ea766d8eedf49907 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:03 -0800 Subject: hwmon: (asus_atk0110) Replace S_ with octal values Replace S_ with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Cc: Luca Tettamanti Signed-off-by: Guenter Roeck --- drivers/hwmon/asus_atk0110.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c index a7cf00885c5d..a5638d1f7e4b 100644 --- a/drivers/hwmon/asus_atk0110.c +++ b/drivers/hwmon/asus_atk0110.c @@ -799,17 +799,17 @@ static void atk_debugfs_init(struct atk_data *data) if (!d || IS_ERR(d)) return; - f = debugfs_create_x32("id", S_IRUSR | S_IWUSR, d, &data->debugfs.id); + f = debugfs_create_x32("id", 0600, d, &data->debugfs.id); if (!f || IS_ERR(f)) goto cleanup; - f = debugfs_create_file("gitm", S_IRUSR, d, data, - &atk_debugfs_gitm); + f = debugfs_create_file("gitm", 0400, d, data, + &atk_debugfs_gitm); if (!f || IS_ERR(f)) goto cleanup; - f = debugfs_create_file("ggrp", S_IRUSR, d, data, - &atk_debugfs_ggrp_fops); + f = debugfs_create_file("ggrp", 0400, d, data, + &atk_debugfs_ggrp_fops); if (!f || IS_ERR(f)) goto cleanup; -- cgit v1.2.3 From 0cd709d0ddbfc2ed64ecbe2dbe8819b90b977684 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:04 -0800 Subject: hwmon: (coretemp) Replace S_ with octal values Replace S_ with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Cc: Fenghua Yu Signed-off-by: Guenter Roeck --- drivers/hwmon/coretemp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c index 10645c9bb7be..5d34f7271e67 100644 --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c @@ -407,7 +407,7 @@ static int create_core_attrs(struct temp_data *tdata, struct device *dev, "temp%d_%s", attr_no, suffixes[i]); sysfs_attr_init(&tdata->sd_attrs[i].dev_attr.attr); tdata->sd_attrs[i].dev_attr.attr.name = tdata->attr_name[i]; - tdata->sd_attrs[i].dev_attr.attr.mode = S_IRUGO; + tdata->sd_attrs[i].dev_attr.attr.mode = 0444; tdata->sd_attrs[i].dev_attr.show = rd_ptr[i]; tdata->sd_attrs[i].index = attr_no; tdata->attrs[i] = &tdata->sd_attrs[i].dev_attr.attr; -- cgit v1.2.3 From 6db587b73fcebf254454468590b93d294a3368f9 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:04 -0800 Subject: hwmon: (da9052-hwmon) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Cc: Support Opensource Acked-by: Steve Twiss Signed-off-by: Guenter Roeck --- drivers/hwmon/da9052-hwmon.c | 105 ++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 66 deletions(-) diff --git a/drivers/hwmon/da9052-hwmon.c b/drivers/hwmon/da9052-hwmon.c index a973eb6a2890..8ec5bf4ce392 100644 --- a/drivers/hwmon/da9052-hwmon.c +++ b/drivers/hwmon/da9052-hwmon.c @@ -87,7 +87,7 @@ static inline int da9052_disable_vddout_channel(struct da9052 *da9052) DA9052_ADCCONT_AUTOVDDEN, 0); } -static ssize_t da9052_read_vddout(struct device *dev, +static ssize_t da9052_vddout_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct da9052_hwmon *hwmon = dev_get_drvdata(dev); @@ -119,7 +119,7 @@ hwmon_err: return ret; } -static ssize_t da9052_read_ich(struct device *dev, +static ssize_t da9052_ich_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct da9052_hwmon *hwmon = dev_get_drvdata(dev); @@ -133,7 +133,7 @@ static ssize_t da9052_read_ich(struct device *dev, return sprintf(buf, "%d\n", DIV_ROUND_CLOSEST(ret * 39, 10)); } -static ssize_t da9052_read_tbat(struct device *dev, +static ssize_t da9052_tbat_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct da9052_hwmon *hwmon = dev_get_drvdata(dev); @@ -141,7 +141,7 @@ static ssize_t da9052_read_tbat(struct device *dev, return sprintf(buf, "%d\n", da9052_adc_read_temp(hwmon->da9052)); } -static ssize_t da9052_read_vbat(struct device *dev, +static ssize_t da9052_vbat_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct da9052_hwmon *hwmon = dev_get_drvdata(dev); @@ -154,7 +154,7 @@ static ssize_t da9052_read_vbat(struct device *dev, return sprintf(buf, "%d\n", volt_reg_to_mv(ret)); } -static ssize_t da9052_read_misc_channel(struct device *dev, +static ssize_t da9052_misc_channel_show(struct device *dev, struct device_attribute *devattr, char *buf) { @@ -242,9 +242,8 @@ static ssize_t __da9052_read_tsi(struct device *dev, int channel) return da9052_get_tsi_result(hwmon, channel); } -static ssize_t da9052_read_tsi(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t da9052_tsi_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct da9052_hwmon *hwmon = dev_get_drvdata(dev); int channel = to_sensor_dev_attr(devattr)->index; @@ -260,7 +259,7 @@ static ssize_t da9052_read_tsi(struct device *dev, return sprintf(buf, "%d\n", input_tsireg_to_mv(hwmon, ret)); } -static ssize_t da9052_read_tjunc(struct device *dev, +static ssize_t da9052_tjunc_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct da9052_hwmon *hwmon = dev_get_drvdata(dev); @@ -282,7 +281,7 @@ static ssize_t da9052_read_tjunc(struct device *dev, return sprintf(buf, "%d\n", 1708 * (tjunc - toffset) - 108800); } -static ssize_t da9052_read_vbbat(struct device *dev, +static ssize_t da9052_vbbat_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct da9052_hwmon *hwmon = dev_get_drvdata(dev); @@ -295,7 +294,7 @@ static ssize_t da9052_read_vbbat(struct device *dev, return sprintf(buf, "%d\n", vbbat_reg_to_mv(ret)); } -static ssize_t show_label(struct device *dev, +static ssize_t label_show(struct device *dev, struct device_attribute *devattr, char *buf) { return sprintf(buf, "%s\n", @@ -324,61 +323,35 @@ static umode_t da9052_channel_is_visible(struct kobject *kobj, return attr->mode; } -static SENSOR_DEVICE_ATTR(in0_input, 0444, da9052_read_vddout, NULL, - DA9052_ADC_VDDOUT); -static SENSOR_DEVICE_ATTR(in0_label, 0444, show_label, NULL, - DA9052_ADC_VDDOUT); -static SENSOR_DEVICE_ATTR(in3_input, 0444, da9052_read_vbat, NULL, - DA9052_ADC_VBAT); -static SENSOR_DEVICE_ATTR(in3_label, 0444, show_label, NULL, - DA9052_ADC_VBAT); -static SENSOR_DEVICE_ATTR(in4_input, 0444, da9052_read_misc_channel, NULL, - DA9052_ADC_IN4); -static SENSOR_DEVICE_ATTR(in4_label, 0444, show_label, NULL, - DA9052_ADC_IN4); -static SENSOR_DEVICE_ATTR(in5_input, 0444, da9052_read_misc_channel, NULL, - DA9052_ADC_IN5); -static SENSOR_DEVICE_ATTR(in5_label, 0444, show_label, NULL, - DA9052_ADC_IN5); -static SENSOR_DEVICE_ATTR(in6_input, 0444, da9052_read_misc_channel, NULL, - DA9052_ADC_IN6); -static SENSOR_DEVICE_ATTR(in6_label, 0444, show_label, NULL, - DA9052_ADC_IN6); -static SENSOR_DEVICE_ATTR(in9_input, 0444, da9052_read_vbbat, NULL, - DA9052_ADC_VBBAT); -static SENSOR_DEVICE_ATTR(in9_label, 0444, show_label, NULL, - DA9052_ADC_VBBAT); - -static SENSOR_DEVICE_ATTR(in70_input, 0444, da9052_read_tsi, NULL, - DA9052_ADC_TSI_XP); -static SENSOR_DEVICE_ATTR(in70_label, 0444, show_label, NULL, - DA9052_ADC_TSI_XP); -static SENSOR_DEVICE_ATTR(in71_input, 0444, da9052_read_tsi, NULL, - DA9052_ADC_TSI_XN); -static SENSOR_DEVICE_ATTR(in71_label, 0444, show_label, NULL, - DA9052_ADC_TSI_XN); -static SENSOR_DEVICE_ATTR(in72_input, 0444, da9052_read_tsi, NULL, - DA9052_ADC_TSI_YP); -static SENSOR_DEVICE_ATTR(in72_label, 0444, show_label, NULL, - DA9052_ADC_TSI_YP); -static SENSOR_DEVICE_ATTR(in73_input, 0444, da9052_read_tsi, NULL, - DA9052_ADC_TSI_YN); -static SENSOR_DEVICE_ATTR(in73_label, 0444, show_label, NULL, - DA9052_ADC_TSI_YN); - -static SENSOR_DEVICE_ATTR(curr1_input, 0444, da9052_read_ich, NULL, - DA9052_ADC_ICH); -static SENSOR_DEVICE_ATTR(curr1_label, 0444, show_label, NULL, - DA9052_ADC_ICH); - -static SENSOR_DEVICE_ATTR(temp2_input, 0444, da9052_read_tbat, NULL, - DA9052_ADC_TBAT); -static SENSOR_DEVICE_ATTR(temp2_label, 0444, show_label, NULL, - DA9052_ADC_TBAT); -static SENSOR_DEVICE_ATTR(temp8_input, 0444, da9052_read_tjunc, NULL, - DA9052_ADC_TJUNC); -static SENSOR_DEVICE_ATTR(temp8_label, 0444, show_label, NULL, - DA9052_ADC_TJUNC); +static SENSOR_DEVICE_ATTR_RO(in0_input, da9052_vddout, DA9052_ADC_VDDOUT); +static SENSOR_DEVICE_ATTR_RO(in0_label, label, DA9052_ADC_VDDOUT); +static SENSOR_DEVICE_ATTR_RO(in3_input, da9052_vbat, DA9052_ADC_VBAT); +static SENSOR_DEVICE_ATTR_RO(in3_label, label, DA9052_ADC_VBAT); +static SENSOR_DEVICE_ATTR_RO(in4_input, da9052_misc_channel, DA9052_ADC_IN4); +static SENSOR_DEVICE_ATTR_RO(in4_label, label, DA9052_ADC_IN4); +static SENSOR_DEVICE_ATTR_RO(in5_input, da9052_misc_channel, DA9052_ADC_IN5); +static SENSOR_DEVICE_ATTR_RO(in5_label, label, DA9052_ADC_IN5); +static SENSOR_DEVICE_ATTR_RO(in6_input, da9052_misc_channel, DA9052_ADC_IN6); +static SENSOR_DEVICE_ATTR_RO(in6_label, label, DA9052_ADC_IN6); +static SENSOR_DEVICE_ATTR_RO(in9_input, da9052_vbbat, DA9052_ADC_VBBAT); +static SENSOR_DEVICE_ATTR_RO(in9_label, label, DA9052_ADC_VBBAT); + +static SENSOR_DEVICE_ATTR_RO(in70_input, da9052_tsi, DA9052_ADC_TSI_XP); +static SENSOR_DEVICE_ATTR_RO(in70_label, label, DA9052_ADC_TSI_XP); +static SENSOR_DEVICE_ATTR_RO(in71_input, da9052_tsi, DA9052_ADC_TSI_XN); +static SENSOR_DEVICE_ATTR_RO(in71_label, label, DA9052_ADC_TSI_XN); +static SENSOR_DEVICE_ATTR_RO(in72_input, da9052_tsi, DA9052_ADC_TSI_YP); +static SENSOR_DEVICE_ATTR_RO(in72_label, label, DA9052_ADC_TSI_YP); +static SENSOR_DEVICE_ATTR_RO(in73_input, da9052_tsi, DA9052_ADC_TSI_YN); +static SENSOR_DEVICE_ATTR_RO(in73_label, label, DA9052_ADC_TSI_YN); + +static SENSOR_DEVICE_ATTR_RO(curr1_input, da9052_ich, DA9052_ADC_ICH); +static SENSOR_DEVICE_ATTR_RO(curr1_label, label, DA9052_ADC_ICH); + +static SENSOR_DEVICE_ATTR_RO(temp2_input, da9052_tbat, DA9052_ADC_TBAT); +static SENSOR_DEVICE_ATTR_RO(temp2_label, label, DA9052_ADC_TBAT); +static SENSOR_DEVICE_ATTR_RO(temp8_input, da9052_tjunc, DA9052_ADC_TJUNC); +static SENSOR_DEVICE_ATTR_RO(temp8_label, label, DA9052_ADC_TJUNC); static struct attribute *da9052_attrs[] = { &sensor_dev_attr_in0_input.dev_attr.attr, -- cgit v1.2.3 From 4b76a6c9b7bb9d0198e2f4e75979a2178925a762 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:04 -0800 Subject: hwmon: (da9055-hwmon) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Cc: Support Opensource Acked-by: Steve Twiss Signed-off-by: Guenter Roeck --- drivers/hwmon/da9055-hwmon.c | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/drivers/hwmon/da9055-hwmon.c b/drivers/hwmon/da9055-hwmon.c index f6e159cabe23..4de6de683908 100644 --- a/drivers/hwmon/da9055-hwmon.c +++ b/drivers/hwmon/da9055-hwmon.c @@ -140,8 +140,9 @@ static int da9055_disable_auto_mode(struct da9055 *da9055, int channel) return da9055_reg_update(da9055, DA9055_REG_ADC_CONT, 1 << channel, 0); } -static ssize_t da9055_read_auto_ch(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t da9055_auto_ch_show(struct device *dev, + struct device_attribute *devattr, + char *buf) { struct da9055_hwmon *hwmon = dev_get_drvdata(dev); int ret, adc; @@ -176,7 +177,7 @@ hwmon_err: return ret; } -static ssize_t da9055_read_tjunc(struct device *dev, +static ssize_t da9055_tjunc_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct da9055_hwmon *hwmon = dev_get_drvdata(dev); @@ -199,34 +200,24 @@ static ssize_t da9055_read_tjunc(struct device *dev, + 3076332, 10000)); } -static ssize_t show_label(struct device *dev, +static ssize_t label_show(struct device *dev, struct device_attribute *devattr, char *buf) { return sprintf(buf, "%s\n", input_names[to_sensor_dev_attr(devattr)->index]); } -static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, da9055_read_auto_ch, NULL, - DA9055_ADC_VSYS); -static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, show_label, NULL, - DA9055_ADC_VSYS); -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, da9055_read_auto_ch, NULL, - DA9055_ADC_ADCIN1); -static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, show_label, NULL, - DA9055_ADC_ADCIN1); -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, da9055_read_auto_ch, NULL, - DA9055_ADC_ADCIN2); -static SENSOR_DEVICE_ATTR(in2_label, S_IRUGO, show_label, NULL, - DA9055_ADC_ADCIN2); -static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, da9055_read_auto_ch, NULL, - DA9055_ADC_ADCIN3); -static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_label, NULL, - DA9055_ADC_ADCIN3); - -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, da9055_read_tjunc, NULL, - DA9055_ADC_TJUNC); -static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, show_label, NULL, - DA9055_ADC_TJUNC); +static SENSOR_DEVICE_ATTR_RO(in0_input, da9055_auto_ch, DA9055_ADC_VSYS); +static SENSOR_DEVICE_ATTR_RO(in0_label, label, DA9055_ADC_VSYS); +static SENSOR_DEVICE_ATTR_RO(in1_input, da9055_auto_ch, DA9055_ADC_ADCIN1); +static SENSOR_DEVICE_ATTR_RO(in1_label, label, DA9055_ADC_ADCIN1); +static SENSOR_DEVICE_ATTR_RO(in2_input, da9055_auto_ch, DA9055_ADC_ADCIN2); +static SENSOR_DEVICE_ATTR_RO(in2_label, label, DA9055_ADC_ADCIN2); +static SENSOR_DEVICE_ATTR_RO(in3_input, da9055_auto_ch, DA9055_ADC_ADCIN3); +static SENSOR_DEVICE_ATTR_RO(in3_label, label, DA9055_ADC_ADCIN3); + +static SENSOR_DEVICE_ATTR_RO(temp1_input, da9055_tjunc, DA9055_ADC_TJUNC); +static SENSOR_DEVICE_ATTR_RO(temp1_label, label, DA9055_ADC_TJUNC); static struct attribute *da9055_attrs[] = { &sensor_dev_attr_in0_input.dev_attr.attr, -- cgit v1.2.3 From ba949ed62dcd51ba2a514f9a7b6b7de252621536 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:04 -0800 Subject: hwmon: (dell-smm-hwmon) Use permission specific SENSOR[_DEVICE]_ATTR variants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Cc: "Pali Rohár" Signed-off-by: Guenter Roeck --- drivers/hwmon/dell-smm-hwmon.c | 68 +++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 41 deletions(-) diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index 367a8a61712c..68c9a6664557 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -618,7 +618,7 @@ static inline void __exit i8k_exit_procfs(void) * Hwmon interface */ -static ssize_t i8k_hwmon_show_temp_label(struct device *dev, +static ssize_t i8k_hwmon_temp_label_show(struct device *dev, struct device_attribute *devattr, char *buf) { @@ -641,7 +641,7 @@ static ssize_t i8k_hwmon_show_temp_label(struct device *dev, return sprintf(buf, "%s\n", labels[type]); } -static ssize_t i8k_hwmon_show_temp(struct device *dev, +static ssize_t i8k_hwmon_temp_show(struct device *dev, struct device_attribute *devattr, char *buf) { @@ -654,7 +654,7 @@ static ssize_t i8k_hwmon_show_temp(struct device *dev, return sprintf(buf, "%d\n", temp * 1000); } -static ssize_t i8k_hwmon_show_fan_label(struct device *dev, +static ssize_t i8k_hwmon_fan_label_show(struct device *dev, struct device_attribute *devattr, char *buf) { @@ -685,9 +685,8 @@ static ssize_t i8k_hwmon_show_fan_label(struct device *dev, return sprintf(buf, "%s%s\n", (dock ? "Docking " : ""), labels[type]); } -static ssize_t i8k_hwmon_show_fan(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t i8k_hwmon_fan_show(struct device *dev, + struct device_attribute *devattr, char *buf) { int index = to_sensor_dev_attr(devattr)->index; int fan_speed; @@ -698,9 +697,8 @@ static ssize_t i8k_hwmon_show_fan(struct device *dev, return sprintf(buf, "%d\n", fan_speed); } -static ssize_t i8k_hwmon_show_pwm(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t i8k_hwmon_pwm_show(struct device *dev, + struct device_attribute *devattr, char *buf) { int index = to_sensor_dev_attr(devattr)->index; int status; @@ -711,9 +709,9 @@ static ssize_t i8k_hwmon_show_pwm(struct device *dev, return sprintf(buf, "%d\n", clamp_val(status * i8k_pwm_mult, 0, 255)); } -static ssize_t i8k_hwmon_set_pwm(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t i8k_hwmon_pwm_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { int index = to_sensor_dev_attr(attr)->index; unsigned long val; @@ -731,35 +729,23 @@ static ssize_t i8k_hwmon_set_pwm(struct device *dev, return err < 0 ? -EIO : count; } -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 0); -static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, i8k_hwmon_show_temp_label, NULL, - 0); -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 1); -static SENSOR_DEVICE_ATTR(temp2_label, S_IRUGO, i8k_hwmon_show_temp_label, NULL, - 1); -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 2); -static SENSOR_DEVICE_ATTR(temp3_label, S_IRUGO, i8k_hwmon_show_temp_label, NULL, - 2); -static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 3); -static SENSOR_DEVICE_ATTR(temp4_label, S_IRUGO, i8k_hwmon_show_temp_label, NULL, - 3); -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, i8k_hwmon_show_fan, NULL, 0); -static SENSOR_DEVICE_ATTR(fan1_label, S_IRUGO, i8k_hwmon_show_fan_label, NULL, - 0); -static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, i8k_hwmon_show_pwm, - i8k_hwmon_set_pwm, 0); -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, i8k_hwmon_show_fan, NULL, - 1); -static SENSOR_DEVICE_ATTR(fan2_label, S_IRUGO, i8k_hwmon_show_fan_label, NULL, - 1); -static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, i8k_hwmon_show_pwm, - i8k_hwmon_set_pwm, 1); -static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, i8k_hwmon_show_fan, NULL, - 2); -static SENSOR_DEVICE_ATTR(fan3_label, S_IRUGO, i8k_hwmon_show_fan_label, NULL, - 2); -static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, i8k_hwmon_show_pwm, - i8k_hwmon_set_pwm, 2); +static SENSOR_DEVICE_ATTR_RO(temp1_input, i8k_hwmon_temp, 0); +static SENSOR_DEVICE_ATTR_RO(temp1_label, i8k_hwmon_temp_label, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_input, i8k_hwmon_temp, 1); +static SENSOR_DEVICE_ATTR_RO(temp2_label, i8k_hwmon_temp_label, 1); +static SENSOR_DEVICE_ATTR_RO(temp3_input, i8k_hwmon_temp, 2); +static SENSOR_DEVICE_ATTR_RO(temp3_label, i8k_hwmon_temp_label, 2); +static SENSOR_DEVICE_ATTR_RO(temp4_input, i8k_hwmon_temp, 3); +static SENSOR_DEVICE_ATTR_RO(temp4_label, i8k_hwmon_temp_label, 3); +static SENSOR_DEVICE_ATTR_RO(fan1_input, i8k_hwmon_fan, 0); +static SENSOR_DEVICE_ATTR_RO(fan1_label, i8k_hwmon_fan_label, 0); +static SENSOR_DEVICE_ATTR_RW(pwm1, i8k_hwmon_pwm, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, i8k_hwmon_fan, 1); +static SENSOR_DEVICE_ATTR_RO(fan2_label, i8k_hwmon_fan_label, 1); +static SENSOR_DEVICE_ATTR_RW(pwm2, i8k_hwmon_pwm, 1); +static SENSOR_DEVICE_ATTR_RO(fan3_input, i8k_hwmon_fan, 2); +static SENSOR_DEVICE_ATTR_RO(fan3_label, i8k_hwmon_fan_label, 2); +static SENSOR_DEVICE_ATTR_RW(pwm3, i8k_hwmon_pwm, 2); static struct attribute *i8k_attrs[] = { &sensor_dev_attr_temp1_input.dev_attr.attr, /* 0 */ -- cgit v1.2.3 From 0ad85c07a1053bf95cae6218f4d06328b6dd1b2f Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:05 -0800 Subject: hwmon: (ds1621) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/ds1621.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index 5c317fc32a4a..6fcdac068a27 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c @@ -234,7 +234,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev) return data; } -static ssize_t show_temp(struct device *dev, struct device_attribute *da, +static ssize_t temp_show(struct device *dev, struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); @@ -243,8 +243,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *da, DS1621_TEMP_FROM_REG(data->temp[attr->index])); } -static ssize_t set_temp(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) +static ssize_t temp_store(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct ds1621_data *data = dev_get_drvdata(dev); @@ -270,7 +270,7 @@ static ssize_t alarms_show(struct device *dev, struct device_attribute *da, return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->conf)); } -static ssize_t show_alarm(struct device *dev, struct device_attribute *da, +static ssize_t alarm_show(struct device *dev, struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); @@ -319,13 +319,11 @@ static ssize_t update_interval_store(struct device *dev, static DEVICE_ATTR_RO(alarms); static DEVICE_ATTR_RW(update_interval); -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); -static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp, set_temp, 1); -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp, set_temp, 2); -static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, - DS1621_ALARM_TEMP_LOW); -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, - DS1621_ALARM_TEMP_HIGH); +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp, 1); +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, 2); +static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, DS1621_ALARM_TEMP_LOW); +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, DS1621_ALARM_TEMP_HIGH); static struct attribute *ds1621_attributes[] = { &sensor_dev_attr_temp1_input.dev_attr.attr, -- cgit v1.2.3 From 57549f3360eefde08b63886b1477c5751fe2e446 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:05 -0800 Subject: hwmon: (ds620) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/ds620.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/hwmon/ds620.c b/drivers/hwmon/ds620.c index 57d6958c74b8..7f8f8869c93c 100644 --- a/drivers/hwmon/ds620.c +++ b/drivers/hwmon/ds620.c @@ -139,7 +139,7 @@ abort: return ret; } -static ssize_t show_temp(struct device *dev, struct device_attribute *da, +static ssize_t temp_show(struct device *dev, struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); @@ -151,8 +151,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *da, return sprintf(buf, "%d\n", ((data->temp[attr->index] / 8) * 625) / 10); } -static ssize_t set_temp(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) +static ssize_t temp_store(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) { int res; long val; @@ -176,7 +176,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da, return count; } -static ssize_t show_alarm(struct device *dev, struct device_attribute *da, +static ssize_t alarm_show(struct device *dev, struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); @@ -207,13 +207,11 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *da, return sprintf(buf, "%d\n", !!(conf & attr->index)); } -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); -static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp, set_temp, 1); -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp, set_temp, 2); -static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, - DS620_REG_CONFIG_TLF); -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, - DS620_REG_CONFIG_THF); +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp, 1); +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, 2); +static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, DS620_REG_CONFIG_TLF); +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, DS620_REG_CONFIG_THF); static struct attribute *ds620_attrs[] = { &sensor_dev_attr_temp1_input.dev_attr.attr, -- cgit v1.2.3 From ae66d2d9e881148acb0092be5a3e39982603ac07 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:05 -0800 Subject: hwmon: (emc1403) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/emc1403.c | 164 ++++++++++++++++++++---------------------------- 1 file changed, 69 insertions(+), 95 deletions(-) diff --git a/drivers/hwmon/emc1403.c b/drivers/hwmon/emc1403.c index aaebeb726d6a..bdab47ac9e9a 100644 --- a/drivers/hwmon/emc1403.c +++ b/drivers/hwmon/emc1403.c @@ -43,8 +43,8 @@ struct thermal_data { const struct attribute_group *groups[4]; }; -static ssize_t show_temp(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t temp_show(struct device *dev, struct device_attribute *attr, + char *buf) { struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); struct thermal_data *data = dev_get_drvdata(dev); @@ -57,8 +57,8 @@ static ssize_t show_temp(struct device *dev, return sprintf(buf, "%d000\n", val); } -static ssize_t show_bit(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t bit_show(struct device *dev, struct device_attribute *attr, + char *buf) { struct sensor_device_attribute_2 *sda = to_sensor_dev_attr_2(attr); struct thermal_data *data = dev_get_drvdata(dev); @@ -71,8 +71,8 @@ static ssize_t show_bit(struct device *dev, return sprintf(buf, "%d\n", !!(val & sda->index)); } -static ssize_t store_temp(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) +static ssize_t temp_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); struct thermal_data *data = dev_get_drvdata(dev); @@ -88,8 +88,8 @@ static ssize_t store_temp(struct device *dev, return count; } -static ssize_t store_bit(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) +static ssize_t bit_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct sensor_device_attribute_2 *sda = to_sensor_dev_attr_2(attr); struct thermal_data *data = dev_get_drvdata(dev); @@ -128,20 +128,20 @@ static ssize_t show_hyst_common(struct device *dev, return sprintf(buf, "%d000\n", is_min ? limit + hyst : limit - hyst); } -static ssize_t show_hyst(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t hyst_show(struct device *dev, struct device_attribute *attr, + char *buf) { return show_hyst_common(dev, attr, buf, false); } -static ssize_t show_min_hyst(struct device *dev, +static ssize_t min_hyst_show(struct device *dev, struct device_attribute *attr, char *buf) { return show_hyst_common(dev, attr, buf, true); } -static ssize_t store_hyst(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) +static ssize_t hyst_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); struct thermal_data *data = dev_get_drvdata(dev); @@ -173,80 +173,54 @@ fail: * Sensors. We pass the actual i2c register to the methods. */ -static SENSOR_DEVICE_ATTR(temp1_min, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x06); -static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x05); -static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x20); -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0x00); -static SENSOR_DEVICE_ATTR_2(temp1_min_alarm, S_IRUGO, - show_bit, NULL, 0x36, 0x01); -static SENSOR_DEVICE_ATTR_2(temp1_max_alarm, S_IRUGO, - show_bit, NULL, 0x35, 0x01); -static SENSOR_DEVICE_ATTR_2(temp1_crit_alarm, S_IRUGO, - show_bit, NULL, 0x37, 0x01); -static SENSOR_DEVICE_ATTR(temp1_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x06); -static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO, show_hyst, NULL, 0x05); -static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO | S_IWUSR, - show_hyst, store_hyst, 0x20); - -static SENSOR_DEVICE_ATTR(temp2_min, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x08); -static SENSOR_DEVICE_ATTR(temp2_max, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x07); -static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x19); -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 0x01); -static SENSOR_DEVICE_ATTR_2(temp2_fault, S_IRUGO, show_bit, NULL, 0x1b, 0x02); -static SENSOR_DEVICE_ATTR_2(temp2_min_alarm, S_IRUGO, - show_bit, NULL, 0x36, 0x02); -static SENSOR_DEVICE_ATTR_2(temp2_max_alarm, S_IRUGO, - show_bit, NULL, 0x35, 0x02); -static SENSOR_DEVICE_ATTR_2(temp2_crit_alarm, S_IRUGO, - show_bit, NULL, 0x37, 0x02); -static SENSOR_DEVICE_ATTR(temp2_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x08); -static SENSOR_DEVICE_ATTR(temp2_max_hyst, S_IRUGO, show_hyst, NULL, 0x07); -static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_hyst, NULL, 0x19); - -static SENSOR_DEVICE_ATTR(temp3_min, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x16); -static SENSOR_DEVICE_ATTR(temp3_max, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x15); -static SENSOR_DEVICE_ATTR(temp3_crit, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x1A); -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 0x23); -static SENSOR_DEVICE_ATTR_2(temp3_fault, S_IRUGO, show_bit, NULL, 0x1b, 0x04); -static SENSOR_DEVICE_ATTR_2(temp3_min_alarm, S_IRUGO, - show_bit, NULL, 0x36, 0x04); -static SENSOR_DEVICE_ATTR_2(temp3_max_alarm, S_IRUGO, - show_bit, NULL, 0x35, 0x04); -static SENSOR_DEVICE_ATTR_2(temp3_crit_alarm, S_IRUGO, - show_bit, NULL, 0x37, 0x04); -static SENSOR_DEVICE_ATTR(temp3_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x16); -static SENSOR_DEVICE_ATTR(temp3_max_hyst, S_IRUGO, show_hyst, NULL, 0x15); -static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO, show_hyst, NULL, 0x1A); - -static SENSOR_DEVICE_ATTR(temp4_min, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x2D); -static SENSOR_DEVICE_ATTR(temp4_max, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x2C); -static SENSOR_DEVICE_ATTR(temp4_crit, S_IRUGO | S_IWUSR, - show_temp, store_temp, 0x30); -static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 0x2A); -static SENSOR_DEVICE_ATTR_2(temp4_fault, S_IRUGO, show_bit, NULL, 0x1b, 0x08); -static SENSOR_DEVICE_ATTR_2(temp4_min_alarm, S_IRUGO, - show_bit, NULL, 0x36, 0x08); -static SENSOR_DEVICE_ATTR_2(temp4_max_alarm, S_IRUGO, - show_bit, NULL, 0x35, 0x08); -static SENSOR_DEVICE_ATTR_2(temp4_crit_alarm, S_IRUGO, - show_bit, NULL, 0x37, 0x08); -static SENSOR_DEVICE_ATTR(temp4_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x2D); -static SENSOR_DEVICE_ATTR(temp4_max_hyst, S_IRUGO, show_hyst, NULL, 0x2C); -static SENSOR_DEVICE_ATTR(temp4_crit_hyst, S_IRUGO, show_hyst, NULL, 0x30); - -static SENSOR_DEVICE_ATTR_2(power_state, S_IRUGO | S_IWUSR, - show_bit, store_bit, 0x03, 0x40); +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp, 0x06); +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, 0x05); +static SENSOR_DEVICE_ATTR_RW(temp1_crit, temp, 0x20); +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0x00); +static SENSOR_DEVICE_ATTR_2_RO(temp1_min_alarm, bit, 0x36, 0x01); +static SENSOR_DEVICE_ATTR_2_RO(temp1_max_alarm, bit, 0x35, 0x01); +static SENSOR_DEVICE_ATTR_2_RO(temp1_crit_alarm, bit, 0x37, 0x01); +static SENSOR_DEVICE_ATTR_RO(temp1_min_hyst, min_hyst, 0x06); +static SENSOR_DEVICE_ATTR_RO(temp1_max_hyst, hyst, 0x05); +static SENSOR_DEVICE_ATTR_RW(temp1_crit_hyst, hyst, 0x20); + +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp, 0x08); +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp, 0x07); +static SENSOR_DEVICE_ATTR_RW(temp2_crit, temp, 0x19); +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 0x01); +static SENSOR_DEVICE_ATTR_2_RO(temp2_fault, bit, 0x1b, 0x02); +static SENSOR_DEVICE_ATTR_2_RO(temp2_min_alarm, bit, 0x36, 0x02); +static SENSOR_DEVICE_ATTR_2_RO(temp2_max_alarm, bit, 0x35, 0x02); +static SENSOR_DEVICE_ATTR_2_RO(temp2_crit_alarm, bit, 0x37, 0x02); +static SENSOR_DEVICE_ATTR_RO(temp2_min_hyst, min_hyst, 0x08); +static SENSOR_DEVICE_ATTR_RO(temp2_max_hyst, hyst, 0x07); +static SENSOR_DEVICE_ATTR_RO(temp2_crit_hyst, hyst, 0x19); + +static SENSOR_DEVICE_ATTR_RW(temp3_min, temp, 0x16); +static SENSOR_DEVICE_ATTR_RW(temp3_max, temp, 0x15); +static SENSOR_DEVICE_ATTR_RW(temp3_crit, temp, 0x1A); +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 0x23); +static SENSOR_DEVICE_ATTR_2_RO(temp3_fault, bit, 0x1b, 0x04); +static SENSOR_DEVICE_ATTR_2_RO(temp3_min_alarm, bit, 0x36, 0x04); +static SENSOR_DEVICE_ATTR_2_RO(temp3_max_alarm, bit, 0x35, 0x04); +static SENSOR_DEVICE_ATTR_2_RO(temp3_crit_alarm, bit, 0x37, 0x04); +static SENSOR_DEVICE_ATTR_RO(temp3_min_hyst, min_hyst, 0x16); +static SENSOR_DEVICE_ATTR_RO(temp3_max_hyst, hyst, 0x15); +static SENSOR_DEVICE_ATTR_RO(temp3_crit_hyst, hyst, 0x1A); + +static SENSOR_DEVICE_ATTR_RW(temp4_min, temp, 0x2D); +static SENSOR_DEVICE_ATTR_RW(temp4_max, temp, 0x2C); +static SENSOR_DEVICE_ATTR_RW(temp4_crit, temp, 0x30); +static SENSOR_DEVICE_ATTR_RO(temp4_input, temp, 0x2A); +static SENSOR_DEVICE_ATTR_2_RO(temp4_fault, bit, 0x1b, 0x08); +static SENSOR_DEVICE_ATTR_2_RO(temp4_min_alarm, bit, 0x36, 0x08); +static SENSOR_DEVICE_ATTR_2_RO(temp4_max_alarm, bit, 0x35, 0x08); +static SENSOR_DEVICE_ATTR_2_RO(temp4_crit_alarm, bit, 0x37, 0x08); +static SENSOR_DEVICE_ATTR_RO(temp4_min_hyst, min_hyst, 0x2D); +static SENSOR_DEVICE_ATTR_RO(temp4_max_hyst, hyst, 0x2C); +static SENSOR_DEVICE_ATTR_RO(temp4_crit_hyst, hyst, 0x30); + +static SENSOR_DEVICE_ATTR_2_RW(power_state, bit, 0x03, 0x40); static struct attribute *emc1402_attrs[] = { &sensor_dev_attr_temp1_min.dev_attr.attr, @@ -328,14 +302,14 @@ static const struct attribute_group emc1404_group = { * array. */ static struct sensor_device_attribute_2 emc1402_alarms[] = { - SENSOR_ATTR_2(temp1_min_alarm, S_IRUGO, show_bit, NULL, 0x02, 0x20), - SENSOR_ATTR_2(temp1_max_alarm, S_IRUGO, show_bit, NULL, 0x02, 0x40), - SENSOR_ATTR_2(temp1_crit_alarm, S_IRUGO, show_bit, NULL, 0x02, 0x01), - - SENSOR_ATTR_2(temp2_fault, S_IRUGO, show_bit, NULL, 0x02, 0x04), - SENSOR_ATTR_2(temp2_min_alarm, S_IRUGO, show_bit, NULL, 0x02, 0x08), - SENSOR_ATTR_2(temp2_max_alarm, S_IRUGO, show_bit, NULL, 0x02, 0x10), - SENSOR_ATTR_2(temp2_crit_alarm, S_IRUGO, show_bit, NULL, 0x02, 0x02), + SENSOR_ATTR_2_RO(temp1_min_alarm, bit, 0x02, 0x20), + SENSOR_ATTR_2_RO(temp1_max_alarm, bit, 0x02, 0x40), + SENSOR_ATTR_2_RO(temp1_crit_alarm, bit, 0x02, 0x01), + + SENSOR_ATTR_2_RO(temp2_fault, bit, 0x02, 0x04), + SENSOR_ATTR_2_RO(temp2_min_alarm, bit, 0x02, 0x08), + SENSOR_ATTR_2_RO(temp2_max_alarm, bit, 0x02, 0x10), + SENSOR_ATTR_2_RO(temp2_crit_alarm, bit, 0x02, 0x02), }; static struct attribute *emc1402_alarm_attrs[] = { -- cgit v1.2.3 From 94bf70da8ac3f815411a24a6ca42e7327c4a4bbb Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:06 -0800 Subject: hwmon: (emc2103) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Cc: Steve Glendinning Signed-off-by: Guenter Roeck --- drivers/hwmon/emc2103.c | 92 +++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 53 deletions(-) diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c index 1ed9a7aa953d..4b7748a0a833 100644 --- a/drivers/hwmon/emc2103.c +++ b/drivers/hwmon/emc2103.c @@ -185,7 +185,7 @@ static struct emc2103_data *emc2103_update_device(struct device *dev) } static ssize_t -show_temp(struct device *dev, struct device_attribute *da, char *buf) +temp_show(struct device *dev, struct device_attribute *da, char *buf) { int nr = to_sensor_dev_attr(da)->index; struct emc2103_data *data = emc2103_update_device(dev); @@ -195,7 +195,7 @@ show_temp(struct device *dev, struct device_attribute *da, char *buf) } static ssize_t -show_temp_min(struct device *dev, struct device_attribute *da, char *buf) +temp_min_show(struct device *dev, struct device_attribute *da, char *buf) { int nr = to_sensor_dev_attr(da)->index; struct emc2103_data *data = emc2103_update_device(dev); @@ -204,7 +204,7 @@ show_temp_min(struct device *dev, struct device_attribute *da, char *buf) } static ssize_t -show_temp_max(struct device *dev, struct device_attribute *da, char *buf) +temp_max_show(struct device *dev, struct device_attribute *da, char *buf) { int nr = to_sensor_dev_attr(da)->index; struct emc2103_data *data = emc2103_update_device(dev); @@ -213,7 +213,7 @@ show_temp_max(struct device *dev, struct device_attribute *da, char *buf) } static ssize_t -show_temp_fault(struct device *dev, struct device_attribute *da, char *buf) +temp_fault_show(struct device *dev, struct device_attribute *da, char *buf) { int nr = to_sensor_dev_attr(da)->index; struct emc2103_data *data = emc2103_update_device(dev); @@ -222,7 +222,8 @@ show_temp_fault(struct device *dev, struct device_attribute *da, char *buf) } static ssize_t -show_temp_min_alarm(struct device *dev, struct device_attribute *da, char *buf) +temp_min_alarm_show(struct device *dev, struct device_attribute *da, + char *buf) { int nr = to_sensor_dev_attr(da)->index; struct emc2103_data *data = emc2103_update_device(dev); @@ -231,7 +232,8 @@ show_temp_min_alarm(struct device *dev, struct device_attribute *da, char *buf) } static ssize_t -show_temp_max_alarm(struct device *dev, struct device_attribute *da, char *buf) +temp_max_alarm_show(struct device *dev, struct device_attribute *da, + char *buf) { int nr = to_sensor_dev_attr(da)->index; struct emc2103_data *data = emc2103_update_device(dev); @@ -239,8 +241,8 @@ show_temp_max_alarm(struct device *dev, struct device_attribute *da, char *buf) return sprintf(buf, "%d\n", alarm ? 1 : 0); } -static ssize_t set_temp_min(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) +static ssize_t temp_min_store(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) { int nr = to_sensor_dev_attr(da)->index; struct emc2103_data *data = dev_get_drvdata(dev); @@ -261,8 +263,8 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *da, return count; } -static ssize_t set_temp_max(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) +static ssize_t temp_max_store(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) { int nr = to_sensor_dev_attr(da)->index; struct emc2103_data *data = dev_get_drvdata(dev); @@ -470,49 +472,33 @@ err: return count; } -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); -static SENSOR_DEVICE_ATTR(temp1_min, S_IRUGO | S_IWUSR, show_temp_min, - set_temp_min, 0); -static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp_max, - set_temp_max, 0); -static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0); -static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_temp_min_alarm, - NULL, 0); -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_temp_max_alarm, - NULL, 0); - -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); -static SENSOR_DEVICE_ATTR(temp2_min, S_IRUGO | S_IWUSR, show_temp_min, - set_temp_min, 1); -static SENSOR_DEVICE_ATTR(temp2_max, S_IRUGO | S_IWUSR, show_temp_max, - set_temp_max, 1); -static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_temp_fault, NULL, 1); -static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_temp_min_alarm, - NULL, 1); -static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_temp_max_alarm, - NULL, 1); - -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); -static SENSOR_DEVICE_ATTR(temp3_min, S_IRUGO | S_IWUSR, show_temp_min, - set_temp_min, 2); -static SENSOR_DEVICE_ATTR(temp3_max, S_IRUGO | S_IWUSR, show_temp_max, - set_temp_max, 2); -static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_temp_fault, NULL, 2); -static SENSOR_DEVICE_ATTR(temp3_min_alarm, S_IRUGO, show_temp_min_alarm, - NULL, 2); -static SENSOR_DEVICE_ATTR(temp3_max_alarm, S_IRUGO, show_temp_max_alarm, - NULL, 2); - -static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3); -static SENSOR_DEVICE_ATTR(temp4_min, S_IRUGO | S_IWUSR, show_temp_min, - set_temp_min, 3); -static SENSOR_DEVICE_ATTR(temp4_max, S_IRUGO | S_IWUSR, show_temp_max, - set_temp_max, 3); -static SENSOR_DEVICE_ATTR(temp4_fault, S_IRUGO, show_temp_fault, NULL, 3); -static SENSOR_DEVICE_ATTR(temp4_min_alarm, S_IRUGO, show_temp_min_alarm, - NULL, 3); -static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_temp_max_alarm, - NULL, 3); +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); +static SENSOR_DEVICE_ATTR_RO(temp1_fault, temp_fault, 0); +static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, temp_min_alarm, 0); +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, temp_max_alarm, 0); + +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); +static SENSOR_DEVICE_ATTR_RO(temp2_fault, temp_fault, 1); +static SENSOR_DEVICE_ATTR_RO(temp2_min_alarm, temp_min_alarm, 1); +static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, temp_max_alarm, 1); + +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_min, temp_min, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_max, 2); +static SENSOR_DEVICE_ATTR_RO(temp3_fault, temp_fault, 2); +static SENSOR_DEVICE_ATTR_RO(temp3_min_alarm, temp_min_alarm, 2); +static SENSOR_DEVICE_ATTR_RO(temp3_max_alarm, temp_max_alarm, 2); + +static SENSOR_DEVICE_ATTR_RO(temp4_input, temp, 3); +static SENSOR_DEVICE_ATTR_RW(temp4_min, temp_min, 3); +static SENSOR_DEVICE_ATTR_RW(temp4_max, temp_max, 3); +static SENSOR_DEVICE_ATTR_RO(temp4_fault, temp_fault, 3); +static SENSOR_DEVICE_ATTR_RO(temp4_min_alarm, temp_min_alarm, 3); +static SENSOR_DEVICE_ATTR_RO(temp4_max_alarm, temp_max_alarm, 3); static DEVICE_ATTR_RO(fan1_input); static DEVICE_ATTR_RW(fan1_div); -- cgit v1.2.3 From 7a61d7197b8eb43fdbc036cd0eeea44986267202 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:06 -0800 Subject: hwmon: (emc6w201) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/emc6w201.c | 150 +++++++++++++++++++---------------------------- 1 file changed, 61 insertions(+), 89 deletions(-) diff --git a/drivers/hwmon/emc6w201.c b/drivers/hwmon/emc6w201.c index 4aee5adf9ef2..b4735e7e18f5 100644 --- a/drivers/hwmon/emc6w201.c +++ b/drivers/hwmon/emc6w201.c @@ -189,8 +189,8 @@ static struct emc6w201_data *emc6w201_update_device(struct device *dev) static const s16 nominal_mv[6] = { 2500, 1500, 3300, 5000, 1500, 1500 }; -static ssize_t show_in(struct device *dev, struct device_attribute *devattr, - char *buf) +static ssize_t in_show(struct device *dev, struct device_attribute *devattr, + char *buf) { struct emc6w201_data *data = emc6w201_update_device(dev); int sf = to_sensor_dev_attr_2(devattr)->index; @@ -200,8 +200,8 @@ static ssize_t show_in(struct device *dev, struct device_attribute *devattr, (unsigned)data->in[sf][nr] * nominal_mv[nr] / 0xC0); } -static ssize_t set_in(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) +static ssize_t in_store(struct device *dev, struct device_attribute *devattr, + const char *buf, size_t count) { struct emc6w201_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; @@ -228,8 +228,8 @@ static ssize_t set_in(struct device *dev, struct device_attribute *devattr, return err < 0 ? err : count; } -static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, - char *buf) +static ssize_t temp_show(struct device *dev, struct device_attribute *devattr, + char *buf) { struct emc6w201_data *data = emc6w201_update_device(dev); int sf = to_sensor_dev_attr_2(devattr)->index; @@ -238,8 +238,9 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, return sprintf(buf, "%d\n", (int)data->temp[sf][nr] * 1000); } -static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) +static ssize_t temp_store(struct device *dev, + struct device_attribute *devattr, const char *buf, + size_t count) { struct emc6w201_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; @@ -266,8 +267,8 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, return err < 0 ? err : count; } -static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, - char *buf) +static ssize_t fan_show(struct device *dev, struct device_attribute *devattr, + char *buf) { struct emc6w201_data *data = emc6w201_update_device(dev); int sf = to_sensor_dev_attr_2(devattr)->index; @@ -282,8 +283,8 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, return sprintf(buf, "%u\n", rpm); } -static ssize_t set_fan(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) +static ssize_t fan_store(struct device *dev, struct device_attribute *devattr, + const char *buf, size_t count) { struct emc6w201_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; @@ -312,83 +313,54 @@ static ssize_t set_fan(struct device *dev, struct device_attribute *devattr, return err < 0 ? err : count; } -static SENSOR_DEVICE_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, input); -static SENSOR_DEVICE_ATTR_2(in0_min, S_IRUGO | S_IWUSR, show_in, set_in, - 0, min); -static SENSOR_DEVICE_ATTR_2(in0_max, S_IRUGO | S_IWUSR, show_in, set_in, - 0, max); -static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, show_in, NULL, 1, input); -static SENSOR_DEVICE_ATTR_2(in1_min, S_IRUGO | S_IWUSR, show_in, set_in, - 1, min); -static SENSOR_DEVICE_ATTR_2(in1_max, S_IRUGO | S_IWUSR, show_in, set_in, - 1, max); -static SENSOR_DEVICE_ATTR_2(in2_input, S_IRUGO, show_in, NULL, 2, input); -static SENSOR_DEVICE_ATTR_2(in2_min, S_IRUGO | S_IWUSR, show_in, set_in, - 2, min); -static SENSOR_DEVICE_ATTR_2(in2_max, S_IRUGO | S_IWUSR, show_in, set_in, - 2, max); -static SENSOR_DEVICE_ATTR_2(in3_input, S_IRUGO, show_in, NULL, 3, input); -static SENSOR_DEVICE_ATTR_2(in3_min, S_IRUGO | S_IWUSR, show_in, set_in, - 3, min); -static SENSOR_DEVICE_ATTR_2(in3_max, S_IRUGO | S_IWUSR, show_in, set_in, - 3, max); -static SENSOR_DEVICE_ATTR_2(in4_input, S_IRUGO, show_in, NULL, 4, input); -static SENSOR_DEVICE_ATTR_2(in4_min, S_IRUGO | S_IWUSR, show_in, set_in, - 4, min); -static SENSOR_DEVICE_ATTR_2(in4_max, S_IRUGO | S_IWUSR, show_in, set_in, - 4, max); -static SENSOR_DEVICE_ATTR_2(in5_input, S_IRUGO, show_in, NULL, 5, input); -static SENSOR_DEVICE_ATTR_2(in5_min, S_IRUGO | S_IWUSR, show_in, set_in, - 5, min); -static SENSOR_DEVICE_ATTR_2(in5_max, S_IRUGO | S_IWUSR, show_in, set_in, - 5, max); - -static SENSOR_DEVICE_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, 0, input); -static SENSOR_DEVICE_ATTR_2(temp1_min, S_IRUGO | S_IWUSR, show_temp, set_temp, - 0, min); -static SENSOR_DEVICE_ATTR_2(temp1_max, S_IRUGO | S_IWUSR, show_temp, set_temp, - 0, max); -static SENSOR_DEVICE_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, 1, input); -static SENSOR_DEVICE_ATTR_2(temp2_min, S_IRUGO | S_IWUSR, show_temp, set_temp, - 1, min); -static SENSOR_DEVICE_ATTR_2(temp2_max, S_IRUGO | S_IWUSR, show_temp, set_temp, - 1, max); -static SENSOR_DEVICE_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, 2, input); -static SENSOR_DEVICE_ATTR_2(temp3_min, S_IRUGO | S_IWUSR, show_temp, set_temp, - 2, min); -static SENSOR_DEVICE_ATTR_2(temp3_max, S_IRUGO | S_IWUSR, show_temp, set_temp, - 2, max); -static SENSOR_DEVICE_ATTR_2(temp4_input, S_IRUGO, show_temp, NULL, 3, input); -static SENSOR_DEVICE_ATTR_2(temp4_min, S_IRUGO | S_IWUSR, show_temp, set_temp, - 3, min); -static SENSOR_DEVICE_ATTR_2(temp4_max, S_IRUGO | S_IWUSR, show_temp, set_temp, - 3, max); -static SENSOR_DEVICE_ATTR_2(temp5_input, S_IRUGO, show_temp, NULL, 4, input); -static SENSOR_DEVICE_ATTR_2(temp5_min, S_IRUGO | S_IWUSR, show_temp, set_temp, - 4, min); -static SENSOR_DEVICE_ATTR_2(temp5_max, S_IRUGO | S_IWUSR, show_temp, set_temp, - 4, max); -static SENSOR_DEVICE_ATTR_2(temp6_input, S_IRUGO, show_temp, NULL, 5, input); -static SENSOR_DEVICE_ATTR_2(temp6_min, S_IRUGO | S_IWUSR, show_temp, set_temp, - 5, min); -static SENSOR_DEVICE_ATTR_2(temp6_max, S_IRUGO | S_IWUSR, show_temp, set_temp, - 5, max); - -static SENSOR_DEVICE_ATTR_2(fan1_input, S_IRUGO, show_fan, NULL, 0, input); -static SENSOR_DEVICE_ATTR_2(fan1_min, S_IRUGO | S_IWUSR, show_fan, set_fan, - 0, min); -static SENSOR_DEVICE_ATTR_2(fan2_input, S_IRUGO, show_fan, NULL, 1, input); -static SENSOR_DEVICE_ATTR_2(fan2_min, S_IRUGO | S_IWUSR, show_fan, set_fan, - 1, min); -static SENSOR_DEVICE_ATTR_2(fan3_input, S_IRUGO, show_fan, NULL, 2, input); -static SENSOR_DEVICE_ATTR_2(fan3_min, S_IRUGO | S_IWUSR, show_fan, set_fan, - 2, min); -static SENSOR_DEVICE_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 3, input); -static SENSOR_DEVICE_ATTR_2(fan4_min, S_IRUGO | S_IWUSR, show_fan, set_fan, - 3, min); -static SENSOR_DEVICE_ATTR_2(fan5_input, S_IRUGO, show_fan, NULL, 4, input); -static SENSOR_DEVICE_ATTR_2(fan5_min, S_IRUGO | S_IWUSR, show_fan, set_fan, - 4, min); +static SENSOR_DEVICE_ATTR_2_RO(in0_input, in, 0, input); +static SENSOR_DEVICE_ATTR_2_RW(in0_min, in, 0, min); +static SENSOR_DEVICE_ATTR_2_RW(in0_max, in, 0, max); +static SENSOR_DEVICE_ATTR_2_RO(in1_input, in, 1, input); +static SENSOR_DEVICE_ATTR_2_RW(in1_min, in, 1, min); +static SENSOR_DEVICE_ATTR_2_RW(in1_max, in, 1, max); +static SENSOR_DEVICE_ATTR_2_RO(in2_input, in, 2, input); +static SENSOR_DEVICE_ATTR_2_RW(in2_min, in, 2, min); +static SENSOR_DEVICE_ATTR_2_RW(in2_max, in, 2, max); +static SENSOR_DEVICE_ATTR_2_RO(in3_input, in, 3, input); +static SENSOR_DEVICE_ATTR_2_RW(in3_min, in, 3, min); +static SENSOR_DEVICE_ATTR_2_RW(in3_max, in, 3, max); +static SENSOR_DEVICE_ATTR_2_RO(in4_input, in, 4, input); +static SENSOR_DEVICE_ATTR_2_RW(in4_min, in, 4, min); +static SENSOR_DEVICE_ATTR_2_RW(in4_max, in, 4, max); +static SENSOR_DEVICE_ATTR_2_RO(in5_input, in, 5, input); +static SENSOR_DEVICE_ATTR_2_RW(in5_min, in, 5, min); +static SENSOR_DEVICE_ATTR_2_RW(in5_max, in, 5, max); + +static SENSOR_DEVICE_ATTR_2_RO(temp1_input, temp, 0, input); +static SENSOR_DEVICE_ATTR_2_RW(temp1_min, temp, 0, min); +static SENSOR_DEVICE_ATTR_2_RW(temp1_max, temp, 0, max); +static SENSOR_DEVICE_ATTR_2_RO(temp2_input, temp, 1, input); +static SENSOR_DEVICE_ATTR_2_RW(temp2_min, temp, 1, min); +static SENSOR_DEVICE_ATTR_2_RW(temp2_max, temp, 1, max); +static SENSOR_DEVICE_ATTR_2_RO(temp3_input, temp, 2, input); +static SENSOR_DEVICE_ATTR_2_RW(temp3_min, temp, 2, min); +static SENSOR_DEVICE_ATTR_2_RW(temp3_max, temp, 2, max); +static SENSOR_DEVICE_ATTR_2_RO(temp4_input, temp, 3, input); +static SENSOR_DEVICE_ATTR_2_RW(temp4_min, temp, 3, min); +static SENSOR_DEVICE_ATTR_2_RW(temp4_max, temp, 3, max); +static SENSOR_DEVICE_ATTR_2_RO(temp5_input, temp, 4, input); +static SENSOR_DEVICE_ATTR_2_RW(temp5_min, temp, 4, min); +static SENSOR_DEVICE_ATTR_2_RW(temp5_max, temp, 4, max); +static SENSOR_DEVICE_ATTR_2_RO(temp6_input, temp, 5, input); +static SENSOR_DEVICE_ATTR_2_RW(temp6_min, temp, 5, min); +static SENSOR_DEVICE_ATTR_2_RW(temp6_max, temp, 5, max); + +static SENSOR_DEVICE_ATTR_2_RO(fan1_input, fan, 0, input); +static SENSOR_DEVICE_ATTR_2_RW(fan1_min, fan, 0, min); +static SENSOR_DEVICE_ATTR_2_RO(fan2_input, fan, 1, input); +static SENSOR_DEVICE_ATTR_2_RW(fan2_min, fan, 1, min); +static SENSOR_DEVICE_ATTR_2_RO(fan3_input, fan, 2, input); +static SENSOR_DEVICE_ATTR_2_RW(fan3_min, fan, 2, min); +static SENSOR_DEVICE_ATTR_2_RO(fan4_input, fan, 3, input); +static SENSOR_DEVICE_ATTR_2_RW(fan4_min, fan, 3, min); +static SENSOR_DEVICE_ATTR_2_RO(fan5_input, fan, 4, input); +static SENSOR_DEVICE_ATTR_2_RW(fan5_min, fan, 4, min); static struct attribute *emc6w201_attrs[] = { &sensor_dev_attr_in0_input.dev_attr.attr, -- cgit v1.2.3 From 22ed7883c138ee5f7c8eec3c12f494f8bd59d8fe Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:06 -0800 Subject: hwmon: (fschmd) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/fschmd.c | 235 ++++++++++++++++++++++++------------------------- 1 file changed, 116 insertions(+), 119 deletions(-) diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c index 22d3a84f13ef..042a166e1858 100644 --- a/drivers/hwmon/fschmd.c +++ b/drivers/hwmon/fschmd.c @@ -331,8 +331,8 @@ static void fschmd_release_resources(struct kref *ref) * Sysfs attr show / store functions */ -static ssize_t show_in_value(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t in_value_show(struct device *dev, + struct device_attribute *devattr, char *buf) { const int max_reading[3] = { 14200, 6600, 3300 }; int index = to_sensor_dev_attr(devattr)->index; @@ -349,8 +349,8 @@ static ssize_t show_in_value(struct device *dev, #define TEMP_FROM_REG(val) (((val) - 128) * 1000) -static ssize_t show_temp_value(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t temp_value_show(struct device *dev, + struct device_attribute *devattr, char *buf) { int index = to_sensor_dev_attr(devattr)->index; struct fschmd_data *data = fschmd_update_device(dev); @@ -358,8 +358,8 @@ static ssize_t show_temp_value(struct device *dev, return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_act[index])); } -static ssize_t show_temp_max(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t temp_max_show(struct device *dev, + struct device_attribute *devattr, char *buf) { int index = to_sensor_dev_attr(devattr)->index; struct fschmd_data *data = fschmd_update_device(dev); @@ -367,8 +367,9 @@ static ssize_t show_temp_max(struct device *dev, return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[index])); } -static ssize_t store_temp_max(struct device *dev, struct device_attribute - *devattr, const char *buf, size_t count) +static ssize_t temp_max_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { int index = to_sensor_dev_attr(devattr)->index; struct fschmd_data *data = dev_get_drvdata(dev); @@ -390,8 +391,8 @@ static ssize_t store_temp_max(struct device *dev, struct device_attribute return count; } -static ssize_t show_temp_fault(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t temp_fault_show(struct device *dev, + struct device_attribute *devattr, char *buf) { int index = to_sensor_dev_attr(devattr)->index; struct fschmd_data *data = fschmd_update_device(dev); @@ -403,8 +404,8 @@ static ssize_t show_temp_fault(struct device *dev, return sprintf(buf, "1\n"); } -static ssize_t show_temp_alarm(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t temp_alarm_show(struct device *dev, + struct device_attribute *devattr, char *buf) { int index = to_sensor_dev_attr(devattr)->index; struct fschmd_data *data = fschmd_update_device(dev); @@ -419,8 +420,8 @@ static ssize_t show_temp_alarm(struct device *dev, #define RPM_FROM_REG(val) ((val) * 60) -static ssize_t show_fan_value(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t fan_value_show(struct device *dev, + struct device_attribute *devattr, char *buf) { int index = to_sensor_dev_attr(devattr)->index; struct fschmd_data *data = fschmd_update_device(dev); @@ -428,8 +429,8 @@ static ssize_t show_fan_value(struct device *dev, return sprintf(buf, "%u\n", RPM_FROM_REG(data->fan_act[index])); } -static ssize_t show_fan_div(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t fan_div_show(struct device *dev, + struct device_attribute *devattr, char *buf) { int index = to_sensor_dev_attr(devattr)->index; struct fschmd_data *data = fschmd_update_device(dev); @@ -438,8 +439,9 @@ static ssize_t show_fan_div(struct device *dev, return sprintf(buf, "%d\n", 1 << (data->fan_ripple[index] & 3)); } -static ssize_t store_fan_div(struct device *dev, struct device_attribute - *devattr, const char *buf, size_t count) +static ssize_t fan_div_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { u8 reg; int index = to_sensor_dev_attr(devattr)->index; @@ -488,8 +490,8 @@ static ssize_t store_fan_div(struct device *dev, struct device_attribute return count; } -static ssize_t show_fan_alarm(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t fan_alarm_show(struct device *dev, + struct device_attribute *devattr, char *buf) { int index = to_sensor_dev_attr(devattr)->index; struct fschmd_data *data = fschmd_update_device(dev); @@ -500,8 +502,8 @@ static ssize_t show_fan_alarm(struct device *dev, return sprintf(buf, "0\n"); } -static ssize_t show_fan_fault(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t fan_fault_show(struct device *dev, + struct device_attribute *devattr, char *buf) { int index = to_sensor_dev_attr(devattr)->index; struct fschmd_data *data = fschmd_update_device(dev); @@ -513,8 +515,9 @@ static ssize_t show_fan_fault(struct device *dev, } -static ssize_t show_pwm_auto_point1_pwm(struct device *dev, - struct device_attribute *devattr, char *buf) +static ssize_t pwm_auto_point1_pwm_show(struct device *dev, + struct device_attribute *devattr, + char *buf) { int index = to_sensor_dev_attr(devattr)->index; struct fschmd_data *data = fschmd_update_device(dev); @@ -527,8 +530,9 @@ static ssize_t show_pwm_auto_point1_pwm(struct device *dev, return sprintf(buf, "%d\n", val); } -static ssize_t store_pwm_auto_point1_pwm(struct device *dev, - struct device_attribute *devattr, const char *buf, size_t count) +static ssize_t pwm_auto_point1_pwm_store(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) { int index = to_sensor_dev_attr(devattr)->index; struct fschmd_data *data = dev_get_drvdata(dev); @@ -605,104 +609,97 @@ static ssize_t alert_led_store(struct device *dev, static DEVICE_ATTR_RW(alert_led); static struct sensor_device_attribute fschmd_attr[] = { - SENSOR_ATTR(in0_input, 0444, show_in_value, NULL, 0), - SENSOR_ATTR(in1_input, 0444, show_in_value, NULL, 1), - SENSOR_ATTR(in2_input, 0444, show_in_value, NULL, 2), - SENSOR_ATTR(in3_input, 0444, show_in_value, NULL, 3), - SENSOR_ATTR(in4_input, 0444, show_in_value, NULL, 4), - SENSOR_ATTR(in5_input, 0444, show_in_value, NULL, 5), + SENSOR_ATTR_RO(in0_input, in_value, 0), + SENSOR_ATTR_RO(in1_input, in_value, 1), + SENSOR_ATTR_RO(in2_input, in_value, 2), + SENSOR_ATTR_RO(in3_input, in_value, 3), + SENSOR_ATTR_RO(in4_input, in_value, 4), + SENSOR_ATTR_RO(in5_input, in_value, 5), }; static struct sensor_device_attribute fschmd_temp_attr[] = { - SENSOR_ATTR(temp1_input, 0444, show_temp_value, NULL, 0), - SENSOR_ATTR(temp1_max, 0644, show_temp_max, store_temp_max, 0), - SENSOR_ATTR(temp1_fault, 0444, show_temp_fault, NULL, 0), - SENSOR_ATTR(temp1_alarm, 0444, show_temp_alarm, NULL, 0), - SENSOR_ATTR(temp2_input, 0444, show_temp_value, NULL, 1), - SENSOR_ATTR(temp2_max, 0644, show_temp_max, store_temp_max, 1), - SENSOR_ATTR(temp2_fault, 0444, show_temp_fault, NULL, 1), - SENSOR_ATTR(temp2_alarm, 0444, show_temp_alarm, NULL, 1), - SENSOR_ATTR(temp3_input, 0444, show_temp_value, NULL, 2), - SENSOR_ATTR(temp3_max, 0644, show_temp_max, store_temp_max, 2), - SENSOR_ATTR(temp3_fault, 0444, show_temp_fault, NULL, 2), - SENSOR_ATTR(temp3_alarm, 0444, show_temp_alarm, NULL, 2), - SENSOR_ATTR(temp4_input, 0444, show_temp_value, NULL, 3), - SENSOR_ATTR(temp4_max, 0644, show_temp_max, store_temp_max, 3), - SENSOR_ATTR(temp4_fault, 0444, show_temp_fault, NULL, 3), - SENSOR_ATTR(temp4_alarm, 0444, show_temp_alarm, NULL, 3), - SENSOR_ATTR(temp5_input, 0444, show_temp_value, NULL, 4), - SENSOR_ATTR(temp5_max, 0644, show_temp_max, store_temp_max, 4), - SENSOR_ATTR(temp5_fault, 0444, show_temp_fault, NULL, 4), - SENSOR_ATTR(temp5_alarm, 0444, show_temp_alarm, NULL, 4), - SENSOR_ATTR(temp6_input, 0444, show_temp_value, NULL, 5), - SENSOR_ATTR(temp6_max, 0644, show_temp_max, store_temp_max, 5), - SENSOR_ATTR(temp6_fault, 0444, show_temp_fault, NULL, 5), - SENSOR_ATTR(temp6_alarm, 0444, show_temp_alarm, NULL, 5), - SENSOR_ATTR(temp7_input, 0444, show_temp_value, NULL, 6), - SENSOR_ATTR(temp7_max, 0644, show_temp_max, store_temp_max, 6), - SENSOR_ATTR(temp7_fault, 0444, show_temp_fault, NULL, 6), - SENSOR_ATTR(temp7_alarm, 0444, show_temp_alarm, NULL, 6), - SENSOR_ATTR(temp8_input, 0444, show_temp_value, NULL, 7), - SENSOR_ATTR(temp8_max, 0644, show_temp_max, store_temp_max, 7), - SENSOR_ATTR(temp8_fault, 0444, show_temp_fault, NULL, 7), - SENSOR_ATTR(temp8_alarm, 0444, show_temp_alarm, NULL, 7), - SENSOR_ATTR(temp9_input, 0444, show_temp_value, NULL, 8), - SENSOR_ATTR(temp9_max, 0644, show_temp_max, store_temp_max, 8), - SENSOR_ATTR(temp9_fault, 0444, show_temp_fault, NULL, 8), - SENSOR_ATTR(temp9_alarm, 0444, show_temp_alarm, NULL, 8), - SENSOR_ATTR(temp10_input, 0444, show_temp_value, NULL, 9), - SENSOR_ATTR(temp10_max, 0644, show_temp_max, store_temp_max, 9), - SENSOR_ATTR(temp10_fault, 0444, show_temp_fault, NULL, 9), - SENSOR_ATTR(temp10_alarm, 0444, show_temp_alarm, NULL, 9), - SENSOR_ATTR(temp11_input, 0444, show_temp_value, NULL, 10), - SENSOR_ATTR(temp11_max, 0644, show_temp_max, store_temp_max, 10), - SENSOR_ATTR(temp11_fault, 0444, show_temp_fault, NULL, 10), - SENSOR_ATTR(temp11_alarm, 0444, show_temp_alarm, NULL, 10), + SENSOR_ATTR_RO(temp1_input, temp_value, 0), + SENSOR_ATTR_RW(temp1_max, temp_max, 0), + SENSOR_ATTR_RO(temp1_fault, temp_fault, 0), + SENSOR_ATTR_RO(temp1_alarm, temp_alarm, 0), + SENSOR_ATTR_RO(temp2_input, temp_value, 1), + SENSOR_ATTR_RW(temp2_max, temp_max, 1), + SENSOR_ATTR_RO(temp2_fault, temp_fault, 1), + SENSOR_ATTR_RO(temp2_alarm, temp_alarm, 1), + SENSOR_ATTR_RO(temp3_input, temp_value, 2), + SENSOR_ATTR_RW(temp3_max, temp_max, 2), + SENSOR_ATTR_RO(temp3_fault, temp_fault, 2), + SENSOR_ATTR_RO(temp3_alarm, temp_alarm, 2), + SENSOR_ATTR_RO(temp4_input, temp_value, 3), + SENSOR_ATTR_RW(temp4_max, temp_max, 3), + SENSOR_ATTR_RO(temp4_fault, temp_fault, 3), + SENSOR_ATTR_RO(temp4_alarm, temp_alarm, 3), + SENSOR_ATTR_RO(temp5_input, temp_value, 4), + SENSOR_ATTR_RW(temp5_max, temp_max, 4), + SENSOR_ATTR_RO(temp5_fault, temp_fault, 4), + SENSOR_ATTR_RO(temp5_alarm, temp_alarm, 4), + SENSOR_ATTR_RO(temp6_input, temp_value, 5), + SENSOR_ATTR_RW(temp6_max, temp_max, 5), + SENSOR_ATTR_RO(temp6_fault, temp_fault, 5), + SENSOR_ATTR_RO(temp6_alarm, temp_alarm, 5), + SENSOR_ATTR_RO(temp7_input, temp_value, 6), + SENSOR_ATTR_RW(temp7_max, temp_max, 6), + SENSOR_ATTR_RO(temp7_fault, temp_fault, 6), + SENSOR_ATTR_RO(temp7_alarm, temp_alarm, 6), + SENSOR_ATTR_RO(temp8_input, temp_value, 7), + SENSOR_ATTR_RW(temp8_max, temp_max, 7), + SENSOR_ATTR_RO(temp8_fault, temp_fault, 7), + SENSOR_ATTR_RO(temp8_alarm, temp_alarm, 7), + SENSOR_ATTR_RO(temp9_input, temp_value, 8), + SENSOR_ATTR_RW(temp9_max, temp_max, 8), + SENSOR_ATTR_RO(temp9_fault, temp_fault, 8), + SENSOR_ATTR_RO(temp9_alarm, temp_alarm, 8), + SENSOR_ATTR_RO(temp10_input, temp_value, 9), + SENSOR_ATTR_RW(temp10_max, temp_max, 9), + SENSOR_ATTR_RO(temp10_fault, temp_fault, 9), + SENSOR_ATTR_RO(temp10_alarm, temp_alarm, 9), + SENSOR_ATTR_RO(temp11_input, temp_value, 10), + SENSOR_ATTR_RW(temp11_max, temp_max, 10), + SENSOR_ATTR_RO(temp11_fault, temp_fault, 10), + SENSOR_ATTR_RO(temp11_alarm, temp_alarm, 10), }; static struct sensor_device_attribute fschmd_fan_attr[] = { - SENSOR_ATTR(fan1_input, 0444, show_fan_value, NULL, 0), - SENSOR_ATTR(fan1_div, 0644, show_fan_div, store_fan_div, 0), - SENSOR_ATTR(fan1_alarm, 0444, show_fan_alarm, NULL, 0), - SENSOR_ATTR(fan1_fault, 0444, show_fan_fault, NULL, 0), - SENSOR_ATTR(pwm1_auto_point1_pwm, 0644, show_pwm_auto_point1_pwm, - store_pwm_auto_point1_pwm, 0), - SENSOR_ATTR(fan2_input, 0444, show_fan_value, NULL, 1), - SENSOR_ATTR(fan2_div, 0644, show_fan_div, store_fan_div, 1), - SENSOR_ATTR(fan2_alarm, 0444, show_fan_alarm, NULL, 1), - SENSOR_ATTR(fan2_fault, 0444, show_fan_fault, NULL, 1), - SENSOR_ATTR(pwm2_auto_point1_pwm, 0644, show_pwm_auto_point1_pwm, - store_pwm_auto_point1_pwm, 1), - SENSOR_ATTR(fan3_input, 0444, show_fan_value, NULL, 2), - SENSOR_ATTR(fan3_div, 0644, show_fan_div, store_fan_div, 2), - SENSOR_ATTR(fan3_alarm, 0444, show_fan_alarm, NULL, 2), - SENSOR_ATTR(fan3_fault, 0444, show_fan_fault, NULL, 2), - SENSOR_ATTR(pwm3_auto_point1_pwm, 0644, show_pwm_auto_point1_pwm, - store_pwm_auto_point1_pwm, 2), - SENSOR_ATTR(fan4_input, 0444, show_fan_value, NULL, 3), - SENSOR_ATTR(fan4_div, 0644, show_fan_div, store_fan_div, 3), - SENSOR_ATTR(fan4_alarm, 0444, show_fan_alarm, NULL, 3), - SENSOR_ATTR(fan4_fault, 0444, show_fan_fault, NULL, 3), - SENSOR_ATTR(pwm4_auto_point1_pwm, 0644, show_pwm_auto_point1_pwm, - store_pwm_auto_point1_pwm, 3), - SENSOR_ATTR(fan5_input, 0444, show_fan_value, NULL, 4), - SENSOR_ATTR(fan5_div, 0644, show_fan_div, store_fan_div, 4), - SENSOR_ATTR(fan5_alarm, 0444, show_fan_alarm, NULL, 4), - SENSOR_ATTR(fan5_fault, 0444, show_fan_fault, NULL, 4), - SENSOR_ATTR(pwm5_auto_point1_pwm, 0644, show_pwm_auto_point1_pwm, - store_pwm_auto_point1_pwm, 4), - SENSOR_ATTR(fan6_input, 0444, show_fan_value, NULL, 5), - SENSOR_ATTR(fan6_div, 0644, show_fan_div, store_fan_div, 5), - SENSOR_ATTR(fan6_alarm, 0444, show_fan_alarm, NULL, 5), - SENSOR_ATTR(fan6_fault, 0444, show_fan_fault, NULL, 5), - SENSOR_ATTR(pwm6_auto_point1_pwm, 0644, show_pwm_auto_point1_pwm, - store_pwm_auto_point1_pwm, 5), - SENSOR_ATTR(fan7_input, 0444, show_fan_value, NULL, 6), - SENSOR_ATTR(fan7_div, 0644, show_fan_div, store_fan_div, 6), - SENSOR_ATTR(fan7_alarm, 0444, show_fan_alarm, NULL, 6), - SENSOR_ATTR(fan7_fault, 0444, show_fan_fault, NULL, 6), - SENSOR_ATTR(pwm7_auto_point1_pwm, 0644, show_pwm_auto_point1_pwm, - store_pwm_auto_point1_pwm, 6), + SENSOR_ATTR_RO(fan1_input, fan_value, 0), + SENSOR_ATTR_RW(fan1_div, fan_div, 0), + SENSOR_ATTR_RO(fan1_alarm, fan_alarm, 0), + SENSOR_ATTR_RO(fan1_fault, fan_fault, 0), + SENSOR_ATTR_RW(pwm1_auto_point1_pwm, pwm_auto_point1_pwm, 0), + SENSOR_ATTR_RO(fan2_input, fan_value, 1), + SENSOR_ATTR_RW(fan2_div, fan_div, 1), + SENSOR_ATTR_RO(fan2_alarm, fan_alarm, 1), + SENSOR_ATTR_RO(fan2_fault, fan_fault, 1), + SENSOR_ATTR_RW(pwm2_auto_point1_pwm, pwm_auto_point1_pwm, 1), + SENSOR_ATTR_RO(fan3_input, fan_value, 2), + SENSOR_ATTR_RW(fan3_div, fan_div, 2), + SENSOR_ATTR_RO(fan3_alarm, fan_alarm, 2), + SENSOR_ATTR_RO(fan3_fault, fan_fault, 2), + SENSOR_ATTR_RW(pwm3_auto_point1_pwm, pwm_auto_point1_pwm, 2), + SENSOR_ATTR_RO(fan4_input, fan_value, 3), + SENSOR_ATTR_RW(fan4_div, fan_div, 3), + SENSOR_ATTR_RO(fan4_alarm, fan_alarm, 3), + SENSOR_ATTR_RO(fan4_fault, fan_fault, 3), + SENSOR_ATTR_RW(pwm4_auto_point1_pwm, pwm_auto_point1_pwm, 3), + SENSOR_ATTR_RO(fan5_input, fan_value, 4), + SENSOR_ATTR_RW(fan5_div, fan_div, 4), + SENSOR_ATTR_RO(fan5_alarm, fan_alarm, 4), + SENSOR_ATTR_RO(fan5_fault, fan_fault, 4), + SENSOR_ATTR_RW(pwm5_auto_point1_pwm, pwm_auto_point1_pwm, 4), + SENSOR_ATTR_RO(fan6_input, fan_value, 5), + SENSOR_ATTR_RW(fan6_div, fan_div, 5), + SENSOR_ATTR_RO(fan6_alarm, fan_alarm, 5), + SENSOR_ATTR_RO(fan6_fault, fan_fault, 5), + SENSOR_ATTR_RW(pwm6_auto_point1_pwm, pwm_auto_point1_pwm, 5), + SENSOR_ATTR_RO(fan7_input, fan_value, 6), + SENSOR_ATTR_RW(fan7_div, fan_div, 6), + SENSOR_ATTR_RO(fan7_alarm, fan_alarm, 6), + SENSOR_ATTR_RO(fan7_fault, fan_fault, 6), + SENSOR_ATTR_RW(pwm7_auto_point1_pwm, pwm_auto_point1_pwm, 6), }; @@ -1169,7 +1166,7 @@ static int fschmd_probe(struct i2c_client *client, for (i = 0; i < (FSCHMD_NO_TEMP_SENSORS[data->kind] * 4); i++) { /* Poseidon doesn't have TEMP_LIMIT registers */ if (kind == fscpos && fschmd_temp_attr[i].dev_attr.show == - show_temp_max) + temp_max_show) continue; if (kind == fscsyl) { -- cgit v1.2.3 From 626f5eaed15ab81e9ece29d3dc1cf9e5881110f3 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:06 -0800 Subject: hwmon: (ftsteutates) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/ftsteutates.c | 202 +++++++++++++++++++------------------------- 1 file changed, 89 insertions(+), 113 deletions(-) diff --git a/drivers/hwmon/ftsteutates.c b/drivers/hwmon/ftsteutates.c index 0801f48a41f7..ca8f4481264b 100644 --- a/drivers/hwmon/ftsteutates.c +++ b/drivers/hwmon/ftsteutates.c @@ -352,7 +352,7 @@ static int fts_watchdog_init(struct fts_data *data) /*****************************************************************************/ /* SysFS handler functions */ /*****************************************************************************/ -static ssize_t show_in_value(struct device *dev, +static ssize_t in_value_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct fts_data *data = dev_get_drvdata(dev); @@ -366,7 +366,7 @@ static ssize_t show_in_value(struct device *dev, return sprintf(buf, "%u\n", data->volt[index]); } -static ssize_t show_temp_value(struct device *dev, +static ssize_t temp_value_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct fts_data *data = dev_get_drvdata(dev); @@ -380,7 +380,7 @@ static ssize_t show_temp_value(struct device *dev, return sprintf(buf, "%u\n", data->temp_input[index]); } -static ssize_t show_temp_fault(struct device *dev, +static ssize_t temp_fault_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct fts_data *data = dev_get_drvdata(dev); @@ -395,7 +395,7 @@ static ssize_t show_temp_fault(struct device *dev, return sprintf(buf, "%d\n", data->temp_input[index] == 0); } -static ssize_t show_temp_alarm(struct device *dev, +static ssize_t temp_alarm_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct fts_data *data = dev_get_drvdata(dev); @@ -410,7 +410,7 @@ static ssize_t show_temp_alarm(struct device *dev, } static ssize_t -clear_temp_alarm(struct device *dev, struct device_attribute *devattr, +temp_alarm_store(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct fts_data *data = dev_get_drvdata(dev); @@ -441,7 +441,7 @@ error: return ret; } -static ssize_t show_fan_value(struct device *dev, +static ssize_t fan_value_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct fts_data *data = dev_get_drvdata(dev); @@ -455,7 +455,7 @@ static ssize_t show_fan_value(struct device *dev, return sprintf(buf, "%u\n", data->fan_input[index]); } -static ssize_t show_fan_source(struct device *dev, +static ssize_t fan_source_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct fts_data *data = dev_get_drvdata(dev); @@ -469,7 +469,7 @@ static ssize_t show_fan_source(struct device *dev, return sprintf(buf, "%u\n", data->fan_source[index]); } -static ssize_t show_fan_alarm(struct device *dev, +static ssize_t fan_alarm_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct fts_data *data = dev_get_drvdata(dev); @@ -484,7 +484,7 @@ static ssize_t show_fan_alarm(struct device *dev, } static ssize_t -clear_fan_alarm(struct device *dev, struct device_attribute *devattr, +fan_alarm_store(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct fts_data *data = dev_get_drvdata(dev); @@ -520,72 +520,56 @@ error: /*****************************************************************************/ /* Temprature sensors */ -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_value, NULL, 0); -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_value, NULL, 1); -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp_value, NULL, 2); -static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp_value, NULL, 3); -static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO, show_temp_value, NULL, 4); -static SENSOR_DEVICE_ATTR(temp6_input, S_IRUGO, show_temp_value, NULL, 5); -static SENSOR_DEVICE_ATTR(temp7_input, S_IRUGO, show_temp_value, NULL, 6); -static SENSOR_DEVICE_ATTR(temp8_input, S_IRUGO, show_temp_value, NULL, 7); -static SENSOR_DEVICE_ATTR(temp9_input, S_IRUGO, show_temp_value, NULL, 8); -static SENSOR_DEVICE_ATTR(temp10_input, S_IRUGO, show_temp_value, NULL, 9); -static SENSOR_DEVICE_ATTR(temp11_input, S_IRUGO, show_temp_value, NULL, 10); -static SENSOR_DEVICE_ATTR(temp12_input, S_IRUGO, show_temp_value, NULL, 11); -static SENSOR_DEVICE_ATTR(temp13_input, S_IRUGO, show_temp_value, NULL, 12); -static SENSOR_DEVICE_ATTR(temp14_input, S_IRUGO, show_temp_value, NULL, 13); -static SENSOR_DEVICE_ATTR(temp15_input, S_IRUGO, show_temp_value, NULL, 14); -static SENSOR_DEVICE_ATTR(temp16_input, S_IRUGO, show_temp_value, NULL, 15); - -static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0); -static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_temp_fault, NULL, 1); -static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_temp_fault, NULL, 2); -static SENSOR_DEVICE_ATTR(temp4_fault, S_IRUGO, show_temp_fault, NULL, 3); -static SENSOR_DEVICE_ATTR(temp5_fault, S_IRUGO, show_temp_fault, NULL, 4); -static SENSOR_DEVICE_ATTR(temp6_fault, S_IRUGO, show_temp_fault, NULL, 5); -static SENSOR_DEVICE_ATTR(temp7_fault, S_IRUGO, show_temp_fault, NULL, 6); -static SENSOR_DEVICE_ATTR(temp8_fault, S_IRUGO, show_temp_fault, NULL, 7); -static SENSOR_DEVICE_ATTR(temp9_fault, S_IRUGO, show_temp_fault, NULL, 8); -static SENSOR_DEVICE_ATTR(temp10_fault, S_IRUGO, show_temp_fault, NULL, 9); -static SENSOR_DEVICE_ATTR(temp11_fault, S_IRUGO, show_temp_fault, NULL, 10); -static SENSOR_DEVICE_ATTR(temp12_fault, S_IRUGO, show_temp_fault, NULL, 11); -static SENSOR_DEVICE_ATTR(temp13_fault, S_IRUGO, show_temp_fault, NULL, 12); -static SENSOR_DEVICE_ATTR(temp14_fault, S_IRUGO, show_temp_fault, NULL, 13); -static SENSOR_DEVICE_ATTR(temp15_fault, S_IRUGO, show_temp_fault, NULL, 14); -static SENSOR_DEVICE_ATTR(temp16_fault, S_IRUGO, show_temp_fault, NULL, 15); - -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO | S_IWUSR, show_temp_alarm, - clear_temp_alarm, 0); -static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO | S_IWUSR, show_temp_alarm, - clear_temp_alarm, 1); -static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO | S_IWUSR, show_temp_alarm, - clear_temp_alarm, 2); -static SENSOR_DEVICE_ATTR(temp4_alarm, S_IRUGO | S_IWUSR, show_temp_alarm, - clear_temp_alarm, 3); -static SENSOR_DEVICE_ATTR(temp5_alarm, S_IRUGO | S_IWUSR, show_temp_alarm, - clear_temp_alarm, 4); -static SENSOR_DEVICE_ATTR(temp6_alarm, S_IRUGO | S_IWUSR, show_temp_alarm, - clear_temp_alarm, 5); -static SENSOR_DEVICE_ATTR(temp7_alarm, S_IRUGO | S_IWUSR, show_temp_alarm, - clear_temp_alarm, 6); -static SENSOR_DEVICE_ATTR(temp8_alarm, S_IRUGO | S_IWUSR, show_temp_alarm, - clear_temp_alarm, 7); -static SENSOR_DEVICE_ATTR(temp9_alarm, S_IRUGO | S_IWUSR, show_temp_alarm, - clear_temp_alarm, 8); -static SENSOR_DEVICE_ATTR(temp10_alarm, S_IRUGO | S_IWUSR, show_temp_alarm, - clear_temp_alarm, 9); -static SENSOR_DEVICE_ATTR(temp11_alarm, S_IRUGO | S_IWUSR, show_temp_alarm, - clear_temp_alarm, 10); -static SENSOR_DEVICE_ATTR(temp12_alarm, S_IRUGO | S_IWUSR, show_temp_alarm, - clear_temp_alarm, 11); -static SENSOR_DEVICE_ATTR(temp13_alarm, S_IRUGO | S_IWUSR, show_temp_alarm, - clear_temp_alarm, 12); -static SENSOR_DEVICE_ATTR(temp14_alarm, S_IRUGO | S_IWUSR, show_temp_alarm, - clear_temp_alarm, 13); -static SENSOR_DEVICE_ATTR(temp15_alarm, S_IRUGO | S_IWUSR, show_temp_alarm, - clear_temp_alarm, 14); -static SENSOR_DEVICE_ATTR(temp16_alarm, S_IRUGO | S_IWUSR, show_temp_alarm, - clear_temp_alarm, 15); +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp_value, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp_value, 1); +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp_value, 2); +static SENSOR_DEVICE_ATTR_RO(temp4_input, temp_value, 3); +static SENSOR_DEVICE_ATTR_RO(temp5_input, temp_value, 4); +static SENSOR_DEVICE_ATTR_RO(temp6_input, temp_value, 5); +static SENSOR_DEVICE_ATTR_RO(temp7_input, temp_value, 6); +static SENSOR_DEVICE_ATTR_RO(temp8_input, temp_value, 7); +static SENSOR_DEVICE_ATTR_RO(temp9_input, temp_value, 8); +static SENSOR_DEVICE_ATTR_RO(temp10_input, temp_value, 9); +static SENSOR_DEVICE_ATTR_RO(temp11_input, temp_value, 10); +static SENSOR_DEVICE_ATTR_RO(temp12_input, temp_value, 11); +static SENSOR_DEVICE_ATTR_RO(temp13_input, temp_value, 12); +static SENSOR_DEVICE_ATTR_RO(temp14_input, temp_value, 13); +static SENSOR_DEVICE_ATTR_RO(temp15_input, temp_value, 14); +static SENSOR_DEVICE_ATTR_RO(temp16_input, temp_value, 15); + +static SENSOR_DEVICE_ATTR_RO(temp1_fault, temp_fault, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_fault, temp_fault, 1); +static SENSOR_DEVICE_ATTR_RO(temp3_fault, temp_fault, 2); +static SENSOR_DEVICE_ATTR_RO(temp4_fault, temp_fault, 3); +static SENSOR_DEVICE_ATTR_RO(temp5_fault, temp_fault, 4); +static SENSOR_DEVICE_ATTR_RO(temp6_fault, temp_fault, 5); +static SENSOR_DEVICE_ATTR_RO(temp7_fault, temp_fault, 6); +static SENSOR_DEVICE_ATTR_RO(temp8_fault, temp_fault, 7); +static SENSOR_DEVICE_ATTR_RO(temp9_fault, temp_fault, 8); +static SENSOR_DEVICE_ATTR_RO(temp10_fault, temp_fault, 9); +static SENSOR_DEVICE_ATTR_RO(temp11_fault, temp_fault, 10); +static SENSOR_DEVICE_ATTR_RO(temp12_fault, temp_fault, 11); +static SENSOR_DEVICE_ATTR_RO(temp13_fault, temp_fault, 12); +static SENSOR_DEVICE_ATTR_RO(temp14_fault, temp_fault, 13); +static SENSOR_DEVICE_ATTR_RO(temp15_fault, temp_fault, 14); +static SENSOR_DEVICE_ATTR_RO(temp16_fault, temp_fault, 15); + +static SENSOR_DEVICE_ATTR_RW(temp1_alarm, temp_alarm, 0); +static SENSOR_DEVICE_ATTR_RW(temp2_alarm, temp_alarm, 1); +static SENSOR_DEVICE_ATTR_RW(temp3_alarm, temp_alarm, 2); +static SENSOR_DEVICE_ATTR_RW(temp4_alarm, temp_alarm, 3); +static SENSOR_DEVICE_ATTR_RW(temp5_alarm, temp_alarm, 4); +static SENSOR_DEVICE_ATTR_RW(temp6_alarm, temp_alarm, 5); +static SENSOR_DEVICE_ATTR_RW(temp7_alarm, temp_alarm, 6); +static SENSOR_DEVICE_ATTR_RW(temp8_alarm, temp_alarm, 7); +static SENSOR_DEVICE_ATTR_RW(temp9_alarm, temp_alarm, 8); +static SENSOR_DEVICE_ATTR_RW(temp10_alarm, temp_alarm, 9); +static SENSOR_DEVICE_ATTR_RW(temp11_alarm, temp_alarm, 10); +static SENSOR_DEVICE_ATTR_RW(temp12_alarm, temp_alarm, 11); +static SENSOR_DEVICE_ATTR_RW(temp13_alarm, temp_alarm, 12); +static SENSOR_DEVICE_ATTR_RW(temp14_alarm, temp_alarm, 13); +static SENSOR_DEVICE_ATTR_RW(temp15_alarm, temp_alarm, 14); +static SENSOR_DEVICE_ATTR_RW(temp16_alarm, temp_alarm, 15); static struct attribute *fts_temp_attrs[] = { &sensor_dev_attr_temp1_input.dev_attr.attr, @@ -642,40 +626,32 @@ static struct attribute *fts_temp_attrs[] = { }; /* Fans */ -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan_value, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan_value, NULL, 1); -static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan_value, NULL, 2); -static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan_value, NULL, 3); -static SENSOR_DEVICE_ATTR(fan5_input, S_IRUGO, show_fan_value, NULL, 4); -static SENSOR_DEVICE_ATTR(fan6_input, S_IRUGO, show_fan_value, NULL, 5); -static SENSOR_DEVICE_ATTR(fan7_input, S_IRUGO, show_fan_value, NULL, 6); -static SENSOR_DEVICE_ATTR(fan8_input, S_IRUGO, show_fan_value, NULL, 7); - -static SENSOR_DEVICE_ATTR(fan1_source, S_IRUGO, show_fan_source, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_source, S_IRUGO, show_fan_source, NULL, 1); -static SENSOR_DEVICE_ATTR(fan3_source, S_IRUGO, show_fan_source, NULL, 2); -static SENSOR_DEVICE_ATTR(fan4_source, S_IRUGO, show_fan_source, NULL, 3); -static SENSOR_DEVICE_ATTR(fan5_source, S_IRUGO, show_fan_source, NULL, 4); -static SENSOR_DEVICE_ATTR(fan6_source, S_IRUGO, show_fan_source, NULL, 5); -static SENSOR_DEVICE_ATTR(fan7_source, S_IRUGO, show_fan_source, NULL, 6); -static SENSOR_DEVICE_ATTR(fan8_source, S_IRUGO, show_fan_source, NULL, 7); - -static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO | S_IWUSR, - show_fan_alarm, clear_fan_alarm, 0); -static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO | S_IWUSR, - show_fan_alarm, clear_fan_alarm, 1); -static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO | S_IWUSR, - show_fan_alarm, clear_fan_alarm, 2); -static SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO | S_IWUSR, - show_fan_alarm, clear_fan_alarm, 3); -static SENSOR_DEVICE_ATTR(fan5_alarm, S_IRUGO | S_IWUSR, - show_fan_alarm, clear_fan_alarm, 4); -static SENSOR_DEVICE_ATTR(fan6_alarm, S_IRUGO | S_IWUSR, - show_fan_alarm, clear_fan_alarm, 5); -static SENSOR_DEVICE_ATTR(fan7_alarm, S_IRUGO | S_IWUSR, - show_fan_alarm, clear_fan_alarm, 6); -static SENSOR_DEVICE_ATTR(fan8_alarm, S_IRUGO | S_IWUSR, - show_fan_alarm, clear_fan_alarm, 7); +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan_value, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan_value, 1); +static SENSOR_DEVICE_ATTR_RO(fan3_input, fan_value, 2); +static SENSOR_DEVICE_ATTR_RO(fan4_input, fan_value, 3); +static SENSOR_DEVICE_ATTR_RO(fan5_input, fan_value, 4); +static SENSOR_DEVICE_ATTR_RO(fan6_input, fan_value, 5); +static SENSOR_DEVICE_ATTR_RO(fan7_input, fan_value, 6); +static SENSOR_DEVICE_ATTR_RO(fan8_input, fan_value, 7); + +static SENSOR_DEVICE_ATTR_RO(fan1_source, fan_source, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_source, fan_source, 1); +static SENSOR_DEVICE_ATTR_RO(fan3_source, fan_source, 2); +static SENSOR_DEVICE_ATTR_RO(fan4_source, fan_source, 3); +static SENSOR_DEVICE_ATTR_RO(fan5_source, fan_source, 4); +static SENSOR_DEVICE_ATTR_RO(fan6_source, fan_source, 5); +static SENSOR_DEVICE_ATTR_RO(fan7_source, fan_source, 6); +static SENSOR_DEVICE_ATTR_RO(fan8_source, fan_source, 7); + +static SENSOR_DEVICE_ATTR_RW(fan1_alarm, fan_alarm, 0); +static SENSOR_DEVICE_ATTR_RW(fan2_alarm, fan_alarm, 1); +static SENSOR_DEVICE_ATTR_RW(fan3_alarm, fan_alarm, 2); +static SENSOR_DEVICE_ATTR_RW(fan4_alarm, fan_alarm, 3); +static SENSOR_DEVICE_ATTR_RW(fan5_alarm, fan_alarm, 4); +static SENSOR_DEVICE_ATTR_RW(fan6_alarm, fan_alarm, 5); +static SENSOR_DEVICE_ATTR_RW(fan7_alarm, fan_alarm, 6); +static SENSOR_DEVICE_ATTR_RW(fan8_alarm, fan_alarm, 7); static struct attribute *fts_fan_attrs[] = { &sensor_dev_attr_fan1_input.dev_attr.attr, @@ -708,10 +684,10 @@ static struct attribute *fts_fan_attrs[] = { }; /* Voltages */ -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_in_value, NULL, 0); -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_in_value, NULL, 1); -static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_in_value, NULL, 2); -static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_in_value, NULL, 3); +static SENSOR_DEVICE_ATTR_RO(in1_input, in_value, 0); +static SENSOR_DEVICE_ATTR_RO(in2_input, in_value, 1); +static SENSOR_DEVICE_ATTR_RO(in3_input, in_value, 2); +static SENSOR_DEVICE_ATTR_RO(in4_input, in_value, 3); static struct attribute *fts_voltage_attrs[] = { &sensor_dev_attr_in1_input.dev_attr.attr, &sensor_dev_attr_in2_input.dev_attr.attr, -- cgit v1.2.3 From f9facc24a6441d6a82d6cca942b162a394ecba66 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Wed, 12 Dec 2018 08:36:36 +0000 Subject: hwmon: (asus_atk0110) Fix debugfs_simple_attr.cocci warnings Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE for debugfs files. Semantic patch information: Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file() imposes some significant overhead as compared to DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe(). Generated by: scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci Signed-off-by: YueHaibing Signed-off-by: Guenter Roeck --- drivers/hwmon/asus_atk0110.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c index a5638d1f7e4b..22be78cc5a4c 100644 --- a/drivers/hwmon/asus_atk0110.c +++ b/drivers/hwmon/asus_atk0110.c @@ -681,10 +681,8 @@ static int atk_debugfs_gitm_get(void *p, u64 *val) return err; } -DEFINE_SIMPLE_ATTRIBUTE(atk_debugfs_gitm, - atk_debugfs_gitm_get, - NULL, - "0x%08llx\n"); +DEFINE_DEBUGFS_ATTRIBUTE(atk_debugfs_gitm, atk_debugfs_gitm_get, NULL, + "0x%08llx\n"); static int atk_acpi_print(char *buf, size_t sz, union acpi_object *obj) { @@ -803,8 +801,8 @@ static void atk_debugfs_init(struct atk_data *data) if (!f || IS_ERR(f)) goto cleanup; - f = debugfs_create_file("gitm", 0400, d, data, - &atk_debugfs_gitm); + f = debugfs_create_file_unsafe("gitm", 0400, d, data, + &atk_debugfs_gitm); if (!f || IS_ERR(f)) goto cleanup; -- cgit v1.2.3 From c9c63915519b1def7043b184680f33c24cd49d7b Mon Sep 17 00:00:00 2001 From: Kangjie Lu Date: Fri, 21 Dec 2018 13:01:33 -0600 Subject: hwmon: (lm80) fix a missing check of the status of SMBus read If lm80_read_value() fails, it returns a negative number instead of the correct read data. Therefore, we should avoid using the data if it fails. The fix checks if lm80_read_value() fails, and if so, returns with the error number. Signed-off-by: Kangjie Lu [groeck: One variable for return values is enough] Signed-off-by: Guenter Roeck --- drivers/hwmon/lm80.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index 08e3945a6fbf..04f9df0d2341 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c @@ -360,9 +360,11 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, struct i2c_client *client = data->client; unsigned long min, val; u8 reg; - int err = kstrtoul(buf, 10, &val); - if (err < 0) - return err; + int rv; + + rv = kstrtoul(buf, 10, &val); + if (rv < 0) + return rv; /* Save fan_min */ mutex_lock(&data->update_lock); @@ -390,8 +392,11 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, return -EINVAL; } - reg = (lm80_read_value(client, LM80_REG_FANDIV) & - ~(3 << (2 * (nr + 1)))) | (data->fan_div[nr] << (2 * (nr + 1))); + rv = lm80_read_value(client, LM80_REG_FANDIV); + if (rv < 0) + return rv; + reg = (rv & ~(3 << (2 * (nr + 1)))) + | (data->fan_div[nr] << (2 * (nr + 1))); lm80_write_value(client, LM80_REG_FANDIV, reg); /* Restore fan_min */ -- cgit v1.2.3 From 9aa3aa15f4c2f74f47afd6c5db4b420fadf3f315 Mon Sep 17 00:00:00 2001 From: Kangjie Lu Date: Fri, 21 Dec 2018 13:10:39 -0600 Subject: hwmon: (lm80) fix a missing check of bus read in lm80 probe In lm80_probe(), if lm80_read_value() fails, it returns a negative error number which is stored to data->fan[f_min] and will be further used. We should avoid using the data if the read fails. The fix checks if lm80_read_value() fails, and if so, returns with the error number. Signed-off-by: Kangjie Lu Signed-off-by: Guenter Roeck --- drivers/hwmon/lm80.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index 04f9df0d2341..0e30fa00204c 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c @@ -628,6 +628,7 @@ static int lm80_probe(struct i2c_client *client, struct device *dev = &client->dev; struct device *hwmon_dev; struct lm80_data *data; + int rv; data = devm_kzalloc(dev, sizeof(struct lm80_data), GFP_KERNEL); if (!data) @@ -640,8 +641,14 @@ static int lm80_probe(struct i2c_client *client, lm80_init_client(client); /* A few vars need to be filled upon startup */ - data->fan[f_min][0] = lm80_read_value(client, LM80_REG_FAN_MIN(1)); - data->fan[f_min][1] = lm80_read_value(client, LM80_REG_FAN_MIN(2)); + rv = lm80_read_value(client, LM80_REG_FAN_MIN(1)); + if (rv < 0) + return rv; + data->fan[f_min][0] = rv; + rv = lm80_read_value(client, LM80_REG_FAN_MIN(2)); + if (rv < 0) + return rv; + data->fan[f_min][1] = rv; hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, data, lm80_groups); -- cgit v1.2.3