Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757019AbcJXBOn (ORCPT ); Sun, 23 Oct 2016 21:14:43 -0400 Received: from mail-db5eur01on0094.outbound.protection.outlook.com ([104.47.2.94]:56685 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756988AbcJXBOk (ORCPT ); Sun, 23 Oct 2016 21:14:40 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; From: Peter Rosin To: CC: Peter Rosin , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , "Peter Meerwald-Stadler" , Rob Herring , "Mark Rutland" , , Subject: [PATCH v3 3/8] iio: mcp4531: provide range of available raw values Date: Mon, 24 Oct 2016 00:39:36 +0200 Message-ID: <1477262381-7800-4-git-send-email-peda@axentia.se> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1477262381-7800-1-git-send-email-peda@axentia.se> References: <1477262381-7800-1-git-send-email-peda@axentia.se> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [217.210.101.82] X-ClientProxiedBy: DB5PR08CA0016.eurprd08.prod.outlook.com (10.163.102.154) To DB6PR0201MB2312.eurprd02.prod.outlook.com (10.169.222.151) X-MS-Office365-Filtering-Correlation-Id: e88d2ea2-8135-4dda-d495-08d3fb959df2 X-Microsoft-Exchange-Diagnostics: 1;DB6PR0201MB2312;2:XCsxIdG+P1iRYVil5kUOb5dzFmefUXVhLuqVszhzOOU0hgxoaTO0/u6in8mapbtQaTeT2etzP7eVerMDjVuZq2VVmAWNhqLdwAhaufprA5MPJPY9muNEclJAmbzEKkX0+a+HQtugSDRxLCeoWnLEDkF4mmmRYKvH9N/NKQKphSsilUWKgSM3opzQ2sqLwUPqfPDKrH0It/bHWGk9DR728g==;3:O28su/P9wqP3uNxFSdZ2eyM6OrYuSEu97qRcPTDlR8W2U/ahg9JIHiPfmkl9/Zq8FBxjS68nd1/h0QI6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OQcSifST0+c6O7HS07+Uf2h7T6MVJgrX4DGtX6ayvkT0OHfYhoFaVqVbwDKszCul13wuI1AaE9AZotKnHsHunccUbM6Pg2UHBPjzCPTypEDcFnQAcCeJfUlqe1OE13emh9gsdusDpGIuRlOFiK7uHXD88WWrdtIFNAJQ3vTEl+0xgxzDUQby3yQb67toPZCMVrHazjmFQz0M9EUBbyZvg+JMTrRsXHlsC6C0j1+tEUgB9wKU8itRamAC7pxJmnYsUm2z6gL1yn15p1BntCWIotewQS3Rw04Q8mXNv45aOyY+sG1taJK9Kc5RZF4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6043046)(6042046);SRVR:DB6PR0201MB2312;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0201MB2312; X-Forefront-PRVS: 0104247462 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(6069001)(7916002)(189002)(199003)(50944005)(5660300001)(68736007)(4326007)(97736004)(50226002)(5003940100001)(2906002)(77096005)(81156014)(92566002)(81166006)(8676002)(101416001)(6116002)(3846002)(586003)(86362001)(189998001)(19580405001)(19580395003)(66066001)(47776003)(6916009)(2950100002)(6666003)(7846002)(8666005)(7736002)(33646002)(76176999)(50986999)(110136003)(48376002)(305945005)(50466002)(36756003)(74482002)(229853001)(2351001)(42186005)(106356001)(105586002)(7059030)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:DB6PR0201MB2312;H:localhost.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DB6PR0201MB2312;23:jU9SesC/xJhsD6cL70Tm5UFrp9qDOMpfZXRweTO?= =?us-ascii?Q?TMavCMFXLxVHLi1fy720Ont5GBBPl/eZ731HZ67hb/Si+Uivf5MBX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b/ifITYJQ3y3KCXY99HOay/lE8lcW1oQpd?= =?us-ascii?Q?FURu0Lsd+mz7KPv2oLEllcBZrn1fPqkrNpYGfen4bAbLTLVTGJR5OW9t6xZI?= =?us-ascii?Q?7aHz36XyE5vd2wTrmq7uQIrRlB7otzpsivpkl1KUEUmw39PKYEZvaQqZ/GJ3?= =?us-ascii?Q?Tgzk4dn8Ff+scIqNjri5Bhjd1pWWbYgA6vPeeUYgisBhJ/QM5U4RaXXFsbxa?= =?us-ascii?Q?uuXycvyS7BPufA1Q2blKHVgA+gbBn+mBOVLde?= X-Microsoft-Exchange-Diagnostics: 1;DB6PR0201MB2312;6:f6ZlDvtNr7xbdR0nH9s65Xrjjz1ApdkZl7F+t1KpTVMf3xbUV5zO4A/cHiZTL8CZQNhjAca2OI+GbXGSMz5DBVeixSOfFGQnBUOM8+mYLBHjm8+DXrb2GPHW/oiJwayqGMXMGv0GiXCwiLC/vrdUHkh5gUaaVDHu6VTasWY0QQBLvuOTE2uyXAQgnx7C1lbnLEqMDjG66Msswmx18wjx36Vt3IJblZOGBoH9jqN3fAZPWeq2/j2U9DzD2X3hmn2oE8XBPiOhbADhrET1f564T0kgJimoIlOIlSOPusUVV5hgmYNH41NYluNLYraHq977Jt+0Kd0pE0bUryBzRTwSxQ==;5:1WBSj8KVStgno+vez6o4Xy0L878AseP3rnmRRlDODDJy0kNnlEZWnkcvuZbysWNeECk1KeJDT3BCR0o7MDDKWktpI2y2YA9BWJDBzH+KvpHSzevP8tqPMzFKXVrHGGQXXR7Rl+NaDjZ4K6v3JM+menxeKfn85yYTNCrtLWe7wYA=;24:9u30TrlzK5G7WhUwdF8e5Pee2OIUdXEB7ScOLwG0FTQZurUcpHC7RgEiajNmC93Sqxgn1IsS5k2I56dJ5dZTSLLiZcdD0nu89H8nV1of6fs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DB6PR0201MB2312;7:beUcG+E/7S3HP2VcKHBv7vNEBk/d8z6I28C8dgbt/7pgIFVckMv+b552FB9W+q0LaPY4YN5OcAGPn6IPRVAnDbt32ciW9nbpnUAXLbBGjqm97yPm5jo9Nud6mGg8zdrLIgSMxdBArrnxJEqih33kSD+O0CIaIk8dqMoB0Gz4bEbnBc7zy5ENr3snHdMNWt5EkIigUv4PxRrxsFSc9HUVPfM3ADDO7WUpJxGiktPKN0TT8ACvg07H1ViJB3uiweVR6IWBoT5ps+/9KI/iNTS2DUiEX7/+JA0dh96aQW1BJpsp9yV09p0sPWJ2CU4G/mYBxE0jS2OC9mqi2TYL5Ldl5O0iALCjplchTjmSbhtb6rU= X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2016 22:40:39.6888 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0201MB2312 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8562 Lines: 199 Example: $ cat '/sys/bus/iio/devices/iio:device0/out_resistance_raw_available' [0 1 256] Meaning: min 0, step 1 and max 256. Signed-off-by: Peter Rosin --- .../testing/sysfs-bus-iio-potentiometer-mcp4531 | 8 ++ MAINTAINERS | 1 + drivers/iio/potentiometer/mcp4531.c | 104 ++++++++++++--------- 3 files changed, 71 insertions(+), 42 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-potentiometer-mcp4531 diff --git a/Documentation/ABI/testing/sysfs-bus-iio-potentiometer-mcp4531 b/Documentation/ABI/testing/sysfs-bus-iio-potentiometer-mcp4531 new file mode 100644 index 000000000000..2a91fbe394fc --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-iio-potentiometer-mcp4531 @@ -0,0 +1,8 @@ +What: /sys/bus/iio/devices/iio:deviceX/out_resistance_raw_available +Date: October 2016 +KernelVersion: 4.9 +Contact: Peter Rosin +Description: + The range of available values represented as the minimum value, + the step and the maximum value, all enclosed in square brackets. + Example: [0 1 256] diff --git a/MAINTAINERS b/MAINTAINERS index 1cd38a7e0064..7c65585e1230 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7694,6 +7694,7 @@ MCP4531 MICROCHIP DIGITAL POTENTIOMETER DRIVER M: Peter Rosin L: linux-iio@vger.kernel.org S: Maintained +F: Documentation/ABI/testing/sysfs-bus-iio-potentiometer-mcp4531 F: drivers/iio/potentiometer/mcp4531.c MEASUREMENT COMPUTING CIO-DAC IIO DRIVER diff --git a/drivers/iio/potentiometer/mcp4531.c b/drivers/iio/potentiometer/mcp4531.c index 13b6ae2fcf7b..0d1bcf89ae17 100644 --- a/drivers/iio/potentiometer/mcp4531.c +++ b/drivers/iio/potentiometer/mcp4531.c @@ -38,7 +38,7 @@ struct mcp4531_cfg { int wipers; - int max_pos; + int avail[3]; int kohms; }; @@ -78,38 +78,38 @@ enum mcp4531_type { }; static const struct mcp4531_cfg mcp4531_cfg[] = { - [MCP453x_502] = { .wipers = 1, .max_pos = 128, .kohms = 5, }, - [MCP453x_103] = { .wipers = 1, .max_pos = 128, .kohms = 10, }, - [MCP453x_503] = { .wipers = 1, .max_pos = 128, .kohms = 50, }, - [MCP453x_104] = { .wipers = 1, .max_pos = 128, .kohms = 100, }, - [MCP454x_502] = { .wipers = 1, .max_pos = 128, .kohms = 5, }, - [MCP454x_103] = { .wipers = 1, .max_pos = 128, .kohms = 10, }, - [MCP454x_503] = { .wipers = 1, .max_pos = 128, .kohms = 50, }, - [MCP454x_104] = { .wipers = 1, .max_pos = 128, .kohms = 100, }, - [MCP455x_502] = { .wipers = 1, .max_pos = 256, .kohms = 5, }, - [MCP455x_103] = { .wipers = 1, .max_pos = 256, .kohms = 10, }, - [MCP455x_503] = { .wipers = 1, .max_pos = 256, .kohms = 50, }, - [MCP455x_104] = { .wipers = 1, .max_pos = 256, .kohms = 100, }, - [MCP456x_502] = { .wipers = 1, .max_pos = 256, .kohms = 5, }, - [MCP456x_103] = { .wipers = 1, .max_pos = 256, .kohms = 10, }, - [MCP456x_503] = { .wipers = 1, .max_pos = 256, .kohms = 50, }, - [MCP456x_104] = { .wipers = 1, .max_pos = 256, .kohms = 100, }, - [MCP463x_502] = { .wipers = 2, .max_pos = 128, .kohms = 5, }, - [MCP463x_103] = { .wipers = 2, .max_pos = 128, .kohms = 10, }, - [MCP463x_503] = { .wipers = 2, .max_pos = 128, .kohms = 50, }, - [MCP463x_104] = { .wipers = 2, .max_pos = 128, .kohms = 100, }, - [MCP464x_502] = { .wipers = 2, .max_pos = 128, .kohms = 5, }, - [MCP464x_103] = { .wipers = 2, .max_pos = 128, .kohms = 10, }, - [MCP464x_503] = { .wipers = 2, .max_pos = 128, .kohms = 50, }, - [MCP464x_104] = { .wipers = 2, .max_pos = 128, .kohms = 100, }, - [MCP465x_502] = { .wipers = 2, .max_pos = 256, .kohms = 5, }, - [MCP465x_103] = { .wipers = 2, .max_pos = 256, .kohms = 10, }, - [MCP465x_503] = { .wipers = 2, .max_pos = 256, .kohms = 50, }, - [MCP465x_104] = { .wipers = 2, .max_pos = 256, .kohms = 100, }, - [MCP466x_502] = { .wipers = 2, .max_pos = 256, .kohms = 5, }, - [MCP466x_103] = { .wipers = 2, .max_pos = 256, .kohms = 10, }, - [MCP466x_503] = { .wipers = 2, .max_pos = 256, .kohms = 50, }, - [MCP466x_104] = { .wipers = 2, .max_pos = 256, .kohms = 100, }, + [MCP453x_502] = { .wipers = 1, .avail = { 0, 1, 128 }, .kohms = 5, }, + [MCP453x_103] = { .wipers = 1, .avail = { 0, 1, 128 }, .kohms = 10, }, + [MCP453x_503] = { .wipers = 1, .avail = { 0, 1, 128 }, .kohms = 50, }, + [MCP453x_104] = { .wipers = 1, .avail = { 0, 1, 128 }, .kohms = 100, }, + [MCP454x_502] = { .wipers = 1, .avail = { 0, 1, 128 }, .kohms = 5, }, + [MCP454x_103] = { .wipers = 1, .avail = { 0, 1, 128 }, .kohms = 10, }, + [MCP454x_503] = { .wipers = 1, .avail = { 0, 1, 128 }, .kohms = 50, }, + [MCP454x_104] = { .wipers = 1, .avail = { 0, 1, 128 }, .kohms = 100, }, + [MCP455x_502] = { .wipers = 1, .avail = { 0, 1, 256 }, .kohms = 5, }, + [MCP455x_103] = { .wipers = 1, .avail = { 0, 1, 256 }, .kohms = 10, }, + [MCP455x_503] = { .wipers = 1, .avail = { 0, 1, 256 }, .kohms = 50, }, + [MCP455x_104] = { .wipers = 1, .avail = { 0, 1, 256 }, .kohms = 100, }, + [MCP456x_502] = { .wipers = 1, .avail = { 0, 1, 256 }, .kohms = 5, }, + [MCP456x_103] = { .wipers = 1, .avail = { 0, 1, 256 }, .kohms = 10, }, + [MCP456x_503] = { .wipers = 1, .avail = { 0, 1, 256 }, .kohms = 50, }, + [MCP456x_104] = { .wipers = 1, .avail = { 0, 1, 256 }, .kohms = 100, }, + [MCP463x_502] = { .wipers = 2, .avail = { 0, 1, 128 }, .kohms = 5, }, + [MCP463x_103] = { .wipers = 2, .avail = { 0, 1, 128 }, .kohms = 10, }, + [MCP463x_503] = { .wipers = 2, .avail = { 0, 1, 128 }, .kohms = 50, }, + [MCP463x_104] = { .wipers = 2, .avail = { 0, 1, 128 }, .kohms = 100, }, + [MCP464x_502] = { .wipers = 2, .avail = { 0, 1, 128 }, .kohms = 5, }, + [MCP464x_103] = { .wipers = 2, .avail = { 0, 1, 128 }, .kohms = 10, }, + [MCP464x_503] = { .wipers = 2, .avail = { 0, 1, 128 }, .kohms = 50, }, + [MCP464x_104] = { .wipers = 2, .avail = { 0, 1, 128 }, .kohms = 100, }, + [MCP465x_502] = { .wipers = 2, .avail = { 0, 1, 256 }, .kohms = 5, }, + [MCP465x_103] = { .wipers = 2, .avail = { 0, 1, 256 }, .kohms = 10, }, + [MCP465x_503] = { .wipers = 2, .avail = { 0, 1, 256 }, .kohms = 50, }, + [MCP465x_104] = { .wipers = 2, .avail = { 0, 1, 256 }, .kohms = 100, }, + [MCP466x_502] = { .wipers = 2, .avail = { 0, 1, 256 }, .kohms = 5, }, + [MCP466x_103] = { .wipers = 2, .avail = { 0, 1, 256 }, .kohms = 10, }, + [MCP466x_503] = { .wipers = 2, .avail = { 0, 1, 256 }, .kohms = 50, }, + [MCP466x_104] = { .wipers = 2, .avail = { 0, 1, 256 }, .kohms = 100, }, }; #define MCP4531_WRITE (0 << 2) @@ -124,13 +124,14 @@ struct mcp4531_data { const struct mcp4531_cfg *cfg; }; -#define MCP4531_CHANNEL(ch) { \ - .type = IIO_RESISTANCE, \ - .indexed = 1, \ - .output = 1, \ - .channel = (ch), \ - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ +#define MCP4531_CHANNEL(ch) { \ + .type = IIO_RESISTANCE, \ + .indexed = 1, \ + .output = 1, \ + .channel = (ch), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_RAW), \ } static const struct iio_chan_spec mcp4531_channels[] = { @@ -156,13 +157,31 @@ static int mcp4531_read_raw(struct iio_dev *indio_dev, return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: *val = 1000 * data->cfg->kohms; - *val2 = data->cfg->max_pos; + *val2 = data->cfg->avail[2]; return IIO_VAL_FRACTIONAL; } return -EINVAL; } +static int mcp4531_read_avail(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, + long mask) +{ + struct mcp4531_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_RAW: + *length = ARRAY_SIZE(data->cfg->avail); + *vals = data->cfg->avail; + *type = IIO_VAL_INT; + return IIO_AVAIL_RANGE; + } + + return -EINVAL; +} + static int mcp4531_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, int val2, long mask) @@ -172,7 +191,7 @@ static int mcp4531_write_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_RAW: - if (val > data->cfg->max_pos || val < 0) + if (val > data->cfg->avail[2] || val < 0) return -EINVAL; break; default: @@ -186,6 +205,7 @@ static int mcp4531_write_raw(struct iio_dev *indio_dev, static const struct iio_info mcp4531_info = { .read_raw = mcp4531_read_raw, + .read_avail = mcp4531_read_avail, .write_raw = mcp4531_write_raw, .driver_module = THIS_MODULE, }; -- 2.1.4