[PATCH] mpt3sas: fix possible NULL dereference

2016-04-08 Thread Sudip Mukherjee
We are dereferencing ioc->sense_dma_pool in pci_pool_free() and after
that we are checking if it is NULL, before calling pci_pool_destroy().
Lets check if it is NULL before calling both pci_pool_free() and
pci_pool_destroy().

Signed-off-by: Sudip Mukherjee <sudip.mukher...@codethink.co.uk>
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 8c44b9c..778c2ec 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -3087,9 +3087,11 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc)
}
 
if (ioc->sense) {
-   pci_pool_free(ioc->sense_dma_pool, ioc->sense, ioc->sense_dma);
-   if (ioc->sense_dma_pool)
+   if (ioc->sense_dma_pool) {
+   pci_pool_free(ioc->sense_dma_pool, ioc->sense,
+ ioc->sense_dma);
pci_pool_destroy(ioc->sense_dma_pool);
+   }
dexitprintk(ioc, pr_info(MPT3SAS_FMT
"sense_pool(0x%p): free\n",
ioc->name, ioc->sense));
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mvumi: fix build warning

2016-03-03 Thread Sudip Mukherjee
While building tilepro allmodconfig we were getting build warning:
drivers/scsi/mvumi.c:2632:12: warning: 'mvumi_suspend' defined but not used
drivers/scsi/mvumi.c:2651:12: warning: 'mvumi_resume' defined but not used

mvumi_suspend() and mvumi_resume() are only used when CONFIG_PM is
defined as mentioned in the mvumi_pci_driver.   

Signed-off-by: Sudip Mukherjee <sudip.mukher...@codethink.co.uk>
---
 drivers/scsi/mvumi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
index 02360de..d9d0736 100644
--- a/drivers/scsi/mvumi.c
+++ b/drivers/scsi/mvumi.c
@@ -2629,6 +2629,7 @@ static void mvumi_shutdown(struct pci_dev *pdev)
mvumi_flush_cache(mhba);
 }
 
+#ifdef CONFIG_PM
 static int mvumi_suspend(struct pci_dev *pdev, pm_message_t state)
 {
struct mvumi_hba *mhba = NULL;
@@ -2716,6 +2717,7 @@ fail:
 
return ret;
 }
+#endif
 
 static struct pci_driver mvumi_pci_driver = {
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] osd: remove deadcode

2016-02-24 Thread Sudip Mukherjee
The variable is_ver1 is always true and so OSD_CAP_LEN can never be
used.
Reported by Coverity.

Signed-off-by: Sudip Mukherjee <sudip.mukher...@codethink.co.uk>
---

v2: Joe Perches asked to mention the tool used in the commit log.

 drivers/scsi/osd/osd_initiator.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c
index d8a2b51..3b11aad 100644
--- a/drivers/scsi/osd/osd_initiator.c
+++ b/drivers/scsi/osd/osd_initiator.c
@@ -2006,9 +2006,8 @@ EXPORT_SYMBOL(osd_sec_init_nosec_doall_caps);
  */
 void osd_set_caps(struct osd_cdb *cdb, const void *caps)
 {
-   bool is_ver1 = true;
/* NOTE: They start at same address */
-   memcpy(>v1.caps, caps, is_ver1 ? OSDv1_CAP_LEN : OSD_CAP_LEN);
+   memcpy(>v1.caps, caps, OSDv1_CAP_LEN);
 }
 
 bool osd_is_sec_alldata(struct osd_security_parameters *sec_parms __unused)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] imm: check parport_claim

2016-02-24 Thread Sudip Mukherjee
parport_claim() can fail and we should be checking if we were able to
claim the port.

Signed-off-by: Sudip Mukherjee <sudip.mukher...@codethink.co.uk>
---
 drivers/scsi/imm.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index f8b88fa..9164ce12 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -77,9 +77,10 @@ static void imm_wakeup(void *ref)
 
spin_lock_irqsave(_lock, flags);
if (dev->wanted) {
-   parport_claim(dev->dev);
-   got_it(dev);
-   dev->wanted = 0;
+   if (parport_claim(dev->dev) == 0) {
+   got_it(dev);
+   dev->wanted = 0;
+   }
}
spin_unlock_irqrestore(_lock, flags);
 }
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] osd: remove deadcode

2016-02-24 Thread Sudip Mukherjee
The variable is_ver1 is always true and so OSD_CAP_LEN can never be
used.

Signed-off-by: Sudip Mukherjee <sudip.mukher...@codethink.co.uk>
---
 drivers/scsi/osd/osd_initiator.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c
index d8a2b51..3b11aad 100644
--- a/drivers/scsi/osd/osd_initiator.c
+++ b/drivers/scsi/osd/osd_initiator.c
@@ -2006,9 +2006,8 @@ EXPORT_SYMBOL(osd_sec_init_nosec_doall_caps);
  */
 void osd_set_caps(struct osd_cdb *cdb, const void *caps)
 {
-   bool is_ver1 = true;
/* NOTE: They start at same address */
-   memcpy(>v1.caps, caps, is_ver1 ? OSDv1_CAP_LEN : OSD_CAP_LEN);
+   memcpy(>v1.caps, caps, OSDv1_CAP_LEN);
 }
 
 bool osd_is_sec_alldata(struct osd_security_parameters *sec_parms __unused)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND] dpt_i2o: fix build warning

2016-02-18 Thread Sudip Mukherjee
We were getting build warning about:
drivers/scsi/dpt_i2o.c:183:29: warning: 'dptids' defined but not used

dptids[] is only used in the MODULE_DEVICE_TABLE so when MODULE is not
defined then dptids[] becomes unused.

Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de>
Signed-off-by: Sudip Mukherjee <su...@vectorindia.org>
---

Resending v1 as v2 had a NACK from Alan about the spec not maintained
while converting to pci driver.

 drivers/scsi/dpt_i2o.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index d4cda5e..21c8d21 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -180,11 +180,14 @@ static u8 adpt_read_blink_led(adpt_hba* host)
  *
  */
 
+#ifdef MODULE
 static struct pci_device_id dptids[] = {
{ PCI_DPT_VENDOR_ID, PCI_DPT_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
{ PCI_DPT_VENDOR_ID, PCI_DPT_RAPTOR_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
{ 0, }
 };
+#endif
+
 MODULE_DEVICE_TABLE(pci,dptids);
 
 static int adpt_detect(struct scsi_host_template* sht)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] [SCSI] dpt_i2o: use proper pci driver

2016-02-17 Thread Sudip Mukherjee

On Wednesday 17 February 2016 07:57 PM, One Thousand Gnomes wrote:

On Wed, 17 Feb 2016 17:50:14 +0530
Sudip Mukherjee <sudipm.mukher...@gmail.com> wrote:


This is a pci device but was not done in the usual way a pci driver is
done. Convert the driver into a proper pci driver.


This looks completely wrong. Please read the I2O 1.5 specification
document before playing with that code. You can't simply convert it to a
standard PCI driver as all the IOPs are supposed to be detected and then
the correct initialization sequence executed across the set of IOPs. IOPs
are allowed to talk to one another and the system table binds it all
together.


Yes, thanks for letting me know about the spec. It is saying
"The host locates each IOP, adds it
to the system configuration table, and initializes the IOP’s outbound 
message queue. The host then
provides each IOP with a list of all IOPs and the physical location of 
their inbound message queue."




If you do hot plug then you need to follow the specification and do
all the extra notifications. Unless you've got multiple FC909/FC920
fibechannel cards or similar to test with I would just leave this well
alone.


point noted.


Your original simple patch is *MUCH* safer in this specific case.


The original patch is already having NACK from Johannes. So i better 
leave this code here.


regards
sudip
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] [SCSI] dpt_i2o: use proper pci driver

2016-02-17 Thread Sudip Mukherjee
This is a pci device but was not done in the usual way a pci driver is
done. Convert the driver into a proper pci driver.

Signed-off-by: Sudip Mukherjee <su...@vectorindia.org>
---

v1: only build warning related to "dptids defined but not used" was
fixed using #ifdef

 drivers/scsi/dpt_i2o.c | 269 ++---
 drivers/scsi/dpti.h|   5 +-
 2 files changed, 120 insertions(+), 154 deletions(-)

diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index d4cda5e..9f50d1ae 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -111,6 +111,7 @@ static int sys_tbl_len;
 
 static adpt_hba* hba_chain = NULL;
 static int hba_count = 0;
+static bool control_reg;
 
 static struct class *adpt_sysfs_class;
 
@@ -187,118 +188,6 @@ static struct pci_device_id dptids[] = {
 };
 MODULE_DEVICE_TABLE(pci,dptids);
 
