aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorMichał Mirosław <mirq-linux@rere.qmqm.pl>2013-02-01 14:40:17 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-02-06 15:18:56 -0500
commit9f3b795a626ee79574595e06d1437fe0c7d51d29 (patch)
tree1952cb2ac880c0e66f291916815c2a36b4ceb300 /drivers/scsi
parent807be03cae191cb88e2f267adcd49aba785c658b (diff)
driver-core: constify data for class_find_device()
All in-kernel users of class_find_device() don't really need mutable data for match callback. In two places (kernel/power/suspend_test.c, drivers/scsi/osd/osd_uld.c) this patch changes match callbacks to use const search data. The const is propagated to rtc_class_open() and power_supply_get_by_name() parameters. Note that there's a dev reference leak in suspend_test.c that's not touched in this patch. Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Acked-by: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/hosts.c4
-rw-r--r--drivers/scsi/osd/osd_uld.c26
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c4
3 files changed, 13 insertions, 21 deletions
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 593085a52275..df0c3c71ea43 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -468,10 +468,10 @@ void scsi_unregister(struct Scsi_Host *shost)
468} 468}
469EXPORT_SYMBOL(scsi_unregister); 469EXPORT_SYMBOL(scsi_unregister);
470 470
471static int __scsi_host_match(struct device *dev, void *data) 471static int __scsi_host_match(struct device *dev, const void *data)
472{ 472{
473 struct Scsi_Host *p; 473 struct Scsi_Host *p;
474 unsigned short *hostnum = (unsigned short *)data; 474 const unsigned short *hostnum = data;
475 475
476 p = class_to_shost(dev); 476 p = class_to_shost(dev);
477 return p->host_no == *hostnum; 477 return p->host_no == *hostnum;
diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
index 43754176a7b7..0fab6b5c7b82 100644
--- a/drivers/scsi/osd/osd_uld.c
+++ b/drivers/scsi/osd/osd_uld.c
@@ -268,18 +268,11 @@ static inline bool _the_same_or_null(const u8 *a1, unsigned a1_len,
268 return 0 == memcmp(a1, a2, a1_len); 268 return 0 == memcmp(a1, a2, a1_len);
269} 269}
270 270
271struct find_oud_t { 271static int _match_odi(struct device *dev, const void *find_data)
272 const struct osd_dev_info *odi;
273 struct device *dev;
274 struct osd_uld_device *oud;
275} ;
276
277int _mach_odi(struct device *dev, void *find_data)
278{ 272{
279 struct osd_uld_device *oud = container_of(dev, struct osd_uld_device, 273 struct osd_uld_device *oud = container_of(dev, struct osd_uld_device,
280 class_dev); 274 class_dev);
281 struct find_oud_t *fot = find_data; 275 const struct osd_dev_info *odi = find_data;
282 const struct osd_dev_info *odi = fot->odi;
283 276
284 if (_the_same_or_null(oud->odi.systemid, oud->odi.systemid_len, 277 if (_the_same_or_null(oud->odi.systemid, oud->odi.systemid_len,
285 odi->systemid, odi->systemid_len) && 278 odi->systemid, odi->systemid_len) &&
@@ -287,7 +280,6 @@ int _mach_odi(struct device *dev, void *find_data)
287 odi->osdname, odi->osdname_len)) { 280 odi->osdname, odi->osdname_len)) {
288 OSD_DEBUG("found device sysid_len=%d osdname=%d\n", 281 OSD_DEBUG("found device sysid_len=%d osdname=%d\n",
289 odi->systemid_len, odi->osdname_len); 282 odi->systemid_len, odi->osdname_len);
290 fot->oud = oud;
291 return 1; 283 return 1;
292 } else { 284 } else {
293 return 0; 285 return 0;
@@ -301,19 +293,19 @@ int _mach_odi(struct device *dev, void *find_data)
301 */ 293 */
302struct osd_dev *osduld_info_lookup(const struct osd_dev_info *odi) 294struct osd_dev *osduld_info_lookup(const struct osd_dev_info *odi)
303{ 295{
304 struct find_oud_t find = {.odi = odi}; 296 struct device *dev = class_find_device(&osd_uld_class, NULL, odi, _match_odi);
305 297 if (likely(dev)) {
306 find.dev = class_find_device(&osd_uld_class, NULL, &find, _mach_odi);
307 if (likely(find.dev)) {
308 struct osd_dev_handle *odh = kzalloc(sizeof(*odh), GFP_KERNEL); 298 struct osd_dev_handle *odh = kzalloc(sizeof(*odh), GFP_KERNEL);
299 struct osd_uld_device *oud = container_of(dev,
300 struct osd_uld_device, class_dev);
309 301
310 if (unlikely(!odh)) { 302 if (unlikely(!odh)) {
311 put_device(find.dev); 303 put_device(dev);
312 return ERR_PTR(-ENOMEM); 304 return ERR_PTR(-ENOMEM);
313 } 305 }
314 306
315 odh->od = find.oud->od; 307 odh->od = oud->od;
316 odh->oud = find.oud; 308 odh->oud = oud;
317 309
318 return &odh->od; 310 return &odh->od;
319 } 311 }
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 31969f2e13ce..59d427bf08e2 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -183,10 +183,10 @@ static struct attribute_group iscsi_endpoint_group = {
183 183
184#define ISCSI_MAX_EPID -1 184#define ISCSI_MAX_EPID -1
185 185
186static int iscsi_match_epid(struct device *dev, void *data) 186static int iscsi_match_epid(struct device *dev, const void *data)
187{ 187{
188 struct iscsi_endpoint *ep = iscsi_dev_to_endpoint(dev); 188 struct iscsi_endpoint *ep = iscsi_dev_to_endpoint(dev);
189 uint64_t *epid = (uint64_t *) data; 189 const uint64_t *epid = data;
190 190
191 return *epid == ep->id; 191 return *epid == ep->id;
192} 192}