From patchwork Thu Mar 24 12:32:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 1609001 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=y9o+G6Xf; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=HTLCwMFV; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-ide-owner@vger.kernel.org; receiver=) Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by bilbo.ozlabs.org (Postfix) with ESMTP id 4KPPkC1Xkgz9sFh for ; Thu, 24 Mar 2022 23:32:19 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237534AbiCXMdo (ORCPT ); Thu, 24 Mar 2022 08:33:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233678AbiCXMdm (ORCPT ); Thu, 24 Mar 2022 08:33:42 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1846AA9944 for ; Thu, 24 Mar 2022 05:32:09 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id A0115210FD; Thu, 24 Mar 2022 12:32:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1648125128; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eNrmEkBd8gq3KlIYY5P5qtJ01dx98Tc+/7D2Qm9iOzk=; b=y9o+G6XfX5KjdVjR0YIP7xkkw8OchMUPMdKPR2b8mTM+n52ulFtAnLF6jH9Mdl1NjTmiBW X+XakMd5gJtGrK1axs1xvc109N714iOMT3BdzfOZ5YOMHh1XZsbni3SoyAnZhmgVlDHJ+d z6QpPkmEuuTobIPU0XHTsXoVKM45wvo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1648125128; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eNrmEkBd8gq3KlIYY5P5qtJ01dx98Tc+/7D2Qm9iOzk=; b=HTLCwMFVQ2CcbYgt2IY8ilAjOFeEY0HxlboQasxI7B+ghQOrp4D/XvvUM76Rc3l455n2/n z4THh6GDX9yZeXAA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 79D6DA3B82; Thu, 24 Mar 2022 12:32:08 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 6BBDC51938FB; Thu, 24 Mar 2022 13:32:08 +0100 (CET) From: Hannes Reinecke To: Damien LeMoal Cc: linux-ide@vger.kernel.org, Hannes Reinecke Subject: [PATCH 1/2] libata: rework sysfs naming Date: Thu, 24 Mar 2022 13:32:03 +0100 Message-Id: <20220324123204.61534-2-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220324123204.61534-1-hare@suse.de> References: <20220324123204.61534-1-hare@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org This patch adds a new dummy bus 'ata', which collects all ata device objects like ata_port, ata_link, and ata_dev, and adds an 'ata' prefix to the message log. To be consistent with the other libata objects the 'ata_port' object name has been changed from 'ata' to 'port'. Signed-off-by: Hannes Reinecke --- drivers/ata/libata-transport.c | 21 +++++++++++-- include/linux/libata.h | 54 ++++++++++------------------------ 2 files changed, 34 insertions(+), 41 deletions(-) diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c index ca129854a88c..555fe6e2293d 100644 --- a/drivers/ata/libata-transport.c +++ b/drivers/ata/libata-transport.c @@ -81,10 +81,13 @@ struct ata_internal { tdev_to_port((dev)->parent) -/* Device objects are always created whit link objects */ +/* Device objects are always created with link objects */ static int ata_tdev_add(struct ata_device *dev); static void ata_tdev_delete(struct ata_device *dev); +struct bus_type ata_bus_type = { + .name = "ata", +}; /* * Hack to allow attributes of the same name in different objects. @@ -288,7 +291,9 @@ int ata_tport_add(struct device *parent, dev->parent = parent; ata_host_get(ap->host); dev->release = ata_tport_release; - dev_set_name(dev, "ata%d", ap->print_id); + dev->bus = &ata_bus_type; + dev_set_name(dev, "port%d", ap->print_id); + transport_setup_device(dev); ata_acpi_bind_port(ap); error = device_add(dev); @@ -444,6 +449,8 @@ int ata_tlink_add(struct ata_link *link) device_initialize(dev); dev->parent = &ap->tdev; dev->release = ata_tlink_release; + dev->bus = &ata_bus_type; + if (ata_is_host_link(link)) dev_set_name(dev, "link%d", ap->print_id); else @@ -695,8 +702,10 @@ static int ata_tdev_add(struct ata_device *ata_dev) device_initialize(dev); dev->parent = &link->tdev; dev->release = ata_tdev_release; + dev->bus = &ata_bus_type; + if (ata_is_host_link(link)) - dev_set_name(dev, "dev%d.%d", ap->print_id,ata_dev->devno); + dev_set_name(dev, "dev%d.%d", ap->print_id, ata_dev->devno); else dev_set_name(dev, "dev%d.%d.0", ap->print_id, link->pmp); @@ -822,8 +831,13 @@ __init int libata_transport_init(void) error = transport_class_register(&ata_dev_class); if (error) goto out_unregister_port; + error = bus_register(&ata_bus_type); + if (error) + goto out_unregister_bus; return 0; + out_unregister_bus: + bus_unregister(&ata_bus_type); out_unregister_port: transport_class_unregister(&ata_port_class); out_unregister_link: @@ -835,6 +849,7 @@ __init int libata_transport_init(void) void __exit libata_transport_exit(void) { + bus_unregister(&ata_bus_type); transport_class_unregister(&ata_link_class); transport_class_unregister(&ata_port_class); transport_class_unregister(&ata_dev_class); diff --git a/include/linux/libata.h b/include/linux/libata.h index 0619ae462ecd..b17683b00c90 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -835,6 +835,7 @@ struct ata_port { struct ata_host *host; struct device *dev; struct device tdev; + struct device cdev; struct mutex scsi_scan_mutex; struct delayed_work hotplug_task; @@ -1458,61 +1459,38 @@ static inline int sata_srst_pmp(struct ata_link *link) return link->pmp; } -#define ata_port_printk(level, ap, fmt, ...) \ - pr_ ## level ("ata%u: " fmt, (ap)->print_id, ##__VA_ARGS__) - #define ata_port_err(ap, fmt, ...) \ - ata_port_printk(err, ap, fmt, ##__VA_ARGS__) + dev_err(&ap->tdev, fmt, ##__VA_ARGS__) #define ata_port_warn(ap, fmt, ...) \ - ata_port_printk(warn, ap, fmt, ##__VA_ARGS__) + dev_warn(&ap->tdev, fmt, ##__VA_ARGS__) #define ata_port_notice(ap, fmt, ...) \ - ata_port_printk(notice, ap, fmt, ##__VA_ARGS__) + dev_notice(&ap->tdev, fmt, ##__VA_ARGS__) #define ata_port_info(ap, fmt, ...) \ - ata_port_printk(info, ap, fmt, ##__VA_ARGS__) + dev_info(&ap->tdev, fmt, ##__VA_ARGS__) #define ata_port_dbg(ap, fmt, ...) \ - ata_port_printk(debug, ap, fmt, ##__VA_ARGS__) - -#define ata_link_printk(level, link, fmt, ...) \ -do { \ - if (sata_pmp_attached((link)->ap) || \ - (link)->ap->slave_link) \ - pr_ ## level ("ata%u.%02u: " fmt, \ - (link)->ap->print_id, \ - (link)->pmp, \ - ##__VA_ARGS__); \ - else \ - pr_ ## level ("ata%u: " fmt, \ - (link)->ap->print_id, \ - ##__VA_ARGS__); \ -} while (0) + dev_dbg(&ap->tdev, fmt, ##__VA_ARGS__) #define ata_link_err(link, fmt, ...) \ - ata_link_printk(err, link, fmt, ##__VA_ARGS__) + dev_err(&link->tdev, fmt, ##__VA_ARGS__) #define ata_link_warn(link, fmt, ...) \ - ata_link_printk(warn, link, fmt, ##__VA_ARGS__) + dev_warn(&link->tdev, fmt, ##__VA_ARGS__) #define ata_link_notice(link, fmt, ...) \ - ata_link_printk(notice, link, fmt, ##__VA_ARGS__) + dev_notice(&link->tdev, fmt, ##__VA_ARGS__) #define ata_link_info(link, fmt, ...) \ - ata_link_printk(info, link, fmt, ##__VA_ARGS__) + dev_info(&link->tdev, fmt, ##__VA_ARGS__) #define ata_link_dbg(link, fmt, ...) \ - ata_link_printk(debug, link, fmt, ##__VA_ARGS__) - -#define ata_dev_printk(level, dev, fmt, ...) \ - pr_ ## level("ata%u.%02u: " fmt, \ - (dev)->link->ap->print_id, \ - (dev)->link->pmp + (dev)->devno, \ - ##__VA_ARGS__) + dev_dbg(&link->tdev, fmt, ##__VA_ARGS__) #define ata_dev_err(dev, fmt, ...) \ - ata_dev_printk(err, dev, fmt, ##__VA_ARGS__) + dev_err(&dev->tdev, fmt, ##__VA_ARGS__) #define ata_dev_warn(dev, fmt, ...) \ - ata_dev_printk(warn, dev, fmt, ##__VA_ARGS__) + dev_warn(&dev->tdev, fmt, ##__VA_ARGS__) #define ata_dev_notice(dev, fmt, ...) \ - ata_dev_printk(notice, dev, fmt, ##__VA_ARGS__) + dev_notice(&dev->tdev, fmt, ##__VA_ARGS__) #define ata_dev_info(dev, fmt, ...) \ - ata_dev_printk(info, dev, fmt, ##__VA_ARGS__) + dev_info(&dev->tdev, fmt, ##__VA_ARGS__) #define ata_dev_dbg(dev, fmt, ...) \ - ata_dev_printk(debug, dev, fmt, ##__VA_ARGS__) + dev_dbg(&dev->tdev, fmt, ##__VA_ARGS__) void ata_print_version(const struct device *dev, const char *version); From patchwork Thu Mar 24 12:32:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 1609000 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=0pUlWmBA; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=vo+on5Ad; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-ide-owner@vger.kernel.org; receiver=) Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by bilbo.ozlabs.org (Postfix) with ESMTP id 4KPPkB5Gljz9sBy for ; Thu, 24 Mar 2022 23:32:18 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348665AbiCXMdn (ORCPT ); Thu, 24 Mar 2022 08:33:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347509AbiCXMdm (ORCPT ); Thu, 24 Mar 2022 08:33:42 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 185AEA9946 for ; Thu, 24 Mar 2022 05:32:09 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id A033021601; Thu, 24 Mar 2022 12:32:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1648125128; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VG7gSSIkIOTl5gU7+sNOqs8b1fbJMjTDoTy6nWXtud8=; b=0pUlWmBAog+BgocZgQdCyrPt4CKxh696tMWDOCUkad0GN6PxDku+PKAoPpBOeNZKCPmrKj 0fcllesv6DzuYve14p9e0GN12jPuipX4SYRUVv0q8KBawTZpKvPw7gPtZbGpimAaKoVjDE ammhzozetUP7+J09+e2vRQ8K0+AZE/I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1648125128; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VG7gSSIkIOTl5gU7+sNOqs8b1fbJMjTDoTy6nWXtud8=; b=vo+on5Ad6SuJ6E9nE6HhFF5gDt9An/IeVd5lBmBzyyDrpevI8xZ61Aa/PFvZ7FmDH3cQ4s Yd0FbU1HzbCbbpAA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 7FA43A3B92; Thu, 24 Mar 2022 12:32:08 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 6FD6E51938FD; Thu, 24 Mar 2022 13:32:08 +0100 (CET) From: Hannes Reinecke To: Damien LeMoal Cc: linux-ide@vger.kernel.org, Hannes Reinecke Subject: [PATCH 2/2] libata: CONFIG_ATA_SYSFS_COMPAT Date: Thu, 24 Mar 2022 13:32:04 +0100 Message-Id: <20220324123204.61534-3-hare@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220324123204.61534-1-hare@suse.de> References: <20220324123204.61534-1-hare@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org Add a config option 'ATA_SYSFS_COMPAT' to create a compability 'ata' symlink in the PCI device sysfs directory. Signed-off-by: Hannes Reinecke --- drivers/ata/Kconfig | 10 ++++++++++ drivers/ata/libata-transport.c | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index e5641e6c52ee..f27b12ba2ce7 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig @@ -51,6 +51,16 @@ config ATA_VERBOSE_ERROR If unsure, say Y. +config ATA_SYSFS_COMPAT + bool "Keep original sysfs layout" + default y + help + This option retains the original sysfs layout by adding an + additional ata_port object with the name of 'ataX' in + to the ATA objects like 'ata_port', 'ata_link', and 'ata_device'. + + If unsure, say Y. + config ATA_FORCE bool "\"libata.force=\" kernel parameter support" if EXPERT default y diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c index 555fe6e2293d..a66c3480bdcf 100644 --- a/drivers/ata/libata-transport.c +++ b/drivers/ata/libata-transport.c @@ -260,7 +260,13 @@ static int ata_tport_match(struct attribute_container *cont, void ata_tport_delete(struct ata_port *ap) { struct device *dev = &ap->tdev; +#ifdef CONFIG_ATA_SYSFS_COMPAT + struct device *parent = dev->parent; + char compat_name[64]; + sprintf(compat_name, "ata%d", ap->print_id); + sysfs_remove_link(&parent->kobj, compat_name); +#endif ata_tlink_delete(&ap->link); transport_remove_device(dev); @@ -284,6 +290,9 @@ int ata_tport_add(struct device *parent, { int error; struct device *dev = &ap->tdev; +#ifdef CONFIG_ATA_SYSFS_COMPAT + char compat_name[64]; +#endif device_initialize(dev); dev->type = &ata_port_type; @@ -313,8 +322,19 @@ int ata_tport_add(struct device *parent, if (error) { goto tport_link_err; } + +#ifdef CONFIG_ATA_SYSFS_COMPAT + sprintf(compat_name, "ata%d", ap->print_id); + error = sysfs_create_link(&parent->kobj, &dev->kobj, compat_name); + if (error) + goto compat_link_err; +#endif return 0; +#ifdef CONFIG_ATA_SYSFS_COMPAT + compat_link_err: + ata_tlink_delete(&ap->link); +#endif tport_link_err: transport_remove_device(dev); device_del(dev);