From patchwork Fri Oct 9 21:47:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 7364171 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CD28FBEEA4 for ; Fri, 9 Oct 2015 21:47:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 339F82085B for ; Fri, 9 Oct 2015 21:47:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 80B4B207DA for ; Fri, 9 Oct 2015 21:47:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932402AbbJIVr2 (ORCPT ); Fri, 9 Oct 2015 17:47:28 -0400 Received: from sauhun.de ([89.238.76.85]:53875 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932128AbbJIVr1 (ORCPT ); Fri, 9 Oct 2015 17:47:27 -0400 Received: from [109.79.89.57] (port=52330 helo=katana) by pokefinder.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1ZkfVc-0004eD-5P; Fri, 09 Oct 2015 23:47:25 +0200 Date: Fri, 9 Oct 2015 22:47:13 +0100 From: Wolfram Sang To: Jarkko Nikula Cc: linux-i2c@vger.kernel.org, alsa-devel@alsa-project.org, linux-acpi@vger.kernel.org, lm-sensors@lm-sensors.org, Mark Brown , "Rafael J. Wysocki" , Jean Delvare , Liam Girdwood , Dustin Byford , linux@roeck-us.net Subject: Re: [RFC] i2c: Revert back to old device naming for ACPI enumerated I2C slaves Message-ID: <20151009214712.GD1481@katana> References: <1440413522-7855-1-git-send-email-jarkko.nikula@linux.intel.com> <20151001203744.GA7514@katana> <560E4DF4.4000901@linux.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <560E4DF4.4000901@linux.intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, T_TVD_MIME_EPI, 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 On Fri, Oct 02, 2015 at 12:27:16PM +0300, Jarkko Nikula wrote: > On 10/01/2015 11:37 PM, Wolfram Sang wrote: > > > >>This is for discussion so I didn't cc stable@vger.kernel.org yet. I was > >>thinking would it work if we'd keep the stable name but have an another > >>symlink in /sys/bus/i2c/devices/ that uses "x-00yz" name. However this > >>feels ill-use of devices directory and probably causes more troubles > >>elsewhere. > > > >Do you foresee troubles already? I am still in favour of a symlink. > > > I haven't looked at this for a while but one problem was that devices/ > directory belongs to private structure of struct bus_type and in order to > create a symlink there it needs to done in drivers/base/bus.c: > bus_add_device() which felt quite hackish to me. This is just a quick prototype and untested; but I did something similar in the i2c-mux code: Shouldn't something like this be enough? diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 5f89f1e3c2f24f..715dca57ba68fd 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -970,13 +970,15 @@ static void i2c_dev_set_name(struct i2c_adapter *adap, { struct acpi_device *adev = ACPI_COMPANION(&client->dev); - if (adev) { - dev_set_name(&client->dev, "i2c-%s", acpi_dev_name(adev)); - return; - } - dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adap), i2c_encode_flags_to_addr(client)); + + if (adev) { + char symlink_name[256]; + + snprintf(symlink_name, sizeof(symlink_name), "i2c-%s", acpi_dev_name(adev)); + sysfs_create_link(&client->dev.kobj, &adap->dev.kobj, symlink_name); + } } /**