From patchwork Fri Dec 15 23:00:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 849410 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=gmail.com header.i=@gmail.com header.b="TtxBSwF4"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yz5Vx2PF6z9s7m for ; Sat, 16 Dec 2017 10:00:25 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755834AbdLOXAX (ORCPT ); Fri, 15 Dec 2017 18:00:23 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:45208 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755824AbdLOXAW (ORCPT ); Fri, 15 Dec 2017 18:00:22 -0500 Received: by mail-wm0-f65.google.com with SMTP id 9so20109440wme.4; Fri, 15 Dec 2017 15:00:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=6L7HdMdJJ3mUywc3iwmWCPyx4HQzVfasPl5EATEZIWY=; b=TtxBSwF4yq2LnShRpT7nJ60fEYXb5PEm60zB26rFbtWPn2+6iVKz7B3Itp8Kpgp8Yz XykXf0ugcf3bmGXFkLso9Nulqx3ysi5kyCRVuG8aPiZzYsQXvFy/CqLERK194r4OGJNx qTPq0qcgdAlmE6uVCNYjA24jZH7K6CJgQUI+gPvp+OE6Q77l5MrVT5iUzJOdnTTDh0IM CGA2/Q0xSb/Cd/kPXcZv2pWT1Nn68uWEFXFscHOGLkwIE/chUl+sTrEprEFiNIRlSEj0 5jp48gqXQ5kiVhD00IlTQO4t+afmlAgea2yNJLJOjdtjlktVCHgUHsCK89WQk6sHKKQJ Cugg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=6L7HdMdJJ3mUywc3iwmWCPyx4HQzVfasPl5EATEZIWY=; b=FBpUJ1Teb21hMhzWkeRtaey4+ayMqIFs4CBe7CU/w5JGgMkcVMPv91AKpyoVjt7XWp SLLb7OoOk7YlaN4U09ulT2XWMkY9a1ngoIpQhIfbXlhgIIoaPjRY4BrhPd23flhuNu7F j6Wpz7p84dMVnWFHDi70F8431kziYbbwQoGU921jAsZ+kVjHHYpzG/+U3WzQPso4bNEf +kl8klDejD9UL98s9X37rjx9aud6/fv7FCu9W+gseeooz179eADWHkgBq66jMMUVi8Jy DfgwOufungcNz8c2CLFEKZO+Lcaw+xcrnHFUDAwzvkatpH7+O/xcYmKrEi6L+q58/DWn iLOw== X-Gm-Message-State: AKGB3mJxLSKEvIYCXpAcnduec7PELhMOBd380QoQq8OhuxCxBFsxUk4z O5+bzXd+72OiLwwAed9TIjT0lA== X-Google-Smtp-Source: ACJfBovFyhna1/MLRqqak0KDp+lpHKARPpXT806Sv3joWL4dwV8IJlBriPe/i1XBo0t8A+IjRomfmg== X-Received: by 10.28.129.69 with SMTP id c66mr6740924wmd.29.1513378821342; Fri, 15 Dec 2017 15:00:21 -0800 (PST) Received: from ?IPv6:2003:ea:8bc0:e400:b0d3:a11f:88fd:f202? (p200300EA8BC0E400B0D3A11F88FDF202.dip0.t-ipconnect.de. [2003:ea:8bc0:e400:b0d3:a11f:88fd:f202]) by smtp.googlemail.com with ESMTPSA id l142sm9760749wmb.43.2017.12.15.15.00.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Dec 2017 15:00:20 -0800 (PST) From: Heiner Kallweit Subject: [PATCH v5 0/3] i2c: introduce devm_i2c_new_dummy and use it in at24 driver To: Bartosz Golaszewski , Wolfram Sang , Peter Rosin Cc: "linux-i2c@vger.kernel.org" , Linux Kernel Mailing List Message-ID: Date: Sat, 16 Dec 2017 00:00:15 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org i2c_new_dummy is typically called from the probe function of the driver for the primary i2c client. It requires calls to i2c_unregister_device in the error path of the probe function and in the remove function. This can be simplified by introducing a device-managed version. Make at24 driver the first user of the new function. Changes in v2: - add change to i2c core to make a version of i2c_new_device available which returns an ERR_PTR instead of NULL in error case - few minor improvements Changes in v3: - rename _i2c_new_device to __i2c_new_device Changes in v4: - add missing kernel doc comments - add Reviewed-by Changes in v5: - fix a copy & paste error in patch 1 - improve readability in patch 2 Heiner Kallweit (3): i2c: core: improve return value handling of i2c_new_device and i2c_new_dummy i2c: core: add device-managed version of i2c_new_dummy eeprom: at24: switch to device-managed version of i2c_new_dummy Documentation/driver-model/devres.txt | 3 + drivers/i2c/i2c-core-base.c | 115 ++++++++++++++++++++++++++++++---- drivers/misc/eeprom/at24.c | 31 ++++----- include/linux/i2c.h | 3 + 4 files changed, 119 insertions(+), 33 deletions(-)