-static int adpt_detect(struct scsi_host_template* sht)
-{
-   struct pci_dev *pDev = NULL;
-   adpt_hba *pHba;
-   adpt_hba *next;
-
-   PINFO("Detecting Adaptec I2O RAID controllers...\n");
-
-/* search for all Adatpec I2O RAID cards */
-   while ((pDev = pci_get_device( PCI_DPT_VENDOR_ID, PCI_ANY_ID, pDev))) {
-   if(pDev->device == PCI_DPT_DEVICE_ID ||
-  pDev->device == PCI_DPT_RAPTOR_DEVICE_ID){
-   if(adpt_install_hba(sht, pDev) ){
-   PERROR("Could not Init an I2O RAID device\n");
-   PERROR("Will not try to detect others.\n");
-   return hba_count-1;
-   }
-   pci_dev_get(pDev);
-   }
-   }
-
-   /* In INIT state, Activate IOPs */
-   for (pHba = hba_chain; pHba; pHba = next) {
-   next = pHba->next;
-   // Activate does get status , init outbound, and get hrt
-   if (adpt_i2o_activate_hba(pHba) < 0) {
-   adpt_i2o_delete_hba(pHba);
-   }
-   }
-
-
-   /* Active IOPs in HOLD state */
-
-rebuild_sys_tab:
-   if (hba_chain == NULL) 
-   return 0;
-
-   /*
-* If build_sys_table fails, we kill everything and bail
-* as we can't init the IOPs w/o a system table
-*/ 
-   if (adpt_i2o_build_sys_table() < 0) {
-   adpt_i2o_sys_shutdown();
-   return 0;
-   }
-
-   PDEBUG("HBA's in HOLD state\n");
-
-   /* If IOP don't get online, we need to rebuild the System table */
-   for (pHba = hba_chain; pHba; pHba = pHba->next) {
-   if (adpt_i2o_online_hba(pHba) < 0) {
-   adpt_i2o_delete_hba(pHba);  
-   goto rebuild_sys_tab;
-   }
-   }
-
-   /* Active IOPs now in OPERATIONAL state */
-   PDEBUG("HBA's in OPERATIONAL state\n");
-
-   printk("dpti: If you have a lot of devices this could take a few 
minutes.\n");
-   for (pHba = hba_chain; pHba; pHba = next) {
-   next = pHba->next;
-   printk(KERN_INFO"%s: Reading the hardware resource table.\n", 
pHba->name);
-   if (adpt_i2o_lct_get(pHba) < 0){
-   adpt_i2o_delete_hba(pHba);
-   continue;
-   }
-
-   if (adpt_i2o_parse_lct(pHba) < 0){
-   adpt_i2o_delete_hba(pHba);
-   continue;
-   }
-   adpt_inquiry(pHba);
-   }
-
-   adpt_sysfs_class = class_create(THIS_MODULE, "dpt_i2o");
-   if (IS_ERR(adpt_sysfs_class)) {
-   printk(KERN_WARNING"dpti: unable to create dpt_i2o class\n");
-   adpt_sysfs_class = NULL;
-   }
-
-   for (pHba = hba_chain; pHba; pHba = next) {
-   next = pHba->next;
-   if (adpt_scsi_host_alloc(pHba, sht) < 0){
-   adpt_i2o_delete_hba(pHba);
-   continue;
-   }
-   pHba->initialized = TRUE;
-   pHba->state &= ~DPTI_STATE_RESET;
-   if (adpt_sysfs_class) {
-   struct device *dev = device_create(adpt_sysfs_class,
-   NULL, MKDEV(DPTI_I2O_MAJOR, pHba->unit), NULL,
-   "dpti%d", pHba->unit);
-   if (IS_ERR(dev)) {
-   printk(KERN_WARNING"dpti%d: unable to "
-   "create device in dpt_i2o class\n",
-   pHba->unit);
-   }
-   }
-   }
-
-   // Register our control device node
-   // nodes will need to be created in /dev to access this
-   // the nodes can not be created from withi

Re: [PATCH] [SCSI] dpt_i2o: fix build warning

2016-02-16 Thread Sudip Mukherjee

On Tuesday 16 February 2016 02:47 PM, Johannes Thumshirn wrote:

On Tue, Feb 16, 2016 at 02:07:36PM +0530, Sudip Mukherjee wrote:

We were getting build warning about:
drivers/scsi/dpt_i2o.c:183:29: warning: ‘dptids’ defined but not used

dptids[] is only used in the MODULE_DEVICE_TABLE so when MODULE is not
defined then dptids[] becomes unused.


Nah. Care to make a proper pci driver from it instead of plastering yet
another #ifdef in?


Ok. I am on it. I hope someone has the hardware to check the changes.

regards
sudip
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [SCSI] dpt_i2o: fix build warning

2016-02-16 Thread Sudip Mukherjee
We were getting build warning about:
drivers/scsi/dpt_i2o.c:183:29: warning: ‘dptids’ defined but not used

dptids[] is only used in the MODULE_DEVICE_TABLE so when MODULE is not
defined then dptids[] becomes unused.

Signed-off-by: Sudip Mukherjee <su...@vectorindia.org>
---
 drivers/scsi/dpt_i2o.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index d4cda5e..21c8d21 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -180,11 +180,14 @@ static u8 adpt_read_blink_led(adpt_hba* host)
  *
  */
 
+#ifdef MODULE
 static struct pci_device_id dptids[] = {
{ PCI_DPT_VENDOR_ID, PCI_DPT_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
{ PCI_DPT_VENDOR_ID, PCI_DPT_RAPTOR_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
{ 0, }
 };
+#endif
+
 MODULE_DEVICE_TABLE(pci,dptids);
 
 static int adpt_detect(struct scsi_host_template* sht)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND] scsi: sim710: fix build warning

2016-02-10 Thread Sudip Mukherjee
We are getting build warning about:
 "Section mismatch in reference from the variable sim710_eisa_driver to
 the function .init.text:sim710_eisa_probe()
 The variable sim710_eisa_driver references the function __init
 sim710_eisa_probe()"

sim710_eisa_probe() was having __init but that was being referenced from
sim710_eisa_driver.

Signed-off-by: Sudip Mukherjee <su...@vectorindia.org>
---

patch first sent on 4th Sept.2015. There is no review or ACK yet.
warning is still there with next-20160209,
build log is at:
https://travis-ci.org/sudipm-mukherjee/parport/jobs/107948115

 drivers/scsi/sim710.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/sim710.c b/drivers/scsi/sim710.c
index 3b3b56f..82ed998 100644
--- a/drivers/scsi/sim710.c
+++ b/drivers/scsi/sim710.c
@@ -176,8 +176,7 @@ static struct eisa_device_id sim710_eisa_ids[] = {
 };
 MODULE_DEVICE_TABLE(eisa, sim710_eisa_ids);
 
-static __init int
-sim710_eisa_probe(struct device *dev)
+static int sim710_eisa_probe(struct device *dev)
 {
struct eisa_device *edev = to_eisa_device(dev);
unsigned long io_addr = edev->base_addr;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND] scsi: ppa: use new parport device model

2016-02-10 Thread Sudip Mukherjee
Modify ppa driver to use the new parallel port device model.

Signed-off-by: Sudip Mukherjee <su...@vectorindia.org>
---

Resending as there was no review or ACK for this change.
This has exactly same changes as done in scsi/imm.c which has already
been accepted.

 drivers/scsi/ppa.c | 46 --
 1 file changed, 40 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index ee00e27..f6ad579 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -37,6 +37,7 @@ typedef struct {
unsigned long recon_tmo;/* How many usecs to wait for 
reconnection (6th bit) */
unsigned int failed:1;  /* Failure flag */
unsigned wanted:1;  /* Parport sharing busy flag*/
+   unsigned int dev_no;/* Device number*/
wait_queue_head_t *waiting;
struct Scsi_Host *host;
struct list_head list;
@@ -985,15 +986,40 @@ static struct scsi_host_template ppa_template = {
 
 static LIST_HEAD(ppa_hosts);
 
+/*
+ * Finds the first available device number that can be alloted to the
+ * new ppa device and returns the address of the previous node so that
+ * we can add to the tail and have a list in the ascending order.
+ */
+
+static inline ppa_struct *find_parent(void)
+{
+   ppa_struct *dev, *par = NULL;
+   unsigned int cnt = 0;
+
+   if (list_empty(_hosts))
+   return NULL;
+
+   list_for_each_entry(dev, _hosts, list) {
+   if (dev->dev_no != cnt)
+   return par;
+   cnt++;
+   par = dev;
+   }
+
+   return par;
+}
+
 static int __ppa_attach(struct parport *pb)
 {
struct Scsi_Host *host;
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waiting);
DEFINE_WAIT(wait);
-   ppa_struct *dev;
+   ppa_struct *dev, *temp;
int ports;
int modes, ppb, ppb_hi;
int err = -ENOMEM;
+   struct pardev_cb ppa_cb;
 
dev = kzalloc(sizeof(ppa_struct), GFP_KERNEL);
if (!dev)
@@ -1002,8 +1028,15 @@ static int __ppa_attach(struct parport *pb)
dev->mode = PPA_AUTODETECT;
dev->recon_tmo = PPA_RECON_TMO;
init_waitqueue_head();
-   dev->dev = parport_register_device(pb, "ppa", NULL, ppa_wakeup,
-   NULL, 0, dev);
+   temp = find_parent();
+   if (temp)
+   dev->dev_no = temp->dev_no + 1;
+
+   memset(_cb, 0, sizeof(ppa_cb));
+   ppa_cb.private = dev;
+   ppa_cb.wakeup = ppa_wakeup;
+
+   dev->dev = parport_register_dev_model(pb, "ppa", _cb, dev->dev_no);
 
if (!dev->dev)
goto out;
@@ -1110,9 +1143,10 @@ static void ppa_detach(struct parport *pb)
 }
 
 static struct parport_driver ppa_driver = {
-   .name   = "ppa",
-   .attach = ppa_attach,
-   .detach = ppa_detach,
+   .name   = "ppa",
+   .match_port = ppa_attach,
+   .detach = ppa_detach,
+   .devmodel   = true,
 };
 
 static int __init ppa_driver_init(void)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] scsi: imm: use new parport device model

2016-01-05 Thread Sudip Mukherjee
Modify imm driver to use the new parallel port device model.

Signed-off-by: Sudip Mukherjee <su...@vectorindia.org>
---

I usually submit checkpatch cleanup and other modifications while
converting a driver to use parport device model. For this driver i
hesitated. If you want I can send a series with this modification and
checkpatch fix. Same for scsi/ppa.c.

 drivers/scsi/imm.c | 50 +++---
 1 file changed, 43 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index 4e1a632..f8b88fa 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -43,6 +43,7 @@ typedef struct {
unsigned dp:1;  /* Data phase present   */
unsigned rd:1;  /* Read data in data phase  */
unsigned wanted:1;  /* Parport sharing busy flag*/
+   unsigned int dev_no;/* Device number*/
wait_queue_head_t *waiting;
struct Scsi_Host *host;
struct list_head list;
@@ -1120,15 +1121,40 @@ static struct scsi_host_template imm_template = {
 
 static LIST_HEAD(imm_hosts);
 
+/*
+ * Finds the first available device number that can be alloted to the
+ * new imm device and returns the address of the previous node so that
+ * we can add to the tail and have a list in the ascending order.
+ */
+
+static inline imm_struct *find_parent(void)
+{
+   imm_struct *dev, *par = NULL;
+   unsigned int cnt = 0;
+
+   if (list_empty(_hosts))
+   return NULL;
+
+   list_for_each_entry(dev, _hosts, list) {
+   if (dev->dev_no != cnt)
+   return par;
+   cnt++;
+   par = dev;
+   }
+
+   return par;
+}
+
 static int __imm_attach(struct parport *pb)
 {
struct Scsi_Host *host;
-   imm_struct *dev;
+   imm_struct *dev, *temp;
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waiting);
DEFINE_WAIT(wait);
int ports;
int modes, ppb;
int err = -ENOMEM;
+   struct pardev_cb imm_cb;
 
init_waitqueue_head();
 
@@ -1141,9 +1167,15 @@ static int __imm_attach(struct parport *pb)
dev->mode = IMM_AUTODETECT;
INIT_LIST_HEAD(>list);
 
-   dev->dev = parport_register_device(pb, "imm", NULL, imm_wakeup,
-   NULL, 0, dev);
+   temp = find_parent();
+   if (temp)
+   dev->dev_no = temp->dev_no + 1;
+
+   memset(_cb, 0, sizeof(imm_cb));
+   imm_cb.private = dev;
+   imm_cb.wakeup = imm_wakeup;
 
+   dev->dev = parport_register_dev_model(pb, "imm", _cb, dev->dev_no);
if (!dev->dev)
goto out;
 
@@ -1207,7 +1239,10 @@ static int __imm_attach(struct parport *pb)
host->unique_id = pb->number;
*(imm_struct **)>hostdata = dev;
dev->host = host;
-   list_add_tail(>list, _hosts);
+   if (!temp)
+   list_add_tail(>list, _hosts);
+   else
+   list_add_tail(>list, >list);
err = scsi_add_host(host, NULL);
if (err)
goto out2;
@@ -1245,9 +1280,10 @@ static void imm_detach(struct parport *pb)
 }
 
 static struct parport_driver imm_driver = {
-   .name   = "imm",
-   .attach = imm_attach,
-   .detach = imm_detach,
+   .name   = "imm",
+   .match_port = imm_attach,
+   .detach = imm_detach,
+   .devmodel   = true,
 };
 
 static int __init imm_driver_init(void)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH resend] scsi: imm: use new parport device model

2016-01-05 Thread Sudip Mukherjee
Modify imm driver to use the new parallel port device model.

Signed-off-by: Sudip Mukherjee <su...@vectorindia.org>
---

Resending as the first mail bounced back with the error:
Delivery to the following recipient failed permanently:
 jbottom...@odin.com

Looking at the MAINTAINERS file gives me multiple email address of
James. Confused. Using the one which James has used on Jan 3. 

I usually submit checkpatch cleanup and other modifications while
converting a driver to use parport device model. For this driver i
hesitated. If you want I can send a series with this modification and
checkpatch fix. Same for scsi/ppa.c.

 drivers/scsi/imm.c | 50 +++---
 1 file changed, 43 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index 4e1a632..f8b88fa 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -43,6 +43,7 @@ typedef struct {
unsigned dp:1;  /* Data phase present   */
unsigned rd:1;  /* Read data in data phase  */
unsigned wanted:1;  /* Parport sharing busy flag*/
+   unsigned int dev_no;/* Device number*/
wait_queue_head_t *waiting;
struct Scsi_Host *host;
struct list_head list;
@@ -1120,15 +1121,40 @@ static struct scsi_host_template imm_template = {
 
 static LIST_HEAD(imm_hosts);
 
+/*
+ * Finds the first available device number that can be alloted to the
+ * new imm device and returns the address of the previous node so that
+ * we can add to the tail and have a list in the ascending order.
+ */
+
+static inline imm_struct *find_parent(void)
+{
+   imm_struct *dev, *par = NULL;
+   unsigned int cnt = 0;
+
+   if (list_empty(_hosts))
+   return NULL;
+
+   list_for_each_entry(dev, _hosts, list) {
+   if (dev->dev_no != cnt)
+   return par;
+   cnt++;
+   par = dev;
+   }
+
+   return par;
+}
+
 static int __imm_attach(struct parport *pb)
 {
struct Scsi_Host *host;
-   imm_struct *dev;
+   imm_struct *dev, *temp;
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waiting);
DEFINE_WAIT(wait);
int ports;
int modes, ppb;
int err = -ENOMEM;
+   struct pardev_cb imm_cb;
 
init_waitqueue_head();
 
@@ -1141,9 +1167,15 @@ static int __imm_attach(struct parport *pb)
dev->mode = IMM_AUTODETECT;
INIT_LIST_HEAD(>list);
 
-   dev->dev = parport_register_device(pb, "imm", NULL, imm_wakeup,
-   NULL, 0, dev);
+   temp = find_parent();
+   if (temp)
+   dev->dev_no = temp->dev_no + 1;
+
+   memset(_cb, 0, sizeof(imm_cb));
+   imm_cb.private = dev;
+   imm_cb.wakeup = imm_wakeup;
 
+   dev->dev = parport_register_dev_model(pb, "imm", _cb, dev->dev_no);
if (!dev->dev)
goto out;
 
@@ -1207,7 +1239,10 @@ static int __imm_attach(struct parport *pb)
host->unique_id = pb->number;
*(imm_struct **)>hostdata = dev;
dev->host = host;
-   list_add_tail(>list, _hosts);
+   if (!temp)
+   list_add_tail(>list, _hosts);
+   else
+   list_add_tail(>list, >list);
err = scsi_add_host(host, NULL);
if (err)
goto out2;
@@ -1245,9 +1280,10 @@ static void imm_detach(struct parport *pb)
 }
 
 static struct parport_driver imm_driver = {
-   .name   = "imm",
-   .attach = imm_attach,
-   .detach = imm_detach,
+   .name   = "imm",
+   .match_port = imm_attach,
+   .detach = imm_detach,
+   .devmodel   = true,
 };
 
 static int __init imm_driver_init(void)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] scsi_dh_alua: fix build warning

2015-12-11 Thread Sudip Mukherjee
We were getting build warning about unused variables "vpd_pg83" and "d"

Fixes: 83ea0e5e3501 ("scsi_dh_alua: use scsi_vpd_tpg_id()")
Cc: Hannes Reinecke <h...@suse.de>
Signed-off-by: Sudip Mukherjee <su...@vectorindia.org>
---
build warning with next-20151211 and build log is at:
https://travis-ci.org/sudipm-mukherjee/parport/jobs/96209206
---

 drivers/scsi/device_handler/scsi_dh_alua.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index f100cbb..5a328bf 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -320,8 +320,6 @@ static int alua_check_tpgs(struct scsi_device *sdev)
  */
 static int alua_check_vpd(struct scsi_device *sdev, struct alua_dh_data *h)
 {
-   unsigned char *d;
-   unsigned char __rcu *vpd_pg83;
int rel_port = -1, group_id;
 
group_id = scsi_vpd_tpg_id(sdev, _port);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: sim710: fix build warning

2015-12-09 Thread Sudip Mukherjee
On Tue, Sep 15, 2015 at 01:30:00PM +0530, Sudip Mukherjee wrote:
> On Fri, Sep 04, 2015 at 07:40:29PM +0530, Sudip Mukherjee wrote:
> > We were getting build warning about:
> >  "Section mismatch in reference from the variable sim710_eisa_driver to
> >  the function .init.text:sim710_eisa_probe()
> >  The variable sim710_eisa_driver references the function __init
> >  sim710_eisa_probe()"
> > 
> > sim710_eisa_probe() was having __init but that was being referenced from
> > sim710_eisa_driver.
> > 
> > Signed-off-by: Sudip Mukherjee <su...@vectorindia.org>
> > ---
> A gentle ping.
> I still get the build warning while building for i386 allmodconfig with
> next-20150915.
> Build is at https://travis-ci.org/sudipm-mukherjee/parport/jobs/80365417

Another gentle ping. Build warning with i386 allmodconfig is still there
with next-20151209.
Build log is at:
https://travis-ci.org/sudipm-mukherjee/parport/jobs/95746184
 
regards
sudip
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] lpfc: fix memory leak and NULL dereference

2015-10-08 Thread Sudip Mukherjee
On Wed, Sep 23, 2015 at 07:02:32PM +0530, Sudip Mukherjee wrote:
> kmalloc() can return NULL and without checking we were dereferencing it.
> Moreover if kmalloc succeeds but the function fails in other parts then
> we were returning the error code but we missed freeing lcb_context.
> While at it fixed one related checkpatch warning.
> 
> Signed-off-by: Sudip Mukherjee <su...@vectorindia.org>
> ---

A gentle ping.

regards
sudip

> 
> I am not exactly sure if LSRJT_UNABLE_TPC is the right error code here.
> But that was my best guess.
> 
>  drivers/scsi/lpfc/lpfc_els.c | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
> index 36bf58b..a27efd9 100644
> --- a/drivers/scsi/lpfc/lpfc_els.c
> +++ b/drivers/scsi/lpfc/lpfc_els.c
> @@ -5209,7 +5209,6 @@ lpfc_els_rcv_lcb(struct lpfc_vport *vport, struct 
> lpfc_iocbq *cmdiocb,
>   rjt_err = LSRJT_CMD_UNSUPPORTED;
>   goto rjt;
>   }
> - lcb_context = kmalloc(sizeof(struct lpfc_lcb_context), GFP_KERNEL);
>  
>   if (phba->hba_flag & HBA_FCOE_MODE) {
>   rjt_err = LSRJT_CMD_UNSUPPORTED;
> @@ -5240,6 +5239,12 @@ lpfc_els_rcv_lcb(struct lpfc_vport *vport, struct 
> lpfc_iocbq *cmdiocb,
>   goto rjt;
>   }
>  
> + lcb_context = kmalloc(sizeof(*lcb_context), GFP_KERNEL);
> + if (!lcb_context) {
> + rjt_err = LSRJT_UNABLE_TPC;
> + goto rjt;
> + }
> +
>   state = (beacon->lcb_sub_command == LPFC_LCB_ON) ? 1 : 0;
>   lcb_context->sub_command = beacon->lcb_sub_command;
>   lcb_context->type = beacon->lcb_type;
> @@ -5250,6 +5255,7 @@ lpfc_els_rcv_lcb(struct lpfc_vport *vport, struct 
> lpfc_iocbq *cmdiocb,
>   if (lpfc_sli4_set_beacon(vport, lcb_context, state)) {
>   lpfc_printf_vlog(ndlp->vport, KERN_ERR,
>LOG_ELS, "0193 failed to send mail box");
> + kfree(lcb_context);
>   lpfc_nlp_put(ndlp);
>   rjt_err = LSRJT_UNABLE_TPC;
>   goto rjt;
> -- 
> 1.9.1
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [SCSI] FlashPoint: fix build warning

2015-10-02 Thread Sudip Mukherjee
On Wed, Sep 16, 2015 at 08:47:43AM -0600, Khalid Aziz wrote:
> On 09/16/2015 08:06 AM, Sudip Mukherjee wrote:
> >We have been getting a warning about non ANSI function.
> >warning: non-ANSI function declaration of function 'FPT_SccbMgrTableInitAll'
> >
> >Signed-off-by: Sudip Mukherjee <su...@vectorindia.org>
> >---
> >  drivers/scsi/FlashPoint.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> >diff --git a/drivers/scsi/FlashPoint.c b/drivers/scsi/FlashPoint.c
> >index 5c74e4c..867b864 100644
> >--- a/drivers/scsi/FlashPoint.c
> >+++ b/drivers/scsi/FlashPoint.c
> >@@ -2136,7 +2136,7 @@ static unsigned char FPT_SccbMgr_bad_isr(u32 p_port, 
> >unsigned char p_card,
> >   *
> >   *-*/
> >
> >-static void FPT_SccbMgrTableInitAll()
> >+static void FPT_SccbMgrTableInitAll(void)
> >  {
> > unsigned char thisCard;
> >
> >
> 
> Acked-by: Khalid Aziz <kha...@gonehiking.org>
> 
> James, please apply this to your SCSI tree.
Hi James,
A gentle reminder that this is waiting to be applied.

regards
sudip
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] lpfc: fix memory leak and NULL dereference

2015-09-23 Thread Sudip Mukherjee
kmalloc() can return NULL and without checking we were dereferencing it.
Moreover if kmalloc succeeds but the function fails in other parts then
we were returning the error code but we missed freeing lcb_context.
While at it fixed one related checkpatch warning.

Signed-off-by: Sudip Mukherjee <su...@vectorindia.org>
---

I am not exactly sure if LSRJT_UNABLE_TPC is the right error code here.
But that was my best guess.

 drivers/scsi/lpfc/lpfc_els.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 36bf58b..a27efd9 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -5209,7 +5209,6 @@ lpfc_els_rcv_lcb(struct lpfc_vport *vport, struct 
lpfc_iocbq *cmdiocb,
rjt_err = LSRJT_CMD_UNSUPPORTED;
goto rjt;
}
-   lcb_context = kmalloc(sizeof(struct lpfc_lcb_context), GFP_KERNEL);
 
if (phba->hba_flag & HBA_FCOE_MODE) {
rjt_err = LSRJT_CMD_UNSUPPORTED;
@@ -5240,6 +5239,12 @@ lpfc_els_rcv_lcb(struct lpfc_vport *vport, struct 
lpfc_iocbq *cmdiocb,
goto rjt;
}
 
+   lcb_context = kmalloc(sizeof(*lcb_context), GFP_KERNEL);
+   if (!lcb_context) {
+   rjt_err = LSRJT_UNABLE_TPC;
+   goto rjt;
+   }
+
state = (beacon->lcb_sub_command == LPFC_LCB_ON) ? 1 : 0;
lcb_context->sub_command = beacon->lcb_sub_command;
lcb_context->type = beacon->lcb_type;
@@ -5250,6 +5255,7 @@ lpfc_els_rcv_lcb(struct lpfc_vport *vport, struct 
lpfc_iocbq *cmdiocb,
if (lpfc_sli4_set_beacon(vport, lcb_context, state)) {
lpfc_printf_vlog(ndlp->vport, KERN_ERR,
 LOG_ELS, "0193 failed to send mail box");
+   kfree(lcb_context);
lpfc_nlp_put(ndlp);
rjt_err = LSRJT_UNABLE_TPC;
goto rjt;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [SCSI] FlashPoint: fix build warning

2015-09-16 Thread Sudip Mukherjee
We have been getting a warning about non ANSI function.
warning: non-ANSI function declaration of function 'FPT_SccbMgrTableInitAll'

Signed-off-by: Sudip Mukherjee <su...@vectorindia.org>
---
 drivers/scsi/FlashPoint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/FlashPoint.c b/drivers/scsi/FlashPoint.c
index 5c74e4c..867b864 100644
--- a/drivers/scsi/FlashPoint.c
+++ b/drivers/scsi/FlashPoint.c
@@ -2136,7 +2136,7 @@ static unsigned char FPT_SccbMgr_bad_isr(u32 p_port, 
unsigned char p_card,
  *
  *-*/
 
-static void FPT_SccbMgrTableInitAll()
+static void FPT_SccbMgrTableInitAll(void)
 {
unsigned char thisCard;
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: sim710: fix build warning

2015-09-15 Thread Sudip Mukherjee
On Fri, Sep 04, 2015 at 07:40:29PM +0530, Sudip Mukherjee wrote:
> We were getting build warning about:
>  "Section mismatch in reference from the variable sim710_eisa_driver to
>  the function .init.text:sim710_eisa_probe()
>  The variable sim710_eisa_driver references the function __init
>  sim710_eisa_probe()"
> 
> sim710_eisa_probe() was having __init but that was being referenced from
> sim710_eisa_driver.
> 
> Signed-off-by: Sudip Mukherjee <su...@vectorindia.org>
> ---
A gentle ping.
I still get the build warning while building for i386 allmodconfig with
next-20150915.
Build is at https://travis-ci.org/sudipm-mukherjee/parport/jobs/80365417

regards
sudip
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] scsi: sim710: fix build warning

2015-09-04 Thread Sudip Mukherjee
We were getting build warning about:
 "Section mismatch in reference from the variable sim710_eisa_driver to
 the function .init.text:sim710_eisa_probe()
 The variable sim710_eisa_driver references the function __init
 sim710_eisa_probe()"

sim710_eisa_probe() was having __init but that was being referenced from
sim710_eisa_driver.

Signed-off-by: Sudip Mukherjee <su...@vectorindia.org>
---
 drivers/scsi/sim710.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/sim710.c b/drivers/scsi/sim710.c
index 3b3b56f..82ed998 100644
--- a/drivers/scsi/sim710.c
+++ b/drivers/scsi/sim710.c
@@ -176,8 +176,7 @@ static struct eisa_device_id sim710_eisa_ids[] = {
 };
 MODULE_DEVICE_TABLE(eisa, sim710_eisa_ids);
 
-static __init int
-sim710_eisa_probe(struct device *dev)
+static int sim710_eisa_probe(struct device *dev)
 {
struct eisa_device *edev = to_eisa_device(dev);
unsigned long io_addr = edev->base_addr;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/14] ppdev: return proper error values from attach

2015-04-08 Thread Sudip Mukherjee
now that we are monitoring the return value from attach, make the
required changes to return proper value from its attach function.

Signed-off-by: Sudip Mukherjee su...@vectorindia.org
---
 drivers/char/ppdev.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index ae0b42b..14374d7 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -748,10 +748,14 @@ static const struct file_operations pp_fops = {
.release= pp_release,
 };
 
-static void pp_attach(struct parport *port)
+static int pp_attach(struct parport *port)
 {
-   device_create(ppdev_class, port-dev, MKDEV(PP_MAJOR, port-number),
- NULL, parport%d, port-number);
+   struct device *dev;
+
+   dev = device_create(ppdev_class, port-dev,
+   MKDEV(PP_MAJOR, port-number), NULL,
+   parport%d, port-number);
+   return PTR_ERR_OR_ZERO(dev);
 }
 
 static void pp_detach(struct parport *port)
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/14] net: plip: return proper error values from attach

2015-04-08 Thread Sudip Mukherjee
now that we are monitoring the return value from attach, make the
required changes to return proper value from its attach function.
also return the proper error code in module_init.

Signed-off-by: Sudip Mukherjee su...@vectorindia.org
---
 drivers/net/plip/plip.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/plip/plip.c b/drivers/net/plip/plip.c
index 040b897..6706bc3 100644
--- a/drivers/net/plip/plip.c
+++ b/drivers/net/plip/plip.c
@@ -1243,7 +1243,7 @@ plip_searchfor(int list[], int a)
 
 /* plip_attach() is called (by the parport code) when a port is
  * available to use. */
-static void plip_attach (struct parport *port)
+static int plip_attach(struct parport *port)
 {
static int unit;
struct net_device *dev;
@@ -1254,13 +1254,13 @@ static void plip_attach (struct parport *port)
plip_searchfor(parport, port-number)) {
if (unit == PLIP_MAX) {
printk(KERN_ERR plip: too many devices\n);
-   return;
+   return -EINVAL;
}
 
sprintf(name, plip%d, unit);
dev = alloc_etherdev(sizeof(struct net_local));
if (!dev)
-   return;
+   return -ENOMEM;
 
strcpy(dev-name, name);
 
@@ -1300,12 +1300,13 @@ static void plip_attach (struct parport *port)
 dev-name, dev-base_addr);
dev_plip[unit++] = dev;
}
-   return;
+   return 0;
 
 err_parport_unregister:
parport_unregister_device(nl-pardev);
 err_free_dev:
free_netdev(dev);
+   return -ENODEV;
 }
 
 /* plip_detach() is called (by the parport code) when a port is
@@ -1379,6 +1380,8 @@ __setup(plip=, plip_setup);
 
 static int __init plip_init (void)
 {
+   int err;
+
if (parport[0] == -2)
return 0;
 
@@ -1387,9 +1390,10 @@ static int __init plip_init (void)
timid = 0;
}
 
-   if (parport_register_driver (plip_driver)) {
+   err = parport_register_driver(plip_driver);
+   if (err) {
printk (KERN_WARNING plip: couldn't register driver\n);
-   return 1;
+   return err;
}
 
return 0;
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/14] i2c-parport: return proper error values from attach

2015-04-08 Thread Sudip Mukherjee
now that we are monitoring the return value from attach, make the
required changes to return proper value from its attach function.

Signed-off-by: Sudip Mukherjee su...@vectorindia.org
---
 drivers/i2c/busses/i2c-parport.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c
index a1fac5a..761a775 100644
--- a/drivers/i2c/busses/i2c-parport.c
+++ b/drivers/i2c/busses/i2c-parport.c
@@ -160,14 +160,14 @@ static void i2c_parport_irq(void *data)
SMBus alert received but no ARA client!\n);
 }
 
-static void i2c_parport_attach(struct parport *port)
+static int i2c_parport_attach(struct parport *port)
 {
struct i2c_par *adapter;
 
adapter = kzalloc(sizeof(struct i2c_par), GFP_KERNEL);
if (adapter == NULL) {
printk(KERN_ERR i2c-parport: Failed to kzalloc\n);
-   return;
+   return -ENOMEM;
}
 
pr_debug(i2c-parport: attaching to %s\n, port-name);
@@ -230,13 +230,14 @@ static void i2c_parport_attach(struct parport *port)
mutex_lock(adapter_list_lock);
list_add_tail(adapter-node, adapter_list);
mutex_unlock(adapter_list_lock);
-   return;
+   return 0;
 
  err_unregister:
parport_release(adapter-pdev);
parport_unregister_device(adapter-pdev);
  err_free:
kfree(adapter);
+   return -ENODEV;
 }
 
 static void i2c_parport_detach(struct parport *port)
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/14] pps: return proper error values from attach

2015-04-08 Thread Sudip Mukherjee
now that we are monitoring the return value from attach, make the
required changes to return proper value from its attach function.

Signed-off-by: Sudip Mukherjee su...@vectorindia.org
---
 drivers/pps/clients/pps_parport.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/pps/clients/pps_parport.c 
b/drivers/pps/clients/pps_parport.c
index 38a8bbe..a411621 100644
--- a/drivers/pps/clients/pps_parport.c
+++ b/drivers/pps/clients/pps_parport.c
@@ -134,7 +134,7 @@ out_both:
return;
 }
 
-static void parport_attach(struct parport *port)
+static int parport_attach(struct parport *port)
 {
struct pps_client_pp *device;
struct pps_source_info info = {
@@ -151,7 +151,7 @@ static void parport_attach(struct parport *port)
device = kzalloc(sizeof(struct pps_client_pp), GFP_KERNEL);
if (!device) {
pr_err(memory allocation failed, not attaching\n);
-   return;
+   return -ENOMEM;
}
 
device-pardev = parport_register_device(port, KBUILD_MODNAME,
@@ -179,7 +179,7 @@ static void parport_attach(struct parport *port)
 
pr_info(attached to %s\n, port-name);
 
-   return;
+   return 0;
 
 err_release_dev:
parport_release(device-pardev);
@@ -187,6 +187,7 @@ err_unregister_dev:
parport_unregister_device(device-pardev);
 err_free:
kfree(device);
+   return -ENODEV;
 }
 
 static void parport_detach(struct parport *port)
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/14] parport: return value of attach and parport_register_driver

2015-04-08 Thread Sudip Mukherjee
On Wed, Apr 08, 2015 at 02:38:32PM +0300, Dan Carpenter wrote:
 1) We can't apply this patch on its own so this way of breaking up the
 patches doesn't work.
yes, if the first patch is reverted for any reason all the others need
to be reverted also. so then everything in one single patch?
 
 2) I was thinking that all the -attach() calls would have to succeed or
 we would bail.  Having some of them succeed and some fail doesn't seem
 like it will simplify the driver code very much.  But I can also see
 your point.  Hm...
to clarify my point more here: any system might have more than one
parallel port but the module might decide to use just one. so in that
case attach will return 0 for the port that it wishes to use, for others
it will be a error code. So in parport_register_driver if we get error
codes in all the attach calls then we know that attach has definitely
failed, but atleast one 0 means one attach call has succeeded, which
will happen in case of staging/panel, net/plip...

 
 Minor comment:  No need to preserve the error code if there are lots
 which we miss.  We may as well hard code an error code.  But that's a
 minor thing.  Does this actually simplify the driver code?  That's the
 more important thing.

i don't think this will simplify the driver code, but atleast now
parport_register_driver() will not report success when we have actually
failed. And as a result module_init will also fail which is supposed to
be the actual behviour.

regards
sudip

 
 regards,
 dan carpenter
 
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/14] parport: check success of attach call

2015-04-08 Thread Sudip Mukherjee
Currently we are not checking if attach has succeeded or not. Also
parport_register_driver() always return 0 even if attach fails.
But in many places where attach has been used, it can fail.
So, modified the parport code to check the return value of attach and
accordingly return either 0 or error code from parport_register_driver.


Sudip Mukherjee (14):
  parport: return value of attach and parport_register_driver
  ALSA: portman2x4: return proper error values from attach
  ALSA: mts64: return proper error values from attach
  staging: panel: return proper error values from attach
  spi: lm70llp: return proper error values from attach
  spi: butterfly: return proper error values from attach
  [SCSI] ppa: return proper error values from attach
  [SCSI] imm: return proper error values from attach
  pps: return proper error values from attach
  pps: return proper error values from attach
  net: plip: return proper error values from attach
  i2c-parport: return proper error values from attach
  ppdev: return proper error values from attach
  char: lp: return proper error values from attach

 drivers/char/lp.c| 16 +++-
 drivers/char/ppdev.c | 10 +++---
 drivers/i2c/busses/i2c-parport.c |  7 ---
 drivers/net/plip/plip.c  | 16 ++--
 drivers/parport/share.c  | 20 +++-
 drivers/pps/clients/pps_parport.c|  7 ---
 drivers/pps/generators/pps_gen_parport.c |  9 +
 drivers/scsi/imm.c   |  4 ++--
 drivers/scsi/ppa.c   |  4 ++--
 drivers/spi/spi-butterfly.c  |  7 ---
 drivers/spi/spi-lm70llp.c|  7 ---
 drivers/staging/panel/panel.c| 11 ++-
 include/linux/parport.h  |  2 +-
 sound/drivers/mts64.c| 13 -
 sound/drivers/portman2x4.c   | 15 ++-
 15 files changed, 93 insertions(+), 55 deletions(-)

-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/14] [SCSI] imm: return proper error values from attach

2015-04-08 Thread Sudip Mukherjee
now that we are monitoring the return value from attach, make the
required changes to return proper value from its attach function.

Signed-off-by: Sudip Mukherjee su...@vectorindia.org
---
 drivers/scsi/imm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index 89a8266..e26330a 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -1225,9 +1225,9 @@ out:
return err;
 }
 
-static void imm_attach(struct parport *pb)
+static int imm_attach(struct parport *pb)
 {
-   __imm_attach(pb);
+   return __imm_attach(pb);
 }
 
 static void imm_detach(struct parport *pb)
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/14] char: lp: return proper error values from attach

2015-04-08 Thread Sudip Mukherjee
now that we are monitoring the return value from attach, make the
required changes to return proper value from its attach function.

Signed-off-by: Sudip Mukherjee su...@vectorindia.org
---
 drivers/char/lp.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index c4094c4..6988480 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -900,34 +900,40 @@ static int lp_register(int nr, struct parport *port)
return 0;
 }
 
-static void lp_attach (struct parport *port)
+static int lp_attach(struct parport *port)
 {
unsigned int i;
+   int ret = -ENODEV;
 
switch (parport_nr[0]) {
case LP_PARPORT_UNSPEC:
case LP_PARPORT_AUTO:
if (parport_nr[0] == LP_PARPORT_AUTO 
port-probe_info[0].class != PARPORT_CLASS_PRINTER)
-   return;
+   return ret;
if (lp_count == LP_NO) {
printk(KERN_INFO lp: ignoring parallel port (max. 
%d)\n,LP_NO);
-   return;
+   return ret;
}
-   if (!lp_register(lp_count, port))
+   if (!lp_register(lp_count, port)) {
lp_count++;
+   ret = 0;
+   }
break;
 
default:
for (i = 0; i  LP_NO; i++) {
if (port-number == parport_nr[i]) {
-   if (!lp_register(i, port))
+   if (!lp_register(i, port)) {
lp_count++;
+   ret = 0;
+   }
break;
}
}
break;
}
+   return ret;
 }
 
 static void lp_detach (struct parport *port)
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/14] pps: return proper error values from attach

2015-04-08 Thread Sudip Mukherjee
now that we are monitoring the return value from attach, make the
required changes to return proper value from its attach function.

Signed-off-by: Sudip Mukherjee su...@vectorindia.org
---
 drivers/pps/generators/pps_gen_parport.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/pps/generators/pps_gen_parport.c 
b/drivers/pps/generators/pps_gen_parport.c
index dcd39fb..499f410 100644
--- a/drivers/pps/generators/pps_gen_parport.c
+++ b/drivers/pps/generators/pps_gen_parport.c
@@ -190,18 +190,18 @@ static inline ktime_t next_intr_time(struct 
pps_generator_pp *dev)
dev-port_write_time + 3 * SAFETY_INTERVAL));
 }
 
-static void parport_attach(struct parport *port)
+static int parport_attach(struct parport *port)
 {
if (attached) {
/* we already have a port */
-   return;
+   return -EALREADY;
}
 
device.pardev = parport_register_device(port, KBUILD_MODNAME,
NULL, NULL, NULL, PARPORT_FLAG_EXCL, device);
if (!device.pardev) {
pr_err(couldn't register with %s\n, port-name);
-   return;
+   return -ENODEV;
}
 
if (parport_claim_or_block(device.pardev)  0) {
@@ -218,10 +218,11 @@ static void parport_attach(struct parport *port)
device.timer.function = hrtimer_event;
hrtimer_start(device.timer, next_intr_time(device), HRTIMER_MODE_ABS);
 
-   return;
+   return 0;
 
 err_unregister_dev:
parport_unregister_device(device.pardev);
+   return -ENODEV;
 }
 
 static void parport_detach(struct parport *port)
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/14] parport: return value of attach and parport_register_driver

2015-04-08 Thread Sudip Mukherjee
On Wed, Apr 08, 2015 at 02:44:37PM +0300, Dan Carpenter wrote:
 On Wed, Apr 08, 2015 at 02:38:32PM +0300, Dan Carpenter wrote:
 
 Then we convert one driver to use the new function pointer and see if
 it simplifies the code.  If so we can transition the others as well.  If
 not then we give up.
i am sending a v2 and also a patch to change one driver.

regards
sudip
 
 regards,
 dan carpenter
 
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/14] ALSA: portman2x4: return proper error values from attach

2015-04-08 Thread Sudip Mukherjee
now that we are monitoring the return value from attach, make the
required changes to return proper value from its attach function.

Signed-off-by: Sudip Mukherjee su...@vectorindia.org
---
 sound/drivers/portman2x4.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
index 464385a..866adbb 100644
--- a/sound/drivers/portman2x4.c
+++ b/sound/drivers/portman2x4.c
@@ -672,32 +672,37 @@ static int snd_portman_probe_port(struct parport *p)
return res ? -EIO : 0;
 }
 
-static void snd_portman_attach(struct parport *p)
+static int snd_portman_attach(struct parport *p)
 {
struct platform_device *device;
+   int ret;
 
device = platform_device_alloc(PLATFORM_DRIVER, device_count);
if (!device)
-   return;
+   return -ENOMEM;
 
/* Temporary assignment to forward the parport */
platform_set_drvdata(device, p);
 
-   if (platform_device_add(device)  0) {
+   ret = platform_device_add(device);
+
+   if (ret  0) {
platform_device_put(device);
-   return;
+   return ret;
}
 
/* Since we dont get the return value of probe
 * We need to check if device probing succeeded or not */
if (!platform_get_drvdata(device)) {
platform_device_unregister(device);
-   return;
+   return -ENODEV;
}
 
/* register device in global table */
platform_devices[device_count] = device;
device_count++;
+
+   return 0;
 }
 
 static void snd_portman_detach(struct parport *p)
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/14] staging: panel: return proper error values from attach

2015-04-08 Thread Sudip Mukherjee
now that we are monitoring the return value from attach, make the
required changes to return proper value from its attach function.

Signed-off-by: Sudip Mukherjee su...@vectorindia.org
---
 drivers/staging/panel/panel.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index ea54fb4..61f6961 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -2188,15 +2188,15 @@ static struct notifier_block panel_notifier = {
0
 };
 
-static void panel_attach(struct parport *port)
+static int panel_attach(struct parport *port)
 {
if (port-number != parport)
-   return;
+   return -ENODEV;
 
if (pprt) {
pr_err(%s: port-number=%d parport=%d, already registered!\n,
   __func__, port-number, parport);
-   return;
+   return -EALREADY;
}
 
pprt = parport_register_device(port, panel, NULL, NULL,  /* pf, kf */
@@ -2206,7 +2206,7 @@ static void panel_attach(struct parport *port)
if (pprt == NULL) {
pr_err(%s: port-number=%d parport=%d, 
parport_register_device() failed\n,
   __func__, port-number, parport);
-   return;
+   return -ENODEV;
}
 
if (parport_claim(pprt)) {
@@ -2230,7 +2230,7 @@ static void panel_attach(struct parport *port)
goto err_lcd_unreg;
}
register_reboot_notifier(panel_notifier);
-   return;
+   return 0;
 
 err_lcd_unreg:
if (lcd.enabled)
@@ -2238,6 +2238,7 @@ err_lcd_unreg:
 err_unreg_device:
parport_unregister_device(pprt);
pprt = NULL;
+   return -ENODEV;
 }
 
 static void panel_detach(struct parport *port)
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/14] spi: lm70llp: return proper error values from attach

2015-04-08 Thread Sudip Mukherjee
now that we are monitoring the return value from attach, make the
required changes to return proper value from its attach function.

Signed-off-by: Sudip Mukherjee su...@vectorindia.org
---
 drivers/spi/spi-lm70llp.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-lm70llp.c b/drivers/spi/spi-lm70llp.c
index ba72347..9b0fde1 100644
--- a/drivers/spi/spi-lm70llp.c
+++ b/drivers/spi/spi-lm70llp.c
@@ -190,7 +190,7 @@ static u32 lm70_txrx(struct spi_device *spi, unsigned 
nsecs, u32 word, u8 bits)
return bitbang_txrx_be_cpha0(spi, nsecs, 0, 0, word, bits);
 }
 
-static void spi_lm70llp_attach(struct parport *p)
+static int spi_lm70llp_attach(struct parport *p)
 {
struct pardevice*pd;
struct spi_lm70llp  *pp;
@@ -201,7 +201,7 @@ static void spi_lm70llp_attach(struct parport *p)
printk(KERN_WARNING
%s: spi_lm70llp instance already loaded. Aborting.\n,
DRVNAME);
-   return;
+   return -EALREADY;
}
 
/* TODO:  this just _assumes_ a lm70 is there ... no probe;
@@ -281,7 +281,7 @@ static void spi_lm70llp_attach(struct parport *p)
pp-spidev_lm70-bits_per_word = 8;
 
lm70llp = pp;
-   return;
+   return 0;
 
 out_bitbang_stop:
spi_bitbang_stop(pp-bitbang);
@@ -296,6 +296,7 @@ out_free_master:
(void) spi_master_put(master);
 out_fail:
pr_info(%s: spi_lm70llp probe fail, status %d\n, DRVNAME, status);
+   return status;
 }
 
 static void spi_lm70llp_detach(struct parport *p)
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/14] parport: return value of attach and parport_register_driver

2015-04-08 Thread Sudip Mukherjee
as of now, we are not checking if attach or parport_register_driver
has succeeded or failed. But attach can fail in the places where they
have been used. Lets check the return of attach, and if attach fails
then parport_register_driver should also fail. We can have multiple
parallel port so we only mark attach as failed only if it has never
returned a 0.

Signed-off-by: Sudip Mukherjee su...@vectorindia.org
---
 drivers/parport/share.c | 20 +++-
 include/linux/parport.h |  2 +-
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/parport/share.c b/drivers/parport/share.c
index 3fa6624..640ce41 100644
--- a/drivers/parport/share.c
+++ b/drivers/parport/share.c
@@ -148,23 +148,33 @@ static void get_lowlevel_driver (void)
  * callback, but if the driver wants to take a copy of the
  * pointer it must call parport_get_port() to do so.
  *
- * Returns 0 on success.  Currently it always succeeds.
+ * Returns 0 on success.
  **/
 
 int parport_register_driver (struct parport_driver *drv)
 {
struct parport *port;
+   int ret, err;
+   bool attached = false;
 
if (list_empty(portlist))
get_lowlevel_driver ();
 
mutex_lock(registration_lock);
-   list_for_each_entry(port, portlist, list)
-   drv-attach(port);
-   list_add(drv-list, drivers);
+   list_for_each_entry(port, portlist, list) {
+   err = drv-attach(port);
+   if (err == 0)
+   attached = true;
+   else
+   ret = err;
+   }
+   if (attached) {
+   list_add(drv-list, drivers);
+   ret = 0;
+   }
mutex_unlock(registration_lock);
 
-   return 0;
+   return ret;
 }
 
 /**
diff --git a/include/linux/parport.h b/include/linux/parport.h
index c22f125..9411065 100644
--- a/include/linux/parport.h
+++ b/include/linux/parport.h
@@ -249,7 +249,7 @@ struct parport {
 
 struct parport_driver {
const char *name;
-   void (*attach) (struct parport *);
+   int (*attach)(struct parport *);
void (*detach) (struct parport *);
struct list_head list;
 };
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/14] ALSA: mts64: return proper error values from attach

2015-04-08 Thread Sudip Mukherjee
now that we are monitoring the return value from attach, make the
required changes to return proper value from its attach function.

Signed-off-by: Sudip Mukherjee su...@vectorindia.org
---
 sound/drivers/mts64.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
index 2a008a9..fb6223e 100644
--- a/sound/drivers/mts64.c
+++ b/sound/drivers/mts64.c
@@ -874,32 +874,35 @@ static int snd_mts64_probe_port(struct parport *p)
return res;
 }
 
-static void snd_mts64_attach(struct parport *p)
+static int snd_mts64_attach(struct parport *p)
 {
struct platform_device *device;
+   int ret;
 
device = platform_device_alloc(PLATFORM_DRIVER, device_count);
if (!device)
-   return;
+   return -ENOMEM;
 
/* Temporary assignment to forward the parport */
platform_set_drvdata(device, p);
 
-   if (platform_device_add(device)  0) {
+   ret = platform_device_add(device);
+   if (ret  0) {
platform_device_put(device);
-   return;
+   return ret;
}
 
/* Since we dont get the return value of probe
 * We need to check if device probing succeeded or not */
if (!platform_get_drvdata(device)) {
platform_device_unregister(device);
-   return;
+   return -ENODEV;
}
 
/* register device in global table */
platform_devices[device_count] = device;
device_count++;
+   return 0;
 }
 
 static void snd_mts64_detach(struct parport *p)
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/14] [SCSI] ppa: return proper error values from attach

2015-04-08 Thread Sudip Mukherjee
now that we are monitoring the return value from attach, make the
required changes to return proper value from its attach function.

Signed-off-by: Sudip Mukherjee su...@vectorindia.org
---
 drivers/scsi/ppa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index 1db8b26..48898ec 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -1090,9 +1090,9 @@ out:
return err;
 }
 
-static void ppa_attach(struct parport *pb)
+static int ppa_attach(struct parport *pb)
 {
-   __ppa_attach(pb);
+   return __ppa_attach(pb);
 }
 
 static void ppa_detach(struct parport *pb)
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/14] ALSA: portman2x4: return proper error values from attach

2015-04-08 Thread Sudip Mukherjee
On Wed, Apr 08, 2015 at 04:32:57PM +0300, Sergei Shtylyov wrote:
 Hello.
 
 On 4/8/2015 2:20 PM, Sudip Mukherjee wrote:
 
 now that we are monitoring the return value from attach, make the
 
So you've first changed the method prototype and follow up with
 the changes to the actual implementations? That's backward. I'm
 afraid such changes can't be done piecemeal.
Dan Carpenter has exlained me the problem with this aproach. I have
already sent a v2 which doesnot break anything and if everyone approves
that way then we can change one driver at a time and nothing will
break.

regards
sudip

 
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] SCSI: sd: fix null dereference

