All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux dev-4.7] drivers/fsi: Remove hub devices during master unregister
@ 2017-03-07  0:55 Christopher Bostic
  2017-03-07  2:37 ` Joel Stanley
  0 siblings, 1 reply; 3+ messages in thread
From: Christopher Bostic @ 2017-03-07  0:55 UTC (permalink / raw)
  To: joel; +Cc: Christopher Bostic, openbmc

All hub devices must be removed when the primary FSI master
is being unregistered.  This ensures that the system is in
a clean state when another scan is attempted.  Failure to do so
will result in duplicate /sys device name errors.

Signed-off-by: Christopher Bostic <cbostic@linux.vnet.ibm.com>
---
 drivers/fsi/fsi-core.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index bd57b41..cc1689e 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -84,6 +84,7 @@ struct fsi_master_hub {
 #define to_fsi_master_hub(d) container_of(d, struct fsi_master_hub, master)
 #define to_fsi_slave(d) container_of(d, struct fsi_slave, dev)
 
+static void fsi_master_unscan(struct fsi_master *master);
 static int fsi_slave_read(struct fsi_slave *slave, uint32_t addr,
 		void *val, size_t size);
 static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
@@ -441,6 +442,7 @@ static int fsi_slave_scan(struct fsi_slave *slave)
 			hub->dev.release = hub_master_release;
 			hub->master.dev = &hub->dev;
 			hub->master.dev->parent = &slave->dev;
+			dev_set_drvdata(&hub->dev, hub);
 			rc = device_add(&hub->dev);
 			if (rc)
 				return rc;
@@ -739,6 +741,18 @@ static int fsi_master_scan(struct fsi_master *master)
 	return 0;
 }
 
+static int fsi_unregister_hubs(struct device *dev, void *data)
+{
+	struct fsi_master_hub *hub =
+				(struct fsi_master_hub *)dev_get_drvdata(dev);
+
+	if (!hub)
+		return 0;
+
+	device_del(dev);
+	fsi_master_unscan(&hub->master);
+}
+
 static void fsi_master_unscan(struct fsi_master *master)
 {
 	struct fsi_slave *slave, *slave_tmp;
@@ -756,6 +770,8 @@ static void fsi_master_unscan(struct fsi_master *master)
 			device_del(&fsi_dev->dev);
 			put_device(&fsi_dev->dev);
 		}
+		/* Remove any hub masters */
+		device_for_each_child(&slave->dev, NULL, fsi_unregister_hubs);
 		device_unregister(&slave->dev);
 	}
 	master->slave_list = false;
-- 
1.8.2.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH linux dev-4.7] drivers/fsi: Remove hub devices during master unregister
  2017-03-07  0:55 [PATCH linux dev-4.7] drivers/fsi: Remove hub devices during master unregister Christopher Bostic
@ 2017-03-07  2:37 ` Joel Stanley
  2017-03-07  3:08   ` Christopher Bostic
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Stanley @ 2017-03-07  2:37 UTC (permalink / raw)
  To: Christopher Bostic, Brad Bishop, Patrick Williams; +Cc: OpenBMC Maillist

On Tue, Mar 7, 2017 at 11:25 AM, Christopher Bostic
<cbostic@linux.vnet.ibm.com> wrote:
>
> +static int fsi_unregister_hubs(struct device *dev, void *data)
> +{
> +       struct fsi_master_hub *hub =
> +                               (struct fsi_master_hub *)dev_get_drvdata(dev);
> +
> +       if (!hub)
> +               return 0;
> +
> +       device_del(dev);
> +       fsi_master_unscan(&hub->master);
> +}

This introduces a warning:

drivers/fsi/fsi-core.c: In function ‘fsi_unregister_hubs’:
drivers/fsi/fsi-core.c:754:1: warning: control reaches end of non-void
function [-Wreturn-type]
 }
 ^

Did you build test this patch?

Have you boot tested it?

What runtime testing did you perform?

Cheers,

Joel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH linux dev-4.7] drivers/fsi: Remove hub devices during master unregister
  2017-03-07  2:37 ` Joel Stanley
@ 2017-03-07  3:08   ` Christopher Bostic
  0 siblings, 0 replies; 3+ messages in thread
From: Christopher Bostic @ 2017-03-07  3:08 UTC (permalink / raw)
  To: Joel Stanley, Brad Bishop, Patrick Williams; +Cc: OpenBMC Maillist



On 3/6/17 8:37 PM, Joel Stanley wrote:
> On Tue, Mar 7, 2017 at 11:25 AM, Christopher Bostic
> <cbostic@linux.vnet.ibm.com> wrote:
>> +static int fsi_unregister_hubs(struct device *dev, void *data)
>> +{
>> +       struct fsi_master_hub *hub =
>> +                               (struct fsi_master_hub *)dev_get_drvdata(dev);
>> +
>> +       if (!hub)
>> +               return 0;
>> +
>> +       device_del(dev);
>> +       fsi_master_unscan(&hub->master);
>> +}
> This introduces a warning:
>
> drivers/fsi/fsi-core.c: In function ‘fsi_unregister_hubs’:
> drivers/fsi/fsi-core.c:754:1: warning: control reaches end of non-void
> function [-Wreturn-type]
>   }
>   ^
>
> Did you build test this patch?
I did build but didn't see the warning. Wasn't looking close enough 
apparently -will correct.

> Have you boot tested it?

I did boot it.
> What runtime testing did you perform?
I ran multiple scans without rebooting to verify the removal and 
creation of sysfs files was done properly.
Also verified no further sysfs warnings attempting to create duplicate 
file names.



> Cheers,
>
> Joel
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-07  3:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-07  0:55 [PATCH linux dev-4.7] drivers/fsi: Remove hub devices during master unregister Christopher Bostic
2017-03-07  2:37 ` Joel Stanley
2017-03-07  3:08   ` Christopher Bostic

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.