From patchwork Thu Dec 7 13:39:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 845575 X-Patchwork-Delegate: bartekgola@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="GnN4PGPW"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3ysxS32Q5cz9s03 for ; Fri, 8 Dec 2017 00:40:03 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754409AbdLGNkA (ORCPT ); Thu, 7 Dec 2017 08:40:00 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:34817 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754351AbdLGNjW (ORCPT ); Thu, 7 Dec 2017 08:39:22 -0500 Received: by mail-wm0-f65.google.com with SMTP id f9so13057519wmh.0 for ; Thu, 07 Dec 2017 05:39:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=caMJvLYQ/Z/es8FNJ0ofgX0bH+dZi9PyZOd6yGWkgXU=; b=GnN4PGPWChVBaL+kYG+2Jc0yBim/S1PiyGbkhle8XrS/Hn+q0fMRlHd7eno3Ndz/hC 7wgDqw839inCXIYLuC+vrXB1CemZkwvHq51ntXiXWLh25YIDyesxOHRcD+l36YricZsT MA73/zVakKlt+TZ+PCXgbKJAR3m/tW5YCBVYqzC5uFEAg9WF5mqj4pxmS32hfT14FEM9 HDCqifz8SkMc+JV96Ab3eoNLSJrotVPHdW9Gp0myN7j1tVMCLzVThajUAmS2X4mNTajg DYmTOiu8TSiD+Njo3y9aJSrqqy78oHg0W/ReC/VPNW2w1vH/CYndbrISlGSuDXuWmxDf nncA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=caMJvLYQ/Z/es8FNJ0ofgX0bH+dZi9PyZOd6yGWkgXU=; b=fkRzgOhalQckhS81KwyF+BNM7G1wvvtzQMPt7jZrJtwV8ja+1UPeHRFIMonw95ehvG b0VlDlmRkJbgCeIrH8HMQd4wxWnjIqt4w9+RAGkaahUmBSREKsEXzXbNofRQsRdWiUK6 XoMc2Dv/g0PrN4Do92Km/OSvhw3JpYl3btBKJXDbuUZYiBcInHqON8e/OQ+EPmEjNqpo NbR9KAypnw4XytJgkBiejOnKysRanTyM4FfZPaoYdsoGVB5UruUQll31+Nqu+eX0hSw4 NYZRZreROFE579Cemcz7jm/qqfyHc5N8y+exA3IyoZynUCalyTLPN6v/oaU34dFWg4fY /W6w== X-Gm-Message-State: AKGB3mLMPfMtoNi/RB3IAJNxgrnBvZEtC3DL85A9A+wF/Q3u6A3ef4UV rkJmDO4U8ULzRcvio8I2HvKhsA== X-Google-Smtp-Source: AGs4zMaNTCQDK5Jwqw0oSJXimxxvPdxMgsJ3CQNMCBD5H0bWzTW9L9mnWKJcf03Pf/GZf6kJjO3AYg== X-Received: by 10.28.139.144 with SMTP id n138mr1231868wmd.78.1512653960877; Thu, 07 Dec 2017 05:39:20 -0800 (PST) Received: from bgdev-debian.baylibre.local ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id l3sm5442423wml.38.2017.12.07.05.39.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 05:39:20 -0800 (PST) From: Bartosz Golaszewski To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Peter Rosin , linux-i2c@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 1/2] eeprom: at24: fix coding style issues Date: Thu, 7 Dec 2017 14:39:14 +0100 Message-Id: <20171207133915.29448-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171207133915.29448-1-brgl@bgdev.pl> References: <20171207133915.29448-1-brgl@bgdev.pl> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Fix issues reported by checkpatch for at24.c. Signed-off-by: Bartosz Golaszewski --- drivers/misc/eeprom/at24.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 625b00166117..2426f2c111c7 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -70,8 +70,8 @@ struct at24_data { */ struct mutex lock; - unsigned write_max; - unsigned num_addresses; + unsigned int write_max; + unsigned int num_addresses; unsigned int offset_adj; struct nvmem_config nvmem_config; @@ -93,16 +93,16 @@ struct at24_data { * * This value is forced to be a power of two so that writes align on pages. */ -static unsigned io_limit = 128; -module_param(io_limit, uint, 0); +static unsigned int io_limit = 128; +module_param(io_limit, uint, 0000); MODULE_PARM_DESC(io_limit, "Maximum bytes per I/O (default 128)"); /* * Specs often allow 5 msec for a page write, sometimes 20 msec; * it's important to recover from write timeouts. */ -static unsigned write_timeout = 25; -module_param(write_timeout, uint, 0); +static unsigned int write_timeout = 25; +module_param(write_timeout, uint, 0000); MODULE_PARM_DESC(write_timeout, "Time (in ms) to try writes (default 25)"); #define AT24_SIZE_BYTELEN 5 @@ -111,8 +111,8 @@ MODULE_PARM_DESC(write_timeout, "Time (in ms) to try writes (default 25)"); #define AT24_BITMASK(x) (BIT(x) - 1) /* create non-zero magic value for given eeprom parameters */ -#define AT24_DEVICE_MAGIC(_len, _flags) \ - ((1 << AT24_SIZE_FLAGS | (_flags)) \ +#define AT24_DEVICE_MAGIC(_len, _flags) \ + ((1 << AT24_SIZE_FLAGS | (_flags)) \ << AT24_SIZE_BYTELEN | ilog2(_len)) /* @@ -264,7 +264,7 @@ MODULE_DEVICE_TABLE(acpi, at24_acpi_ids); static struct at24_client *at24_translate_offset(struct at24_data *at24, unsigned int *offset) { - unsigned i; + unsigned int i; if (at24->chip.flags & AT24_FLAG_ADDR16) { i = *offset >> 16; @@ -319,7 +319,7 @@ static ssize_t at24_regmap_read(struct at24_data *at24, char *buf, static size_t at24_adjust_write_count(struct at24_data *at24, unsigned int offset, size_t count) { - unsigned next_page; + unsigned int next_page; /* write_max is at most a page */ if (count > at24->write_max) @@ -515,7 +515,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) bool writable; struct at24_data *at24; int err; - unsigned i, num_addresses; + unsigned int i, num_addresses; const struct regmap_config *config; u8 test_byte; From patchwork Thu Dec 7 13:39:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 845574 X-Patchwork-Delegate: bartekgola@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="dAFkw8f6"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3ysxRd3h79z9s03 for ; Fri, 8 Dec 2017 00:39:41 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755271AbdLGNj0 (ORCPT ); Thu, 7 Dec 2017 08:39:26 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:38915 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753933AbdLGNjY (ORCPT ); Thu, 7 Dec 2017 08:39:24 -0500 Received: by mail-wr0-f195.google.com with SMTP id a41so7521220wra.6 for ; Thu, 07 Dec 2017 05:39:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=f5BLMjpAa7sM/5r3fkJrIE9Jxw8EL4cU4xW0vk9o1qg=; b=dAFkw8f6A+zEnHJTuxv42utQ+Bz6uxdMHSQonBOK1uCEKzbP+o14Ves0CIW+5PlD71 hZwiNXSnnGZ2pvxRHNFtX6ooesvb8Wqlbt8lbBO97jQf6LDC/Fye7nDLgCOQq353k4ox SwOYn9ZQZHnGoSbn2m758pxpBPfr7jJDJrGVog7C4p62RVYg5oXPwhzuLtFBIrcjgjUs FNvARqtPld/r3dL3ZygtfjNPVb7utJyTgLf1FgEogf9qj2EapQIb+B2vMKiLKoxv3yOW q1zr8aRJ8MU0FPIulsUSsgj+v+vsIOyOyKslzVLEZ6YyNtawop9/lmgOUUPtCK5jtVG4 2r8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=f5BLMjpAa7sM/5r3fkJrIE9Jxw8EL4cU4xW0vk9o1qg=; b=gZldAKYB13kXAqiSkHAwozx1T6ztPJ3mK+SZmxQPiPh2xwF9V8X6QjT6uceYMOpssX OSdwMCoJMWpnzY+/FAMtuoXVCXpmBZUv2WSCG9J/W/xnOuupv1drUIkAsrEqVsmA/2Qb TfFVrop0F8qS4eH5aifwABuCcYJOS6m5p9MUDB+YZWlcMVTnwVRKMih2yKNUhRk2Y5oY UF/pbim56EcpCSYp1x6JFElqaIn1GxhZJjSXNCWGAlzeOD0xx3wYMe5b/0fLeHdfjcnS WwhY3ot/PtaqS9Xma6l4JUwWUk57fDpUBXORncsW772DgoQnobVQKa3EVMB4OHArN4vX f0Rw== X-Gm-Message-State: AJaThX4a2rVYp7iOtcGr3OHR2+F/NgULMPiKnSzyZswlKC/bjBbGB7fc 5bQ1Qmzdt0QT735vcFVEog2nnw== X-Google-Smtp-Source: AGs4zMboe9diodJO+a2ZPe2WgBQNaPhCPLsNLIvKT10EjNn6WRczw95EjD0Oo0tc/FZajzBbS8TugQ== X-Received: by 10.223.139.3 with SMTP id n3mr22829877wra.166.1512653962705; Thu, 07 Dec 2017 05:39:22 -0800 (PST) Received: from bgdev-debian.baylibre.local ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id l3sm5442423wml.38.2017.12.07.05.39.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 05:39:21 -0800 (PST) From: Bartosz Golaszewski To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Peter Rosin , linux-i2c@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 2/2] eeprom: at24: use a common prefix for all symbols in at24.c Date: Thu, 7 Dec 2017 14:39:15 +0100 Message-Id: <20171207133915.29448-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171207133915.29448-1-brgl@bgdev.pl> References: <20171207133915.29448-1-brgl@bgdev.pl> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org There are a couple symbols defined in the driver source file which are missing the at24_ prefix. This patch fixes that. For module params: use module_param_named() in order to not break userspace. Signed-off-by: Bartosz Golaszewski --- drivers/misc/eeprom/at24.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 2426f2c111c7..27497286912a 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -93,17 +93,17 @@ struct at24_data { * * This value is forced to be a power of two so that writes align on pages. */ -static unsigned int io_limit = 128; -module_param(io_limit, uint, 0000); -MODULE_PARM_DESC(io_limit, "Maximum bytes per I/O (default 128)"); +static unsigned int at24_io_limit = 128; +module_param_named(io_limit, at24_io_limit, uint, 0000); +MODULE_PARM_DESC(at24_io_limit, "Maximum bytes per I/O (default 128)"); /* * Specs often allow 5 msec for a page write, sometimes 20 msec; * it's important to recover from write timeouts. */ -static unsigned int write_timeout = 25; -module_param(write_timeout, uint, 0000); -MODULE_PARM_DESC(write_timeout, "Time (in ms) to try writes (default 25)"); +static unsigned int at24_write_timeout = 25; +module_param_named(write_timeout, at24_write_timeout, uint, 0000); +MODULE_PARM_DESC(at24_write_timeout, "Time (in ms) to try writes (default 25)"); #define AT24_SIZE_BYTELEN 5 #define AT24_SIZE_FLAGS 8 @@ -126,8 +126,9 @@ MODULE_PARM_DESC(write_timeout, "Time (in ms) to try writes (default 25)"); * iteration of processing the request. Both should be unsigned integers * holding at least 32 bits. */ -#define loop_until_timeout(tout, op_time) \ - for (tout = jiffies + msecs_to_jiffies(write_timeout), op_time = 0; \ +#define at24_loop_until_timeout(tout, op_time) \ + for (tout = jiffies + msecs_to_jiffies(at24_write_timeout), \ + op_time = 0; \ op_time ? time_before(op_time, tout) : true; \ usleep_range(1000, 1500), op_time = jiffies) @@ -290,13 +291,13 @@ static ssize_t at24_regmap_read(struct at24_data *at24, char *buf, regmap = at24_client->regmap; client = at24_client->client; - if (count > io_limit) - count = io_limit; + if (count > at24_io_limit) + count = at24_io_limit; /* adjust offset for mac and serial read ops */ offset += at24->offset_adj; - loop_until_timeout(timeout, read_time) { + at24_loop_until_timeout(timeout, read_time) { ret = regmap_bulk_read(regmap, offset, buf, count); dev_dbg(&client->dev, "read %zu@%d --> %d (%ld)\n", count, offset, ret, jiffies); @@ -347,7 +348,7 @@ static ssize_t at24_regmap_write(struct at24_data *at24, const char *buf, client = at24_client->client; count = at24_adjust_write_count(at24, offset, count); - loop_until_timeout(timeout, write_time) { + at24_loop_until_timeout(timeout, write_time) { ret = regmap_bulk_write(regmap, offset, buf, count); dev_dbg(&client->dev, "write %zu@%d --> %d (%ld)\n", count, offset, ret, jiffies); @@ -613,7 +614,8 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) writable = !(chip.flags & AT24_FLAG_READONLY); if (writable) { - at24->write_max = min_t(unsigned int, chip.page_size, io_limit); + at24->write_max = min_t(unsigned int, + chip.page_size, at24_io_limit); if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C) && at24->write_max > I2C_SMBUS_BLOCK_MAX) at24->write_max = I2C_SMBUS_BLOCK_MAX; @@ -728,12 +730,12 @@ static struct i2c_driver at24_driver = { static int __init at24_init(void) { - if (!io_limit) { - pr_err("at24: io_limit must not be 0!\n"); + if (!at24_io_limit) { + pr_err("at24: at24_io_limit must not be 0!\n"); return -EINVAL; } - io_limit = rounddown_pow_of_two(io_limit); + at24_io_limit = rounddown_pow_of_two(at24_io_limit); return i2c_add_driver(&at24_driver); } module_init(at24_init);