2015-03-06 Thread Sudip Mukherjee
we were dereferencing sdkp first and then we were checking for it
being NULL. 

Signed-off-by: Sudip Mukherjee su...@vectorindia.org
---
 drivers/scsi/sd_dif.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/sd_dif.c b/drivers/scsi/sd_dif.c
index 14c7d42..a514645 100644
--- a/drivers/scsi/sd_dif.c
+++ b/drivers/scsi/sd_dif.c
@@ -40,11 +40,16 @@
  */
 void sd_dif_config_host(struct scsi_disk *sdkp)
 {
-   struct scsi_device *sdp = sdkp-device;
-   struct gendisk *disk = sdkp-disk;
-   u8 type = sdkp-protection_type;
+   struct scsi_device *sdp = NULL;
+   struct gendisk *disk = NULL;
+   u8 type;
int dif, dix;
 
+   if (!sdkp)
+   return;
+   sdp = sdkp-device;
+   disk = sdkp-disk;
+   type = sdkp-protection_type;
dif = scsi_host_dif_capable(sdp-host, type);
dix = scsi_host_dix_capable(sdp-host, type);
 
@@ -77,9 +82,6 @@ void sd_dif_config_host(struct scsi_disk *sdkp)
 
disk-integrity-flags |= BLK_INTEGRITY_DEVICE_CAPABLE;
 
-   if (!sdkp)
-   return;
-
if (type == SD_DIF_TYPE3_PROTECTION)
disk-integrity-tag_size = sizeof(u16) + sizeof(u32);
else
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/1 linux-next] hpsa: remove set but unused variable rc

