From patchwork Fri Jan 4 11:21:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 154764 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp511766ljp; Fri, 4 Jan 2019 03:21:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vnhfdq77thkDWP2OQt+3mvA5nF5ZrgrAHGUthX4/IIXREgSgsAAqlKL26T/TczM1UYaxME X-Received: by 2002:a62:8dd9:: with SMTP id p86mr51318777pfk.143.1546600907064; Fri, 04 Jan 2019 03:21:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546600907; cv=none; d=google.com; s=arc-20160816; b=o9+dBS4sJT+U6WWyTqG9QerqJ8ac11Z03zvPDHZylMpt1nauNwGYPNytj7Qauyr0yA NsDQ85KyBp5qGMhVVOzKq2O75PAn9hcXNFDe+xQ3U6wQsV1wxu2cgPqY2eM8UXa4FmPG tNjWNsIABx54CCOFQLtRiV6j06o8AhjLgwpO90vrsg7Xf4/wr98MeZ3CNO8vIahPYN5v j6GHr88oF52NV3l5Ux8r9VHN8I78RWz2OyhXpAJv91fYGwVWqKR4bGQl1aRbR584UNDw gr8v5izGoJNrx4CCuwsd/ClXjeuOjSjEuWxHzIgaEL65Ehtpx709XfRBxFivQfUDoUXa nKxg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=dw9NjoFYhvf6M4Vz2GwYclwDkvyBXFnP8DEQI0aGMjY=; b=xBZt4eTcfOrNA8b1mi66c6kj1gNj1Ubd61+boWkr21Q9/r/PJPe8pBNYS4vG6cWrpB 70BYrwe0IYmCWyZ5okmC9JufGwmyqK9ocBf2vN06RZoILC+lm4sB8TgkULXGSI3PTutq 8hcKdYI4du3u2sbOE5n9GS5V5g9o3I2WraTtN8gmh4EJihNWO+8LHDG9HVu/4ZMxItcz FkuNPRxXkXogzx7eBbu2Qc1KUipIusksFVXt10igmFr3Vs0HHCZ+x0k9mbCSE4D9zVo2 Jgj8VDzz0MUk70mAKXUspnVJW/EXirJ/e7vgi2Ux4dJYWc1G0k24tMMuxvC3ruPkq/ig dYaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 31si9445213plj.244.2019.01.04.03.21.46; Fri, 04 Jan 2019 03:21:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-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 devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727714AbfADLVq (ORCPT + 7 others); Fri, 4 Jan 2019 06:21:46 -0500 Received: from mx2.suse.de ([195.135.220.15]:52408 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727625AbfADLVq (ORCPT ); Fri, 4 Jan 2019 06:21:46 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1F256AE65; Fri, 4 Jan 2019 11:21:44 +0000 (UTC) From: =?utf-8?q?Andreas_F=C3=A4rber?= To: linux-lpwan@lists.infradead.org, linux-serial@vger.kernel.org Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , Rob Herring , =?utf-8?q?Andreas_F=C3=A4rber?= , "David S. Miller" , netdev@vger.kernel.org Subject: [PATCH lora-next 2/5] net: lora: sx130x: Prepare storing driver-specific data Date: Fri, 4 Jan 2019 12:21:28 +0100 Message-Id: <20190104112131.14451-3-afaerber@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190104112131.14451-1-afaerber@suse.de> References: <20190104112131.14451-1-afaerber@suse.de> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Some drivers (e.g., serdev) may need to access private data not part of the core sx130x_priv, which is inaccessible to other source files. As the sx130x core expects to obtain the net_device from the dev's drvdata, we can't reuse that in derived drivers and need a new field plus helpers. Signed-off-by: Andreas Färber --- drivers/net/lora/sx130x.c | 19 +++++++++++++++++++ include/linux/lora/sx130x.h | 2 ++ 2 files changed, 21 insertions(+) -- 2.16.4 diff --git a/drivers/net/lora/sx130x.c b/drivers/net/lora/sx130x.c index 840052955874..978c921ca5ec 100644 --- a/drivers/net/lora/sx130x.c +++ b/drivers/net/lora/sx130x.c @@ -58,6 +58,7 @@ struct sx130x_priv { struct regmap *regmap; struct regmap_field *regmap_fields[ARRAY_SIZE(sx130x_regmap_fields)]; struct mutex io_lock; + void *drvdata; }; struct regmap *sx130x_get_regmap(struct device *dev) @@ -68,6 +69,24 @@ struct regmap *sx130x_get_regmap(struct device *dev) return priv->regmap; } +void sx130x_set_drvdata(struct device *dev, void *drvdata) +{ + struct net_device *netdev = dev_get_drvdata(dev); + struct sx130x_priv *priv = netdev_priv(netdev); + + priv->drvdata = drvdata; +} +EXPORT_SYMBOL_GPL(sx130x_set_drvdata); + +void *sx130x_get_drvdata(struct device *dev) +{ + struct net_device *netdev = dev_get_drvdata(dev); + struct sx130x_priv *priv = netdev_priv(netdev); + + return priv->drvdata; +} +EXPORT_SYMBOL_GPL(sx130x_get_drvdata); + void sx130x_io_lock(struct device *dev) { struct net_device *netdev = dev_get_drvdata(dev); diff --git a/include/linux/lora/sx130x.h b/include/linux/lora/sx130x.h index d6f027ef283f..85b088ec77b8 100644 --- a/include/linux/lora/sx130x.h +++ b/include/linux/lora/sx130x.h @@ -14,6 +14,8 @@ #include extern const struct regmap_config sx130x_regmap_config; +void sx130x_set_drvdata(struct device *dev, void *drvdata); +void *sx130x_get_drvdata(struct device *dev); int sx130x_early_probe(struct regmap *regmap, struct gpio_desc *rst); int sx130x_probe(struct device *dev); int sx130x_remove(struct device *dev);