From patchwork Thu Aug 20 07:07:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 7041141 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5BCF19F344 for ; Thu, 20 Aug 2015 07:09:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6DDA020546 for ; Thu, 20 Aug 2015 07:09:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D840320547 for ; Thu, 20 Aug 2015 07:09:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752909AbbHTHIp (ORCPT ); Thu, 20 Aug 2015 03:08:45 -0400 Received: from lists.s-osg.org ([54.187.51.154]:58795 "EHLO lists.s-osg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752865AbbHTHIn (ORCPT ); Thu, 20 Aug 2015 03:08:43 -0400 Received: from localhost.localdomain (95.111.23.95.dynamic.jazztel.es [95.23.111.95]) by lists.s-osg.org (Postfix) with ESMTPSA id E90C34632A; Thu, 20 Aug 2015 00:08:41 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Javier Martinez Canillas , Javier Martinez Canillas , Mark Brown , linux-spi@vger.kernel.org Subject: [PATCH 18/18] spi: (RFC, don't apply) report OF style modalias when probing using DT Date: Thu, 20 Aug 2015 09:07:31 +0200 Message-Id: <1440054451-1223-19-git-send-email-javier@osg.samsung.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1440054451-1223-1-git-send-email-javier@osg.samsung.com> References: <1440054451-1223-1-git-send-email-javier@osg.samsung.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Javier Martinez Canillas An SPI driver that supports both OF and legacy platforms, will have both an OF and SPI ID table. This means that when built as a module, the aliases will be filled from both tables, e.g: $ modinfo cros_ec_spi | grep alias alias: spi:cros-ec-spi alias: of:N*T*Cgoogle,cros-ec-spi* But currently the SPI core always report a module alias of the form spi:, e.g: $ cat /sys/devices/12d40000.spi/spi_master/spi2/spi2.0/modalias spi:cros-ec-spi And also this spi: is always reported to user-space as MODALIAS regardless of the mechanism that was used to register the device (i.e: OF or board code). This means that OF-only drivers needs to have both OF and SPI id tables that have to be kept in sync and also the dev node compatible manufacturer prefix is stripped when reporting the MODALIAS. Which can lead to issues if two vendors use the same SPI device name for example. This patch changes the SPI core to report an OF related MODALIAS uevent (of:N*T*C) env var instead so the module can be auto-loaded and also the correct modalias is reported on sysfs, e.g: $ cat /sys/devices/12d40000.spi/spi_master/spi2/spi2.0/modalias of:Ncros-ecTCgoogle,cros-ec-spi Signed-off-by: Javier Martinez Canillas Signed-off-by: Javier Martinez Canillas --- drivers/spi/spi.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 08861a0233ca..beb7fb2b15c5 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -59,6 +59,10 @@ modalias_show(struct device *dev, struct device_attribute *a, char *buf) const struct spi_device *spi = to_spi_device(dev); int len; + len = of_device_get_modalias(dev, buf, PAGE_SIZE - 1); + if (len != -ENODEV) + return len; + len = acpi_device_modalias(dev, buf, PAGE_SIZE - 1); if (len != -ENODEV) return len; @@ -250,6 +254,10 @@ static int spi_uevent(struct device *dev, struct kobj_uevent_env *env) const struct spi_device *spi = to_spi_device(dev); int rc; + rc = of_device_uevent_modalias(dev, env); + if (rc != -ENODEV) + return rc; + rc = acpi_device_uevent_modalias(dev, env); if (rc != -ENODEV) return rc;