2014-10-30 Thread Sudip Mukherjee
On Thu, Oct 30, 2014 at 06:28:13AM +, Elliott, Robert (Server Storage) 
wrote:
 
 
  -Original Message-
  From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi-
  ow...@vger.kernel.org] On Behalf Of Sudip Mukherjee
  Sent: Thursday, October 30, 2014 12:55 AM
  To: Fabian Frederick
  Cc: linux-ker...@vger.kernel.org; Stephen M. Cameron; James E.J.
  Bottomley; iss_storage...@hp.com; linux-scsi@vger.kernel.org
  Subject: Re: [PATCH 1/1 linux-next] hpsa: remove set but unused variable
  rc
  
  On Wed, Oct 29, 2014 at 04:15:04PM +0100, Fabian Frederick wrote:
   Fix -Wunused-but-set-variable warning
  
  you should also mention why you have left the call to
  irq_set_affinity_hint().
  i am not sure , but it looks like irq_set_affinity_hint() is only
  checking if
  the lock is available or not. It is just locking ,then if lock is
  successfull then
  returning 0 or if lock fails then return -EINVAL, and unlocks before
  returnig.
  not doing anything else.
  
  thanks
  sudip
 
 No, that function sets a mask value that shows up in 
   /proc/irq/nnn/affinity_hint
 that a program like irqbalance may use to set the CPU affinity mask
 for each irq via 
   /proc/irq/nnn/smp_affinity   (bitmap format)
   /proc/irq/nnn/smp_affinity_list   (range format)
 
 The reason is that in many cases, it is best when all these occur 
 on the same CPU that submitted the IO:
 * LLD submission queues (if multiple are supported)
 * LDD completion queues
 * MSI-X interrupt indicating completion
 * LLD completion interrupt handler
 * block layer completion handler
 
 Benefits include:
 * cache efficiency - the data structures for the IO aren't
 pulled from CPU to CPU.
 
 * avoid IPI overhead in the block layer to get the completion 
 processed on the submitting CPU (which is done if using 
 rq_affinity=2 and the interrupt is routed to on another CPU).
 
 * self-throttle the CPUs - avoid swamping one CPU with 
 completion processing for IOs submitted by many other CPUs
 (which leads to stalls on the victim and timeouts on the
 aggressors).
 
 You must run irqbalance with an option to honor the hints;
 some versions default to that, others don't.  Or, disable
 the irqbalance service and set them up the affinities
 manually.
 
