Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2444177yba; Mon, 6 May 2019 06:16:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqzeyxnCRhNGrvBLrN+8AyriCNweHQqXbWUYSslqMWCPhN+3DkbNJ6m5v3sJC94MSLJazKWM X-Received: by 2002:a63:7:: with SMTP id 7mr32452704pga.108.1557148614815; Mon, 06 May 2019 06:16:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557148614; cv=none; d=google.com; s=arc-20160816; b=b71dcsbjhgCQKLWHbeHpwlMZDhbKmwYJ+ycnj8SLFSNh/rCDkC7GyQ0g4H8X3y7ZoF e+s2pjivIKAAFxgmdRzC+QnZMklBGxH6SA+7E/Outaq1sFl+q52l59AOcWb3ZUYPQWM+ izidEx4j9L+tHKooA3blPjwiDOm4LHXraAh95aRv+NmqLQtq+IpS0mRk50NXYB3ei3HB S7FXCddtdl7QdvkoG7E0WH22mi/Twsh1z1A3dM0dpahrwPTbYkdDKN62sUH2K+WEzCpP NGR/vlvN1eZmD7PlKMy1jmdqHieYO19qOyXNIaDM1uQUYV8H8W55WvB3Z1g9/ep8JS6E GecQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:message-id:subject:cc:to:from:date; bh=4Q6+H8QEfYrNKXXOMTEQ90btyjFEkqDqsBrZGjHRGJU=; b=dT5sncz3CtI4PZLehc7NG0qRA3sPEx9dbrnynNoE+qTEhoIOlnJa3lAu/HeGMUKJkg 74ThCa0i1xd1kSG8A40GgnVwucH7UT49z3T+ZSSj1amWvGXSg9CzPZzaxlq4TruVDZda obi7F7req9HlxaTI82XI5EmDWxFLoVO22QZTqZAmvmYDTU6ycyLdVAxPQmZ67ugBa0OT FBhi4AK5Oiea5yaWsHFVtCNufVV00ZCryr0GVr/IdpA22nr2F7p6wLX8Xfx7RxQ78VYL TdrNYYCOcuvu6+5sAXrJT3aIb79kBWtCqJjKFU8RwmkB+oExKcWf5jlTU3vkhDZgenGb o1+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q90si15428230pfa.245.2019.05.06.06.16.36; Mon, 06 May 2019 06:16:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726160AbfEFNPm (ORCPT + 99 others); Mon, 6 May 2019 09:15:42 -0400 Received: from mx2.suse.de ([195.135.220.15]:55776 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725886AbfEFNPm (ORCPT ); Mon, 6 May 2019 09:15:42 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 391F7AF08; Mon, 6 May 2019 13:15:40 +0000 (UTC) Date: Mon, 6 May 2019 15:15:39 +0200 From: Jean Delvare To: LKML Cc: Linux I2C , Arnd Bergmann , Greg Kroah-Hartman , Jarkko Nikula Subject: [PATCH 1/2] eeprom: ee1004: Move selected page detection to a separate function Message-ID: <20190506151539.69ee75e8@endymion> Organization: SUSE Linux X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.31; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org No functional change, this is in preparation for future needs. Signed-off-by: Jean Delvare Tested-by: Jarkko Nikula Cc: Arnd Bergmann Cc: Greg Kroah-Hartman --- drivers/misc/eeprom/ee1004.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) --- linux-5.0.orig/drivers/misc/eeprom/ee1004.c 2019-05-06 11:23:14.833319076 +0200 +++ linux-5.0/drivers/misc/eeprom/ee1004.c 2019-05-06 11:56:58.478375343 +0200 @@ -57,6 +57,24 @@ MODULE_DEVICE_TABLE(i2c, ee1004_ids); /*-------------------------------------------------------------------------*/ +static int ee1004_get_current_page(void) +{ + int err; + + err = i2c_smbus_read_byte(ee1004_set_page[0]); + if (err == -ENXIO) { + /* Nack means page 1 is selected */ + return 1; + } + if (err < 0) { + /* Anything else is a real error, bail out */ + return err; + } + + /* Ack means page 0 is selected, returned value meaningless */ + return 0; +} + static ssize_t ee1004_eeprom_read(struct i2c_client *client, char *buf, unsigned int offset, size_t count) { @@ -190,17 +208,10 @@ static int ee1004_probe(struct i2c_clien } /* Remember current page to avoid unneeded page select */ - err = i2c_smbus_read_byte(ee1004_set_page[0]); - if (err == -ENXIO) { - /* Nack means page 1 is selected */ - ee1004_current_page = 1; - } else if (err < 0) { - /* Anything else is a real error, bail out */ + err = ee1004_get_current_page(); + if (err < 0) goto err_clients; - } else { - /* Ack means page 0 is selected, returned value meaningless */ - ee1004_current_page = 0; - } + ee1004_current_page = err; dev_dbg(&client->dev, "Currently selected page: %d\n", ee1004_current_page); mutex_unlock(&ee1004_bus_lock); -- Jean Delvare SUSE L3 Support