thanks , i think this is happening at desc-affinity_hint = m;

thanks
sudip
 
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/1 linux-next] hpsa: remove set but unused variable rc

2014-10-29 Thread Sudip Mukherjee
On Wed, Oct 29, 2014 at 04:15:04PM +0100, Fabian Frederick wrote:
 Fix -Wunused-but-set-variable warning

you should also mention why you have left the call to irq_set_affinity_hint().
i am not sure , but it looks like irq_set_affinity_hint() is only checking if
the lock is available or not. It is just locking ,then if lock is successfull 
then
returning 0 or if lock fails then return -EINVAL, and unlocks before returnig.
not doing anything else.

thanks
sudip

 
 Signed-off-by: Fabian Frederick f...@skynet.be
 ---
  drivers/scsi/hpsa.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
 index cef5d49..34330e1 100644
 --- a/drivers/scsi/hpsa.c
 +++ b/drivers/scsi/hpsa.c
 @@ -6619,11 +6619,11 @@ static void hpsa_free_cmd_pool(struct ctlr_info *h)
  
  static void hpsa_irq_affinity_hints(struct ctlr_info *h)
  {
 - int i, cpu, rc;
 + int i, cpu;
  
   cpu = cpumask_first(cpu_online_mask);
   for (i = 0; i  h-msix_vector; i++) {
 - rc = irq_set_affinity_hint(h-intr[i], get_cpu_mask(cpu));
 + irq_set_affinity_hint(h-intr[i], get_cpu_mask(cpu));
   cpu = cpumask_next(cpu, cpu_online_mask);
   }
  }
 -- 
 1.9.3
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-kernel in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] drivers: target: target_core_transport.c: build warning

2014-09-09 Thread Sudip Mukherjee
build is giving : 
warning: passing argument 1 of 'strlen' makes pointer from integer 
without a cast [enabled by default]

the snprintf after the strlen is trying to put the Unsupported string
at the end of exising string. so len should give the string length here

Signed-off-by: Sudip Mukherjee su...@vectorindia.org
---
 drivers/target/target_core_transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/target/target_core_transport.c 
b/drivers/target/target_core_transport.c
index 1dd1181..3ce85ed 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -953,7 +953,7 @@ int transport_dump_vpd_ident_type(
strlcat(buf, SCSI name string\n, sizeof(buf));
break;
default:
-   len = strlen(len);
+   len = strlen(buf);
snprintf(buf[len], sizeof(buf) - len, Unsupported: 0x%02x\n,
vpd-device_identifier_type);
ret = -EINVAL;
-- 
1.8.1.2

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] drivers: target: target_core_transport.c: build warning

2014-09-09 Thread Sudip Mukherjee
On Tue, Sep 09, 2014 at 12:53:50PM +0530, Sudip Mukherjee wrote:
 build is giving : 
 warning: passing argument 1 of 'strlen' makes pointer from integer 
 without a cast [enabled by default]
 
 the snprintf after the strlen is trying to put the Unsupported string
 at the end of exising string. so len should give the string length here
 
 Signed-off-by: Sudip Mukherjee su...@vectorindia.org
 ---
  drivers/target/target_core_transport.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/target/target_core_transport.c 
 b/drivers/target/target_core_transport.c
 index 1dd1181..3ce85ed 100644
 --- a/drivers/target/target_core_transport.c
 +++ b/drivers/target/target_core_transport.c
 @@ -953,7 +953,7 @@ int transport_dump_vpd_ident_type(
   strlcat(buf, SCSI name string\n, sizeof(buf));
   break;
   default:
 - len = strlen(len);
 + len = strlen(buf);
   snprintf(buf[len], sizeof(buf) - len, Unsupported: 0x%02x\n,
   vpd-device_identifier_type);
   ret = -EINVAL;
 -- 
 1.8.1.2
 

please discard this patch. This is based on next-20140908 , and the
issue has been corrected in next-20140909.

thanks
sudip
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html